akhauriyash/Code-Regression huggingface dataset:
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
typedef long long LL;
const int MAXN = 200000;
const int MAXM = 400000;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int in[MAXN + 5][2], tot, head[MAXN + 5];
struct Edge {
  int to, nxt;
  Edge() {}
  Edge(int _to, int _nxt) : to(_to), nxt(_nxt) {}
}edge[MAXM + 5];
inline void add(int u, int v) {
  edge[tot] = Edge(v, head[u]);
  head[u] = tot++;
  edge[tot] = Edge(u, head[v]);
  head[v] = tot++;
}

int ch[MAXN + 5], n, m;
queue<int> que;

void init() {
//  enableFileIO();

  tot = 0;
  memset(head, -1, sizeof(head));
  
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i) ch[i] = getchar() - 'A'; 
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    add(u, v);
    ++in[v][ch[u]];
    ++in[u][ch[v]];
  }
}

int sum;
bool vis[MAXN + 5];

int main() {
  init();
  
  for (int i = 1; i <= n; ++i) {
    if (!in[i][0] || !in[i][1]) {
      que.push(i);
      vis[i] = true;
      ++sum;
    }
  }

  while (!que.empty()) {
    int u = que.front();
    que.pop();
    
    for (int i = head[u]; ~i; i = edge[i].nxt) {
      int v = edge[i].to;
      if (!--in[v][ch[u]] && !vis[v]) {
        que.push(v);
        vis[v] = true;
        ++sum;
      }
    }
  }
  
  if (sum < n) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 7040
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt();
		if(0>=a&&b>=0||a>=0&&0>=b) System.out.print("Zero");
		else if(0>a&&0>b&&(a-b)%2==0) System.out.print("Negative");
		else System.out.print("Positive");
	}
}

Measured memory_bytes: 21716
N = int(input())
A = list(map(int, input().split()))
B = []
C = []

#0をひとまとめにする
count = 0
for a in A:
    if a != 0:
        if count != 0:
            B.append(0)
            C.append(count)
        B.append(a)
        C.append(1)
        count = 0
    else:
        count += 1
if count != 0:
    B.append(0)
    C.append(count)

# print (A)
# print (B)
# print (C)
N = len(B)

count = 0
for l in range(N):
    tmp = C[l] #スタート地点の数
    tmp_count = 0
    total = B[l]
    xor = B[l]
    for r in range(l + 1, N):
        total += B[r]
        xor ^= B[r]
        if total == xor:
            tmp_count += C[r]
        else:
            break
    # print (tmp_count, tmp)
    count += tmp_count * tmp
    count += (tmp * (tmp + 1)) // 2
    # print (count)

#最後の1個だけ別に
# count += (C[-1] * (C[-1] + 1)) // 2

print (count)



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

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << "\t|";
    __f(comma + 1, args...);
}


#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<int> ans(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                ll a = i * i + j * j + k * k + i * j + j * k + k * i;
                if (a <= n) {
                    ans[a]++;
                } else {
                    break;
                }
            }
        }
    }
    
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;


vector<int>G[(int)(1e5+1)];
int main(){
    int N,M;
    cin>>N>>M;
    vector<LL> H(N);
    REP(i,N)cin>>H[i];
    
    REP(i,M){
        int A,B;
        cin>>A>>B;A--;B--;
        G[A].PB(B);
        G[B].PB(A);
    }
    int res=0;
    REP(node,N){
        bool flag=true;
        for(auto nei:G[node]){
            if(H[nei]>=H[node])flag=false;
        }
        if(flag)res++;
    }
    cout<<res<<endl;
    return 0;
}

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

int main( )
{
    int n, i, j, k, s = 0;
    int t[111];
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> t[i];
        s += t[i];
    }
    cin >> n;
    while (n--) {
        cin >> j >> k;
        cout << (s - t[j] + k) << '\n';
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
int p[111];
int r[33];
int main(void){
  int a,b;
  while(~scanf("%d,%d",&a,&b)){
    if(!a && !b) break;
    p[a] += b;
    r[b] = 1;
  }

  for(int i = 30; i >= 0; i--){
    r[i] += r[i+1];
  }

  while(~scanf("%d",&a)){
    printf("%d\n",r[p[a]]);
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll X[51],Y[51];

double ret;

void hoge(double x,double y) {
	double r=0;
	int i;
	FOR(i,N) r=max(r,hypot(X[i]-x,Y[i]-y));
	ret=min(ret,r);
}

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i]>>Y[i];
	ret=1e9;
	
	FOR(z,N) FOR(y,z) {
        // 二点を直径とする円
		double rx=(X[y]+X[z])/2.0;
		double ry=(Y[y]+Y[z])/2.0;
		hoge(rx,ry);
		
        // 三点でできる三角形の外心を中心とする円
		FOR(x,y) {
			double a=hypot(X[y]-X[z],Y[y]-Y[z]); //hypot: 平方根
			double b=hypot(X[z]-X[x],Y[z]-Y[x]);
			double c=hypot(X[x]-X[y],Y[x]-Y[y]);
			
			if(abs(a+b-c)<1e-9) continue;
			if(abs(a+c-b)<1e-9) continue;
			if(abs(c+b-a)<1e-9) continue;
			
			double rx=(a*a*(b*b+c*c-a*a)*X[x]+b*b*(a*a+c*c-b*b)*X[y]+c*c*(b*b+a*a-c*c)*X[z])/(a*a*(b*b+c*c-a*a)+b*b*(a*a+c*c-b*b)+c*c*(b*b+a*a-c*c));
			double ry=(a*a*(b*b+c*c-a*a)*Y[x]+b*b*(a*a+c*c-b*b)*Y[y]+c*c*(b*b+a*a-c*c)*Y[z])/(a*a*(b*b+c*c-a*a)+b*b*(a*a+c*c-b*b)+c*c*(b*b+a*a-c*c));
			hoge(rx,ry);
		}
	}
	_P("%.12lf\n",ret);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
  long long N, X, M; cin >> N >> X >> M;
  map<long long, long long> Map;
  
  long long A = X;
  long long count = 2;
  long long count_; // サイクル周期
  long long res;
  bool flag = true;
  Map[A] = 1;
  while (flag) {
    A = (A * A) % M;
    if (Map[A] >= 1) {
      flag = false;
      count_ = count - Map[A];
      res = A;
    }
    else Map[A] = count;
    count++;
  }
  long long start = Map[res]; // サイクルはじめ
  if (N - start + 1 <= count_) {
    long long sum = X;
    for (long long i = 0; i < N - 1; i++){
      X = (X * X) % M;
      sum += X;
    }
    cout << sum << endl;
  }
  else {
    long long sum = X;
    if (start == 1) sum = 0;
    for (long long i = 0; i < start - 2; i++){
      X = (X * X) % M;
      sum += X;
    }
    long long sum_ = 0;
    if (start == 1){
      sum_ += X;
      for (long long i = 0; i < count_ - 1; i++){
        X = (X * X) % M;
        sum_ += X;
      }
    }
    else {
      for (long long i = 0; i < count_; i++){
        X = (X * X) % M;
        sum_ += X;
      }
    }
    sum += ((N - start + 1) / count_) * sum_;
    for (long long i = 0; i < N - ((start - 1) + ((N - start + 1) / count_) * count_); i++){
      X = (X * X) % M;
      sum += X;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 6676
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt() * 2;
        int[] l = IntStream.rangeClosed(1, k).toArray();
        int m = sc.nextInt();
        while (m-- > 0) {
            int n = sc.nextInt();
            int[] t = new int[k];
            if (n == 0) {
                for (int i = 0; i < k; i++) {
                    t[i] = l[(i % 2 == 0 ? i : k + i) / 2];
                }
            } else {
                for (int i = 0; i < k; i++) {
                    t[i] = l[(i + n) % k];
                }
            }
            l = t;
        }
        for (int i : l) {
            System.out.println(i);
        }
    }
}



Measured memory_bytes: 34840
#include <bits/stdc++.h>
#define MOD 1000000007
#define EPS ((long double)1e-12)
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define sz(x) ((long long)(x).size())
#define endl '\n'
#define DUMP_NAME(name,a) cout << "#dump " << (name) << " = " << (a) << "  "
#define dump(a) DUMP_NAME(#a, (a));
#define FOREACH(it,x) for(__typeof__((x).begin()) it = (x).begin();it!=(x).end();++it)
#define FOR(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define ROF(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
const ld PI = 3.141592653589793238L;
const ll N = 500005;
using namespace std;

ull a[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    #endif
    //<<>>

    ll n,x; cin >> n >> x;
    FOR(i,1,n) cin >> a[i];
    reverse(a + 1 , a + n + 1);
    ROF(i,n - 1,1) a[i] += a[i + 1];

    ull ans = ULLONG_MAX;
    FOR(k,1,n){
        ull ans1 = k * x;
        bool take = 1;

        FOR(i,1,n){
            ull ans2 = (a[i] - a[i + k]) * max(5ll , 2 * ((i - 1) / k + 1) + 1);
            if(ans - ans2 <= ans1) take = 0;
            ans1 += ans2;

            i += k - 1;
        }

        if(take == 1) ans = ans1;
    }

    ans += (ull) n * x;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
base_ = sum(Ts)

for m in range(M):
  p, t = map(int, input().split())
  #print(Ts[p-1])
  #print(t)
  #print((Ts[p-1]-t))
  print(base_ - (Ts[p-1]-t))


Measured memory_bytes: 38256
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1
d_max = max(d.values())
ans = [k for k, v in d.items() if v == d_max]
for a in sorted(ans):
    print (a)


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

int w, h, n, x, y, a;
bool rect[105][105];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
 	cin >> w >> h >> n;
 	while (n--) {
 		cin >> x >> y >> a;
 		int i = 0, j = 0, k = h-1, l = w-1;
 		if (a == 1) {
 			l = x-1;
 		}
 		else if (a == 2) {
 			j = x;
 		}
 		else if (a == 3) {
 			k = y-1;
 		}
 		else {
 			i = y;
 		}

 		for (int height = i; height <= k; height++) {
 			for (int width = j; width <= l; width++) {
 				rect[height][width] = 1;
 			}
 		}
 	}

 	int area = 0;
 	for (int i = 0; i < h; i++) {
 		for (int j = 0; j < w; j++) {
 			area += (rect[i][j] == 0);
 		}
 	}
 	cout << area << '\n';
 	
	return 0;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        n:usize,
       mut xl:[(i64,i64);n],
    }
    let mut ps = vec![];
    for &(x, l) in xl.iter() {
        ps.push((x + l, x - l));
    }
    ps.sort();
    let mut now = -INF;
    let mut ans = 0;
    for &(r, l) in ps.iter() {
        if now <= l {
            ans += 1;
            now = r;
        }
    }
    println!("{}", ans);
}
const INF: i64 = 1 << 60;


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

using namespace std;

int main()
{

    int n,k;
    cin>>n>>k;
    int mod = 998244353;
    vector<pair<int,int>> steps;
    for(int i = 0;i<k;i++)
    {
        int x,y;
        cin>>x>>y;
        steps.push_back({x,y});
    }

    sort(steps.begin(),steps.end());
    vector<int> dp(n);
    dp[0] = 1;
    for(int i = 1;i<n;i++)
    {
        for(int j = 0;j<k;j++)
        {
            int l = i - steps[j].second;
            int r = i - steps[j].first;
            if(r >= 0)
            {
                dp[i] = (dp[i] + dp[r]) % mod;
            }
            if(l > 0)
            {
                dp[i] = (dp[i] - dp[l-1] + mod) % mod;
            }
        }

        if(i != n-1)
        {
            dp[i] = (dp[i] + dp[i-1]) % mod;
        }
    }

    cout<<dp[n-1];
    
    return 0;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);
void solve()
{
	string s, t;
	cin >> s >> t;
	int res = 0;
	rep(i, 3) res += s[i] != t[i];
	cout << sz(s) - res;
}	
int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 256
#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 >;

int main() {
    int N;
    cin >> N;
    vector< P > A(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        A[i] = P(a, b);
    }
    vector< P > B(N);
    rep(i, N) {
        int c, d;
        cin >> c >> d;
        B[i] = P(c, d);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    set< int > used;
    rep(i, N) {
        int best = -1;
        int idx = -1;
        rep(j, N) {
            if (B[i].first > A[j].first && B[i].second > A[j].second) {
                if (best < A[j].second && !used.count(j)) {
                    best = A[j].second;
                    idx = j;
                }
            }
        }
        if (idx != -1) {
            used.insert(idx);
        }
    }
    cout << used.size() << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue
import itertools

n,r = map(int, input().split())
print(r if n >= 10 else r + 100 * (10 - n))


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

int main() {
  ll n,k;cin>>n>>k;
  ll ans=min(n%k,k-n%k);
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
import Data.Either
import Control.Applicative

data Op = S | E | N | W deriving (Show, Eq, Enum)

fromChar c | c == 'S' = S
           | c == 'E' = E
           | c == 'N' = N
           | c == 'W' = W
           | otherwise = error $ "Invalid char " ++ [c]

fromString [] = []
fromString (x:xs) = (fromChar x):(fromString xs)

data Dice = Dice { top :: Int, front :: Int, right :: Int, left :: Int, back :: Int, bottom :: Int }
  deriving (Show, Eq)

makeDice [t, f, r, l, ba, bo] = Dice t f r l ba bo

roll S (Dice t f r l ba bo) = Dice ba t r l bo f
roll N (Dice t f r l ba bo) = Dice f bo r l t ba
roll E (Dice t f r l ba bo) = Dice l f t bo ba r
roll W (Dice t f r l ba bo) = Dice r f bo t ba l
rolls [] dice = dice
rolls (x:xs) dice = rolls xs (roll x dice)


main = do
  labels <- map read . words <$> getLine :: IO [Int]
  ops <- fromString <$> getLine :: IO [Op]
  print . top . rolls ops . makeDice $ labels




Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	cin >> s >> t;
	int len = s.size();
	for(int i = 0; i < len; i++){
		bool ok = true;
		for(int j = 0; j < len; j++){
			int now = i+j;
			if(now >= len) now -= len;
			if(s[j] != t[now]){
				ok = false;
				break;
			}
		}
		if(ok){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

// Thursday 3/19/20

//  158 C Tax Increase

int main() {
	int A, B;
	cin >> A >> B;
	bool notFound = true;
	int value = -1;
	for (int i = B*10; i < B*10 + 10 && notFound; ++i) {
		if (int(i * .08) == A && int(i * .1) == B) {
			notFound = false;
			value = i;
		}
	}
	cout << value;
	return 0;
}

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

int main() {
    ll N;cin>>N;
    ll tmp = 0,evac = N;
    while(N/5){
        N/=5;
        tmp++;
    }
    ll ans=0;
    N = evac;
    ll  t=10;
    while(t<=N){
        ans += N/t;
        t *= 5;       
    }
    if(N%2!=0)cout << 0 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  double p=0;
  if(n%2==0){
    p=n/2.0/n;}
  else {
    p=(n+1.0)/2.0/n;}
  cout << fixed << setprecision(15) << p << endl;
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    int n = N - 2;
    if(N == 2 && K == 0){
        cout << 1 << endl << 1 << ' ' << 2 << endl;
        return 0;
    }
    if(N == 2 || (n*n + n)/2 < K){
        cout << -1 << endl;
      return 0;
    }
    vector<pair<int,int>> V;
    int cnt = 0;
    REPP(i,2,N+1){
        V.pb({1,i});
    }
    if((n*n + n)/2 - K){
        REPP(i,2,N+1){
            REPP(j,i+1,N+1){
                cnt++;
                V.pb({i,j});
                if(cnt == (n*n + n)/2 - K) break;
            }
            if(cnt == (n*n + n)/2 - K) break;
        }
    }
    cout << cnt + N-1 << endl;
    REP(i,V.size()){
        cout << V[i].first << ' ' << V[i].second << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
#define END "\n"
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////



int main()
{
    fast
    #ifdef ANUBHAB
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll a, b, i;
    cin >> a >> b;
    for (i = 1; i <= 1000000; i++) if (((i * 10) / 100) == b && ((i * 8) / 100) == a) break;
    if (i == 1000001) i = -1;
  cout << i;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
   char s[7];
   scanf("%s",s);
   for(int i=0;s[i]!='\0';i++){
      if(s[2]==s[3] &&s[4]==s[5]){
         printf("Yes");
         break;
      }else{
         printf("No");
         break;
      }
   }
   return 0;
}


Measured memory_bytes: 1716
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new RitProA().doIt();
	}
	class RitProA{
		void doIt(){
			int n = in.nextInt();
			ArrayList<Frame> list = new ArrayList<Frame>();
			for(int i=0;i<n;i++)list.add(new Frame(in.nextInt(),in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt()));
			Collections.sort(list);
			
			double maxKyori1 = -1.000000;
			int minTime1 = Integer.MAX_VALUE/2;
			double maxKyori2 = -1.000000;
			int minTime2 = Integer.MAX_VALUE/2;
			for(int i=0;i<n-1;i++){
				Frame f1 = list.get(i);
				Frame f2 = list.get(i+1);
				Point2D p1 = new Point2D.Double(f1.x,f1.y);
				Point2D p2 = new Point2D.Double(f2.x,f2.y);
				if(f1.t!=f2.t)continue;
				if(f1.t == 0){
					if(p1.distance(p2) > maxKyori1 && f1.a != f2.a){
						maxKyori1 = p1.distance(p2)*1.000000;
						minTime1 = f2.f - f1.f;
					}else if(Math.abs(p1.distance(p2) - maxKyori1) < 0.00000000001){
						maxKyori1 = p1.distance(p2)*1.000000;
						minTime1 = f2.f - f1.f;
					}
				}else{
					if(p1.distance(p2) >= maxKyori2 && f1.a != f2.a){
						maxKyori2 = p1.distance(p2)*1.000000;
						minTime2 = f2.f - f1.f;
					}else if(Math.abs(p1.distance(p2) - maxKyori2) < 0.00000000001){
							maxKyori2 = p1.distance(p2)*1.000000;
							minTime2 = f2.f - f1.f;
					}
				}
			}
			if(maxKyori1 == -1.0){
				System.out.println("-1 -1");
			}else System.out.printf("%.5f %.5f\n",maxKyori1,minTime1/60.0);
			if(maxKyori2 == -1.0)System.out.println("-1 -1");
			else System.out.printf("%.5f %.5f\n",maxKyori2,minTime2/60.0);
		}
	}
	
	class Frame implements Comparable<Frame>{
		int a,t,x,y,f;
		public Frame(int _f,int _a,int _t,int _x,int _y){
			this.f = _f;
			this.x = _x;
			this.y = _y;
			this.a = _a;
			this.t = _t;
		}
		public int compareTo(Frame f) {
			return this.f - f.f;
		}
		
		
	}
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[3][100005];
int dp[100005][3];
void solve(){
    cin>>n;
    rep(j,1,n+1){
        rep(i,0,3){
            cin>>a[i][j];
        }
    }
    rep(i,1,n+1){
        rep(j,0,3){
            rep(k,0,3){
                if(j==k) continue;
                dp[i][j]=max(dp[i-1][k]+a[j][i],dp[i][j]);
            }
        }
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=405;

int n;
int a[N], pref[N];
int cache[N][N];

int dp(int i, int j)
{
	if(i==j)
		return 0;
	int &ans=cache[i][j];
	if(ans!=-1)
		return ans;
	ans=1e15;
	for(int k=i;k<=j-1;k++)
		ans=min(ans, dp(i, k) + dp(k+1, j) + pref[j]-pref[i-1]);
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pref[i]=pref[i-1] + a[i];
	}
	cout<<dp(1, n);
	return 0;
}

Measured memory_bytes: 1536
fun main(arr:Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toLong() }
    if(h == 1L || w == 1L) {
        println(1)
        return
    }
    val ans = (h*w/2) + (h*w)%2
    println(ans)
}

Measured memory_bytes: 36016
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
int popcount(int x) {
	int ans=0;
	int tmp;
	while (x != 0) {
		tmp = x >> 2;
			tmp = tmp << 1;
			if (tmp == x) {
				ans++;
			}
			x >> 1;
	}
	return ans;

}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (b + c <= a) {

		cout << 0;
	}
	else {
		cout << b + c - a;
	}
}
	


Measured memory_bytes: 3604
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

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

using namespace std;
typedef long long ll;
const int INF = INT_MAX / 4;

const int max_n = 1e3;

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

  int N, M;
  cin >> N >> M;

  int a[N];
  REP(i, N) {
    cin >> a[i];
    a[i]--;
  }

  ll s[M], ea[M], er[M], total = 0;
  REP(i, M) {
    s[i] = ea[i] = er[i] = 0;
  }
  int d, as;
  ll cd = 0, c = 0;
  for(int i = 1;i < N;i++) {
    d = a[i] - a[i-1];
    if (d < 0) d += M;
    total += d;
    if (d >= 2) {
      as = a[i-1] + 2;
      if (as >= M) as -= M;
      s[as] += 1;
      ea[a[i]] += 1;
      er[a[i]] += d-1;
      if (a[i] < as){
	cd += 1;
	c += M - as;
      }
    }
  }

  // // dbg
  // REP(i, M) cerr << ea[i] << " ";
  // cerr << "\n";
  // REP(i, M) cerr << er[i] << " ";
  // cerr << "\n";

  ll max_c = 0;
  REP(i, M) {
    cd += s[i];
    c += cd;
    // cerr << c << " ";
    if (c > max_c) max_c = c;
    cd -= ea[i];
    c -= er[i];
  }

  cout << total - max_c << "\n";
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L;
  cin >> N >> L;
  int sum=(L*2+N-1)*N/2;
  if (L+N-1<0){
    cout << sum-(L+N-1) << endl;
  }
  else if (L>0){
    cout << sum-L << endl;
  }
  else {
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#if __cplusplus >= 201103L
template<class ...Args> inline int err( Args ...args ){ return fprintf( stderr, args... ); }
#else
#define err(...) 1
#endif
#define i64 long long
#define f80 long double
#define rgt register
#define fp( i, b, e ) for ( int i(b), I(e); i <= I; ++i )
#define fd( i, b, e ) for ( int i(b), I(e); i >= I; --i )
#define go( i, b ) for ( int i(b), v(to[i]); i; v = to[i = nxt[i]] )
template<typename T> inline bool cmax( T &x, T y ){ return x < y ? x = y, 1 : 0; }
template<typename T> inline bool cmin( T &x, T y ){ return y < x ? x = y, 1 : 0; }
template<typename T>
inline void read( T &x ){ char t(getchar()), flg(0); x = 0;
	for ( ; !isdigit(t); t = getchar() ) flg = t == '-';
	for ( ; isdigit(t); t = getchar() ) x = x * 10 + ( t & 15 );
	flg ? x = -x : x;
}

const int MAXN = 2e5 + 5; int N, x;
int a[MAXN]; bool vis[MAXN]; int l(1), r;
inline int GetL(){ while( l <= r && vis[l] ) ++l; vis[l] = 1; return l; }
inline int GetR(){ while( l <= r && vis[r] ) --r, vis[r] = 1; return r; }


signed main(){
	read(N), read(x), r = 2 * N - 1;
	if ( N == 1 ) return printf( "%d\n", x ), 0;
	if ( x == 1 || x == 2 * N - 1 ) return printf( "No\n" ), 0;
	a[N] = x, vis[x] = 1, a[N + 1] = GetR(), a[N - 1] = GetL();
	if ( x == 1 ) a[N - 2] = GetR(); else a[N + 2] = GetL();
	fp( i, 1, 2 * N - 1 ) if ( !a[i] ) a[i] = GetL();
	printf( "Yes\n" );
	fp( i, 1, 2 * N - 1 ) printf( "%d\n", a[i] );
	return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	string S;
	cin >> S;

	auto dp = make_vec(N + 1, 4, 1000, char(0));//dp[i+1][j][k]:i文字目まで見てj文字確定したときの文字列kが実現できるなら1
	dp[0][0][0] = 1;

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 3; j++) {
			for (Int k = 0; k < 100; k++) {
				if (!dp[i][j][k]) {
					continue;
				}
				//i文字目を選択する場合
				dp[i + 1][j + 1][10 * k + (S[i] - '0')] = true;
			
				//i文字目を選択しない場合
				dp[i + 1][j][k] = true;
			}
		}
	}

	Int ans = 0;
	vector<char> seen(1000,0);
	for (Int i = 1; i <= N; i++) {
		for (Int k = 0; k < 1000; k++) {
			if (dp[i][3][k]) {
				if (seen[k]) {
					continue;
				}
				ans++;
				seen[k] = true;
			}
		}
	}
	cout << ans << "\n";

}


Measured memory_bytes: 122368
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(123456789)
#define LINF (long long int)(123456789012345678)
#define MAX_V 1000

//rev: G[to][rev]で逆辺にアクセスできるようにしている
struct edge {int to, cap, rev;};
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, (int)G[to].size()});
	G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

//vからtに流せたフローの量を返す　fはvが保持しているフローの量
int dfs(int v, int t, int f){
	if(v == t) return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		memset(used,0,sizeof(used));//usedを0で初期化してるだけ
		int f = dfs(s,t,INF);
		if(f==0) return flow;
		flow += f;
	}
}

int main(void){
	int n,a,b,c,d;
	vector<int> A,B,C,D;
	cin>>n;
	rep(i,n){
		cin>>a>>b;
		A.push_back(a);
		B.push_back(b);
		add_edge(0,i+1,1);
	}
	rep(i,n){
		cin>>c>>d;
		C.push_back(c);
		D.push_back(d);
		add_edge(n+i+1,2*n+1,1);
	}
	rep(i,n){
		rep(j,n){
			if(A[i]<C[j] && B[i]<D[j]){
				add_edge(i+1,n+j+1,1);
			}
		}
	}
	cout<<max_flow(0,2*n+1)<<endl;;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ld INF = (ld)10000000000000;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
int n, m;
priority_queue<LP, vector<LP>, greater<LP>> q;
int main() {
	cin >> n >> m;
	ll sum = 0;
	rep(i, n) {
		int a, b; cin >> a >> b;
		q.push({ a,b });
	}
	ll cnt = 0;
	while (cnt < m) {
		LP p = q.top(); q.pop();
		ll mi = min(m - cnt, p.second);
		cnt += mi; sum += mi * p.first;
	}
	cout << sum << endl;
	//stop
	return 0;
}

Measured memory_bytes: 2420
use text_io::*;
use std::collections::HashMap;
use std::process::exit;

fn main() {
    let a:usize = read!();
    let b:usize = read!();
    let c:usize = read!();
    let d:usize = read!();
    if a*b<c*d {
        println!("{}",c*d);
        exit(0);
    }
    println!("{}",a*b);
}

Measured memory_bytes: 2160
from itertools import permutations
from collections import defaultdict
from math import sqrt, factorial

N = int(input())
point = defaultdict(list)
for i in range(1, N+1):
    x, y = list(map(int, input().split()))
    point[i] = [x, y]

res = 0
for permutation in permutations(range(1, N+1)):
    for i in range(1, N):
        nx, pre = permutation[i], permutation[i-1]
        res += sqrt( pow((point[nx][0] - point[pre][0]), 2) + pow((point[nx][1] - point[pre][1]), 2) )

print(res / factorial(N))



Measured memory_bytes: 40940
from collections import deque
n,m=map(int,input().split())
r=[[] for i in range(n+1)]
R=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    r[a].append(b)
    r[b].append(a)
    R[a].append(b)
    R[b].append(a)
dep=[-1]*(n+1)
dep[0]=0
dep[1]=0
data=deque([1])
d=0
while len(data)>0:
    p=data.popleft()
    for i in r[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
    
if not all(dep[i+1]>=0 for i in range(n)):
    print("No")
else:
    print("Yes")
    for i in range(2,n+1):
        for j in R[i]:
            if dep[j]==dep[i]-1:
                print(j)
                break


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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) s.begin(), s.end()
#define SZ(s) s.size()

template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(b<a){a=b;return true;}return false;}

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int s;
    cin >> s;
    
    vector<bool> a(1000000);
    int n = s;
    for(int i = 1; i < 1000000; i++) {
        if(a[n]) {
            cout << i;
            break;
        }
        a[n] = true;
        if(n % 2 == 0) {
            n = n / 2;
        } else {
            n = 3 * n + 1;
        }
    }
    
    return 0;
}


Measured memory_bytes: 384
n = int(input())

if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n - 90)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n - 9090)
else:
    print(90909)

Measured memory_bytes: 2940
import numpy as np
X = int(input())
flag = 1
for c in range(1, np.power(10, 9)):
    x = X
    if x % c == 0:
        x = x // c
        for a in range(np.power(10, 3)):
            b = a-c
            y = 0
            for i in range(5):
                y += np.power(a, 4 - i) * np.power(b, i)
            if y == x:
                print(a, a - c)
                flag = 0
                break
    if flag == 0:
        break

Measured memory_bytes: 27132
#include<stdio.h>
#define ll long long
int main(){
  ll a,b,k,i;
  scanf("%lld%lld%lld",&a,&b,&k);
  if(k<=a){
    printf("%lld %lld",a-k,b);
    return 0;
  }else if(a<k&&k<=a+b){
    printf("%d %lld",0,a+b-k);
    return 0;
  }else{
    printf("0 0");
    return 0;
  }
}

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

using namespace std;

int main()
{
	int n,i;
	
	cin>>n;
	
	int a[n];
	
	for(i=0; i<n; i++)
	cin>>a[i];
	
	int b[n];
	
	b[0]=0;
	
	b[1]=abs(a[1]-a[0]);
	
	for(i=2; i<n; i++)
	{
		b[i]=min(b[i-2]+abs(a[i]-a[i-2]),b[i-1]+abs(a[i]-a[i-1]));
	}
	
	cout<<b[n-1];
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
j = 0
count = 0
index = []
index2 = []
for i in range(1, K+1):
    d = int(input())
    index.append(input().split())
for i in range(len(index)):
    for j in index[i]:
        index2.append(j)
        index3 = set(index2)
print(N - len(index3))

Measured memory_bytes: 9684
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] zahyo = new int[n];
		for(int i=0; i<n; i++)
			zahyo[i] = sc.nextInt();
		sc.close();

		Arrays.sort(zahyo);
		System.out.println(zahyo[n-1] - zahyo[0]);
	}
}


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

using namespace std;
typedef long long ll;
const double PI = 3.14159265;

void fastInOut();

const int N = 100005;
int a[N];

int main() {

    fastInOut();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0)
            continue;
        if (i + 1 < n) {
            int sum = a[i] + a[i + 1];
            res += sum / 2;
            if (sum % 2 && a[i + 1])
                a[i + 1] = 1;
            else
                a[i + 1] = 0;

        } else res += a[i] / 2;
    }
    cout << res;
    return 0;
}

void fastInOut() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
}

Measured memory_bytes: 768
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N = int(input())
    n1 = N%10
    answer = ""
    if n1 in set((2, 4, 5, 7, 9)):
        answer = "hon"
    elif n1 in set((0, 1, 6, 8)):
        answer = "pon"
    else:
        answer = "bon"
    print(answer)

if __name__ == "__main__":
    main()




Measured memory_bytes: 9188
#include<iostream>
#include<cstdio>
using namespace std;
int N,T,L,B;
bool l[200];
bool b[200];

double dp[200][200];

double rec(int x,int y){
  if(y<0)return 0;
  if(x==N)return 1;
  if(y==0)return 0;
  if(dp[x][y]!=-1.0)return dp[x][y];
  double res=0.0;
  for(int i=1;i<=6;i++){
    int w=x+i;
    if(N<w)w=N-(w-N);
    if(b[w])w=0;
    if(l[w])res+=rec(w,y-2);
    else res+=rec(w,y-1);
  }
  return dp[x][y]=res/6.0;
}

int main(){
  while(1){
    cin>>N>>T>>L>>B;
    if(N==0&&T==0&&L==0&&B==0)break;
    for(int i=0;i<200;i++){
      l[i]=b[i]=false;
      for(int j=0;j<200;j++)dp[i][j]=-1.0;
    }
    int a;
    for(int i=0;i<L;i++){      cin>>a;      l[a]=true;    }
    for(int i=0;i<B;i++){      cin>>a;      b[a]=true;    }
    printf("%.8f\n",rec(0,T));
  }
  return 0;
}

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


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

    string s;
    cin >> s;
    if (s=="Sunny") cout << "Cloudy" << endl;
    else if (s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
    int S,W;
    cin >> S >>W;

    if (S <= W) { cout << "unsafe" << endl; }
    else { cout << "safe" << endl; }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<char>s(21);
  for(int i=0;i<21;i++){
    cin >> s.at(i);
  }
  vector<char>ans(3);
  for(int i=0;i<3;i++){
    ans.at(i)=s.at(i);
    cout << ans.at(i);
  }
  cout << endl;
}
  
  

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, d; cin >> n >> d;
        vector<vector<int>> a(n, vector<int>(d));
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                        cin >> a[i][j];
                }
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                        int dist = 0;
                        for (int k = 0; k < d; k++) dist += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
                        if (sqrt(dist) == (int) sqrt(dist)) {
                                ans++;
                        }
                }

        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
const int MAX_N = 1<<17;

ll n,dat[2*MAX_N-1];

void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=0;
}

void update(int k,ll a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=max(dat[k*2+1],dat[k*2+2]);
  }
}

ll query(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return dat[k];
  else{
    ll vl=query(a,b,k*2+1,l,(l+r)/2);
    ll vr=query(a,b,k*2+2,(l+r)/2,r);
    return max(vl,vr);
  }
}

int main(){
  ll num,x;
  cin>>n;
  num=n;
  init(n+1);
  for(int i=0;i<num;i++){
    cin>>x;
    update(x,query(0,x,0,0,n)+x);
  }
  cout<<num*(num+1)/2-query(0,num+1,0,0,n)<<endl;
  return 0;
}

Measured memory_bytes: 5144
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
int W,H;
int fie[100][100];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int search(int x,int y){
  int ret=0;
  for(int i=0;i<4;i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if( nx < 0 || ny < 0 || nx >= W || ny >= H ) continue;
    if(fie[nx][ny]==0) continue;
    fie[nx][ny] = 0;
    ret = max(ret,search(nx,ny)+1);
    fie[nx][ny] = 1;
  }
  return ret;
}
int main(){
  while(1){
    scanf("%d %d",&W,&H);
    if(!W && !H) break;
    for(int y=0;y<H;y++)
      for(int x=0;x<W;x++)
	scanf("%d",&fie[x][y]);
    int res=0;
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	if(fie[x][y]){
	  fie[x][y]=0;
	  res = max(res,search(x,y)+1);
	  fie[x][y]=1;
	}
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
using ll = long long;
using namespace std;


void solve() {
   int l, r, d;
   cin >> l >> r >> d;
   cout << ((r / d) - (l - 1) / d) << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}

inline ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll lcm(ll a, ll b) {
    return a * (b / gcd(a, b));
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << '\n';
    


    return 0;
}

Measured memory_bytes: 256