akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <map>
//#include <bits/stdc++.h>
using namespace std;
/*inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}*/
typedef long long ll;
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}
long long a[100004],b[100004],k[1000001];
int main() {
    int n,x;
    while(cin>>n)
    {
        long long ans=0,mi=9999999,k=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            ans+=abs(a[i]);
            if(a[i]<0)
                k++;
            mi=min(mi,abs(a[i]));
        }
        if(k%2==0)
            cout<<ans<<endl;
        else
            cout<<ans-2*mi<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import itertools
n,c = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=lambda x:x[0])
a.sort(key=lambda x:x[2])

# 同じチャンネルの番組を繋げる。
for i in range(n-1):
    if a[i][1]==a[i+1][0] and a[i][2]==a[i+1][2]:
        a[i][1]-=1
# いもす法
x=[0]*(10**5+5)
for i in range(n):
    x[a[i][0]]+=1
    x[a[i][1]+1]-=1

x = itertools.accumulate(x)
print(max(x))

Measured memory_bytes: 69208
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int MAXN = (int)1e2 + 10;

int m,n;
int p[MAXN];
int a[MAXN][MAXN];
int vis[MAXN];
int d[MAXN];
const int INF = (int) 0x3f3f3f3f;

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) p[i]=i;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int ans=0;
    int cur=1,cnt=1;
    vis[1]=1;
    for(int i=2;i<=n;i++) d[i]=INF;
    for(int i=1;i<=n;i++)if(a[1][i]!=-1) d[i]=a[1][i];
    while(cnt<n){
        int id=0;
        for(int i=1;i<=n;i++)if(!vis[i]){
            if(id==0||d[id]>d[i]){
                id=i;
            }
        }
        vis[id]=1;
        cnt++;
        ans+=d[id];
        for(int i=1;i<=n;i++)if(!vis[i]&&a[id][i]!=-1){
            d[i]=min(d[i],a[id][i]);
        }
    }
    if(cnt==n) printf("%d\n",ans);
    else printf("-1\n");
}

int main(){
    work();
    return 0;
}

/*
5
-1 2 3 1 -1
2 -1 -1 4 -1
3 -1 -1 1 1
1 4 1 -1 3
-1 -1 1 3 -1
*/



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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll fac[400010];
ll inv[400010];

 long long pow_mod(long long n, long long p) {
     long long ret = 1;
     while (p > 0) {
         if (p & 1) ret = (ret * n) % MOD;
         n = (n * n) % MOD;
         p >>= 1;
     }
     return ret;
 }
 
 void prepare() {
     fac[0] = fac[1] = 1LL;
     inv[0] = inv[1] = 1LL;
     for (long long i = 2; i <= 400000; i++) {
         fac[i] = fac[i - 1] * i;
         fac[i] %= MOD;
         inv[i] = pow_mod(fac[i], MOD - 2LL);
     }
 }
 
 long long ncr_mod(long long n, long long r) {
     return fac[n] * inv[n - r] % MOD * inv[r] % MOD;
 }

int main() {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    prepare();

    ll ans = 0;
    for (ll w = B; w < W; w++) {
        ll w1 = w;
        ll h1 = (H - 1 - A);
        ll sum1 = ncr_mod(w1 + h1, w1);

        ll w2 = W - w1 - 1;
        ll h2 = A - 1;
        ll sum2 = ncr_mod(w2 + h2, w2);

        ans += (sum1 * sum2) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
flag = True
n = input()
a = input().split()
a = [int(a_tmp) for a_tmp in a]

even =[]

for i in a:
    if i%2 == 0:
        even.append(i)

for i in even:
    if i%3 != 0 and i%5 != 0:
        flag = False
        break
    
if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
    int x[5] = {1,1,1,1,1};
    int a;
    for(a = 0;a < 5;a++){
        scanf("%d",&x[a]);
    }
    for(a = 0;a < 5;a++){
        if(x[a] == 0){
            printf("%d\n",a+1);
        }
    }
    return 0;
}


Measured memory_bytes: 1732
fun main (args : Array<String>) {
	val (n1, n2, n3) = readLine()!!.split(" ").map(String::toInt)
	val r : Int = n1.toInt()
	val D : Int = n2.toInt()
	val x : Int = n3.toInt()
	var num : Int = (r * x) - D
	var result : Int = 0
	println("${num}")
	for (i in 1..9) {
		result = (r * num) - D
		num = result
		println("${result}")
	}
}

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

signed main(void)
{
	int n;
	string s;
	long long sum, r, g, b;

	cin >> n >> s;
	r = g = b = 0;
	rep(i, n)
	{
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else if (s[i] == 'B') b++;
	}
	sum = r * g * b; 
	rep(i, n - 1)
	{
		for(int j = i + 1; j < n; j++)
		{
			int k = 2 * j - i;
			if (k >= n) continue;
			if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
				sum--;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll extended_GCD(ll a , ll b , ll &x , ll &y){
    if(a == 0){
        x = 0;
        y = 1;
        return b;
    }
    ll x1 , y1;
    ll gcd = extended_GCD(b%a , a , x1 , y1);
    x = y1 - (b/a)*x1; 
    y = x1;
    return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod ){
    ll x , y;
    extended_GCD(a , mod , x , y);
    if(x < 0) x += mod;
    return x;
}

ll mul(ll a,ll b,ll m)
{
    return (a%m*b%m)%m;
}
  
 


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    ll a[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<ll> pre(m);
    cin>>pre[0];
    for(int i=1;i<m;i++)
    {
        ll b;
        cin>>b;
        pre[i] = pre[i-1] + b;
    }
    ll s = 0;
    ll ans = 0;;
    int g = lower_bound(pre.begin(),pre.end(),k) - pre.begin();
    if(pre[g]!=k)
        g--;
    ans = g+1;
    for(ll i=0;i<n;i++)
    {
        s+=a[i];
        if(k-s<0)
            continue;
        ll g = lower_bound(pre.begin(),pre.end(),k-s) - pre.begin();
        if(pre[g]!=k-s)
            g--;
        ans = max(ans,g+1+i+1);
    }
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 6332
import java.util.Scanner;

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

public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	while (in.hasNext()) {
		final int val = 18 - Math.abs(18 - in.nextInt());
		int count = 0;
		if (val <= 36 / 2) {
			for (int a = 0; a < 10; a++) {
				if (val >= a) {
					for (int b = 0; b < 10; b++) {
						int ab = a + b;
						if (val >= ab) {
							for (int c = 0; c < 10; c++) {
								int abc = ab + c;
								if (val >= abc) {
									for (int d = 0; d < 10; d++) {
										if ((abc + d) == val) {
											count++;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		System.out.println(count);
	}
}
}

Measured memory_bytes: 0
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
b = [a[i][: ] for i in range(N)]
for k in range(N):
 for i in range(N):
  for j in range(N):
   b[i][j] = min(b[i][j], b[i][k] + b[k][j])
inf = 10 ** 10
if a == b:
 dp = [[inf] * N for _ in range(N)]
 for i in range(N):
  for j in range(N):
   mn = i
   for k in range(N):
    if k == j: continue
    if a[i][k] + a[k][j] == a[i][j]:
     if a[mn][j] > a[k][j]:
      mn = k
   if dp[mn][j] == inf:
    dp[mn][j] = a[mn][j]
   elif dp[mn][j] != a[mn][j]:
    print(-1)
    exit(0)
 for i in range(N):
  for j in range(N):
   if dp[i][j] == inf: dp[i][j] = 0
 print(sum([sum(dp[i]) for i in range(N)]) // 2)
else: print(-1)

Measured memory_bytes: 76516
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	string s;
	cin >> s;
	rep(i, 0, s.size()) {
		if (s[i] == 'A') {
			for (int j = s.size() - 1; j > i; j--) {
				if (s[j] == 'Z') {
					cout << j - i + 1 << endl;
					return 0;
				}
			}
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a,b,n;
int main(){
	cin>>a>>b;
	a=b*2+1;
	int m=b;
	if(b%2==1){
		int l=1,r=m;
		while(l!=r){
			printf("%d %d\n",l,r);
			l++;r--;
		}
		l=m+1,r=m*2+1;
		while(l<=r){
			printf("%d %d\n",l,r);
			l++;r--;
		}
	}
	if(b%2==0){
		int l=1,r=m+1;
		while(l!=r){
			printf("%d %d\n",l,r);
			l++;r--;
		}
		l=m+2,r=m*2+1;
		while(l<=r){
			printf("%d %d\n",l,r);
			l++;r--;
		}
	}
}

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

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int H,W;

int dx[2] = {1,0};
int dy[2] = {0,1};

void bfs(vector<vector<char>> &c, vector<vector<int>> &seen) {
    int cnt = 0;
    queue<P> qw,qb;
    vector<vector<bool>> queued(H,vector<bool>(W,false));
    
    bool now = true;
    if (c[0][0]=='.') {
        qw.push(make_pair(0,0));
        queued[0][0] = true;
    }
    else {
        qb.push(make_pair(0,0));
        queued[0][0] = true;
    }
    while(qb.size() || qw.size()) {
        if (now) {
            while(qw.size()) {
                auto q = qw.front();
                qw.pop();
                int h,w;
                h = q.first;
                w = q.second;
                seen[h][w] = cnt;
                
                rep(i,2) {
                    if (h+dy[i]>=H || w+dx[i]>=W) {
                        continue;
                    }
                    else if (seen[h+dy[i]][w+dx[i]]!=INF) continue;
                    else if (queued[h+dy[i]][w+dx[i]] == true) continue;
                    else if (c[h+dy[i]][w+dx[i]]=='#') {
                        qb.push(make_pair(h+dy[i],w+dx[i]));
                        queued[h+dy[i]][w+dx[i]] = true;
                    }
                    else {
                        qw.push(make_pair(h+dy[i],w+dx[i]));
                        queued[h+dy[i]][w+dx[i]] = true;
                    }
                }
            }
            cnt++;
            now = false;
        }
        if (!now) {
            while(qb.size()) {
                auto q = qb.front();
                qb.pop();
                int h,w;
                h = q.first;
                w = q.second;
                seen[h][w] = cnt;
                
                rep(i,2) {
                    if (h+dy[i]>=H || w+dx[i]>=W) {
                        continue;
                    }
                    else if (seen[h+dy[i]][w+dx[i]]!=INF) continue;
                    else if (queued[h+dy[i]][w+dx[i]] == true) continue;
                    else if (c[h+dy[i]][w+dx[i]]=='.') {
                        qw.push(make_pair(h+dy[i],w+dx[i]));
                        queued[h+dy[i]][w+dx[i]] = true;
                    }
                    else {
                        qb.push(make_pair(h+dy[i],w+dx[i]));
                        queued[h+dy[i]][w+dx[i]] = true;
                    }
                }
            }
            cnt++;
            now = true;
        }
    }
}

int main(){
    cin >> H >> W;

    vector<vector<char>> c(H,vector<char>(W));
    vector<vector<int>> seen(H,vector<int>(W,INF));

    rep(h,H) {
        string tmp;
        cin >> tmp;
        rep(w,W) {
            c[h][w] = tmp[w];
        }
    }
    bfs(c,seen);
    if (c[H-1][W-1]=='.') {
        cout << seen[H-1][W-1]/2 << endl;
    }
    else {
        cout << seen[H-1][W-1]/2+1 << endl;
    }

}


Measured memory_bytes: 3700
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;


/*
I,O,J,Lの四種類しか使うことができない。
Oは、1つごとに横幅 +2。
I,J,Lは、2つごとに横幅 +4。
それとは別に、I+J+Lで横幅 +6できる。
*/

int main() {
	long long aI, aO, aT, aJ, aL, aS, aZ;
	long long ans;
	scanf("%lld %lld %lld %lld %lld %lld %lld", &aI, &aO, &aT, &aJ, &aL, &aS, &aZ);

	ans = aO  + (aI/2)*2 + (aJ/2)*2 +(aL/2)*2;
	if (aI % 2 == 1 && aL % 2 == 1 && aJ % 2 == 1) {
		ans = ans + 3;
	}
	if (aI>0 && aI % 2 == 0 && aL % 2 == 1 && aJ % 2 == 1) {
		ans = ans + 1;
	}
	if (aI % 2 == 1 && aL>0 && aL % 2 == 0 && aJ % 2 == 1) {
		ans = ans + 1;
	}
	if (aI % 2 == 1 && aL % 2 == 1 && aJ % 2 == 0 && aJ>0) {
		ans = ans + 1;
	}
	printf("%lld", ans);
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Text;

public class Program{
    public static void Main(){
        var watch = new Stopwatch();
        watch.Start();
        var isTest = false;
        var stream = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
        Console.SetOut(stream);
        TextReader reader;
        string filename="";
        
        if(filename.Length!=0){
            reader = new StreamReader(filename);
        }else{
            reader = Console.In;
        }

        var n = int.Parse(reader.ReadLine());
        var a = reader.ReadLine().Split().Select(int.Parse).ToArray();
        var ans = a.Max()-a.Min();
        Console.WriteLine(ans);

        watch.Stop();
        if(isTest){
            Console.WriteLine($"実行時間{watch.ElapsedMilliseconds}ミリ秒");
        }
        Console.Out.Flush();
    }
}


Measured memory_bytes: 11476
#include<stdio.h>

#define MAX 100005
#define NIL -1

struct Node{
    int p, l, r;
};

struct Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r, d+1);
}

int setHeight(int u){
    int h1=0, h2=0;

    if(T[u].l != NIL) h1 = setHeight(T[u].l) + 1;
    if(T[u].r != NIL) h2 = setHeight(T[u].r) + 1;

    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
    if(T[u].p == NIL) return NIL;
    if(T[T[u].p].l != u && T[T[u].p].l != NIL) return T[T[u].p].l;
    if(T[T[u].p].r != u && T[T[u].p].r != NIL) return T[T[u].p].r;
    return NIL;
}

void print(int u){
    int deg=0;

    printf("node %d: parent = %d, sibling = %d, ", u, T[u].p, getSibling(u));
    
    if(T[u].l != NIL) deg++;
    if(T[u].r != NIL) deg++;

    printf("degree = %d, depth = %d, height = %d, ", deg, D[u], H[u]);

    if(T[u].p == NIL){
        printf("root\n");
    }else if(T[u].l == NIL && T[u].r == NIL){
        printf("leaf\n");
    }else{
        printf("internal node\n");
    }

}

int main(){
    int i;
    int v, l, r, root=0;

    scanf("%d", &n);

    for(i=0; i<n; i++) T[i].p = NIL;

    for(i=0; i<n; i++){
        scanf("%d%d%d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }

    for(i=0; i<n; i++){
        if(T[i].p == NIL) root = i;
    }

    setDepth(root, 0);
    setHeight(root);

    for(i=0; i<n; i++) print(i);

    return 0;
}





Measured memory_bytes: 2100
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let r: f64 = sc.read();
    const PI: f64 = std::f64::consts::PI;
    println!("{:.09} {:.09}", r*r*PI, 2.0*r*PI);
}



Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);++(i))
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);--(i))
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, a + b + 1) + b << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[]=new int[31];
			a[0]=0;
			a[1]=1;
			a[2]=2;
			a[3]=4;
			for(int i=4;i<=n;i++)
				a[i]=a[i-1]+a[i-2]+a[i-3];
			System.out.println((a[n]/365/10)+1);
		}
	}
}

Measured memory_bytes: 12000
//
// Created by 倉澤　一詩 on 2019/12/31.
//

#include <iostream>

using namespace std;

int main(){

    int n;

    cin >> n;

    while(1){

        int prime_count = 0;

        for (int i = 2; i < n-1; i++) {

            if( !(n%i) ){
                prime_count++;
            }
        }

        if(!prime_count) {
            cout << n;
            return 0;
        }

        n++;
    }

}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var A1 = Sarray();
            var A2 = Sarray();
            var a1sum = 0L;
            var a2sum = A2.Sum();
            var ans = 0L;
            for(var i=0;i<N;++i)
            {
                a1sum += A1[i];
                ans = Max(ans, a1sum + a2sum);
                a2sum -= A2[i];
            }
            WriteLine(ans);
        }
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28196
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	while(1){
		int x,a;
		cin>>x;
		if(x==0) break;
		rep(i,0,9){
			cin>>a; x-=a;
		}
		o(x);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

    ll ans=1;
    for (int i = 1; i <= n; i++) {
        ans = ans*i % 1000000007;
    }

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

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


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

int main()
{
	int h, w, d, n, r;
	bool f;
	while (cin>>h>>w>>d, h||w||d) {
		cin>>n;
		while (n-- >  0) {
			cin>>r;
			f = 0;
			if (h*h+w*w < 4*r*r) f = 1;
			if (w*w+d*d < 4*r*r) f = 1;
			if (d*d+h*h < 4*r*r) f = 1;
			if (f) cout<<"OK"<<endl;
			else cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N; cin >> N;
  vector <int> p(N);
  for (int i = 0; i < N; i++){
    cin >> p[i]; p[i]--;
  }

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

    if (i == 0){
      if (p[i] == i){
        ans++;
        p[0] = p[1]; p[1] = 0;
      }
    }else if(i == N - 1){
      if (p[i] == i){
        ans++;
      }
    }else{
      if (p[i] == i){
        ans++;
        p[i + 1] = p[i];
      }
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <bits/stdc++.h>
using namespace std;  
int size=200000; 
vector<bool> used(size,false); 
 
 pair<int,int> BFS(vector<vector<int> > al,int s){ 
 	int n=al.size(); 
 	vector<int> d(n,0); 
	queue<int> q; 
 	q.push(s);  
 	used[s]=true; 
 	while(!q.empty() ){ 
		int v=q.front();  
 		 q.pop(); 
 		 for(int u: al[v]){ 
 		 	if(!used[u]){ 
 		 		d[u]=d[v]+1;  
 		 		used[u]=true; 
 		 		q.push(u);
			  }
		  }
	 } 
	 int m=0; 
	 int v; 
	 for(int i=0;i<n;i++){ 
	 	if(d[i]>m){ 
	 		m=d[i]; 
	 		v=i; 
		 }
	 } 
	 return pair<int,int>(m,v); 
 }
 
 int main(){
  	ios::sync_with_stdio(false);
    cin.tie(0);  
    int N; 
    cin>>N; 
	vector<vector<int> > al(N);  
    for(int i=1;i<N;i++){ 
    	int a,b; 
    	cin>>a>>b;
    	a--; 
    	b--;  
    	al[a].push_back(b); 
		al[b].push_back(a); 
		 
	}  
	
	pair<int,int> mv=BFS(al,0); 
	for(int i=0;i<N;i++){ 
		used[i]=false; 
	} 
	pair<int,int> mvf=BFS(al,mv.second); 
	int val=mvf.first;  
	if (val%3==1){ 
		cout<<"Second"; 
	}else{ 
		cout<<"First"; 
	}
	
    
    return 0; 
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++){
    cin >> V.at(i);
  }
  for (int i = 0; i < N; i++){
    cin >> C.at(i);
  }
  
  int c, count;
  for (int i = 0; i < N; i++){
    c = V.at(i) - C.at(i);
    if(c > 0){
      count += c;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    int n, x; cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];

    int pos = 0;
    int ans = 1;
    rep(i, n){
        pos += l[i];
        if(pos <= x) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 100000000001
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};


int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m;
bool check(char s[100][100], int i, int j) {
	if (j == 0) if (s[i][j+1]=='#') return true;
	if (j == m-1) if (s[i][j-1]=='#') return true;
	if (j>0 && j<m-1) if (s[i][j+1]=='#' or s[i][j-1]=='#') return true;
	if (i == 0) if (s[i+1][j]=='#') return true;
	if (i == n-1) if (s[i-1][j]=='#') return true;
	if (i>0 && i<n-1) if (s[i-1][j]=='#' or s[i+1][j]=='#') return true;
	return false;
}
int main () {
	cin >> n >> m;
	char s[100][100];
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> s[i][j];
		}
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			if (s[i][j] == '#' && check(s, i, j) == false) {cout << "No"; return 0;}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>


 
int main(void)
{
	double r;
	double l, s, PI = 3.141592653589;
	scanf("%lf", &r);
	l = 1.0 * 2 * r*PI;
	s = 1.0*r*r*PI;
	printf("%f %f\n", s,l);
	return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

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

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


int main() {
    ll n;
    cin>>n;
    vector<pair<ll,int>> a(n),b(n);
    rep(i,n){
        ll k;
        cin>>k;
        a[i] = {k,i};
    }
    rep(i,n){
        ll k;
        cin>>k;
        b[i] = {k,i};
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    rep(i,n){

        if(a[i].first>b[i].first){
          //  cout<<a[i].first<<b[i].first;
            cout<<"No"<<endl;return 0;
        }
    }

   for(int i=1;i<n;i++){
       if(a[i].first<=b[i-1].first){
           cout<<"Yes"<<endl;
           return 0;
       }
   }

   vector<ll> to(n,0);
   rep(i,n){
       to[a[i].second] = b[i].second;
   }

   int cnt = 1;
   ll next = to[0];
   set<ll> s;
   s.insert(0);
   while(true){
       next = to[next];
       cnt ++;
       if(next==0)break;
   }

   if(cnt == n){
       cout<<"No"<<endl;
   }else{
       cout<<"Yes"<<endl;
   }





    return 0;
}


Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
"""
B - Ruined Square
https://atcoder.jp/contests/abc108/tasks/abc108_b

"""
import sys


def solve(x1, y1, x2, y2):
    dx = x2 - x1
    dy = y2 - y1
    x3, y3 = x2 - dy, y2 + dx
    dx = x3 - x2
    dy = y3 - y2
    x4, y4 = x3 - dy, y3 + dx
    return (x3, y3, x4, y4)


def main(args):
    x1, y1, x2, y2 = map(int, input().split())
    ans = solve(x1, y1, x2, y2)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef pair<ll,ll> P;
const ll MAX_N=1e5,INF=2e9;
ll N;
P pbl[MAX_N],seg[2][MAX_N+1];
ll len(P p){
	return max(p.second-p.first+1,0ll);
}
P crs(P a,P b){
	return P(max(a.first,b.first),min(a.second,b.second));
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N){
		ll l,r;
		cin>>l>>r;
		pbl[i]=P(l,r);
	}
	sort(pbl,pbl+N,[](P a,P b){
		return a.second<b.second;
	});
	sort(pbl+1,pbl+N,[](P a,P b){
		return a.first<b.first;
	});
	REP(t,2){
		seg[t][0]=P(-INF,INF);
		REP(i,N){
			seg[t][i+1]=crs(seg[t][i],pbl[i]);
		}
		reverse(pbl,pbl+N);
	}
	ll ans=0;
	REP(i,N-1){
		ans=max(ans,len(seg[0][i+1])+len(seg[1][N-i-1]));
	}
	REP(i,N){
		ans=max(ans,len(pbl[i])+len(crs(seg[0][i],seg[1][N-i-1])));
	}
	cout<<ans<<endl;
}


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

ll euclid(ll a, ll b)
{
    int nr = 0;
    while (b != 0)
    {
        int c = b;
        b = a % b;
        a = c;
        nr++;
    }
    return nr;

}
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int H, W;
int A, B;

signed main(){
    cin >> H >> W >> A >> B;
    rep(i, B){
        string ans = "";
        rep(j, A) ans += "0";
        rep(j, W-A) ans += "1";
        cout << ans << endl;
    }
    rep(i, H-B){
        string ans = "";
        rep(j, A) ans += "1";
        rep(j, W-A) ans += "0";
        cout << ans << endl;
    }
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long long int n, ans = 0;
    cin >> n;
    vector<int> a(n + 1), b(n);
    for(int i = 0;i < n + 1;i++) cin >> a[i];
    for(int i = 0;i < n;i++) cin >> b[i];

    for(int i = 0;i < n;i++){
        if(a[i] + a[i + 1] >= b[i]){
            ans += b[i];
            if(b[i] - a[i] >= 0){
                a[i + 1] = a[i + 1] - (b[i] - a[i]);
            }
            b[i] = 0;
        }
        else{
            ans += a[i] + a[i + 1];
            b[i] -= a[i] + a[i + 1];
            a[i + 1] = 0;
        }
    }

    cout << ans;

    return 0;
}


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


using namespace std;


template<typename T>
class UF
{
public:
	UF() {
		size = 0;
	}

	//値を挿入する
	void push( T a ) {
		M[a] = size;
		V.push_back( size );
		rank.push_back( 0 );
		C.push_back( 1 );
		size++;
	}

	//同じグループにする
	void unite( T a, T b ) {
		long long int x = find( M[a] );
		long long int y = find( M[b] );
		if( x == y )return;
		if( rank[x] < rank[y] ) {
			V[x] = y;
			C[y] += C[x];
		} else {
			V[y] = x;
			C[x] += C[y];
			if( rank[x] == rank[y] )rank[x]++;
		}
	}

	void merge( T a, T b ) {
		unite( a, b );
	}

	//同じグループにいるかどうか判定する
	bool same( T a, T b ) {
		return find( M[a] ) == find( M[b] );
	}

	//今何グループあるか数を返す
	long long int group() {
		set<long long int>S;
		for( long long int i = 0; i < V.size(); i++ ) {
			S.insert( find( V[i] ) );
		}
		return S.size();
	}

	//グループに属している数を返す
	long long int count( T a ) {
		return C[find( M[a] )];
	}

	//今属しているグループのIDを返す
	long long int groupID( T a ) {
		return find( M[a] );
	}

	//同じグループのメンバーを返す
	vector<T>friendList( T a ) {
		long long int inputID = groupID( M[a] );
		vector<T>ret;
		for( auto now : M ) {
			if( find( now.second ) == inputID ) {
				ret.emplace_back( now.first );
			}
		}
		return ret;
	}

private:
	vector<long long int>C, V, rank;
	map < T, long long int>M;
	long long int size;

	//祖先までたどる
	long long int find( long long int x ) {
		if( V[x] == x )return x;
		else return V[x] = find( V[x] );
	}
};



int main() {
	long long int N, K, L;
	cin >> N >> K >> L;

	//UnionFind初期化
	UF<long long int>uf1, uf2;
	for( size_t i = 0; i < N; i++ ) {
		uf1.push( i );
		uf2.push( i );
	}

	//uf1は道路グループ
	for( size_t i = 0; i < K; i++ ) {
		long long int p, q;
		cin >> p >> q;
		p--; q--;
		uf1.merge( p, q );
	}

	//uf2は鉄道グループ
	for( size_t i = 0; i < L; i++ ) {
		long long int r, s;
		cin >> r >> s;
		r--; s--;
		uf2.merge( r, s );
	}

	map<long long int, map<long long int, long long int>>ansmap;
	for( size_t i = 0; i < N; i++ ) {
		ansmap[uf1.groupID( i )][uf2.groupID( i )]++;
	}

	for( size_t i = 0; i < N; i++ ) {
		cout << ansmap[uf1.groupID( i )][uf2.groupID( i )] << (i == N - 1 ? "\n" : " ");
	}
}

Measured memory_bytes: 62120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
#define rep(i, n) for(int i = 0; i < n; i++)
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(){
    //入力
    int n, C; scanf("%d%d", &n, &C);
    int D[30][39] = {0};
    int c[n][n] = {0};
    int mn = 1 << 30;
    rep(i, C){
        rep(j, C){
            scanf("%d",&D[i][j]);
        }
    }
    int color[3][30];
    rep(i, n){
        rep(j, n){
            scanf("%d", &c[i][j]),
            color[(i+j)%3][c[i][j]-1]++;
        }
    }
    rep(i, C)rep(j, C)if(i != j)rep(k, C)if(i != k && j != k){
                        int tt = 0;
                        rep(l,C) tt += D[l][i]*color[0][l];
                        rep(l,C) tt += D[l][j]*color[1][l];
                        rep(l,C) tt += D[l][k]*color[2][l];
                        mn = min(mn, tt); 
    }
    printf("%d\n", mn);
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    ll a[n],b[n];
    ll ans=0;
    rep(i,n){
        cin>>a[i]>>b[i];
        ans+=a[i];
    }
    vector<int>ord(n);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return a[x]+b[x] > a[y]+b[y];
    });
    rep(i,n){
        if(i%2){
            ans-=a[ord[i]]+b[ord[i]];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
bool check(int arr[], int j, int n) {
    for (int i=j+1; j<n; j++) {
        if (arr[i-1] < arr[i])
            continue;
        else
        {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    scanf("%d", &n);
    vector<int> A(n+1);
    vector<int> B(n);
    for (int i=0; i<n+1; i++) {
        scanf("%d", &A[i]);
    }
    for (int i=0; i<n; i++) {
        scanf("%d", &B[i]);
    }
    long long total = 0;
    int i=0, j=0;
    while(i<n && j<n+1) {
        if ((i==j || i == j-1)) {
            if (A[j] >= B[i]) {
                A[j]-=B[i];
                total += B[i];
                B[i]=0;
                i++;
            } else {
                B[i] -= A[j];
                total += A[j];
                A[j] = 0;
                j++;
            }
        } else if (j > i)
            i++;
        else if (i > j)
            j++;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	vector<int> b(N);
	int i;
	int count=0;
	for (i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == b[i]) {
			count++;
		}
		else {
			count = 0;
		}
		if (count > 2) {
			cout << "Yes";
			break;
		}
	}
	if (count <= 2) {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
long long s,sum,n,a[1000001],b[1000001],cnt,ans;
long long f(long long x,long long y)
{
	if (x*y%9!=0)
		return x*y%9;
	if (x==0)
		return 0;
	return 9; 
} 
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>a[i]>>b[i];
		ans+=b[i];
	}
	for (int i=1;i<=n;++i)
	{
		cnt=0;
		for (int j=0;j<=8;++j)
			if (f(a[i],j)+a[i]>9)
				cnt++;
		cnt*=(b[i]/9);
		for (int j=0;j<=b[i]%9-1;++j)
			if (f(a[i],j)+a[i]>9)
				cnt++;
		if (f(a[i],0)+a[i]>9)
			cnt--;
		ans+=cnt;
	}
	for (int i=1;i<=n;++i)
		a[i]=f(a[i],b[i]);
	for (int i=1;i<=n;++i)
		{
			sum+=a[i];
			if (sum>9)
			{
				sum-=9;
				ans++;
			}
		}
	cout<<ans-1<<endl;
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vint h(n);
    for (auto& x : h)
    {
        cin >> x;
    }

    int ans = 0;
    int max_h = 0;
    rep(i, n) {
        if (max_h <= h[i]) {
            ++ans;
            max_h = h[i];
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V <= W:
    if A == B:
        print('YES')
        exit()
    else:
        print('NO')
        exit()
else:
    t = abs(A-B)/(V-W)
    if T >= t:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 61620
# C - Splitting Pile
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sum = sum(a)
    cnt = 0
    ans = float('inf')

    for i in range(n-1):
        cnt += a[i]
        ans = min(ans, abs(a_sum-cnt*2))
    else:
        print(ans)


if __name__ ==  "__main__":
    main()

Measured memory_bytes: 30592
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()

    cnt = [0] * N
    for i in range(2, N + 1):
        x = i
        for j in range(2, i + 1):
            while x % j == 0:
                x //= j
                cnt[j - 1] += 1
            if x == 1: break

    ret = 1
    for r in cnt:
        ret *= r + 1
        ret %= MOD
    print(ret)


if __name__ == '__main__':
    main()


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

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

  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') cnt++;
  }

  if (15 - s.size() + cnt >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = (ss); ii < (ll)(ee); ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define MSB(bm) ((bm==0)?-1:(63-__builtin_clzll((bm))))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
// #define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
// #define degug(...) 663
#define cerr if(0)cout
#endif
ll a,b,c;
int main(){
	FAST
	ll n;cin>>n;ll A[n];
	FOR(i,0,n) cin>>A[i];
	A[0]--;
	FOR(i,1,n){
		if(A[i]-1 >= A[i-1]) --A[i];
		if(A[i] < A[i-1]) { cout<<"No\n"; return 0; }
	} 
	cout<<"Yes\n";
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
typedef struct Dice
{
  int top;
  int bottom;
  int front;
  int back;
  int right;
  int left;
} dice;
void input(dice*);
void roll(dice*,char);
int main(void)
{
  int i;
  int len;
  dice d;
  char op[200];
  input(&d);
  scanf("%s",op);
  len=strlen(op);
  for(i=0;i<len;i++) roll(&d,op[i]);
  printf("%d\n",d.top);
  return 0;
}
void input(dice *d)
{
  scanf("%d",&d->top);
  scanf("%d",&d->front);
  scanf("%d",&d->right);
  scanf("%d",&d->left);
  scanf("%d",&d->back);
  scanf("%d",&d->bottom);
}
void roll(dice *d,char c)
{
  int temp;
  switch(c)
    {
    case 'E':
      temp=d->right;
      d->right=d->top;
      d->top=d->left;
      d->left=d->bottom;
      d->bottom=temp;
      break;
    case 'N':
      temp=d->back;
      d->back=d->top;
      d->top=d->front;
      d->front=d->bottom;
      d->bottom=temp;
      break;
    case 'S':
      temp=d->front;
      d->front=d->top;
      d->top=d->back;
      d->back=d->bottom;
      d->bottom=temp;
      break;
    case 'W':
      temp=d->left;
      d->left=d->top;
      d->top=d->right;
      d->right=d->bottom;
      d->bottom=temp;
      break;
    }
}


Measured memory_bytes: 2040
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n;
	cin >> n;

	vector<ll> vec(5);
	for (ll i = 0; i < 5; i++) {
		cin >> vec[i];
	}

	ll minMove = *min_element(begin(vec), end(vec));
	ll ans = n / minMove + 5L
		- (ll)(minMove == 1LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int a ;
	int b ;
	scanf("%d%d",&a,&b) ;
	char abc[55] ;
	scanf("%s", &abc) ;
	abc[b-1]+= 32 ;
	printf("%s", abc) ;
	
	
	
	
	
	
	return 0 ;
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	vector<int> a(3);
	get a.at(0);
	get a.at(1);
	get a.at(2);

	std::sort(a.begin(), a.end());

	int ans = abs(a.at(0) - a.at(1)) + abs(a.at(1) - a.at(2));
	put ans;

}

int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


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

int main() {
  float x, y, z;
  string result;
  
  cin >> x;
  cin >> y;
  cin >> z;
  
  if(x / z <= y) {
    result = "Yes";
  } else {
    result = "No";
  }
  //cout << x / z << endl; 
  
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 3724