akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int N, M, xi, yi, zi;
vector<pair<int, int> > g[100099];
vector<int> visited_1(100099, -1);
vector<int> visited_2(100099, -1);

bool issue = false;

void dfs(int s, vector<int> &visited, int label) {
  visited[s] = label;

  for(auto &pi : g[s]) {
    if(visited[pi.first] != -1) {
      if((visited[s] + pi.second + visited[pi.first]) % 2) {
        issue = true;
      }
    } else {
      dfs(pi.first, visited, (visited[s] + pi.second) % 2);
    }
  }
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N >> M;
  for(int i = 0;i < M;i++) {
    cin >> xi >> yi >> zi;
    g[xi].push_back({yi, zi % 2});
    g[yi].push_back({xi, zi % 2});
  }

  int ans = 0;
  for(int i = 1;i <= N;i++) {
    if(visited_1[i] == -1) {
      dfs(i, visited_1, 1);
      bool i1 = issue;
      issue = false;
      dfs(i, visited_2, 0);
      bool i2 = issue;
      issue = false;
      if(i1 + i2 == 0) ans++;
      // cout << i1+i2 << endl;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll i, o, t, j, l, s, z;
ll ans;

int main(){
	cin >> i >> o >> t >> j >> l >> s >> z;

	int cou = 0;
	if (i % 2 == 1)cou++;
	if (j % 2 == 1)cou++;
	if (l % 2 == 1)cou++;
	if (i > 0 && j > 0 && l > 0 && cou > 1) {
		ans += 3;
		i--; j--; l--;
	}
	ans += 2 * (i / 2) + 2 * (j / 2) + 2 * (l / 2) + o;

	cout << ans << endl;

	return 0;
}


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

int n, m;
string a, b;
void read(){
    getline(cin, a);
    getline(cin, b);
    n = a.size();
    m = b.size();
    a = '0' + a;
    b = '0' + b;
}

int f[3005][3005];
void hdl(){
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            if (a[i] == b[j]) f[i][j] = f[i-1][j-1] + 1;
            else f[i][j] = max(f[i-1][j], f[i][j-1]);

        }

    }

    if (f[n][m] == 0){
        exit(0);
    }
}

void trace(){
    string res = "";
    int i = n, j = m;
    while (i > 0 && j > 0){
        if (a[i]==b[j]){
            res = a[i] + res;
            i--;
            j--;
        }
        else if (f[i-1][j] > f[i][j-1]){
            i--;
        }
        else j--;
    }
    cout<<res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    read();
    hdl();
    trace();
}


Measured memory_bytes: 35456
#include <iostream>

long long int gcd(long long int a, long long int b)
{
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

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

int main()
{
	int n;
	std::cin >> n;
	long long int a = 0;
	
	for (int i = 0; i < n; ++i)
	{
		long long int x;
		std::cin >> x;
		
		if (a != 0)
			a =	lcm(x, a);
		else
			a = x;
	}
	
	std::cout << a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b;
  cin>>a>>b;
  int ans=a;
  if(b<a)ans--;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 125696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

void solve(){
    ll n,m,k;cin>>n>>m>>k;
    vl a(m),b(m);rep(i,m)cin>>a[i]>>b[i];
    vl c(k),d(k);rep(i,k)cin>>c[i]>>d[i];
    vl cnt(n);
    rep(i,m){
        a[i]--,b[i]--;
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    rep(i,k){
        c[i]--,d[i]--;
    }

    UnionFind uf(n);
    rep(i,m){
        uf.unite(a[i],b[i]);
    }
    vl cnt2(n);
    rep(i,n)cnt2[i]=uf.size(i)-1-cnt[i];
    rep(i,k){
        if(uf.find(c[i])==uf.find(d[i])){
            cnt2[c[i]]--;
            cnt2[d[i]]--;
        }
    }
    rep(i,n){
        if(i>0)cout<<" ";
        cout<<cnt2[i];
    }
    cout<<endl;
}

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


Measured memory_bytes: 6144
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;

	cin >> N;

	vector<string> s(N);
	vector<int> t(N);

	int count = 0;

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

	string X;

	cin >> X;

	int c = 0;

	for(int i = 0; i < N; i++) {
		c += t[i];
		if(s[i] == X) {
			break;
		}
	}

	cout << count - c << endl;
}


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

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = 0;

    if(c <= a && a <= d && d <= b){
        ans = max(0, min(b,d)-max(a,c));
    }
    else{
        ans = max(0, min(b,d) - max(a,c));
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int v[3];
    int max{0};
    int sum{0};
    for (int i = 0; i < 3; ++i) {
        std::cin >> v[i];
        sum += v[i];
        if (max <= v[i]) max = v[i];
    }
    std::cout << (sum - max) << std::endl;

    return 0;
}


Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st=new StringTokenizer(br.readLine());
		int H=Integer.parseInt(st.nextToken());
		int W=Integer.parseInt(st.nextToken());

		while(H!=0 || W!=0) {

			int i=1;
			int j=0;

			while(j<H) {
				while(i<W) {
					System.out.print("#");
					i++;
				}
				System.out.println("#");
				i=1;
				j++;
			}
			System.out.println("");
			StringTokenizer sa=new StringTokenizer(br.readLine());
			H=Integer.parseInt(sa.nextToken());
			W=Integer.parseInt(sa.nextToken());

		}
	}

}



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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  a *= -1;
  if (a + b <= 0) {
    cout << "delicious" << endl;
  } else if (a + b <= x) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int A = Integer.parseInt(stdin.next());
		int B = Integer.parseInt(stdin.next());
		
		int seki = A*B;
		int tasu = A+B;
		int hiku = A-B;

		out.println(Math.max(seki,Math.max(tasu,hiku)));
		out.flush();
	}

	
}

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

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int x=__gcd(i,j);
            for(int k=1;k<=n;k++)
            {
                int y=__gcd(x,k);
                sum+=y;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;

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

	int a, b; cin >> a >> b;
	cout << max(0, a - 2 * b) << endl;
	
	return 0;
}


Measured memory_bytes: 256
import Data.List

countPartOf :: Eq a => [a] -> [a] -> Int
countPartOf _ [] = 0
countPartOf [] _ = 0
countPartOf a b = if a `isPrefixOf` b
                  then succ $ countPartOf a (drop (length a) b)
                  else countPartOf a (drop 1 b)

main :: IO ()
main = do
    _ <- getLine
    s <- getLine
    print $ countPartOf "ABC" s

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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		int K = sc.nextInt();
		Long[] A = new Long[X];
		Long[] B = new Long[Y];
		Long[] C = new Long[Z];
		List<Long> ABC = new ArrayList<Long>();
		for (int i=0;i<X;i++) {
			A[i]=Long.parseLong(sc.next());
		}
		Arrays.sort(A,Comparator.reverseOrder());
		for (int i=0;i<Y;i++) {
			B[i]=Long.parseLong(sc.next());
		}
		Arrays.sort(B,Comparator.reverseOrder());
		for (int i=0;i<Z;i++) {
			C[i]=Long.parseLong(sc.next());
		}
		Arrays.sort(C,Comparator.reverseOrder());
		int n=0;
		for (int i=0;i<X;i++) {
			for (int j=0;j<Y;j++) {
					for (int k=0;k<Z;k++) {
						if ((i+1)*(j+1)*(k+1)<=K) {
							ABC.add(A[i]+B[j]+C[k]);
							n++;
						} else {
							break;
						}
					}
			}
		}
		Collections.sort(ABC,Comparator.reverseOrder());

		for (int i=0;i<K;i++) {
			System.out.println(ABC.get(i));
		}
	}
}

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

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main(){
  ll N,m=0;
  cin >> N;
  vector<ll> C(N);
  rep(i,N){
    cin >> C.at(i);
  }
  sort(all(C));
  reverse(all(C));
  rep(i,N){
    m+=(i+2)*C.at(i);
    m%=MOD;
  }
  m*=modPow(4,N-1);
  m%=MOD;
  cout << m << endl;   
  
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n,m;
    cin>>n>>m;

    int ans=0;

    ans = ans + max(0,n*(n-1))/2 + max(0,m*(m-1))/2;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

vector<pi> v;

int main()
{	
	int n;
	cin >> n;
	v.resize(n);

	ll sum = 0;
	rep(i, n) {
		cin >> v[i].first >> v[i].second;
	}

	sort(v.begin(),v.end());

	int pre = 1;
	rep(i, n) {
		sum += v[i].first - pre;
		pre = v[i].first;
	}
	sum += v[n - 1].second + 1;
	cout << sum << endl;
	return	0;
}




Measured memory_bytes: 1024
import math


def insertionsort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return cnt


def shellsort(A, n):
    G = []         
    gap = 1
    while gap <= math.ceil(n / 3):
        G.append(gap)
        gap = gap * 3 + 1
    G = G[::-1]
    m = len(G)
    print(m)
    print(*G)
    cnt = 0
    for i in range(m):
        cnt += insertionsort(A, n, G[i])
    print(cnt)


n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellsort(A, n)
for i in range(n):
    print(A[i])

Measured memory_bytes: 47484
#include<bits/stdc++.h>
using namespace std;
int n, x, a[100005], ans = 0;
int main() {
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> x;
        a[x - 1] ++; a[x] ++; a[x + 1] ++;
    }
    for (int i = 0; i <= 100001; i ++) ans = max(ans, a[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<limits.h>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
const int MAX=1000,V=INT_MIN;
struct P{int x,y;};
double S(int x){return x*x;}
int F(P a,P b){return ceil(sqrt(S(a.x-b.x)+S(a.y-b.y)));}
int main()
{
	int T,N,X,Y,i,j,t[MAX];
	P p,s,a[MAX];
	std::vector<int>v[MAX];
	for(scanf("%d",&T);T--;)
	{
		std::queue<P>q;
		scanf("%d%d%d%d%d",&N,&X,&Y,&p.x,&p.y);
		for(i=0;i<N;++i)
		{
			t[i]=V,v[i].clear(),scanf("%d%d",&a[i].x,&a[i].y);
			if(F(p,a[i])<=10)s.x=i,s.y=X,q.push(s);
		}
		for(i=0;i<N;++i)
			for(j=i+1;j<N;++j)
			if(F(a[i],a[j])<=50)
				v[i].push_back(j),v[j].push_back(i);
		while(!q.empty())
		{
			p=q.front();q.pop();
			if(t[p.x]+X+Y>=p.y)continue;
			if(t[p.x]!=V && t[p.x]+X+Y<p.y)goto E;
			t[p.x]=p.y;
			for(i=0;i<v[p.x].size();++i)s.x=v[p.x][i],s.y=p.y+X,q.push(s);
		}
		printf("%d\n",std::max(0,*std::max_element(t,t+N)));
		continue;
E:
		puts("You're always welcome!");
	}
	return 0;
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,x,t;
  cin >> n >> x >> t;

  cout << (n+x-1)/x*t << endl;

}

Measured memory_bytes: 3632
module Main where

import Control.Applicative
import Control.Monad
import Data.Array

check :: Array (Int, Int) Char -> (Int, Int) -> Bool
check a (i, j)
    | a ! (i, j) == '.' = True
    | otherwise         = any (\w -> a ! w == '#') ws
  where
    bs = bounds a
    ws = filter (inRange bs) [(i-1, j), (i+1, j), (i, j-1), (i, j+1)]

main :: IO ()
main = do
    [h, w] <- fmap read . words <$> getLine
    ss <- concat <$> replicateM h getLine
    let ary = listArray ((1, 1), (h, w)) ss
    let ans = all (check ary) (indices ary)
    if ans
        then putStrLn "Yes"
        else putStrLn "No"

Measured memory_bytes: 1020
import bisect
n,m =map(int,input().split())
a = list(map(int,input().split()))
b = []
c = []
a = sorted(a)
dic = []
for i in range(m):
    ba,ca = map(int,input().split())
    b.append(ba)
    c.append(ca)
    dic.append([ba,ca])


dic = sorted(dic, key=lambda x:x[1], reverse=True)
#print(dic)

length = 0
lo = []
s = 1
for i in range(len(dic)):
    for k in range(dic[i][0]):
        lo.append(dic[i][1])
        length += 1
        if length > len(a):
            s = 0
            break
    if s == 0:
        break
for i in range(len(a)):

    if i < len(lo) and a[i] < lo[i]:
        a[i] = lo[i]
#rint(a)
ans = 0
for i in range(len(a)):
    ans += a[i]
print(ans)


Measured memory_bytes: 100120
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> P;

signed main(){
    vector<int> prime(100010, 1), num(100010, 0);
    prime[0] = 0; prime[1] = 0;
    for(int i = 2; i < prime.size(); i++){
        if(!prime[i]) continue;
        for(int j = i * 2; j < prime.size(); j += i){
            prime[j] = 0;
        }
    }
    for(int n = 3; n < prime.size(); n++){
        if(prime[n] && prime[(n + 1)/2]){
            num[n] = 1;
        }
    }
    for(int i = 1; i < num.size(); i++) num[i] += num[i - 1]; 
    int Q; cin >> Q;
    for(int i = 0; i < Q; i++){
        int l, r; cin >> l >> r;
        cout << num[r] - num[l - 1] << endl;
     }
}    

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(curr_v, pare_v, curr_sum, visited, g):
    if curr_sum%2 == 0:
        visited[curr_v] = 0
    else:
        visited[curr_v] = 1
    for neib_vw in g[curr_v]:
        if neib_vw[0] == pare_v: continue
        dfs(neib_vw[0], curr_v, curr_sum+neib_vw[1], visited, g)
    

N = int(input())
g = [ [] for _ in range(N+1)]
visited = [-1] * (N+1)

for _ in range(N-1):
    u, v, w = map(int, input().split()) 
    w%=2
    g[u].append((v,w))
    g[v].append((u,w))

dfs(1, -1, 0, visited, g)
for p in visited[1:]:
    print(p)
    



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

int main () {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int a2 = 1;
  while (a2 < b){
    a2 += a-1;
    ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	for(;;){
		int a,b;
		char d;
		scanf("%d %c %d\n",&a,&d,&b);
		if(d=='?')
		break;
		 if(d=='+')
		printf("%d\n",a+b);
		 if(d=='-')
		printf("%d\n",a-b);
		if(d=='*')
		printf("%d\n",a*b);
		 if(d=='/')
		printf("%d\n",a/b);
	}
	return 0;
}

Measured memory_bytes: 1744
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int ma = line.indexOf(" ");
        int jobAmount = Integer.parseInt(line.substring(0, ma));
        int quantum = Integer.parseInt(line.substring(ma+1));
        
        ArrayList<String> lingerJob = new ArrayList<String>();
        ArrayList<Integer> lingerTime = new ArrayList<Integer>();
        
        for(int i=0;i<jobAmount;i++){
        	String line2 = sc.nextLine();
        	int ma2 = line2.indexOf(" ");
        	
        	lingerJob.add(line2.substring(0, ma2));
        	lingerTime.add(Integer.parseInt(line2.substring(ma2+1)));
        }
        
        
        
        int nowTime=0;
        
        while(lingerJob.size()!=0){
        	
        	if(lingerTime.get(0)>quantum){
        		lingerJob.add(lingerJob.get(0));
        		lingerJob.remove(0);
        		lingerTime.add(lingerTime.get(0)-quantum);
        		lingerTime.remove(0);
        		nowTime+=quantum;  		
        	}else{
        		nowTime+=lingerTime.get(0);
        		System.out.println(lingerJob.get(0)+" "+nowTime);
        		lingerJob.remove(0);
        		lingerTime.remove(0);       		
        	}
        }
    }
}

Measured memory_bytes: 103004
package main

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

func print(a, b, c int) {
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	a := nextInt(scanner)
	b := nextInt(scanner)
	c := nextInt(scanner)
	print(a, b, c)
}



Measured memory_bytes: 1104
#include<stdio.h>
#include<vector>
using namespace std;
vector< vector<int> > adj;
vector< pair<int,int> > res;
int check[1000000],num,v,out[1000000],n,m,u;
void DFS(int pos,int par){
	check[pos]=++num;
	for(int i=0;i<adj[pos].size();i++){
		int nxt=adj[pos][i];
		if(check[nxt]==0){
			DFS(nxt,pos);
			if(out[nxt]%2==1){
				res.push_back(make_pair(nxt,pos));
				out[nxt]++;
			}else{
				res.push_back(make_pair(pos,nxt));
				out[pos]++;
			}
		}else if(nxt!=par&&check[nxt]<check[pos]){
			out[pos]++;
			res.push_back(make_pair(pos,nxt));
		}
	}
}
int main(){
	scanf("%d %d", &n,&m);
	adj.resize(n+1);
	for(int i=1;i<=m;i++){
		scanf("%d %d", &u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	if(m%2==1){
		printf("-1");
		return 0;
	}
	DFS(1,0);
	for(int i=0;i<res.size();i++) printf("%d %d\n", res[i].first,res[i].second);
}

Measured memory_bytes: 21620
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
  auto N=readln.chomp.to!int;
  auto K=readln.chomp.to!int;
  auto X=readln.chomp.to!int;
  auto Y=readln.chomp.to!int;
  if(N<=K)writeln(X*N);
  else writeln(X*K+Y*(N-K));
}  

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    vector<vector<ll>> amin(n, vector<ll>(n));

    for(int i=0; i<n; i++){
        amin[i][0] = a[i];
        for(int j=1; j<n; j++){
            amin[i][j] = min(a[(i-j+n)%n], amin[i][j-1]);
        }
    }

    ll ans = INF;
    for(ll magic=0; magic<n; magic++){

        ll sum = 0;
        for(int i=0; i<n; i++){
            sum += amin[i][magic];
        }

        chmin(ans, sum + magic * x);
    }

    cout << ans << endl;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int H,N;
    cin>>H>>N;
    int arr[N];
    int max=0;
    for(int i=0;i<N;i++)
    {
        cin>>arr[i];
        max+=arr[i];
    }
    if(max>=H)
    {
        cout<<"Yes"<<"\n";
    }
    else
    {
        cout<<"No\n";
    }
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);

mint f(int n, int k) {
  if (n < 0) return 0;
  // nPk = nCk * k!
  mint res = comb(n,k);
  res *= comb.fact[k];
  return res;
}

vector<int> to[100005];
mint ans;
int k;

void dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        dfs(u,v);
    }
    int nk = (p==-1) ? k : k-2;
    int c = (p==-1) ? to[v].size()+1 : to[v].size()-1;
    ans *= f(nk, c);
}

int main() {
    int n;
    cin >> n >> k;
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans = 1;
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13632
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		String S =nextString();
		String ans = "AC";
		StringBuffer sb = new StringBuffer(S);
		for(int i=2;i<sb.length()-1;i++){
			if(sb.charAt(i)=='C'){
				sb.deleteCharAt(i);
				break;
			}
			if(i==sb.length()-2){
				sb.append("C");
			}
		}

		if(sb.charAt(0)=='A'){
			sb.deleteCharAt(0);
		}else{
			sb.append("C");
		}

		while(sb.length()>0){
			if(Character.isUpperCase(sb.charAt(0))){
				break;
			}
			sb.deleteCharAt(0);
		}
		System.out.println(sb.length()==0?"AC":"WA");
	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

//最大値の中央値あたりが怪しい
int main() {

    ll N;
    cin >> N;
    
    vector<ll > A(N, 0);
    
  	for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    
    double center = A[0] / 2;
    double t_abs = INF;
    ll t_idx = 0;
    for(ll i = 1; i < N; i++){
        
        if(t_abs > abs(center-A[i])){
            t_abs = abs(center-A[i]);
            t_idx = i;
        }
    }
    
    cout << A[0] << " " <<  A[t_idx] << endl;

}

Measured memory_bytes: 1024
def main():
    n = int(input())
    hs = list(map(int, input().split()))

    ans = 0
    while True:
        if sum(hs) == 0:
            break

        i = 0
        while (i < n):
            if hs[i] == 0:
                i += 1
            else:
                ans += 1
                while (i < n and hs[i] > 0):
                    hs[i] -= 1
                    i += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9032
def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1000):
        pw = str(i).zfill(3)
        pw_ind = 0
        for s in S:
            if s == pw[pw_ind]:
                pw_ind += 1
                if pw_ind == 3:
                    break
        if pw_ind == 3:
            ans += 1

    return print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, x, y, i, j, k, f[1005][1005];
char c;
int main(){
    scanf("%c", &c);
    if(c<='Z'&&c>='A') printf("A");
    else printf("a");
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>

using namespace std;
int main(){

	int a,b,c;
	cin >> a >> b >> c ;
	
	if ( a > b ){
		swap ( a , b );
	} if ( b > c ){
		swap ( b , c );
	} if ( a > b ){
		swap ( a , b );
	}
	
	cout << a << " " << b << " " << c <<endl;
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

double x[3], y[3];
double e[3];
double cs[3];
double ang[3];

bool inside(double r) {
    rep(i, 3) {
        double xx1,xx2;
        xx1 = r / tan(ang[i]); xx2 = r / tan(ang[(i + 1) % 3]);
        if (xx1 + xx2 + 2 * r + 1e-14 <= e[(i + 2) % 3]) {
            return true;
        }
    }
    return false;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i, 3) cin >> x[i] >> y[i];
    rep(i, 3) e[i] = sqrt(pow(abs(x[(i + 1) % 3] - x[i]), 2) + pow(abs(y[(i + 1) % 3] - y[i]), 2));
    rep(i, 3) {
        cs[i] = (pow(e[(i + 2) % 3], 2) + pow(e[(i + 1) % 3], 2) - pow(e[i], 2)) / (2 * e[(i + 1) % 3] * e[(i + 2) % 3]);
        ang[i] = acos(cs[i]) / 2;
    }
    double l = 0;
    double r = 100000;
    rep(i, 100) {
        double m = (r + l) / 2;
        if (inside(m)) l = m;
        else r = m;
    }
    cout << fixed << setprecision(12) << l << endl;
}


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

using namespace std;
#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++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<ll> X(N), Y(N), H(N);
    for (ll i = 0; i < N; i++) {
        cin >> X[i] >> Y[i] >> H[i];
    }
    for (ll x = 0; x <= 100; x++) {
        for (ll y = 0; y <= 100; y++) {
            int k;
            for (int i = 0; i < N; i++) {
                if (H[i] != 0) {
                    k = i;
                    break;
                }
            }
            ll h = H[k] + abs(x - X[k]) + abs(y - Y[k]);
            int flag = 1;
            for (int i = 0; i < N; i++) {
                ll hh = max(0LL, h - abs(X[i] - x) - abs(Y[i] - y));
                if (hh != H[i]) {
                    flag = 0;
                    break;
                }
            }
            if (flag) {
                cout << x << " " << y << " " << h << endl;
                return;
            }
        }
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

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

Measured memory_bytes: 3164
package main

import (
	"fmt"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	ds := make([]int, n)
	for i := 0; i < n-1; i++ {
		ds[i] = as[i+1] - as[i]
	}
	ds[n-1] = k - as[n-1] + as[0]

	mx := 0
	ans := 0
	for i := 0; i < n; i++ {
		ans += ds[i]
		mx = max(mx, ds[i])
	}
	ans -= mx
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 8116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

int main(){
    int N,K;
    cin>>N>>K;
    vi vt(3);
    for(int i=0;i<3;i++){
        cin>>vt[i];
    }
    string s;
    cin>>s;
    vvi dp(N,vi(3,0));
    for(int j=0;j<K;j++){
        for(int i=0;i+j<N;i+=K){
            int t=i+j;
            if(t-K>=0){
                if(s[t]=='r'){
                    dp[t][2]+=(vt[2]+max(dp[t-K][0],dp[t-K][1]));
                    dp[t][1]+=max(dp[t-K][0],dp[t-K][2]);
                    dp[t][0]+=max(dp[t-K][2],dp[t-K][1]);
                }
                if(s[t]=='s'){
                    dp[t][2]+=(max(dp[t-K][0],dp[t-K][1]));
                    dp[t][1]+=max(dp[t-K][0],dp[t-K][2]);
                    dp[t][0]+=(vt[0]+max(dp[t-K][2],dp[t-K][1]));
                }
                if(s[t]=='p'){
                    dp[t][2]+=(max(dp[t-K][0],dp[t-K][1]));
                    dp[t][1]+=(vt[1]+max(dp[t-K][0],dp[t-K][2]));
                    dp[t][0]+=(max(dp[t-K][2],dp[t-K][1]));
                }
            }else{
                if(s[t]=='r'){
                    dp[t][2]+=(vt[2]);
                    dp[t][1]+=0;
                    dp[t][0]+=0;
                }
                if(s[t]=='s'){
                    dp[t][2]+=0;
                    dp[t][1]+=0;
                    dp[t][0]+=(vt[0]);
                }
                if(s[t]=='p'){
                    dp[t][2]+=0;
                    dp[t][1]+=(vt[1]);
                    dp[t][0]+=0;
                }
            }
        }
    }
    int sum=0;
    for(int i=N-1;i>max(-1,N-K-1);i--){
        //cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
        sum+=max({dp[i][0],dp[i][1],dp[i][2]});
    }
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 5888
/*************************************************************************
  > File Name: a.cpp
  > Author: Samuel
  > Mail: enminghuang21119@gmail.com
  > Created Time: Sun Mar 22 20:00:51 2020
*************************************************************************/

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1) / 2) + (m * (m - 1) / 2) << '\n';
    return 0;
}


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

int main() {
  int N, K, i, sum=1, m, n;
  cin >> N >> K;

  for(i=0; i < N;i++){
    m = sum *2;
    n = sum + K;
    sum = min(m, n);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [k] <- readInts
  print . showAnswer $ solve k

type Input  = (Int)
type Output = Int

solve :: Input -> Output
solve k = if even k then x*x else x*(x+1)
  where
    x = k `div` 2

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    dd = [(0,-1),(1,0),(0,1),(-1,0)]

    while True:
        n = I()
        if n == 0:
            break
        a = [(0,0)]
        for _ in range(n-1):
            i,di = LI()
            ai = a[i]
            d = dd[di]
            a.append((ai[0]+d[0], ai[1]+d[1]))
        y = sorted(list(map(lambda x: x[0], a)))
        x = sorted(list(map(lambda x: x[1], a)))
        rr.append('{} {}'.format(x[-1]-x[0]+1, y[-1]-y[0]+1))

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9080
#include <iostream>

int main(){

    int ans=0;
    int A,B;
    std::cin>>A>>B;

    if(A>=13){
        ans=B;
    }else if(A>=6){
        ans=B/2;
    }else{
        ans=0;
    }

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int n, m;
vector<vector<int>> v(8);
int cnt;

void dfs(int x, vector<bool> mp) {
  if (mp[x-1]) return;
  mp[x-1] = true;
  int i = 0;
  while (i < n && mp[i]) i++;
  if (i == n) {
    cnt++;
    return;
  }
  for (int j = 0; j < (int)v[x-1].size(); j++) {
    dfs(v[x-1][j], mp);
  }
  return;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    pi tmp;
    cin >> tmp.first >> tmp.second;
    v[tmp.first-1].push_back(tmp.second);
    v[tmp.second-1].push_back(tmp.first);
  }
  vector<bool> x(n, false);
  dfs(1, x);
  dump(cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll x,a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int sx,sy,tx,ty;
string a,b,c,d;
cin>>sx>>sy>>tx>>ty;
for(int i=0;i<tx-sx;i++){
  a+="R";
  b+="L";
}
for(int i=0;i<ty-sy;i++){
  c+="U";
  d+="D";
}
cout<<a<<c<<b<<d;
cout<<"L"<<c<<"UR"<<a<<"DR"<<d<<"DL"<<b<<"U"<<endl;;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    int k = 0;
    while (k * (k - 1) / 2 < n) k++;
    if (k * (k - 1) / 2 != n){
        cout << "No" << endl;
        return 0;
    }
    VVI s(k);
    int x = 1;
    REP(i,k) REP(j,i){
        s[i].push_back(x);
        s[j].push_back(x);
        x++;
    }
    cout << "Yes" << endl << k << endl;
    REP(i,k){
        cout << s[i].size();
        for (int x : s[i]) cout << " " << x;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2304
import sys
import math

a, b, c = map(int, sys.stdin.readline().rstrip().split())

# if 2 * math.sqrt(a*b) < c - a -b:
#     print("Yes")
# else:
#     print("No")

if c - a - b <= 0:
    print("No")
elif 4 * a * b < (c - a - b)**2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
	int f=1,ans=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return f*ans;
}
const int MAXN=200001;
int n,a[MAXN],b[MAXN],l,r,maxn;
bool check(int val){
	for(int i=1;i<=2*n-1;i++) b[i]=(a[i]>=val);
	for(int i=0;i<n-1;i++){
		if(b[n-i]==b[n-i-1]) return b[n-i];
		if(b[n+i]==b[n+i+1]) return b[n+i];
	}return b[1];
}
int main(){
//	freopen("4.in","r",stdin);
	n=read();
	for(int i=1;i<=2*n-1;i++) a[i]=read();
	l=1,r=2*n-1;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) l=mid+1,maxn=mid;
		else r=mid-1;
	}printf("%d\n",maxn);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        sc.close();
        if(x+r>X||y+r>Y||x+r<=0||y+r<=0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int k, t;
    cin >> k >> t;
    int m = 0;
    rep(i, t) {
        int a; cin >> a;
        m = max(m, a);
    }
    k -= m;
    if (m < k) cout << 0 << endl;
    else cout << (m - k - 1) << endl;
    return 0;
}

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

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

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(0,b+c-a);

    return 0;
}


Measured memory_bytes: 256