akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

ll n;
ll a[9], b[9];
ll x[25000005];
ll mx1, mx2;

int main()
{
    cin>>n;
    for(ll i = 0; i < 3; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 0; i < 3; i++)
    {
        scanf("%lld", &b[i]);
    }
    memset(x, -1, sizeof(x));
    x[0] = 0;
    for(ll i = 0; i <= n; i++)
    {
        for(ll j = 0; j < 3; j++)
        {
            if(i < a[j]) continue;
            if(b[j] - a[j] <= 0) continue;
            if(x[i - a[j]] == -1) continue;
            x[i] = max(x[i], x[i - a[j]] + b[j] - a[j]);
        }
        mx1 = max(mx1, x[i]);
    }
    memset(x, -1, sizeof(x));
    x[0] = 0;
    for(ll i = 0; i <= n + mx1; i++)
    {
        for(ll j = 0; j < 3; j++)
        {
            if(i < b[j]) continue;
            if(a[j] - b[j] <= 0) continue;
            if(x[i - b[j]] == -1) continue;
            x[i] = max(x[i], x[i - b[j]] + a[j] - b[j]);
        }
        mx2 = max(mx2, x[i]);
    }
    cout<<mx1 + mx2 + n<<endl;
    return 0;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        if ((i + 1) % 3 == 0)
        {
            cout << ' ' << i + 1;
        }
        else
        {
            int x = i + 1;
            while (1)
            {
                if (x % 10 == 3)
                {
                    cout << ' ' << i + 1;
                    break;
                }
                if (x / 10 == 0)
                {
                    break;
                }
                else
                {
                    x /= 10;
                }
            }
        }
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
from collections import defaultdict
N = int(input())
g = [[] for i in range(N)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    g[a] += [b]
    g[b] += [a]
    
def bfs(g, st):
    queue = [st]
    distances = [-1 for i in range(N)]
    distances[st] = 0
    
    while queue:
        node = queue.pop(0)
        for h in g[node]:
            if distances[h] == -1:
                distances[h] = distances[node] + 1
                queue += [h]
 
    return distances
 
dB = bfs(g, 0)
dW = bfs(g, N-1)
 
B, W = 0, 0
for i in range(N):
    if dB[i] <= dW[i]:
        B += 1
    else:
        W += 1
print("Fennec" if B > W else "Snuke")

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 2147483647;
const double eps = 1e-9;
typedef pair<int, int> P;

int sx, sy, gx, gy;
char maze[20][20];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int H, W;

int bfs (int sx, int sy, int gx, int gy) {
    int d[20][20];
    queue<P> que;
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) d[i][j] = inf;
    que.push(P(sx, sy));
    d[sx][sy] = 0;
    
    while (que.size()) {
        P p = que.front();
        que.pop();
        if (p.first == gx && p.second == gy) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if (0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != '#' && d[nx][ny] == inf) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    if (d[gx][gy] == inf) return 0;
    return d[gx][gy];
}

int main()
{
    int ans = 0;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> maze[i][j];
        }
    }

    for (sx = 0; sx < H; sx++) {
        for (sy = 0; sy < W; sy++) {
            for (gx = 0; gx < H; gx++) {
                for (gy = 0; gy < W; gy++) {
                    if (sx == gx && sy == gy) continue;
                    if (maze[sx][sy] == '#' or maze[gx][gy] == '#') continue;
                    ans = max(bfs(sx, sy, gx, gy), ans);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
TAB = [list(map(int, input().split())) for _ in range(3)]
T = TAB[0]
A = TAB[1]
B = TAB[2]
dV1, dV2 = A[0] - B[0], A[1] - B[1]

dL1, dL2 = dV1 * T[0], dV2 * T[1]
if dL1 + dL2 == 0:
  print("infinity")
else:
  if dL1 * (dL1 + dL2) > 0:
    print(0)
  else:
    m = dL2 * T[0] - dL1 * T[1]
    n = dL1 + dL2
    m += n * T[1]
    cnt = m // (n * (T[0] + T[1]))
    if m % (n * (T[0] + T[1])) == 0:
      print(2*cnt-2)
    else:
      print(2*cnt-1)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  x -= a;
  x %= b;
  cout << x << endl;
  return 0;
}


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

using namespace std;

typedef long long int lld;

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

int main()
{
	int n,k,x,y;
	cin >> n >> k >> x >> y;

	int sol = 0;

	for(int i = 1; i <= n; i++)
	{
		if (i <= k)
		{
			sol += x;
		}else
		{
			sol += y;
		}
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static final int MOD = 998244353;

	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}

	static int mul(int a, int b) {
		int res = (int) ((long) a * b % MOD);
		return res < 0 ? res + MOD : res;
	}

	static void solve() throws Exception {
		int a = scanInt(), b = scanInt(), c = scanInt(), d = scanInt();
		int dyn1[][] = new int[c - a + 1][d - b + 1];
		int dyn2[][] = new int[c - a + 1][d - b + 1];
		dyn1[0][0] = 1;
		for (int i = 0; i <= c - a; i++) {
			for (int j = 0; j <= d - b; j++) {
				if (i < c - a) {
					dyn1[i + 1][j] = add(mul(dyn1[i][j], b + j), dyn2[i][j]);
				}
				if (j < d - b) {
					dyn2[i][j + 1] = mul(add(dyn1[i][j], dyn2[i][j]), a + i);
				}
			}
		}
		out.print(add(dyn1[c - a][d - b], dyn2[c - a][d - b]));
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int ma = 1024 * 1024;
const ll mod = int(1e9) + 7;

int n, m, use[1000000];
ll ans = 0, cnt[2];
bool ok;
vector<int> e[1000000];

void dfs(int nu) {
	cnt[use[nu]]++;
	for (int v : e[nu]) {
		if (use[v] == -1) {
			use[v] = 1 ^ use[nu];
			dfs(v);
		}
		if (use[v] == use[nu])
			ok = false;
	}
} 

int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m;
	forn (i, n) {
		use[i] = -1;
	}
	forn (i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	forn (i, n) {
		if (use[i] == -1) {
			cnt[0] = cnt[1] = 0;
			use[i] = 0;
			ok = true;
			dfs(i);
			if (ok) {
				ans += cnt[0] * cnt[1];
			} else {
				ans += (cnt[0] + cnt[1] - 1) * (cnt[0] + cnt[1]) / 2LL;
			}
		}
	}
	ans -= m;
	cout << ans;
}

Measured memory_bytes: 28800
#include<iostream>
#include<vector>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cctype>
/* #include<span> */
#include<algorithm>
#include<cinttypes>

using namespace std;
using ll = long long;
using vi = vector<int>;

template <typename T>
T ceil(T a, T b){
    return !(a%b) ? a/b : a/b+1 ;
}

template <typename T>
T gcd( T a, T b ) { 
    return !a ? b : gcd( b%a, a);
}

template <typename T>
T lcm( T a, T b ) {
    return (a*b)/gcd(a,b);
}

template <typename T>
std::istream& operator<<(std::istream& io,std::vector<T>& v){
    for(auto &x: v){
        io >> x;
    }
    return io;
}

template <typename T>
std::ostream& operator>>(std::ostream& os, std::vector<T>const v){
    for(auto x: v){
        std::cout << x << ' ';
    }
    std::cout << '\n';
    return os;
}

#define bug(a) std::cout << #a << ' ' << a << '\n';

template <typename T>
void debug( vector<T> &v ){
    for(decltype(v.size()) i = 0; i < v.size(); ++i){
        std::cout << "v[" << i << "]: " << v[i] << '\n';
    }
}

/* template <typename T> */
/* std::ostream& operator<<(std::ostream& os,std::span<T> a){ */
/*     for(auto x: a){ */
/*         os << a << ' '; */
/*     } */
/*     os.put('\n'); */
/*     return os; */
/* } */

/* template <typename T> */
/* void debug(std::span<T> a){ */
/*     for(auto i=0; i < a.size(); ++i){ */
/*         cout << "a[" << i << "]: " << a[i] << '\n'; */
/*     } */
/* } */

#define all(a)  std::begin((a)),std::end((a))
#define po2(a) { ((a)&((a)-1)) == 0 }
#define endl '\n'


int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll result = max({max(a,b)*max(c,d), max(a,b)*min(c,d), min(a,b)*max(c,d), min(a,b)*min(c,d) });
    cout << result << endl;

/* #ifdef __linux__ */
/*     cout<<"Have you checked for lowest constraints?"<<endl; */
/*     cout<<"Have you checked for highest constraints?"<<endl; */
/*     cout<<"Check for time complexity!"<<endl; */
/*     cout<<"Check for 1 and 0"<<endl; */
/*     cout<<"Check for time, you stupid!"<<endl; */
/* #endif */

    return 0;
}





Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=100005;
int n;
int a[M];
int C[M*10];
int s[M*10];
int lowbit(int i)
{
    return i & -i;//或者是return i-(i&(i-1));表示求数组下标二进制的非0最低位所表示的值
}
void update(int i,int val)//单点更新
{
    while(i<=2*M){
        C[i]+=val;
        i+=lowbit(i);//由叶子节点向上更新树状数组C，从左往右更新
    }
}
ll sum(int i)//求区间[1,i]内所有元素的和
{
    ll ret=0;
    while(i>0){
        ret+=C[i];//从右往左累加求和
        i-=lowbit(i);
    }
    return ret;
}

bool check(int x)
{
    for(int i=1;i<=2*M;i++) C[i]=0;
    s[0]=0;
    for(int i=1;i<=n;i++)
        s[i]=s[i-1]+(a[i]>=x?1:-1);
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        ans+=sum(s[i]+M);
        update(s[i]+M,1);
    }
    return ans>=(ll)n*(n+1)/4;
}



int main()
{
    int l=0,r=0;
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        r=max(r,a[i]);
    }
    int ans=0;
    while(l!=r)
    {
        int mid=(l+r)/2+1;
        if(check(mid))
              l=mid;
        else
              r=mid-1;
          //  cout<<l <<" "<<r<<endl;
    }
    cout<<l<<endl;
}

Measured memory_bytes: 6784
chomp($_ = <STDIN>);
my ($a, $b, $k) = split;

if ($b - $a + 1 <= $k * 2) {
    for ($a..$b) {
        print "$_\n";
    }
} else {
    for ($a..($a + $k - 1)) {
        print "$_\n";
    }

    for (($b - $k + 1) .. $b) {
        print "$_\n";
    }
}




Measured memory_bytes: 512
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;

bool isPrime(ll n) {
	if(n == 2) return true;
	for(int i = 2; i <= sqrt(n);) {
		if(n % i == 0) return false;
		if(i == 2) i++;
		else i += 2;
		}
		return true;	
}

void solve() {
	ll x;
	cin >> x;
	while(!isPrime(x)) x++;
	cout << x << endl;
}


int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
}
 
 
 



Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func Split(a int) []int {
	var x []int
	for _, rune := range strconv.Itoa(a) {
		b, _ := strconv.Atoi(string(rune))
		x = append(x, b)
	}

	return x
}

type Pair struct{
	x int
	y int
}

func main() {
	n := nextInt()
	m := map[Pair]int{}

	for i:=1; i<=n; i++ {
		s := Split(i)
		k := Pair{s[0], s[len(s) - 1]}
		m[k] += 1
	}

	total := 0
	for pair, cnt := range m {
		total += cnt * m[Pair{pair.y, pair.x}]
	}

	fmt.Printf("%d", total)
}


Measured memory_bytes: 7680
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
#- 1要望 a→c,b→c分断要望に対して、a<bならb→cだけ考慮すればいい -#
want_list = [0]*(N+1)
for _ in range(M):
    a,b = map(int,input().split())
    want_list[b]=max(want_list[b],a)


#-分断した時の橋とindexと要望を見比べて、要望を満たしていないならカウントする-#
cnt = 0
cutNo = 0
for idx,val in enumerate(want_list):
    if val >cutNo:
        cutNo = idx-1
        cnt += 1
print(cnt)



Measured memory_bytes: 12104
n,x=int(input()),10**6+100
a,b,c=list(map(int,input().split())),[0]*(2*x),0
for i in a:
    b[i]+=1
for i in range(x):
    c+=1 if b[i]==1 else 0
    if b[i]==0:
        continue
    for j in range(1,x):
        if i*j>=x:
            break
        b[i*j]=0
print(c)

Measured memory_bytes: 35020
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define M 16
ll ten[M], ten9[M];
//unordered_set<int> ok;
bitset<100000010> bt, sk;

ll pow_mod(ll a, ll r, ll m){
	ll x = 1;
	while(r){
		if(r&1) (x*=a)%=m;
		(a*=a)%=m;
		r>>=1;
	}
	return x;
}

ll len(ll x){
	ll res = 0;
	if(x>=1e3){
		x /= 1e4;
		res += 4;
	}
	if(x>=1e1){
		x /= 1e2;
		res += 2;
	}
	while(x){
		x /= 10;
		res++;
	}
	return res;
}

int main(){
	ten[0] = 1;
	rep(i, M-1) ten[i+1] = ten[i]*10;
	rep(i, M) ten9[i] = ten[i]*9;
	ll n;
	cin>>n; n++;
	while(--n){
		bt.reset();
		sk.reset();
	ll res = 0;
	{
		ll l = 1, r = 1, m = 0;
		while(l<=1e7){
			while(m<n){
				m += len(r);
				r++;
			}
			//if(len(l)==len(r-1)) break;
			//if(m==n) ok.insert(r-l);
			//if(m==n) bt[r-l] = 1;
			if(m==n /*&& len(l)!=len(r-1)*/) bt[r-l] = 1;
			//if(m==n&&len(l)!=len(r-1)) res++;
			m -= len(l);
			l++;
		}
	}
	for(ll i = 1; i*i <= n; i++){
		ll j = n/i;
		if(i*j!=n) continue;
		//sk[i] = sk[j] = 1;
		if((j>=10||i<=ten9[j-1])){
			sk[i] = 1;
			(res+=pow_mod(10, j-1, mod)*9%mod+mod-i+1)%=mod;
		}
		if(i==j) break;
		if(i>=10||j<=ten9[i-1]){
			sk[j] = 1;
			(res+=pow_mod(10, i-1, mod)*9%mod+mod-j+1)%=mod;
		}
	}

	//res += n/8;
	rep1(i, n){
		if(sk[i]) continue;
		if(i<=n/8||bt[i]) res++;
	}
	(res = res+mod)%=mod;
	cout<<res<<endl;
	break;
	}
	return 0;
}

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

int main(){
    int i, j, damy, mthei[10];

	for(i = 0; i < 10; i++){
		cin >> mthei[i];
	}

	for(i = 0; i < 10; i++){
		for(j = i + 1; j < 10; j++){
			if(mthei[i] < mthei[j]){
				damy = mthei[i];
				mthei[i] = mthei[j];
				mthei[j] = damy;
			}
		}
	}

	for(i = 0; i < 3; i++){
		cout << mthei[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	string s;cin>>s;
	int ans = 0;
	rep(i,s.size()){
		ans += (s[i]=='+'?1:-1);
	}
	cout<<ans<<endl;

	return 0;
}


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

int main(void)
{
    int n;
    cin >> n;
    if (n%10==3) cout << "bon" << endl;
    else if (n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) cout << "hon" << endl;
    else cout << "pon" << endl;
}


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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	long long sum = 0, ans_even = 0, ans_odd = 0;
	for(int i = 0; i < n; i++){
        long long sign = (i % 2 == 0) ? 1 : (-1);
        sum += a[i];
        if(sum * sign <= 0){
            ans_even += abs(sum - sign);
            sum = sign;
        }
    }
    sum = 0;
    for(int i = 0; i < n; i++){
        long long sign = (i % 2 != 0) ? 1 : (-1);
        sum += a[i];
        if(sum * sign <= 0){
            ans_odd += abs(sum - sign);
            sum = sign;
        }
    }
	cout << min(ans_even, ans_odd) << endl;
	// system("pause");
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
		String b = sc.next();
		int c = Integer.parseInt(a + b);
		for (int i = 1; i * i <= c; i++) {
			if (i * i == c) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
  }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int k;
  cin >> k;
  vector<ll> a(k);
  rep(i,k)cin >> a[i];
  ll pre = a.back();
  for(int i = k-2;i >= 0;i--)pre = (pre+a[i]-1)/a[i]*a[i];
  if(pre == 1){
    cout << 2 << " " << 2 << endl;
    return 0;
  }
  {
    ll l = pre;
    rep(i,k)l = l/a[i]*a[i];
    if(l != 2){
      cout << -1 << endl;
      return 0;
    }
  }
  ll left = pre,right = 1ll << 60;
  while(right-left > 1){
    ll mid = (right+left)/2;
    ll l = mid;
    rep(i,k)l = l/a[i]*a[i];
    if(l == 2)left = mid;
    else right = mid;
  }
  cout << pre << " " << right-1 << endl;
  






  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MOD 1000000007
#define F first
#define S second

typedef long long ll;
using namespace std;


string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    if (s[0] != 'A') {
        puts("WA");
        return 0;
    }
    bool flag = false;
    for (int i = 1; i < s.size(); ++i) {
        if (i > 1 && i < s.size() - 1 && s[i] == 'C') {
            if (flag) {
                puts("WA");
                return 0;
            }
            flag = true;
        }
        if (s[i] != 'C' && s[i] < 'a') {
            puts("WA");
            return 0;
        }
    }
    flag ? puts("AC") : puts("WA");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;

char mp[100][100];
int main()
{
  int A, B;
  cin >> A >> B;
  REP(i, 100) {
    REP(j, 50) mp[i][j] = '.';
    REP(j, 50) mp[i][j + 50] = '#';
  }

  int y = 0, x = 0;
  REP(i, B - 1) {
    mp[y][x] = '#';
    x += 2;
    if (x >= 49) {
      x = 0;
      y += 2;
    }
  }

  y = 0, x = 51;
  REP(i, A - 1) {
    mp[y][x] = '.';
    x += 2;
    if (x >= 98) {
      x = 51;
      y += 2;
    }
  }

  cout << 100 << ' ' << 100 << endl;
  REP(i, 100) {
    REP(j, 100) cout << mp[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int a[55]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1];

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        cin >> c[i];
    }
    vector<vector<int>> dp(h + 1, vector<int>(w + 1, INF));
    dp[0][0] = (c[0][0] == '#');
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 && j == 0) {
                continue;
            }
            if (i > 0) {
                chmin(dp[i][j], dp[i - 1][j] + (c[i][j] == '#'));
            }
            if (j > 0) {
                chmin(dp[i][j], dp[i][j - 1] + (c[i][j] == '#'));
            }
            queue<P> q;
            q.emplace(i, j);
            vector<vector<int>> vis(h + 1, vector<int>(w + 1));
            vis[i][j] = 1;
            while (!q.empty()) {
                int y = q.front().first, x = q.front().second;
                q.pop();
                chmin(dp[i][j], dp[y][x]);
                if (y > 0 && !vis[y - 1][x] && c[y - 1][x] == '#') {
                    vis[y - 1][x] = 1;
                    q.emplace(y - 1, x);
                }
                if (x > 0 && !vis[y][x - 1] && c[y][x - 1] == '#') {
                    vis[y][x - 1] = 1;
                    q.emplace(y, x - 1);
                }
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = 0;

            var i = cin.ReadInt;

            int[] list = new int[i];
            for (var x = 0; x < i; x = x + 1)
            {
                list[x] = cin.ReadInt;
            }

            var fla = false;
            for (var x = 0; true; x = x + 1)
            {
                for (var c = 0; c < i; c = c + 1)
                {
                    if (list[c] % 2 == 1 || list[c] == 0)
                    {
                        a = x;
                        fla = true;
                        break;
                    }
                    list[c] = list[c] / 2;
                }
                if (fla == true)
                {
                    break;
                }
            }


            WriteLine(a.ToString());
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 28208
function Main(input) {
  input = input.split("\n");
  const S = input[0];
  const T = input[1];
  let answer = 0;

  for (i = 0; i < S.length; i++){
    if (S[i] !== T[i]) {
      answer++;
    }
  }

  console.log(answer);

}
// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32884
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=1000000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll n;cin>>n;
        map<ll,ll> ans[4];ll arr[n];
        for(ll i=0;i<n;i++){
            cin>>arr[i];
            ans[0][arr[i]-i-1]++;
            ans[1][-arr[i]-i-1]++;
            ans[2][arr[i]+i+1]++;
            ans[3][-arr[i]+i+1]++;
        }
        ll num,count=0;
        for(ll i=0;i<n;i++){
            count+=ans[1][arr[i]-1-i];
            count+=ans[3][arr[i]+1+i];
            // if(i==1)cout<<count<<" ";
        }
        count/=2;
        cout<<count;
}


Measured memory_bytes: 73696
module Main where

import           Debug.Trace
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
    [n, vertexX, vertexY] <- map read . words <$> getLine

    let aaaList = 
                sumShortest [((aaaa (i,j) vertexX vertexY) - 1,1) | i<-[1 .. n-1], j<-[i+1..n] ] n
    
    --mapM putStrLn (map  (\x->show (snd x))  aaaList)
    VU.mapM_ print (trace (show aaaList) aaaList)

aaaa :: (Int,Int) -> Int -> Int -> Int
aaaa x vertexX vertexY  =  min (abs (start-vertexX) + 1 + abs (end-vertexY)) (end - start)
  where
    start    = fst x :: Int
    end      = snd x :: Int
    smaller a b = if a < b then a else b

sumShortest :: [(Int,Int)] -> Int-> VU.Vector Int
sumShortest shortestList n =
    VU.accum (+) (VU.replicate (n-1) 0) shortestList

Measured memory_bytes: 1404
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int c=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]+a[j]>a[k])
                {
                    c++;
                }
            }
        }
    }
    cout<<c;
}



Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>

const int M = 102, N = 100020, Inf = 1 << 20;
char c[M][M];
int n, m, S, T, i, j, k = 1;
int h[N], t[N], v[N], w[N], l[N];
int q[N], s, e, g[N], d[N], flw;

void add(int a, int b, int c) {
	t[++k] = h[a]; h[a] = k; v[k] = b; w[k] = c;
	t[++k] = h[b]; h[b] = k; v[k] = a; w[k] = 0;
}
void init() {
	scanf("%d%d", &n, &m);
	S = 1; T = 1 + n + m + 1;
	for (i = 1; i <= n; i++) {
		scanf("%s", c[i] + 1);
		for (j = 1; j <= m; j++) {
			if (c[i][j] == 'S') {
				add(S, 1 + i, Inf);
				add(S, 1 + n + j, Inf);
			}
			if (c[i][j] == 'T') {
				add(1 + i, T, Inf);
				add(1 + n + j, T, Inf);
			}
			if (c[i][j] == 'o') {
				add(1 + i, 1 + n + j, 1);
				add(1 + n + j, 1 + i, 1);
			}
		}
	}
}
int min(int x, int y) {
	return x < y ? x : y;
}
int dfs(int i, int p) {
	if (i == T)return p;
	int f = 0;
	for (int& j = l[i], x; j; j = t[j])
		if (w[j] && d[i] == d[v[j]] + 1) {
			x = dfs(v[j], min(w[j], p));
			p -= x; f += x;
			w[j] -= x; w[j ^ 1] += x;
			if (p == 0)return f;
		}
	if (!--g[d[i]])d[S] = T + 1;
	g[++d[i]]++; l[i] = h[i];
	return f;
}
void work() {
	for (i = 1; i <= T; i++)
		l[i] = h[i];
	g[d[q[s = e = 0] = T] = 1]++;
	while (s <= e)
		for (j = h[i = q[s++]]; j; j = t[j])
			if (!d[v[j]])
				g[d[v[j]] = d[i] + 1]++, q[++e] = v[j];
	do
		flw += dfs(S, Inf);
	while (d[S] <= T);
	printf("%d", flw > 2000 ? -1 : flw);
}

int main() {
	init();
	work();
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	int bf;
	cin >> a >> b >> c;
	if(a > b){
		bf = b;
		b = a;
		a = bf;
	}
	if(b > c){
		bf = c;
		c = b;
		b = bf;
	}
	if(a > b){
		bf = b;
		b = a;
		a = bf;
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

template<typename T> 
map<T,int> factorize(T x){
    map<T,int> res;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            res[i]++;
        }
    }
    if(x!=1) res[x]++;
    return res;
}

ll n;

void solve(){
    cin >> n;
    map<ll,int> D=factorize(n);
    int ans=0;
    for(auto p:D){
        int d=p.second;
        int k=1;
        while(p.second>=2*k+1){
            p.second-=k;
            k++;
        }
        ans+=k;
    }  
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3660
using System;

class ITP1_7_A{
    public static void Main()
    {
        string[] Input;
        string Output = "";
        int m, f, r, count=0;

        while (true)
        {
            Input = Console.ReadLine().Split(' ');
            m = int.Parse(Input[0]);
            f = int.Parse(Input[1]);
            r = int.Parse(Input[2]);

            if (m == -1 && f == -1 && r == -1) break;

            Output += judge(m, f, r);
            count++;
        }

        for (int i = 0; i < count; i++)
            Console.WriteLine(Output[i]);
    }

    static char judge(int m, int f, int r)
    {
        int total = m + f;
        if (m == -1 || f == -1 || total < 30) return 'F';
        if (total >= 80) return 'A';
        if (total >= 65) return 'B';
        if (total >= 50 || r >= 50) return 'C';
        return 'D';
    }
}

Measured memory_bytes: 8916
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

const int B = 320;

int n;
int x[100000];
int l;
int q;
int a[100000];
int b[100000];
int z[20][100000];

int main(){
  cin >> n;
  rep(i, n) cin >> x[i];
  cin >> l >> q;
  rep(i, q){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    if (a[i] > b[i]) swap(a[i], b[i]);
  }
  rep(i, n){
    z[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1;
  }
  rep(i, 19) rep(j, n){
    z[i + 1][j] = z[i][z[i][j]];
  }
  rep(i, q){
    int lb = 0, ub = n - 1;
    while (ub - lb > 1){
      int md = (lb + ub) / 2;
      int t = md;
      int p = a[i];
      rep(j, 20) if (t >> j & 1) p = z[j][p];
      (p >= b[i] ? ub : lb) = md;
    }
    cout << ub << endl;
  }
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define fast std::ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;

void solve(){
    int x,k;
    cin>>x>>k;
    vector<int>v(x);
    long long sum=0, y,mx=0;
    for(int i=0;i<x;i++){
       cin>>v[i];
    }
    sort(v.begin(),v.end());
    int mn=INT_MAX;
    for(int i=0;i<=x-k;i++){
         mn=min(mn,abs(v[i]-v[i+(k-1)]));
    }
    cout<<mn;

}
int main()
{
    fast
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)

typedef long long ll;
typedef unsigned int uint;

int main(void)
{
    string b;
    cin >> b;
    if (b == "A") {
        cout << "T" << endl;
    } else if (b == "C") {
        cout << "G" << endl;    
    } else if (b == "G") {
        cout << "C" << endl;
    } else if (b == "T") {
        cout << "A" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
-- skip.hs --- Skip

-- author: Seong Yong-ju <sei40kr@gmail.com>

main :: IO ()
main = do
  [n, x0] <- map (read :: String -> Int) . take 2 . words <$> getLine
  xs <- map (read :: String -> Int) . take n . words <$> getLine
  let ds = map (abs . (-x0 +)) xs
  print $ foldl gcd (head ds) (tail ds)


Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	string n;
 	cin >> n;
 	if(n[2]==n[1]){
 		if(n[0]==n[1]||n[3]==n[2]){
 			cout << "Yes" << endl;
 			return 0;
 		}
 	}
 	cout << "No" << endl;
 }

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

int main (){
	string str;
	long long N,K,num;
	cin>>str>>N;
	for(int i=0;i<100;i++){
		if(str[i]=='1'&&i+1<N){
			
		}else if(str[i]=='1'&&i+1>=N){
			cout<<1;
			return 0;
		}else if(str[i]!='1'){
			cout<<str[i]<<endl;
			return 0;	
		}	
	}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int> ;

using namespace std;

const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	int minNum = n+1;
	int p;

	int ans = 0;
	rep(i, n) {
		cin >> p;
		if (p <= minNum) ++ans;

		minNum = min(minNum, p);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
// Problem : D - Semi Common Multiple
// Contest : AtCoder - AtCoder Beginner Contest 150
// URL : https://atcoder.jp/contests/abc150/tasks/abc150_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
template <typename T>
T LCM(T x, T y)
{
    T z = __gcd(x, y);
    return x * y / z;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll n,m;
	cin>>n>>m;
	vl a(n);
	cin>>a[0];
	a[0]/=2;
	int l=a[0];
	int count=0;
	while(l%2==0)
	{
		count++;
		l/=2;
	}
	//cout<<count<<nl;
	l00p(i,1,n)
	{
		cin>>a[i];
		a[i]/=2;
	}
	ll lcm=1;
	loop(i,n)
	{
		lcm=LCM(lcm,a[i]);
		int cnt=0;
		while(a[i]%2==0)
		{
			cnt++;
			a[i]/=2;
		}
		//cout<<cnt<<" "<<count<<nl;
		if(cnt!=count)
		{
			cout<<0<<nl;
			return 0;
		}
		
	}
	ll ans=m/lcm;
	cout<<(ans+1)/2;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 4012
#include <stdio.h>

int Operation(int array[], int n)
{
	int num[1000];
	int i, j = 0, f;
	
	while (1){
		f = 0;
		for (i = 1; i < 1000; i++){
			num[i] = 0;
		}
		
		for (i = 0; i < n; i++){
			num[array[i]]++;
		}
		
		for (i = 0; i < n; i++){
			if (f == 0 && array[i] != num[array[i]]){
				f = 1;
			}
			array[i] = num[array[i]];
		}
				
		if (f == 0){
			return (j);
		}
		j++;
	}
}

int main(void)
{
	int array[12], i, n, s;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		printf("%d\n", Operation(array, n));
		
		for (i = 0; i < n; i++){
			if (i != 0){
				printf(" ");
			}
			printf("%d", array[i]);
		}
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 616
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

int main() {
    int N;
    cin >> N;
    auto P = Vec<int>(N, 0);
    for (auto& p : P) cin >> p;

    auto incr = Vec<int>(N + 1, 0);
    // incr[i]=カードiを末尾とする公差1LISの長さ
    for (auto p : P) {
        incr[p] = incr[p - 1] + 1;
    }

    cout << N - *max_element(incr.begin(), incr.end()) << endl;
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 300

struct Info{
	int process,request;
};
int N,num_resource,T;
int num[NUM],available_num[NUM];
int need[NUM][NUM],tmp_have[NUM][NUM];
int gather_num[NUM];
bool finished[NUM];
Info info[200000];

bool is_lock(int tmp_time){

	for(int i = 0; i < N; i++){
		finished[i] = false;
		gather_num[i] = 0;
	}

	for(int i = 0; i < num_resource; i++){
		available_num[i] = num[i];
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < num_resource; k++){
			tmp_have[i][k] = 0;
			if(need[i][k] == 0){
				gather_num[i]++;
			}
		}
	}

	int remain_num = N;
	int proc,req;

	for(int i = 0; i < tmp_time; i++){

		if(available_num[info[i].request] == 0)continue;

		proc = info[i].process;
		req = info[i].request;

		tmp_have[proc][req]++;
		available_num[req]--;

		if(tmp_have[proc][req] == need[proc][req]){
			gather_num[proc]++;

			if(gather_num[proc] == num_resource){

				finished[proc] = true;
				remain_num--;
				for(int k = 0; k < num_resource; k++){
					available_num[k] += tmp_have[proc][k];
				}
			}
		}
	}

	bool FLG,can_finish;

	while(true){

		FLG = false;

		for(int i = 0; i < N; i++){

			if(finished[i])continue;

			can_finish = true;
			for(int k = 0; k < num_resource; k++){
				if(available_num[k] < need[i][k]-tmp_have[i][k]){
					can_finish = false;
					break;
				}
			}
			if(can_finish){
				finished[i] = true;
				FLG = true;
				remain_num--;
				for(int k = 0; k < num_resource; k++){
					available_num[k] += tmp_have[i][k];
				}
			}
		}
		if(!FLG)break;
	}
	return remain_num > 0;
}

int main(){

	scanf("%d %d %d",&N,&num_resource,&T);

	for(int i = 0; i < num_resource; i++){
		scanf("%d",&num[i]);
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < num_resource; k++){
			scanf("%d",&need[i][k]);
		}
	}

	for(int i = 0; i < T; i++){
		scanf("%d %d",&info[i].process,&info[i].request);
		info[i].process--;
		info[i].request--;
	}

	int left = 0,right = T,m = (left+right)/2;
	int ans = -1;

	while(left <= right){

		if(is_lock(m)){
			ans = m;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 5480
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 500;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	VVV dp(n + 1, VV(N, V(N, upper)));
	dp[0][0][0] = 0;
	V d(n), e(n), f(n);
	rep(i, n) {
		cin >> d[i] >> e[i] >> f[i];
	}
	rep(i, n) rep(j, N - 50) rep(k, N - 50) {
		chmin(dp[i + 1][j + d[i]][k + e[i]], dp[i][j][k] + f[i]);
		chmin(dp[i + 1][j][k], dp[i][j][k]);
	}
	int ans = upper;
	rep1(i, 45) {
		chmin(ans, dp[n][a * i][b * i]);
	}
	cout << (ans == upper ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 45200