akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
ll mod=1000000007;

int main(){
    ll n,answer=0,answer2=0;cin>>n;
    vector<ll> a(n+1),key(n+1);
    
    for(i=1;i<=n;i++){cin>>a[i];}
    for(i=1;i<=n;i++){key[i]=a[i]-i;}

    sort(key.begin()+1,key.end());
    
    double center;
    if(n%2==0){center=(key[n/2]+key[n/2+1])/2;}
    else{center=key[(n+1)/2];}

    ll llcenter=(ll)(center);
    if(center>=0 && abs(double(llcenter)-center)-abs(double(llcenter+1)-center)>=0){
        llcenter=llcenter+1;
    }
    if(center<0 && abs(double(llcenter)-center)-abs(double(llcenter-1)-center)>=0){
        llcenter=llcenter-1;
    }

    for(i=1;i<=n;i++){
        answer+=abs(key[i]-llcenter);
    }
    cout<<answer<<endl;
    return 0;
}

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

typedef long long ll;
const int n_num = 1e5+5;
const ll inf = 1e9+7;

typedef struct {
	int I;
	int from;
	int cost;
	vector<pair<int,int>> to;
} _node;

bool operator > (const _node& a,const _node& b) {
	return a.cost > b.cost;
}

_node node[n_num];
priority_queue<_node,vector<_node>,greater<_node>> pque;

string ans;

void ds_init() {
	for (int i = 0;i < n_num;i++) {
		node[i].I = i;
		node[i].from = i;
		node[i].cost = inf;
	}
}

void dijkstra() {
	while (!pque.empty()) {
		_node next = pque.top();
		pque.pop();
		if (next.cost > node[next.I].cost) continue;
		for (int i = 0;i < next.to.size();i++) {
			if (node[next.to[i].first].cost > next.cost + next.to[i].second) {
				node[next.to[i].first].cost = next.cost + next.to[i].second;
				node[next.to[i].first].from = next.I;
				pque.push(node[next.to[i].first]);
			}
		}
	}
}

void searchpath(int now) {
	if (node[now].from != now) {
		ans = to_string(node[now].from) + " " + ans;
		searchpath(node[now].from);
	} else {
		return;
	}
}

int main() {
	int k;
	cin >> k;
	for (int i = 0;i < k;i++) {
		node[i].to.push_back({(i+1)%k,1});
		node[i].to.push_back({(i*10)%k,0});
	}
	ds_init();
	node[1].cost = 1;
	for (int i = 0;i < node[1].to.size();i++) {
		node[node[1].to[i].first].cost = node[1].to[i].second + node[1].cost;
		node[node[1].to[i].first].from = 1;
		pque.push(node[node[1].to[i].first]);
	}
	dijkstra();
	cout << node[0].cost << endl;
}

Measured memory_bytes: 11796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,m,b[800005],c[800005];
vector<pair<ll,ll> > a[800005];
void f(ll x,ll l,ll r,ll rl,ll rr,ll z){
    if(rl<=l and r<=rr){
        b[x]+=z,c[x]+=z;
        return ;
    }
	ll mid=(l+r)>>1;
	if(rl<=mid)f(x*2,l,mid,rl,rr,z);
	if(rr>mid)f(x*2+1,mid+1,r,rl,rr,z);
	b[x]=max(b[x*2],b[x*2+1])+c[x];
}
int main(){
	n=read(),m=read();
	for(int i=0;i<m;i++){
		ll x=read(),y=read(),z=read();
		a[y].push_back({x,z});
	}
	for(int i=1;i<=n;i++){
        f(1,1,n,i,i,b[1]);
        for(int j=0;j<a[i].size();j++)
            f(1,1,n,a[i][j].first,i,a[i][j].second);
    }
    printf("%lld",max(0ll,b[1]));
	return 0;
}

Measured memory_bytes: 37248
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))

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

v = [False] * n
roop = []

for i in range(n):
    if not v[i]:
        tmp = [i]
        while True:
            t = p[tmp[-1]]
            v[t] = True
            if tmp[0] == t:
                break
            else:
                tmp.append(t)
        roop.append(tmp)

s = []

for li in roop:
    s1 = 0
    for i in li:
        s1 += c[i]
    s.append(s1)

s2 = []

for li in roop:
    tmp = [0]
    for i in li:
        tmp.append(tmp[-1] + c[i])
    for i in li:
        tmp.append(tmp[-1] + c[i])
    s2.append(tmp)

v2 = [-1] * n

for i,li in enumerate(roop):
    for j in li:
        v2[j] = i

ans = -10**20

for i,li in enumerate(roop):
    t = -10**20
    if s[i] <= 0:
        for j in range(len(li)):
            for k1 in range(j+1, j + 1 + min(k, len(li))):
                t = max(t, s2[i][k1] - s2[i][j])
        ans = max(ans, t)
    else:
        for cnt in range(min(len(li), k)+1):
            for j in range(len(li)):
                if k >= cnt:
                    t = max(t, s2[i][cnt+j] - s2[i][j] + s[i] * ((k - cnt) // len(li)))
        ans = max(ans, t)

print(ans)


Measured memory_bytes: 75332
#include<stdio.h>
#include<string.h>

int main(void)
{
  char s[100];
  scanf("%s",s);
  int n = strlen(s);
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n/2+i+1]){
      printf("No\n");
      return 0;
    }
    else if(s[i]!=s[n-i-1]){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
int x[10];
int y[10];
double ans;

signed main(){
    int n;
    cin >> n;
    REP(i,n){
        cin >> x[i] >> y[i];
    }
    REP(i,n){
        for(int j=i+1;j<n;j++){
            ans += sqrt(1.0*(x[i]-x[j])*(x[i]-x[j]) + 1.0*(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    ans *= 2;
    ans /= n;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 1076 Time Manipulation
// 2018.2.3 bal4u

#include <stdio.h>

int p[21];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long gcd(long long a, long long b)
{
	long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

long long lcm(long long a, int b) { return a/gcd(a, b)*b; }

int main()
{
	int n, m, i, j, f, a, lim;
	long long sum, t, k, b;

	while (n = in()) {
		m = in();
		for (i = 0; i < m; i++)	p[i] = in();

		sum = (long long)n*(n+1) >> 1;
		k = n;
		lim = 1 << m;
		for (i = 1; i < lim; i++) {
			f = 0, t = 1;
			for (j = 0; j < m; j++) if ((i >> j) & 1) {
				f++, t = lcm(t, p[j]);
			}

			a = n / (int)t, b = t*a*(a+1) >> 1;
			if (f & 1) sum -= b, k -= a;
			else       sum += b, k += a;
		}
		if (k) printf("%.10lf\n", (double)sum/k);
		else puts("0.0000000000");
	}
	return 0;
}


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

int main() {
   int N;
   cin >> N;
   vector<int> A(N,0);
   for(int i = 0; i < N; ++i){
     cin >> A.at(i);
   }
   sort( A.begin(), A.end() );
   cout << A.at(N-1) - A.at(0) << endl;

   return 0;
}

Measured memory_bytes: 3540
#include<algorithm>
#include<typeinfo>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#define eps 0.01
#define pi acos(-1)
#define e exp(1)
using namespace std;
typedef long long ll;
const int maxn = 2e5;
int n;
ll num[maxn + 10];
int main() {
    while (cin >> n) {
        num[0] = 0;
        for (int i = 1; i <= n; ++i) {
            cin >> num[i];
            num[i] += num[i - 1];
        }
        ll a, b, c, d;
        ll ans = 2e10;
        int l = 1;
        int r = 3;
        for (int i = 2; i < n - 1; ++i) {
            a = num[l];
            b = num[i] - num[l];
            for (int j = l + 1; j < i; ++j) {
                ll aa = num[j];
                ll bb = num[i] - num[j];
                ll des1 = abs(a - b);
                ll des2 = abs(aa - bb);
                if (des2 >= des1)
                    break;
                a = aa;
                b = bb;
                l = j;
            }
            c = num[r] - num[i];
            d = num[n] - num[r];
            for (int j = r + 1; j < n; ++j) {
                ll cc = num[j] - num[i];
                ll dd = num[n] - num[j];
                ll des3 = abs(c - d);
                ll des4 = abs(cc - dd);
                if (des4 >= des3)
                    break;
                c = cc;
                d = dd;
                r = j;
            }
            ll maxx = max({ a,b,c,d });
            ll minn = min({ a,b,c,d });
            /*cout << i << " " << l << " " << r << endl;
            cout << a << " " << b << " " << c << " " << d << endl;*/
            ans = min(ans, maxx - minn);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll arr[2000005];
int arr2[1000005];
//ll Pow(ll base , ll power)
//void sieve_eratosthenes(int n);
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,k,temp,finale=1e9,sum=0,mas=-1;
cin>>k>>n;
ll x;
cin>>temp ;
ll first =temp ;
for(ll i=1;i<n;i++)
{
   cin>>x ;
   ll dif =x-temp;
   sum+=dif;
   mas= max(dif,mas);
   temp =x ;
   if(i==n-1)
   {
       dif = first-temp+k;sum+=dif;mas=max(dif,mas);
   }
}
cout<<sum-mas<<endl;






}

/*
void sieve_eratosthenes(int n)
    {
bool primes[n+2]={false};
for(int i=3;i<=n;i+=2)
    primes[i]=1;
    primes[2]=1;
for(int i=3;i*i<=n;i+=2)
{
    if(primes[i]==1){
    for(int j=i*i;j<=n;j+=i)
        primes[j]=0;
    }
}
for(int i=2;i<=n;i++)
    if(primes[i]==1)
    cout<<i<<endl;
return;
    }
ll Pow(ll base , ll power)
        {
            if(power==0)return 1;
            ll x = Pow(base,power/2);
            x*=x;
            if(power&1)
                return base*x;
            else
                return x;
        }
*/


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 16:49:00 2020

@author: matsui
"""



N,K=map(int,input().split())
h=[int(num) for num in input().split()]

dp=[0]*N
dp[1]=abs(h[0]-h[1])
   
def cost(h,N,K,dp):
    for i in range(2,N):
        dp[i]=min([abs(h[i]-h[j])+dp[j] for j in range(max(0, i-K), i)])
    return dp[-1]
    
print(cost(h,N,K,dp))

Measured memory_bytes: 13980
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

ll n,val[105],w[105],maxw;
ll dp[105][100005];

ll go(ll i, ll abtakval){
    // abtak now stores i-1 tak li hui values ka sum
    if(i<=0){
        if(abtakval==0) return 0;
        else return 1e17;
    }
    if(dp[i][abtakval]!=-1) return dp[i][abtakval];
    ll ans=1e17;
    
    ans=min(ans,go(i-1,abtakval));
    ll tmp=go(i-1,abtakval-val[i]);
    if(tmp!=1e17) tmp+=w[i];
    ans=min(ans,tmp);

    return dp[i][abtakval]=ans;

}

int main()
{
    io
    ll i,j;
    memset(dp,-1,sizeof dp);
    cin>>n>>maxw;
    for(i=1;i<=n;i++) cin>>w[i]>>val[i];

    for(ll abtakval=1000LL*n;abtakval>=n;abtakval--){
        if(go(n,abtakval)<=maxw) {cout<<abtakval; return 0;}
    }

    return 0;
}

Measured memory_bytes: 82304
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nx = readn::<usize>(" ");
    let n = nx[0];
    let x = nx[1];
    let mut a = readn::<usize>(" ");

    let mut ans = if a[0] > x {
        a[0] - x
    } else {
        0usize
    };
    a[0] = std::cmp::min(a[0], x);
    for i in 1..n {
        if a[i] + a[i-1] > x {
            let d = a[i] + a[i-1] - x;
            ans += d;
            a[i] -= d;
        }
    }

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

Measured memory_bytes: 8444
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    S, T = input().split()

    res = ""

    for a, b in zip(S, T):
        res += a
        res += b

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61976
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
class P
{
    static void Main()
    {
        int[] ipts = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (ipts[1] % ipts[0] == 0)
        {
            Console.WriteLine(ipts[0] + ipts[1]);
            return;
        }
        Console.WriteLine(ipts[1] - ipts[0]);
    }
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 300;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int D, S, T;
vector<int> g[N];
int c[N][N];
int f[N][N];
int cur[N];
bool used[N];
int d[N];

int dfs(int u, int mi)
{
    if (used[u])
        return 0;
    used[u] = true;
    if (u == T)
        return mi;
    for (; cur[u] < sz(g[u]); cur[u]++)
    {
        int v = g[u][cur[u]];
        if (c[u][v] - f[u][v] < D || d[v] != d[u] + 1)
            continue;
        int x = dfs(v, min(mi, c[u][v] - f[u][v]));
        if (x > 0)
        {
            f[u][v] += x;
            f[v][u] -= x;
            return x;
        }
    }
    return 0;
}

bool bfs()
{
    fill(d, d + T + 1, inf);
    d[S] = 0;
    queue<int> q;
    q.push(S);
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int v : g[u])
            if (c[u][v] - f[u][v] >= D && d[v] > d[u] + 1)
            {
                d[v] = d[u] + 1;
                q.push(v);
            }
    }
    return d[T] < inf;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    string a[n];
    rep(i, 0, n)
        cin >> a[i];
    int x1, y1, x2, y2;
    rep(i, 0, n)
        rep(j, 0, m)
        {
            if (a[i][j] == 'S')
            {
                x1 = i; y1 = j;
                a[i][j] = 'o';
            }
            if (a[i][j] == 'T')
            {
                x2 = i; y2 = j;
                a[i][j] = 'o';
            }
        }
    if (x1 == x2 || y1 == y2)
    {
        cout << -1 << endl;
        return 0;
    }
    S = n + m; T = n + m + 1;
    g[S].push_back(x1);
    g[x1].push_back(S);
    c[S][x1] = c[x1][S] = inf;

    g[S].push_back(n + y1);
    g[n + y1].push_back(S);
    c[S][n + y1] = c[n + y1][S] = inf;

    g[x2].push_back(T);
    g[T].push_back(x2);
    c[x2][T] = c[T][x2] = inf;

    g[n + y2].push_back(T);
    g[T].push_back(n + y2);
    c[n + y2][T] = c[T][n + y2] = inf;

    rep(i, 0, n)
        rep(j, 0, m)
            if (a[i][j] == 'o')
            {
                g[i].push_back(n + j);
                g[n + j].push_back(i);
                c[i][n + j] = c[n + j][i] = 1;
            }
    D = 1;
    while (bfs())
    {
        fill(cur, cur + T + 1, 0);
        while (true)
        {
            fill(used, used + T + 1, false);
            if (dfs(S, inf) == 0)
                break;
        }
    }

    int ans = 0;
    rep(i, 0, T + 1)
        ans += f[i][T];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a;
    int b;
    string op;

    cin >> a >> op >> b;

    if (op == "+") {
        cout << (a + b);
    } else {
        cout << (a - b);
    }

    return 0;
}

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

int main(){
    int n,w;
    cin >> n >> w;
    vector<vector<int>> items(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        items.at(i).push_back(a);
        items.at(i).push_back(b);
    }

    vector<int> dp(1e5+1), p(1e5+1);
    rep(i,p.size()) p.at(i) = -1;
    p[0] = w;
    rep(i,n){
        swap(dp,p);
        int cw = items.at(i).at(0);
        int cv = items.at(i).at(1);
        
        rep(j,p.size()){
            // j 次の重さ
            if(j-cv >= 0 && dp.at(j-cv)-cw >= 0){
                // cout << j << ":ok" << endl;
                p[j] = max(dp[j], dp.at(j-cv)-cw);
            }else{
                // cout << j << ":ng" << endl;
                p[j] = dp[j];
            }
        }

        // rep(j,p.size()){
        //     if(p.at(j) >= 0) cout << "(" << j << "," << p.at(j) << ") ";
        // }
        // cout << endl;
    }

    int res = 0;
    for(int j=p.size()-1;j>=0;j--){
        if(p.at(j) >= 0)
        {
            res = j;
            break;
        }

    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

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

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int K;
    cin >> K;
    
    ll Sum = 0;
    for (int a = 1; a <= K; ++a) {
        for (int b = 1; b <= K; ++b) {
            int Temp = Gcd(a, b);
            for (int c = 1; c <= K; ++c) {
                Sum += Gcd(Temp, c);
            }
        }
    }
    cout << Sum << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  double n = 0.0;
  if (N % 2 == 0){
    n = N / 2.0;
  }
  else{
    n = (N + 1) / 2.0;
  }
  cout << n / N << endl;
}
  

Measured memory_bytes: 3776
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"r,g,b,n=map(int,input().split());print(sum((n-j)%b<1for i in range(0,n+1,r)for j in range(i,n+1,g)))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 7104
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>S;
    cout<<(N >= 3200 ? S : "red")<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int card[100000];
bool shiro = false;
int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0 and m==0){break;}
		shiro=false;
		for(int i=0;i<100000;i++){card[i]=0;}
		for(int i=0;i<m;i++){
			int u;
			cin>>u;
			if(u!=0){card[u-1]++;}
			else{shiro=true;}
		}
		if(shiro==false){
			int ans=0;
			int poyo=0;
			for(int i=0;i<n;i++){
				if(card[i]==1){poyo++;}
				else{ans=max(ans,poyo);poyo=0;}
			}
			cout<<ans<<endl;
		}
		else{
			int ans=0;
			int poyo=0;
			int piyo=0;
			for(int i=0;i<n;i++){
				if(card[i]==1){poyo++;}
				else{ans=max(ans,poyo+piyo+1);piyo=poyo;poyo=0;}
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int cnt,head[maxn],num[maxn]={0};
int co[maxn];
struct edge{
	int next,to,id;
}e[maxn];
void add(int u,int v,int id)
{
    e[++cnt].to = v;
    e[cnt].id=id;
    e[cnt].next = head[u];
    head[u] = cnt;
}
void dfs(int u,int fa,int id){
	int nu=1;
	for(int i=head[u];i;i=e[i].next){
		int v=e[i].to;
		if(v==fa)continue;
		if(nu==id)nu++;
		co[e[i].id]=nu;
		dfs(v,u,nu);
		nu++;
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		add(a,b,i);
		add(b,a,i);
		num[a]++;
		num[b]++;
	}
	int maxx=0,now;
	for(int i=1;i<=n;i++){
		if(num[i]>maxx){
			maxx=num[i];
			now=i;
		}
	}
	dfs(now,0,0);
	printf("%d\n",maxx);
	for(int i=1;i<n;i++)printf("%d\n",co[i]);
}


Measured memory_bytes: 7424
#include <cstdio>
#include <algorithm>
template < int xn, int xe > struct flow
{
	int head[xn], next[xe], to[xe], fl[xe], N, E, q[xn + 1], dep[xn], cur[xn];
	inline void add(int u, int v, int f)
	{
		next[E] = head[u], to[E] = v, fl[E] = f, head[u] = E++;
		next[E] = head[v], to[E] = u, fl[E] = 0, head[v] = E++;
	}
	void clear(int n)
	{
		N = n, E = 0;
		for (int i = 0; i < N; i++)
			head[i] = -1;
	}
	bool BFS()
	{
		for (int i = 0; i < N; i++)
		{
			dep[i] = 0;
			cur[i] = head[i];
		}
		int H = 0, T = 1, u;
		q[1] = 0;
		dep[0] = 1;
		while (H < T)
			for (int e = head[u = q[++H]]; ~e; e = next[e])
				if (fl[e] && !dep[to[e]])
				{
					dep[q[++T] = to[e]] = dep[u] + 1;
					if (to[e] == N - 1)
						return true;
				}
		return false;
	}
	int DFS(int p, int f)
	{
		if (p == N - 1)
			return f;
		int u = 0, y;
		for (int &e = cur[p]; ~e; e = next[e])
			if (fl[e] && dep[to[e]] == dep[p] + 1)
				if (y = DFS(to[e], std::min(f, fl[e])))
				{
					fl[e] -= y;
					fl[e ^ 1] += y;
					u += y;
					f -= y;
					if (!f)
						return u;
				}
		if (!u)
			dep[p] = 0;
		return u;
	}
	int operator () ()
	{
		int r = 0;
		while (BFS())
			r += DFS(0, 1000000000);
		return r;
	}
};
flow < 100000, 1000000 > G;
int N;
std::pair < int, int > p[502];
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", &p[i].first);
		p[i].second = i;
	}
	p[N + 1] = { N * N + 1, 0 };
	std::sort(p + 1, p + N + 1);
	G.clear(1 + (2 * N) + (N + 1) + 1);
	for (int i = 1; i <= N; i++)
	{
		G.add(0, i, p[i].second - 1);
		G.add(0, N + i, N - p[i].second);
		for (int j = 1; j <= i; j++)
			G.add(i, N + N + j, 1000000000);
		for (int j = i + 1; j <= N + 1; j++)
			G.add(N + i, N + N + j, 1000000000);
	}
	for (int i = 1; i <= N + 1; i++)
		G.add(N + N + i, G.N - 1, p[i].first - p[i - 1].first - 1);
	if (G() != N * (N - 1))
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	for (int i = 1; i <= N + 1; i++)
	{
		for (int e = G.head[N + N + i]; ~e; e = G.next[e])
			if (1 <= G.to[e] && G.to[e] <= N + N)
			{
				int u = p[G.to[e] <= N ? G.to[e] : G.to[e] - N].second, f = G.fl[e];
				while (f--)
					printf("%d ", u);
			}
		if (i <= N)
			printf("%d ", p[i].second);
	}
	puts("");
}


Measured memory_bytes: 13056
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n,m,x,y;
	cin>>n>>m;
	map<int, vector<int>> mp;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		mp[x].pb(y);
	}
	int ans = 0;
	priority_queue<int> q;
	for(int day=1;day<=m;day++)
	{
		for(auto it: mp[day])
			q.push(it);
		int x(0);
		if(!q.empty())
		{
			x = q.top();
			q.pop();
		}
		ans += x;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10880
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
// #include <complex>
#include <random>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
// const ll INF = 1e9;
const ld INF = 1e20;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
//const double PI = acos(-1);


void solve() {
    int n, i = 0, j = 0;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    while (i < n) {
        j = i + 1;
        while (j < n && s[j] == s[i]) {
            ++j;
        }
        ++ans;
        i = j;
    }
    cout << ans;
}

int main() {
    // freopen("moscow.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;
 
int main() {
  ll N, H; cin >> N >> H;
  ll a[N], b[N]; rep(i, N) cin >> a[i] >> b[i];
  sort(a, a+N, greater<int>());
  sort(b, b+N, greater<int>());
 
  ll result = 0;
  rep(i, N) {
    if (b[i]<=a[0]) break;
    result++; H-= b[i];
    if (H <= 0) break;
  }
  if (H>0) { result += H/a[0]; if (H%a[0]!=0) result++; }
 
  cout << result << endl;
  return 0;
}

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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}


int main()
{
    textIO();
    fastIO();

    long long n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<long long> f(n), s(m);

    for(int i=0;i<n;i++){
        cin >> f[i];
    }

    for(int i=0;i<m;i++){
        cin >> s[i];
    }

    long long i = 0, j = 0, cnt = 0;

    while(k-f[i] >= 0 && i<n){
        k-=f[i];
        i++;
        cnt++;
    }

    i--;

    ans = max(cnt, ans);

    while(j<m){
        while(k-s[j] >= 0 && j<m){
            k-=s[j];
            j++;
            cnt++;
        }
        ans = max(ans, cnt);

        if(i>=0){
            k+=f[i];
            i--;
            cnt--;
        }
        else{
            break;
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 6296
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t,pref[N],mk,tut;

vector<ll> ans;


int main()
{
	fast;
	cin>>n>>m;
	fs(ar,n);
	ll l=1,r=n;
	for(int i=1;i<=n;i++)
		if(ar[i]+ar[i+1]>mk)
			mk=ar[i]+ar[i+1],tut=i;
	if(mk<m)
		return cout<<"Impossible",0;;
	cout<<"Possible"<<endl;
	for(int i=1;i<tut;i++)
		cout<<i<<endl;
	for(int i=n-1;i>tut;i--)
		cout<<i<<endl;
	cout<<tut<<endl;


}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 4992
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>
#include <cstring>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int MN = 110;
int V;
vector<int> G[MN];
vector<int> rG[MN];
vector<int> vs;
bool used[MN];
int cmp[MN];

void add_edge(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v) {
    used[v] = true;
    for(int i=0;i<G[v].size();i++) {
        if(!used[G[v][i]]) dfs(G[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for(int i=0;i<rG[v].size();i++) {
        if (!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
}

int scc() {
    memset(used, 0, sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++) {
        if (!used[v]) dfs(v);
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for(int i=vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
}

int g[MN][MN];
bool solve() {
    for (int i = 0; i < V; i++) {
        if (g[i][i]) return false;
    }
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            if (g[i][j]) add_edge(i, j);
        }
    }
    return scc() == V;
}

int main() {
    int n;
    int s[MN][MN][2];
    for (int i = 0; i < MN; i++) {
        for (int j = 0; j < MN; j++) {
            s[i][j][0] = 0;
            s[i][j][1] = 1000;
        }
    }
    cin >> V >> n;
    for (int i = 0; i < V; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int a, b;
            char c;
            scanf("%d %c= %d", &a, &c, &b); a--;
            if (c == '>') {
                s[i][a][0] = max(s[i][a][0], b);
            } else {
                s[i][a][1] = min(s[i][a][1], b);
            }
        }
    }
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            bool f = false;
            for (int k = 0; k < MN; k++) {
                if (s[i][k][0] > s[j][k][1]) {
                    f = true;
                }
            }
            g[i][j] = f ? 1 : 0;
        }
    }
    if (solve()) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1492
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, C, D) = Read4Longs();

            var count = 0L;
            for (int i = 0; i < 101; i++)
            {
                if (A <= i && i < B && C <= i && i < D)
                {
                    count++;
                }
            }

            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

vector<pair<ll, ll>> prime_decompose(ll N) {
	vector<pair<ll, ll>> res;
	for (ll p = 2; p*p <= N; ++p) {
		if (N%p != 0)continue;
		ll num = 0;
		while (N%p == 0) { ++num; N /= p; }
		res.push_back(make_pair(p, num));
	}
	if (N != 1) res.push_back(make_pair(N, 1));
	return res;
}

int main() {
	ll N, P; cin >> N >> P;
	vector<pair<ll, ll>> dec = prime_decompose(P);

	ll ans = 1;

	for (int i = 0; i < dec.size(); i++) {
		ll cnt = dec[i].second;
		ll elem = dec[i].first;
		while (cnt >= N) {
			ans *= elem;
			cnt -= N;
		}
	}

	cout << ans << endl;








	return 0;
}


Measured memory_bytes: 256
s=int(input())
A=[s]
i=int(0)
while 1:
    now=int(A[i])
    if now%2==0:
        now=int(now/2)
        A.append(now)
    else:
        now=3*now+1
        A.append(now)
    i+=1
    if A.count(now)==2:
        print(i+1)
        break

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        String t = A;
        while (true) {
            if (t == A) {
                if (t.length() == 0) {
                    System.out.println("A");
                    return;
                }
                A = A.substring(1);
            } else if (t == B) {
                if (t.length() == 0) {
                    System.out.println("B");
                    return;
                }
                B = B.substring(1);
            } else {
                if (t.length() == 0) {
                    System.out.println("C");
                    return;
                }
                C = C.substring(1);
            }
            // System.out.println(A+" "+B+" "+C);
            // System.out.println(t.charAt(0));
            t = (t.charAt(0) == 'a') ? A : ((t.charAt(0) == 'b') ? B : C);
        }
    }
}


Measured memory_bytes: 21588
class SegmentTree:

    def __init__(self, n, op, e):
        """
        :param n: 要素数
        :param op: 二項演算
        :param e: 単位減
        """
        self.n = n
        self.op = op
        self.e = e
        self.size = 1 << (self.n - 1).bit_length()      # st[self.size + i] = array[i]
        self.tree = [self.e] * (self.size << 1)

    def built(self, array):
        """arrayを初期値とするセグメント木を構築"""
        for i in range(self.n):
            self.tree[self.size + i] = array[i]
        for i in range(self.size - 1, 0, -1):
            self.tree[i] = self.op(self.tree[i<<1], self.tree[(i<<1)|1])

    def update(self, i, x):
        """i 番目の要素を x に更新　(0-indexed) """
        i += self.size
        self.tree[i] = x
        while i > 1:
            i >>= 1
            self.tree[i] = self.op(self.tree[i<<1], self.tree[(i<<1)|1])

    def get(self, l, r):
        """ [l, r)の区間取得の結果を返す　(0-indexed) """
        l += self.size
        r += self.size
        res_l = self.e
        res_r = self.e
        while l < r:
            if l & 1:
                res_l = self.op(res_l, self.tree[l])
                l += 1
            if r & 1:
                r -= 1
                res_r = self.op(self.tree[r], res_r)
            l >>= 1
            r >>= 1
        return self.op(res_l, res_r)

    def __iter__(self):
        for a in self.tree[self.size:self.size+self.n]:
            yield a

    def __str__(self):
        return str(self.tree[self.size:self.size+self.n])

##################################################################################################################
import sys
input = sys.stdin.readline


N, K = map(int, input().split())
P = list(map(int, input().split()))
e = float("inf")
op = lambda x, y : x if x < y else y
st1 = SegmentTree(N, op, e)
st1.built(P)
e = 0
op = lambda x, y : x if x > y else y
st2 = SegmentTree(N, op, e)
st2.built(P)

Q = [1]
for i in range(N-1):
    if P[i] < P[i+1]:
        Q.append(Q[-1]+1)
    else:
        Q.append(1)

res, flg = 1, 0
if Q[K-1]>=K:
    flg = 1
for i in range(1,N-K+1):
    mi, ma = st1.get(i,i+K-1), st2.get(i,i+K-1)
    if (P[i+K-1] < ma or P[i-1] > mi):
        if Q[i+K-1]<K:
            res += 1
        elif not flg:
            res += 1
            flg = 1
print(res)


Measured memory_bytes: 113448
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N,sum=0;
	cin >> N;
	vector<int> b(N), a(N);
	for (int i = 0; i < N-1; i++)
	{
		cin >> b[i];
	}
	
	a[N - 1] = b[N - 2];
	a[0] = b[0];
	if (N != 2) {
		a[1] = min(b[0], b[1]);
	}
	else a[1] = b[0];
	for (int i = 1; i < N - 2; i++) {
		if (b[i] <= b[i + 1]) {
			a[i + 1] = b[i];
		}
		else {
			a[i + 1] = b[i + 1];
		}
	}
	
	for (int i = 0; i < N; i++) {
		sum += a[i];
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

typedef complex<double> P;
typedef vector<P> Poly;

#define EPS 1e-8
#define EQ (abs((a)-(b))<EPS)
const double PI = acos(-1.0);

inline int signum(double x) { return abs(x) < EPS ? 0 : x > 0 ? 1 : -1; }

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

double area_poly(Poly poly) {
    double ans = 0.0;
    for (int i = 0; i < poly.size(); i++) ans += cross(poly[i], poly[(i + 1) % poly.size()]);
    return abs(ans) / 2.0;
}

int main() {

    int N;
    cin >> N;

    Poly poly(N);
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        poly[i] = P(x, y);
    }

    cout << fixed << setprecision(1) << area_poly(poly) << endl;

}














































Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int x;
	cin >> x;
	int ans = 0;
	if(x<4)
	{
		cout<<1<<endl;
		return 0;
	}
	for(int i =2 ; i<=x;i++)
	{
		int now = i;
		while(now*i<=x)
		{
			now *= i;
			ans = max(ans,now);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;
using T = tuple<int, int, lint>;

/****************** グラフ ******************/
// 諸宣言
using Weight = lint;
using Flow = lint;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
    Edge(int s, int d, Weight w, Flow c) : src(s), dst(d), weight(w), cap(c) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
    g[b].emplace_back(b, a, w, c);
}
void add_arc(Graph &g, int a, int b, Weight w = 1, Flow c = 1) {
    g[a].emplace_back(a, b, w, c);
}

// ワーシャルフロイド法 (O(V^3))
Matrix warshall_floyd(const Graph &g) {
    auto const INF = numeric_limits<Weight>::max() / 8;
    int n = g.size();
    Matrix d(n, Array(n, INF));
    repeat(i, n) d[i][i] = 0;
    repeat(i, n) for (auto &e : g[i]) d[e.src][e.dst] = min(d[e.src][e.dst], e.weight);
    repeat(k, n) repeat(i, n) repeat(j, n) {
        if (d[i][k] != INF && d[k][j] != INF) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    return d;
}

int main(void) {
    int n;
    cin >> n;
    Graph g(n);
    Matrix ori(n, Array(n));
    
    queue<T> q;
    
    repeat(i, n) {
        repeat(j, n) {
            cin >> ori[i][j];
            if (i >= j) continue;
            add_edge(g, i, j, ori[i][j]);
            q.emplace(T{i, j, ori[i][j]});
        }
    }
    Matrix dis = warshall_floyd(g);
    
    lint ans = 0;
    repeat(i, n) {
        repeat(j, n) {
            if (dis[i][j] < ori[i][j]) {
                cout << -1;
                return 0;
            }
            if (i < j) ans += dis[i][j];
        }
    }
    
    while (!q.empty()) {
        int i, j;
        lint c;
        tie(i, j, c) = q.front();
        q.pop();
        
        repeat(k, n) {
            if (k == i or k == j) continue;
            if (dis[i][k] + dis[k][j] == dis[i][j]) {
                ans -= dis[i][j];
                break;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 6016
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()

print("Yes" if sqrt(10**(len(str(b)))*a+b) == int(sqrt(10**(len(str(b)))*a+b)) else "No")

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

int main() {
  int N, l, r, sum;
  sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> l >> r;
    sum += (r - l + 1);
  }
  cout << sum <<endl;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

bool era[10000001]={false};


void makeERA(){
    for(int i=2;i<10000001;i++){
        if(era[i]==true){
            int x=10000000/i;
            for(int j=2;j<=x;j++){
                era[i*j]=false;
            }
        }
    }
    era[2]=true;
}


int main(){
    for(int i=0;i<10000001;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();

    int n,x;
    while(cin>>n>>x){
        if(n==0&&x==0)break;
        vector<int> data(n);
        rep(i,n) cin>>data[i];
        
        static bool dp[1000100];
        rep(i,1000100)dp[i] = false;
        dp[0] = true;
        
        rep(i,n){
            int val = data[i];
            rep(j,x+1){
                if(j-val>=0) dp[j] |= dp[j-val];
            }
        }
        for(int i=x;i>=0;i--){
            if(era[i]&&dp[i]){
                cout<<i<<endl;
                goto next;
            }
        }
        cout<<"NA"<<endl;
    next:;
    }
}

Measured memory_bytes: 11932
#include <iostream>
#include <vector>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;



int main(){
		#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("myin.txt", "r", stdin);
    // for writing output to output.txt
    freopen("myout.txt", "w", stdout);
#endif

int d,t,s;
cin>>d>>t>>s;
double T;
T=(double)d/s;
if(T<=t) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;

const int MAXN = 234567;
LL sum[MAXN];

int main() {
    int N;
    while (~scanf("%d", &N)) {
          for (int i = 1; i <= N; i++) {
              LL tmp;
              scanf("%lld", &tmp);
              sum[i] = sum[i - 1] + tmp;
          }
          LL ans = (LL)1e18;
          for (int i = 1; i < N; i++) {
              LL f = sum[i], s = sum[N] - sum[i];
              ans = min(ans, abs(f - s));
          }
          printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1792
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	ss := make([]int, m)
	for i := 0; i < m; i++ {
		k := getNextInt(scanner)
		for j := 0; j < k; j++ {
			s := getNextInt(scanner) - 1
			ss[i] |= 1 << uint(s)
		}
	}

	pp := make([]int, m)
	for i := 0; i < m; i++ {
		pp[i] = getNextInt(scanner)
	}
	ans := 0
	for b := 0; b < 1<<uint(n); b++ {
		sum := 0
		for i := 0; i < m; i++ {
			target := b & ss[i]
			on := 0
			for j := 0; j < n; j++ {
				on += target >> uint(j) & 1
			}
			if on%2 == pp[i] {
				sum++
			}
		}
		if sum == m {
			ans++
		}
	}

	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640