akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
int n,a,b;
cin >>n>> a >>b;

cout<< min(a*n,b);
return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define ff first
#define ss second
#define int long long 
#define endl "\n"
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	

const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
int n , m;

void solve(){
	cin >> n >> m;
	int x = 0 , sum = 0;
	for(int i = 0 ; i<m ; i++){	
		cin >> x;
		sum += x;
	}	
	if(sum>n)	cout<<"-1";
	else	cout<<n-sum;
	
}

int32_t main(){
	FAST;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define N 100
#define INF 9999999
#define W 0
#define G 1
#define B 2

int A[N][N],color[N],d[N],p[N];
int n,time = 0;

void dijkstra(){
  int i,min,v,u;
  for(i = 0; i < n; i++){
    color[i] = W;
    d[i] = INF;
  }
  d[0] = 0;
  p[0] = -1;

  while(1){
    min = INF;
    u = -1;
    for(i = 0; i < n; i++){
      if(color[i] != B && d[i] < min){
	min = d[i];
	u = i;
      }
    }
    if(u == -1) break;

    color[u] = B;

    for(v = 0; v < n; v++){
      if(color[v] != B && A[u][v] != INF){
	if(d[u] + A[u][v] < d[v]){
	  d[v] = d[u] + A[u][v];
	  p[v] = u;
	  color[v] = G;
	}
      }
    }
    
  }
  
    for(i = 0; i < n; i++){
      if(d[i] == INF) printf("%d %d\n",i,-1);
      else printf("%d %d\n",i,d[i]);
  }


}


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

  dijkstra();
 
 
  return 0;
}



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

int out(int *A,int N){
	int i;
	for (i=0;i<=N-2;i++){
		cout << A[i] <<" ";
	}
	cout << A[N-1] <<endl;
}

int BubbleSort(int *A,int N){
	int count=0;
	int flag=1;
	int j;
	while (flag){
		flag=0;
		for(j=N-1;j>=1;j--){
			if (A[j]<A[j-1]){
				std::swap(A[j],A[j-1]);
				flag=1;
				count++;
			}
		}
	}
	out(A,N);
	return count;
}

int main(){
	int N,count;
	cin >> N;
	int i;
	int A[N];
	for (i=0;i<=N-1;i++){
		cin >> A[i];
	}
	count=BubbleSort(A,N);
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner

object Main {
  def main(args : Array[String]) = {
    val scanner = new Scanner(System.in)
    var inputs = List.empty[Array[Int]]
    while(scanner.hasNextLine) {
      inputs = scanner.nextLine().split(" ").map(_.toInt) :: inputs
    }

    inputs
      .reverse
      .map(it => (it(0) + it(1)).toString.length)
      .foreach(println(_))

  }
}

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

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(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 nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}

	public static void main(String[] args) 
	{ 
        FastReader sc = new FastReader(); 
        PrintWriter out = new PrintWriter(System.out); 

        int n = sc.nextInt();
        long[][] arr = new long[n][3], dp = new long[n][3];
        
        for(int i=0;i<n;i++){
        	for(int j=0;j<3;j++){
        		arr[i][j] = sc.nextLong();	
        	}
        }

        dp[0][0] = arr[0][0];
        dp[0][1] = arr[0][1];
        dp[0][2] = arr[0][2];

        for(int i=0;i<n-1;i++){
        	for(int j=0;j<3;j++){
            	for(int k=0;k<3;k++){
            		if(k!=j){
            			dp[i+1][k] = Math.max(dp[i][j]+arr[i+1][k], dp[i+1][k]);   
            		}
            	}
        	}
        }

        out.println(Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
        out.close();
	} 
} 


Measured memory_bytes: 52972
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        StringBuilder sb = new StringBuilder();
        while (n>0) {
            n -=1;
            long amari = n % 26;
            sb.append((char)(amari + 'a'));
            n /= 26;
        }
        System.out.println(sb.reverse().toString());
    }
}

Measured memory_bytes: 35752
#include<cstdio>

int tbl[200000];

int main(void) {
    int n;
    scanf("%d",&n);

    tbl[1] = 1;

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

    for(int i=0; i<100500; i++)
        tbl[i+1] += tbl[i];

    int res=0;
    for(int i=0; i<100500; i++)
        if(tbl[i] >= i) res = i;
    printf("%d\n",res-1);
    
    return 0;
}

Measured memory_bytes: 1416
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  int ans = 0;
  for (; n > 0; n /= k) ++ans;
  cout << ans << '\n';
  return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;

    int cnt = 0, tap = 1;
    for (int i = 0; i < 100; i++) {
        if (B <= tap) {
            cout << cnt << endl;
            return 0;
        }
        else {
            tap += A - 1;
            cnt++;
        }
    }
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int main() {
    int n;
    scanf("%d",&n);

    LL a=1,b=1;
    for(int i=1;i<=n;i++){
        LL x,y;
        scanf("%lld%lld",&x,&y);
        LL percent=max(a/x,b/y);
        while(true){
            if(percent*x>=a&&percent*y>=b)
                break;
            percent++;
        }
        a=percent*x;
        b=percent*y;
    }
    printf("%lld\n",a+b);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char s[500001];
char t[500001];
int match[500000];
int par[20][500000];
int tlen, slen;
int main(void){
    int i, j, k;
    int base[] = {2, 3, 5, 7, 9, 11, 13, 17, 19, 23};
    int m = 10;//baseの数
    scanf("%s", s);
    scanf("%s", t);

    tlen = strlen(t);
    slen = strlen(s);

    long long int mod = 1000000007;
    long long int thash[100], shash[100];

    //初期のハッシュ値を求める
    for(j = 0; j < m; j++){
        thash[j] = 0;
        shash[j] = 0;
        for(i = 0; i < tlen; i++){
            shash[j] += s[i%slen];
            thash[j] += t[i];
            if(i == tlen - 1){
                break;
            }
            thash[j] *= base[j];
            thash[j] %= mod;
            shash[j] *= base[j];
            shash[j] %= mod;
        }
    }

    long long int tmp[100];
    //base^(plen-1)%mod の値を求める
    for(j = 0; j < m; j++){
        tmp[j] = 1;
        for(i = 0; i < tlen-1; i++){
            tmp[j] *= base[j];
            tmp[j] %= mod;
        }
    }
    for(i = 0; i < slen; i++){
        match[i] = -1;
    }

    for(i = 0; i < slen; i++){
        int cnt = 0;
        for(j = 0; j < m; j++){
            if(thash[j] == shash[j]){
                cnt++;
            }
            shash[j] = (shash[j] - tmp[j] * s[i])*base[j] + s[(i+tlen)%slen];
            while(shash[j] < 0){
                shash[j] += mod; 
            }
            shash[j] %= mod;
        }
        if(cnt == m){
            match[i] = 0;
        }
    }

    //degub用，
    // for(i = 0; i < slen; i++){
    //     printf("%d\n", match[i]);
    // }

    //parの計算
    int chk[500000];
    for(i = 0; i < slen; i++){
        chk[i] = -1;
    }
    for(i = 0; i < slen; i++){
        if(chk[i] != -1){
            continue;
        }
        if(match[i] == -1){
            chk[i] = 0;
            continue;
        }
        int v = i;
        //前に探索
        int cnt = 1;
        while(1){
            v += tlen;
            v %= slen;
            if(match[v] != 0){
                break;
            }
            chk[v] = 1;
            cnt++;
            if(cnt > 500000){
                printf("-1\n");
                return 0;
            }
            continue;
        }

        //後ろに探索
        v = i;
        while(1){
            v -= tlen;
            while(v < 0){
                v += slen;
            }
            v %= slen;
            if(match[v] != 0){
                break;
            }
            chk[v] = 1;
            cnt++;
            if(cnt > 500000){
                printf("-1\n");
                return 0;
            }
            continue;
        }
        chk[i] = cnt;
    }
    int ans = 0;
    for(i = 0; i < slen; i++){
        ans = ans > chk[i] ? ans : chk[i];
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 6612
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(a, b);
    cout << a*b << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3640
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
void print(){cout << endl;} void prints(){}
template<typename T=int> T get(){T x; cin >> x; return x;}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clear(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int mod = 1e9+7;
const int N = 1e6+1;

int32_t main(){
	fast_io();

	int n = get();
	int w = get();
	vi wi(n);
	vi vi(n);
	for (int i = 0; i < n; ++i) {
		cin >> wi[i] >> vi[i];
	}

	int dp[n+1][w+w];
	clear(dp);

	#define push(a, b) a = max(a, b);

	for (int i = 0; i < n; ++i) {
		for (int wt = w; wt >= 0; --wt) {
			push(dp[i+1][wt], dp[i][wt]);
			push(dp[i+1][wt+wi[i]], dp[i][wt] + vi[i]);
		}
	}

	for (int i = 0; i < n+1; ++i) {
		debug(arr(dp[i], w+1));
	}

	print(dp[n][w]);

	return 0;
}

Measured memory_bytes: 158080
X,N = map(int,input().split())
P = set(list(map(int,input().split())))
reverseP = []
for i in range(102):
    if i not in P:
        reverseP.append(i)
ans = 0
diff = float("INF")
for a in reverseP:
    if abs(a-X)<diff:
        ans = a
        diff = abs(a-X)
print(ans)

Measured memory_bytes: 79668
#include <bits/stdc++.h>
 
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define ll	long long
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.141592653589793
 
const ll mod = 1e18;
 
int main() 
{	fastio;
	int testcases = 1;
	//cin>>testcases;
	while (testcases--) {
		int n;
		cin>>n;
		vector <ll> a(100005);
		for (int i = 0; i < n; i++) {
			cin>>a[i];
		}
		for (int i = 0; i < n; i++) {
			if (a[i] == 0) {
				cout<<0;
				return 0;
			}
		}
		ll ans = 1ll;
		for (int i = 0; i < n; i++) {
			if (ans <= mod/a[i]) {
				ans *= a[i];
			}
			else {
				ans = -1;
				break;
			}
		}
		cout<<ans;
		cout<<"\n";	
	}
    return 0; 
}


Measured memory_bytes: 3992
S = input().replace("A","1").replace("B","2").replace("C","3").replace("?","0")
#while S[0:1] == "B" or S[0:1] == "C":
#    S = S[1:]
#while S[-1:] == "A" or S[-1:] == "B":
#    S = S[:-1]

# ABC
# AB?,A?C,?BC
# A??,?B?,??C
# ???
front = [0,0,0,0]
back = []
for i in range(4):
    back.append(S.count(str(i)))
Q = back[0]
q3s = [(3**t)%1000000007 for t in [Q-3,Q-2,Q-1,Q]]

ans = 0

for i in range(len(S)):
    num = S[i:i+1]
    back[int(num)] -= 1
    if num == "2":
        ans += front[1]*back[3]*q3s[3] #ABC
        ans += front[1]*back[0]*q3s[2] #AB?
        ans += front[0]*back[3]*q3s[2] #?BC
        ans += front[0]*back[0]*q3s[1] #?B?
    elif num == "0":
        ans += front[1]*back[3]*q3s[2] #A?C
        ans += front[1]*back[0]*q3s[1] #A??
        ans += front[0]*back[3]*q3s[1] #??C
        ans += front[0]*back[0]*q3s[0] #???
    front[int(num)] += 1
    ans = int(ans)%1000000007

print(ans)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ans(n) ;

  for (int i = 0; i < m; i++) {
      vector<int> v(2);
      cin >> v.at(0) >> v.at(1);
      int x, y;
      x = v.at(0);
      y = v.at(1);
      ans.at(x-1)++;
      ans.at(y-1)++;
    }
  
  for (int i = 0; i < n; i++) {
    cout << ans.at(i) << endl;
  } 
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, i;
    cin>> n;

    for(i=1; i*i<= n; i++)
    {
        if(n%i== 0 && n <= i*9)
            break;

    }


    cout << (i* i <=n ? "Yes\n" : "No\n");

    return 0;
}




Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#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 FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string T;
  cin >> T;
  int t = T.length();
  FOR(i, 0, t - 1) {
    if (T[i] == '?') T[i] = 'D';
  }
  printf("%s\n", T.c_str());
  return 0;
}

Measured memory_bytes: 3772
# https://atcoder.jp/contests/abc164/tasks/abc164_d

import sys
input = sys.stdin.readline


S = input().rstrip()

res = 0

x = 0
p = 1
MOD = 2019
reminder = [0]*2019
reminder[0] = 1
for s in reversed(S):
    """ 累積和 """
    x += int(s)*p
    x %= MOD
    p *= 10
    p %= MOD
    res += reminder[x]
    reminder[x] += 1

print(res)

Measured memory_bytes: 73920
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n, ans = 0;
	cin >> n;
	vector<int> arr(n);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	for(int k = 0; k <= 100; k++) {
		bool cur = 0;
		for(int i = 0; i < n; i++) {
			if(arr[i])
				ans += !cur, cur = 1, arr[i]--;
			else
				cur = 0;
		}
	}
	cout << ans << '\n';

	return 0;
}


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

int digit(int num) {
    int cnt = 0;
    while(num != 0) {
        cnt++;
        num /= 10;
    }
    return(cnt);
}

int main(void) {
    int a, b;
    
    while(scanf("%d %d", &a, &b) != EOF) {
        cout << digit(a + b) << endl;
    }
    
    return(0);
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <stdlib.h>

long long int min(long long int a, long long int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	int n, i;
	scanf("%d", &n);
	int *a = (int *)malloc(sizeof(int) * n);
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	long long int ans1 = 0, ans2 = 0, sum = 0;
	int f = -1;
	for(i = 0; i < n; i++){
		sum += a[i];
		if(f == 1 && sum <= 0){
			ans1 += 1 - sum;
			sum = 1;
		}
		else if(f == -1 && sum >= 0){
			ans1 += 1 + sum;
			sum = -1;
		}
		if(f == 1){
			f = -1;
		}
		else if(f == -1){
			f = 1;
		}
	}
	f = 1;
	sum = 0;
	for(i = 0; i < n; i++){
		sum += a[i];
		if(f == 1 && sum <= 0){
			ans2 += 1 - sum;
			sum = 1;
		}
		else if(f == -1 && sum >= 0){
			ans2 += 1 + sum;
			sum = -1;
		}
		if(f == 1){
			f = -1;
		}
		else if(f == -1){
			f = 1;
		}
	}
	printf("%lld\n", min(ans1, ans2));
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  	string s;
  	cin >> s;
  	bool triggered = false;
  	for (int i = 0; i < s.length(); i++) {
      	if (i % 2 == 0 && (s[i] == 'L')) {
      		cout << "No";
          	triggered = true;
          	break;
        } else if (i % 2 == 1 && s[i] == 'R') {
          	cout << "No";
          	triggered = true;
          	break;
        }
    }
  	if (!triggered) {
      	cout << "Yes";
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int s = saori.saori_hayami();
		HashSet<Integer> num = new HashSet<>();
		int ans = 0;
		for(int i = 1;i <= 1000000;i++){
			num.add(s);
			if(s % 2 == 0){
				s = s/2;
			} else {
				s = 3*s + 1;
			}
			if(num.contains(s)){
				ans = i+1;
				break;
			}
		}
		System.out.println(ans);

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22484
import sys
import math
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int():
    return int(input())

def map_int_input():
    return map(int, input())

MII = map_int_input

def MII_split():
    return map(int, input().split())

def MII_to_index():
    return map(to_index, input())

def MII_split_to_index():
    return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs():
    return list(map(int, input()))

LII = list_int_inputs

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

# 2次元リスト化
def LII_2D(rows_number):
    return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number):
    return [LII_split() for _ in range(rows_number)]

K = input_int()

count = 0
for a in range(K):
    ap = a + 1

    for b in range(K):
        bp = b + 1
        gcd_ab = math.gcd(ap, bp)
        for c in range(K):
            count += math.gcd(gcd_ab, c + 1)

print(count)

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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
	int n;
	cin>>n;
	int t[n+1],x[n+1],y[n+1];
	t[0]=x[0]=y[0]=0;
	for(int i=1;i<=n;++i){
		cin>>t[i]>>x[i]>>y[i];
	}
	bool can=true;
	
	for(int i=0;i<n;++i){
		int dt=t[i+1]-t[i];
		int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		if(dt<dist) can=false;
		if(dt%2!=dist%2) can=false;
	}
	
	if(can) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1408
d = {}
for i in range(3):
    a, b = map(int, input().split())
    if a not in d:
        d[a] = [b]
    else:
        d[a].append(b)

    if b not in d:
        d[b] = [a]
    else:
        d[b].append(a)

ans = True
for a in range(1, 5):
    if len(d[a]) >= 3:
        ans = False
if ans:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 100005, MAX_M = 200010;
// code
//#define int long long
const int X = (1 << 22);
bitset<X> dp;
void Solve() {
    int n, s = 0; cin >> n; dp[0] = 1;
    for (int i = 1, x; i <= n; i++){
      	cin >> x; s += x; dp = dp | (dp << x);
    }
    //cout << s << endl;
  	for (int ans = (s+1)/2; ans <= s; ans ++)
      	if (dp[ans]) {cout << ans; break;}
}

signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll asum = 0, bsum = 0;
    rep(i, n){
        cin >> a[i];
        asum += a[i];
    }
    rep(i, n){
        cin >> b[i];
        bsum += b[i];
    }
    ll mact = bsum - asum;
    ll act1 = 0, act2 = 0;
    rep(i, n){
        if(a[i] > b[i]){
            act1 += a[i] - b[i];
        }
        if(a[i] < b[i]){
            act2 += ceil(((double)b[i] - (double)a[i]) / 2);
        }
    }
    if(mact >= act1 && mact >= act2) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

int main() {
  string n;

  cin >> n;

  for (int i = 0; i < 3; i++) {
    if (n[i] == '7') {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";

  return 0;
}

Measured memory_bytes: 3620
s = gets.chomp

check = true
check = false if s[0] != "A"
check = false if s[2..(s.length-2)].count("C") != 1
if check then
  s = s[1..(s.length)]
  s = s[0] + s[1..(s.length-2)].delete("C") + s[s.length-1]
  check = false if s.downcase!
end

if check then
  puts "AC"
else
  puts "WA"
end


Measured memory_bytes: 1788
import java.util.Scanner;

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

	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int d = sc.nextInt();

	if (Math.abs(a-c) <= d)
	    System.out.println("Yes");
	else if (Math.abs(a-b) <= d && Math.abs(c-b) <= d){
	    System.out.println("Yes");
	} else
	    System.out.println("No");
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>

int main(void) {
    char l2[1];
    scanf("%s", l2);
    int l = atoi(l2);
    double answer = 0.0;
    if(l%2 == 1) {
        answer = (l/2+(l%2 == 1))/(double)l;
    }
    else {
        answer = l/2/(double)l;
    }
    printf("%lf", answer);    
    return 0;
}

Measured memory_bytes: 128
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let s: Vec<Vec<char>> = (0..n)
        .map(|_| sc.read::<String>().chars().collect())
        .collect();

    let mut ans = 0;
    for a in 0..n {
        let mut ok = true;
        for i in 0..n {
            for j in 0..n {
                if s[(i + a) % n][j] != s[(j + a) % n][i] {
                    ok = false;
                }
            }
        }

        if ok {
            ans += 1;
        }
    }

    println!("{}", ans * n);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    long double l;
    cin >> l;
    l /= 3;
    cout << setprecision(10) << l * l * l << endl;

    return 0;
}


Measured memory_bytes: 256
a,b = map(int, input().split())

if ((a%2 == 1)and(b%2==1)):
    c = (a+b)/2
    print(int(c))

elif ((a%2==0)and(b%2==0)):
    c =(a+b)/2
    print(int(c))

else:
    print("IMPOSSIBLE")

Measured memory_bytes: 3060
a, b, c, x = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
    (0..b).each do |j|
        (0..c).each do |k|
            cnt += 1 if i * 500 + j * 100 + k * 50 == x
        end
    end
end
 
puts cnt

Measured memory_bytes: 1788
import java.util.*;

class Main{
 public static void main(String args[]){
   Scanner scn = new Scanner(System.in);
   int n = scn.nextInt(); 
   String s = scn.next();
   String t = scn.next();
   String st = "";
   for(int i = 0; i<n; i++){
     st += s.substring(i,i+1);
     st += t.substring(i,i+1);
   }
   System.out.println(st);
 }
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	long long n, x;
	cin >> n >> x;
	vector<long long> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long cnt = 0;
	for(int i = 1; i < n; i++) {
		long long adj = a[i] + a[i - 1];
		if(adj > x) {
			cnt += adj - x;
			a[i] = max(a[i] - (adj - x), 1LL * 0);
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
n = int(input())
*A, = map(int, input().split())
maxA = max(A)
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
D = {a: 0 for a in A}
for a in A:
    if C[a] > 1:
        D[a] = 1
    for b in range(2 * a, maxA + 1, a):
        D[b] = 1
print(sum([D[a] == 0 for a in A]))


Measured memory_bytes: 218320
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = new int[n];
			int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
			for (int i = 0; i < n; i++) {
				int t = in.nextInt();
				a[i] = t;
				min = Math.min(min, t);
				max = Math.max(max, t);
			}

			List<P> ans = new ArrayList<>();

			boolean isPositive = Math.abs(max) >= Math.abs(min);
			int idx = -1;
			int tar = isPositive ? max : min;
			for (int i = 0; i < n; i++) {
				if (tar == a[i]) {
					idx = i;
					break;
				}
			}
			if (isPositive) {
				for (int i = 0; i < n; i++) {
					ans.add(new P(idx, i));
				}
				for (int i = 1; i < n; i++) {
					ans.add(new P(i-1, i));
				}

			} else {
				for (int i = 0; i < n; i++) {
					ans.add(new P(idx, i));
				}

				for (int i = n-1; i > 0; i--) {
					ans.add(new P(i, i-1));
				}
			}

			out.println(ans.size());
			for (P p : ans) {
				out.println((p.x+1) +" "+ (p.y+1));
			}
		}
	}

	static class P {
		int x, y;

		public P(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 24916
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	ll N,a[100010],cnt=0,f=1;
    cin>>N;
    REP(i,N){
        cin>>a[i];
        if(a[i]%2==1){
            f=0;
        }
       
    }

    if(f==0){
        cout<<"first"<<endl;
        return 0;
    }
    else{
        cout<<"second"<<endl;
        return 0;
    }

    if(cnt%2==1){
        cout<<"first"<<endl;
    }
    else{
        cout<<"second"<<endl;
    }
	
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n_orig; cin >> n_orig;
    ll n = n_orig;
    int ulimit = 1000001;

    vector <bool> is_sosus(ulimit, true);
    is_sosus[0] = false;
    is_sosus[1] = false;

    REP(i, ulimit){
        if (!is_sosus[i]){
            continue;
        }
        ll cnt = i*2;
        while(cnt < ulimit){
            is_sosus[cnt] = false;
            cnt += i;

        }
    }

    vector <ll> sosu_cnt(ulimit, 0);

    REP(i, ulimit){
        if (!is_sosus[i]){
            continue;
        }
        if (n%i != 0){
            continue;
        }
        while(n%i == 0){
            n/=i;
            sosu_cnt[i]++;
        }
    }

    ll ans = 0;
    REP(i, ulimit-1){
        if (sosu_cnt[i] == 0){
            continue;
        }
        ll sub = 1;
        ll cnt = sosu_cnt[i];

        dump(cnt)
        while(cnt > 0){
            cnt -= sub;
            sub++;
            if (cnt >= 0){
                ans++;
            }
        }
    }
    dump(ans)
    if ((n != 1) && (n_orig > 1e6)){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11180
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

bool tplsort(tuple<int64_t, int64_t, int64_t, int64_t> a1, tuple<int64_t, int64_t, int64_t, int64_t> a2){
    if(get<1>(a1)==get<1>(a2)){
        return !(get<2>(a1)>=get<2>(a2));
    }else{
        return !(get<1>(a1)>=get<1>(a2));
    }
}

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m,p,y;
    cin >> n >> m;
    vector<tuple<int64_t, int64_t, int64_t, int64_t>> tpl(m);
    rep(i,m){
        cin >> p >> y;
        tpl.at(i) = make_tuple(i,p,y,0);
    }
    sort(tpl.begin(), tpl.end(), tplsort);
    vector<pair<int64_t, int64_t>> pair(m);
    int64_t num=0, pref = -1;
    rep(i,m){
        num = pref!=get<1>(tpl.at(i)) ? 1 : num+1;
        pref =get<1>(tpl.at(i));
        get<3>(tpl.at(i)) = num;
    }
    sort(tpl.begin(), tpl.end());
    rep(i,m){
        cout << setfill('0') << setw(6) << get<1>(tpl.at(i)) << setfill('0') << setw(6) << get<3>(tpl.at(i)) << endl;
    }
}


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

const int MAX_N=60;
int par[MAX_N];
int myrank[MAX_N];

void init(int n){
  for(int i=0;i<n;i++){par[i]=i; myrank[i]=0;}
}

int find(int x){
  if(par[x]==x){return x;}
  else{return par[x]=find(par[x]);}
}

void unite(int x,int y){
  x=find(x); y=find(y);
  if(x==y){return;}
  if(myrank[x]<myrank[y]){par[x]=y;}
  else{par[y]=x;}
  if(myrank[x]==myrank[y]){myrank[x]++;}
}

bool same(int x,int y){
  return find(x)==find(y);
}

int main(){
  int N,M;
  cin >> N >> M;
  int count=0;
  vector<int> a(60),b(60);
  for(int i=0;i<M;i++){cin >> a[i] >> b[i];}
  for(int i=0;i<M;i++){
    init(60);
    for(int j=0;j<i;j++){unite(a[j],b[j]);}
    for(int j=i+1;j<M;j++){unite(a[j],b[j]);}
    if(same(a[i],b[i])==0){count++;}
    init(60);
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>

#include <algorithm>
#include <queue>
#include <cctype>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)

int N;
long long h[100003];
long long dp[100003];
const long long MAX = 1LL << 60;

int main() {
    fill(dp, dp + 100003,MAX);
    cin >> N;
    rep(i, N) {
        cin >> h[i];
    }
    dp[0] = 0;
    rep(i, N - 1) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    cout << dp[N-1] << '\n';
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val s = readLine()!!
    for (i in 1..s.length) {
        if ((i % 2 == 1 && s[i-1] == 'L') || (i % 2 == 0 && s[i-1] == 'R')) {
            println("No")
            System.exit(0)
        }
    }
    println("Yes")
}

Measured memory_bytes: 31768
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;

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

  sort(L,L+N);
  int sum=0;
  for(int i=0; i<N-1;i++)
  sum+=L[i];

  if(sum > L[N-1]) cout<<"Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    unsigned long long int n, m;
    scanf("%lld %lld", &n, &m);
    unsigned long long int ans = 0;
    if (n * 2 <= m)
    {
        ans = n;
        m -= 2 * n;
    }
    else
    {
        ans = m / 2;
        m = 0;
    }
    ans += m / 4;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
MOD = 10**9+7

if n < 2:
  ans = 0
else:
  ans = 1
  bns = 1
  cns = 1
  for _ in range(n):
    ans *= 10
    ans %= MOD
    bns *= 9
    bns %= MOD
    cns *= 8
    cns %= MOD 
  ans = (ans - 2 * bns + cns) % MOD

print(ans)
  

Measured memory_bytes: 9000
var
   s: string;
   az: array[0..25] of Integer;
   i: Integer;
begin
   for i := 0 to 25 do begin
      az[i] := 0;
   end;
   readln(s);
   for i := 1 to Length(s) do begin
      Inc(az[integer(s[i]) - integer('a')]);
      if az[integer(s[i]) - integer('a')] > 1 then begin
         writeln('no');
         Exit;
      end;
   end;
   writeln('yes');
end.


Measured memory_bytes: 128
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl



int main(){
    int a,b,h;cin >> a >> b >> h;
    
    cout << ((a+b)*h)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int selectionSort(int A[], int N){
    int i, j, sw = 0, minj;

    for(i = 0; i < N - 1; i++){
        minj = i;
        for(j = i; j < N; j++)  if(A[j] < A[minj])  minj = j;
        swap(A[i], A[minj]);
        if(i != minj)  sw++;  //
    }
    return sw;
}

int main(){
    int A[105], N, i, sw;

    scanf("%d", &N);
    for(i = 0; i < N; i++)  scanf("%d", &A[i]);

    sw = selectionSort(A, N);

    for(i = 0; i < N; i++){
        if(i > 0)  printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);

    return 0;
}



Measured memory_bytes: 2744