akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int dataset = sc.nextInt();
		for(int i = 0; i < dataset; i++){
			double x1 = sc.nextDouble();
			double y1 = sc.nextDouble();
			double x2 = sc.nextDouble();
			double y2 = sc.nextDouble();
			double x3 = sc.nextDouble();
			double y3 = sc.nextDouble();
			Point p = new Point(x1, y1);
			Point q = new Point(x2, y2);
			Point r = new Point(x3, y3);
			Circle result = circumscribedCircle(p, q, r);
			Point c = result.getCenter();
			double rad = result.getR();
			System.out.printf("%.3f %.3f %.3f\n", c.getX(), c.getY(), rad);
		}
		sc.close();
	}
	
	static Point solve(Point p, Point q, Point a){
		double det = p.getX() * q.getY() - p.getY() * q.getX();
		return new Point((q.getY() * a.getX() - p.getY() * a.getY()) / det,
				(-q.getX() * a.getX() + p.getX() * a.getY()) / det);
	}
	
	static double distance(Point a, Point b){
		double x_dist = a.getX() - b.getX();
		double y_dist = a.getY() - b.getY();
		return Math.sqrt(x_dist * x_dist + y_dist * y_dist);
	}
	
	static Circle circumscribedCircle(Point p1, Point p2, Point p3){
		double a1 = 2 * p2.getX() - 2 * p1.getX();
		double a2 = 2 * p2.getY() - 2 * p1.getY();
		double a3 = sq(p2.getX()) - sq(p1.getX()) + sq(p2.getY())
				- sq(p1.getY());
		double b1 = 2 * p3.getX() - 2 * p1.getX();
		double b2 = 2 * p3.getY() - 2 * p1.getY();
		double b3 = sq(p3.getX()) - sq(p1.getX()) + sq(p3.getY())
				- sq(p1.getY());
		Point c = solve(new Point(a1, a2), new Point(b1, b2), new Point(a3, b3));
		double r = distance(p1, c);
		return new Circle(c, r);
	}
	
	static double sq(double d){
		return d * d;
	}
}

class Circle{
	
	private Point center;
	private double r;
	
	public Point getCenter(){
		return this.center;
	}
	
	public double getR(){
		return this.r;
	}
	
	public Circle(Point center, double r){
		this.center = center;
		this.r = r;
	}
}

class Point{
	
	private double x;
	private double y;
	
	public double getX(){
		return this.x;
	}
	
	public double getY(){
		return this.y;
	}
	
	public Point(double d, double e){
		this.x = d;
		this.y = e;
	}
}

Measured memory_bytes: 20752
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[100][100],retu[100]={0},gyou[100]={0},sum=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
            retu[i] += a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            gyou[i] += a[j][i];
        }
        sum = sum+gyou[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout << a[i][j] << " ";
        }
        cout << retu[i] << endl;
    }
    for(int i=0;i<m;i++)cout << gyou[i] << " ";
    cout << sum << endl;
     
     
}


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

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

	int N;
	string S;
	int i,k;
	int ans=0;
	int ctr=0;

	cin >> S;

	if(S=="SUN")
		cout << 7 << endl;
	if(S=="MON")
		cout << 6 << endl;
	if(S=="TUE")
		cout << 5 << endl;
	if(S=="WED")
		cout << 4 << endl;
	if(S=="THU")
		cout << 3 << endl;
	if(S=="FRI")
		cout << 2 << endl;
	if(S=="SAT")
		cout << 1 << endl;

	return 0;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

/* UnionFind */
struct UnionFind {
    vector<ll> par,rank,siz;

    UnionFind(ll N) : par(N),rank(N),siz(N) {
        REP(i,N){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    ll root(ll x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        if(rank[rx] < rank[ry]){
            par[rx] = ry;
            siz[ry] += siz[rx];
        }else{
            par[ry] = rx;
            siz[rx] += siz[ry];
            if(rank[rx] == rank[ry])rank[rx]++;
        }
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,M;
    cin >> N >> M;
    UnionFind uf(N);
    REP(i,M){
        ll A,B;
        cin >> A >> B;
        A--;
        B--;
        uf.unite(A,B);
    }
    ll ma = 0;
    REP(i,N){
        chmax(ma,uf.size(i));
    }
    cout << ma << "\n";
}

Measured memory_bytes: 7956
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;

int main() {
    string s;
    cin >> s;
    int n=s.size();
    bool flag=1;
    rep(i,n/2) {
        if (s[i]!=s[n-1-i]) flag=0;
    }
    rep(i,n/4) {
        if (s[i]!=s[n/2-1-i]) flag=0;
        if (s[n/2+1+i]!=s[n-1-i]) flag=0;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
if y>10000*n:
    print("-1 -1 -1")
else:
    for i in range(n+1):
        #print(i)
        for j in range(n-i+1):
            if y==10000*i+5000*j+(n-i-j)*1000:
                print(i,j,(n-i-j))
                exit()
    print("-1 -1 -1")

Measured memory_bytes: 3188
//#pragma GCC optimize("03", "unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(i,n) for(i=0;i<n;i++)
#define FORn(i,j,n) for(i=j;i<n;i++)
#define pb push_back
#define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define vprint(v) for(auto t:v)cout<<t<<" "
#define endl "\n"

using namespace std;

typedef long long int lli;
typedef long int li;
typedef vector<lli> vli; 
typedef vector<int> vi; 
typedef vector<string> vs; 


const lli mod=1000000007;
const lli limit=1000000;


void fc(lli &x)
    {
        bool neg=false;
        register char c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    }

int main() {

    fast()
    lli n,q,t;
    lli temp,temp1,temp2,temp3;
    lli i,j,k;
    cin>>i>>j;
    if(i>j)cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;
 
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    cin >> n;
    vector<int64_t> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    int64_t result1 = 0, s1 = 0, result2 = 0, s2 = 0;
    rep(i, n)
    {
        s1 += a[i];
        s2 += a[i];
        if (i % 2 == 0) {
            int64_t dif1 = max(0L, 1 - s1);
            s1 += dif1;
            result1 += dif1;

            int64_t dif2 = max(0L, s2 - (-1));
            s2 -= dif2;
            result2 += dif2;
        } else {
            int64_t dif1 = max(0L, s1 - (-1));
            s1 -= dif1;
            result1 += dif1;

            int64_t dif2 = max(0L, 1 - s2);
            s2 += dif2;
            result2 += dif2;
        }
    }

    cout << min(result1, result2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

ll com[51][51];
ll combination(ll n,ll r){
	if(com[n][r]!=0)return com[n][r];
	if(n==r)return com[n][n] = 1;
	if(r==1)return com[n][r] = n;
	return com[n][r]=combination(n-1,r-1)+combination(n-1,r);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,A,B,ans=0;
	long double ave=0;
	cin >> N >> A >> B;
	vector<ll> v(N);
	FOR(i,0,N)cin>>v[i];
	map<ll,ll> ma;
	SORT(v);
	FOR(i,0,N)ma[v[i]]++;
	REV(v);
	//1///////////////
	if(v[A-1]==v[0]){
		ave = (long double)v[0];
		FOR(i,A,min(B,ma[v[0]])+1){
			ans += combination(ma[v[0]],i);
		}
	}else{
		ll k = 0;
		FOR(i,0,A){
			if(v[i]==v[A-1])k++;
			ave += (long double)v[i];
		}
		ave /= (long double)A;
		ans = combination(ma[v[A-1]],k);
	}
	cout << fixed;
	cout << setprecision(8) << ave << endl;
	cout << ans << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 5e3 + 5;

int N, A, B, p[maxn];
ll f[maxn];

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N >> A >> B;
  for(int i = 1; i <= N; ++i)
    cin >> p[i];
  p[N + 1] = N + 1;
  for(int i = 1; i <= N + 1; ++i){
    int le = 0, ri = 0;
    f[i] = 1e18;
    for(int j = i - 1; j >= 0; --j){
      if(p[j] < p[i]) f[i] = min(f[i], f[j] + 1ll * B * le + 1ll * A * ri);
      le += p[j] < p[i], ri += p[j] > p[i];
    }
  }
  cout << f[N + 1];
}


Measured memory_bytes: 384
n, m = map(int,input().split())
drink = []
for i in range(n):
  drink.append(list(map(int,input().split())))
sorteddrink = sorted(drink, key = lambda x:x[0])

count = 0
cost = 0
index = 0

while True:
  if index > n - 1:
    break
  if count + sorteddrink[index][1] > m:
    break
  cost += sorteddrink[index][0] * sorteddrink[index][1]
  count += sorteddrink[index][1]
  index += 1

if index <= n - 1:
  cost += sorteddrink[index][0] * (m - count)
print(cost)

Measured memory_bytes: 29788
<?php
	$n = intval(fgets(STDIN));
	$val = array_map('intval', preg_split('/\s/', fgets(STDIN)));
 
	for($i = $n - 1;$i >= 0;$i -= 2){
		echo $val[$i]." ";
	}
    
	for($j = abs($i+1);$j < $n;$j += 2){
		echo $val[$j]." ";
	}


Measured memory_bytes: 67812
for i in range (0,100000000):
    txt = input("")
    txt1,txt2 = txt.split(" ")
    a = int(txt1)
    b = int(txt2)
    if(a==0&b==0):
        break
    for i in range(0,a):
        for j in range(0,b):
            if((i==0)|(j==0)|(i==(a-1))|(j==(b-1))):
                print("#", end="")
            else:
                print(".", end="")
        print("")
    print("")



Measured memory_bytes: 7016
N, K = map(int, input().split())
A = [0]
for a in map(int, input().split()):
    A.append(a)

if K <= N:
    now = 1
    for i in range(1, K+1):
        now = A[now]
    print(now)
else:
    check = [-1]*(N+1)
    check[1] = 0
    now = 1
    for i in range(1, N+1):
        now = A[now]
        if check[now] >= 0:
            first = check[now]
            second = i
            break
        else:
            check[now] = i
    now = 1
    for i in range(first):
        now = A[now]
    K = (K-first)%(second-first)
    for i in range(K):
        now = A[now]
    print(now)

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> vec (H);
	for(int i = 0;i < H;i++){
		cin >> vec.at(i);
	}
	
	for(int i = 0;i < W + 2;i++){
		cout << '#';
	}
	cout << endl;
	for(int i = 0;i < H;i++){
		cout << '#' << vec.at(i) << '#' << endl;
	}
	for(int i = 0;i < W + 2;i++){
		cout << '#';
	}
	cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n)for(int i=0;i<(int)(n);i++)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main(){
	string s;cin>>s;
	if(s=="SSS")cout<<0<<endl;
	else if(s=="RRR")cout<<3<<endl;
	else if(s=="RRS"||s=="SRR")cout<<2<<endl;
	else cout<<1<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <random>

using namespace std;


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

	long long n, i, j, k, ans, x, y, v;
	cin >> n >> k;

	ans = 0;
	for (i = k + 1; i <= n; i++) {
		x = (n + 1) / i;
		y = (n + 1) % i;

		v = x * (i - k) + max(0LL, y - k);
		if (k == 0) v--;
		ans += v;

		//cout << i << " " << v << "\n";
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3184
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int stu[127] = {0};
int main(){
    char str[100005];
    scanf("%s",str);
    for(int i=0;str[i];i++){
        stu[str[i]]++;
    }
    bool flag=1;
    for(int i='a';i<='z';i++){
        if(stu[i]&1){
            flag=0;
            break;
        }
    }
    if(flag)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=(res*x)%mod;
        x=(x*x)%mod;
        b/=2;
    }
    return res;
}
signed main(){
    ll n,k;cin>>n>>k;
    vector<ll>d(k+1);
    for(int i=k;i>=1;i--){
        ll res=rui(k/i,n);
        ll cnt=0;
        ll now=2;
        while(i*now<=k){
            cnt=(cnt+d[i*now])%mod;
            now++;
        }
        res=(res-cnt)%mod;
        if(res<0)res+=mod;
        d[i]=res;
    }
    ll ans=0;
    REP(i,1,k+1){
        ans=(ans+i*d[i]%mod)%mod;
    }
    cout<<ans<<endl;
}

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

int main()
{
    int a,b;
    int c[4]={0};
    cin>>a>>b;
    c[a]=1;
    c[b]=1;
    for(int i=1;i<4;i++)
        if(c[i]==0)
        cout<<i<<endl;
    return 0;
}


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

typedef long long ll;
#define int ll
#define pb push_back
// const int INF = 1e18;
const int inf = 1e9;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);



	int a,b,n;

	cin>>a>>b>>n;
	int k = min(b-1,n);
	cout<<(k*a)/b;

	

	return 0;
}

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 所持カード枚数を取得
		Scanner sc = new Scanner(System.in);
		int cards = sc.nextInt();

		// 絵柄ごとのリストをつくる
		ArrayList<Integer> spadelist = new ArrayList<>();
		ArrayList<Integer> heartlist = new ArrayList<>();
		ArrayList<Integer> clublist = new ArrayList<>();
		ArrayList<Integer> diamondlist = new ArrayList<>();

		// 所持カードを絵柄ごとに分ける
		for (int cnt = 1; cnt <= cards; cnt++) {
			// 所持カードの絵柄と数字を取得
			String suit = sc.next();
			int num = sc.nextInt();

			// 所持カードの絵柄ごとのリストを作成
			if (suit.equals("S")) {
				spadelist.add(num);
				Collections.sort(spadelist);
			}

			if (suit.equals("H")) {
				heartlist.add(num);
				Collections.sort(heartlist);
			}

			if (suit.equals("C")) {
				clublist.add(num);
				Collections.sort(clublist);
			}

			if (suit.equals("D")) {
				diamondlist.add(num);
				Collections.sort(diamondlist);
			}
		}

		// 所持してないカードを表示
		for (int i = 1; i <= 13; i++) {
			if (!(spadelist.contains(i))) {
				System.out.println("S" + " " + i);
			}
		}

		for (int i = 1; i <= 13; i++) {
			if (!(heartlist.contains(i))) {
				System.out.println("H" + " " + i);
			}
		}

		for (int i = 1; i <= 13; i++) {
			if (!(clublist.contains(i))) {
				System.out.println("C" + " " + i);
			}
		}

		for (int i = 1; i <= 13; i++) {
			if (!(diamondlist.contains(i))) {
				System.out.println("D" + " " + i);
			}
		}
	}
}


Measured memory_bytes: 26144
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N,M,Q;
ll L[200010];
ll R[200010];
ll S[510];
ll T[510][510];
ll point[510];

void calc(){
    rep(i,N){
        rep(j,M){
            if (R[j] <= i){
                S[i]++;
            }
            if (L[j] < i && R[j] >i){
                T[i][R[j]]++;
            }
        }
    }
    rep(i,M){
        if (L[i] == R[i]) point[L[i]]++;
    }
    
    return;
}

int main() {
    scanf("%lld%lld%lld",&N,&M,&Q);
    rep(i,M){
        ll l,r; scanf("%lld%lld",&l,&r);
        L[i] = l-1;
        R[i] = r-1;
    }
    rep(i,510) {
        S[i]=0;
        point[i] = 0;
    }
    rep(i,510){
        rep(j,510) T[i][j] = 0;
    }
    calc();
    rep(i,Q){
        ll p,q; scanf("%lld%lld",&p,&q);
        ll trivial = 0;
        repi(j,p,q) trivial += T[p-1][j];
        cout << S[q-1]-S[p-1]-trivial+point[p-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

class Main {

	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);

		int m, n;
		int a1, a2, a3, a4;
		int c;
		int a[][];
		int b[];
		int s[];
		
		n = scan.nextInt();
		m = scan.nextInt();
		a = new int[n][m];
		b = new int[m];
		s = new int[n];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a1 = scan.nextInt();
				a[i][j] = a1;
			}
		}
		for(int k = 0; k < m;k++){
			c = scan.nextInt();
			b[k] = c;
		}
		
		for(int i = 0; i < n ;i++){
			for(int j = 0; j < m; j++){
				s[i] += a[i][j] * b[j];
			}
			System.out.println(s[i]);
		}
		
			
	}
}	

Measured memory_bytes: 40920
#include <iostream>

using namespace std;

int main() {
  int n;
  long v, min, max;
  long sum = 0;

  cin >> n;
  
  for (int i = 0; i < n; i++) {
	cin >> v;
	sum += v;
	if (i == 0) {
	  max = v;
	  min = v;
	}
	else {
	  if (max <= v) {
		max = v;
	  }
	  if (min >= v) {
		min = v;
	  }
	}
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  set<string> color;
  int over3200 = 0;
  for (int i = 0; i < N; i++) {
    int r;
    cin >> r;
    if (r < 400) color.insert("gray");
    else if (r < 800) color.insert("brown");
    else if (r < 1200) color.insert("green");
    else if (r < 1600) color.insert("lightblue");
    else if (r < 2000) color.insert("blue");
    else if (r < 2400) color.insert("yellow");
    else if (r < 2800) color.insert("orange");
    else if (r < 3200) color.insert("red");
    else over3200++;
  }
  if (over3200 == 0) cout << color.size() << " " << color.size() << endl;
  else {
    if (color.size() == 0) cout << 1 << " " << over3200 << endl;
    else cout << color.size() << " " << color.size() + over3200 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
	cin >>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i]; 
	cout <<ceil((double)(n-1)/(k-1))<<endl;
	return 0;
 } 


Measured memory_bytes: 640
// inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  var r = input[0];
  var D = input[1];
  var x = input[2];
  
  for (var i = 2000; i <= 2009; i++){
    x = r * x - D;
    console.log(x);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

vector<string> ans[26];

ll K;
void cal(ll index){
    if(K == 0) return;
    vector<string> ret;
    rep(i, ans[index].size()){
        rmsame(ans[index]);
        rep(j, (ans[index][i].size())){
            ret.pb(ans[index][i].substr(0,j+1));
        }
    }
    rmsame(ret);
    if(K > ret.size()) K-= ret.size();
    else {
        cout << ret[K-1] << endl;
        K =0;
    }
}

string find(ll index, ll num){
    vector<string> ret;
    rep(i, ans[index].size()){
        rmsame(ans[index]);
        rep(j, (ans[index][i].size())){
            ret.pb(ans[index][i].substr(0,j+1));
        }
    }
    rmsame(ret);
    return ret[num-1];
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s ;
    cin >> K;
    
    rep(i,s.size()){
       // cout << s.substr(i,5) << endl;
        ans[s[i]-'a'].pb(s.substr(i,5));
    }
  //  cout <<"--" << endl;
    rep(i,26){
        cal(i);
    }
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int max,min;
 vector <int>a(5);
  for (int i=0;i<5;i++)
  cin >> a.at(i);
  cin >> max;
  if(a.at(4)-a.at(0)<=max)
  cout << "Yay!" << endl;
  else
  {
      cout << ":(" << endl;
  }
  

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>

using namespace std;

int main(){

	int n;
	cin>>n;
	int p[n],q[n];
	for(int i=0;i<n;i++)cin>>p[i];
	for(int i=0;i<n;i++)cin>>q[i];

	int p1=1,q1=1;
	for(int i=0;i<n;i++){
		p1*=(i+1);
		q1*=(i+1);
	}
	int pnum=0,qnum=0;
	for(int i=0;i<n;i++){
		pnum+=((p[i]-1)*(p1/(n-i)));
		for(int j=i+1;j<n;j++){
			if(p[j]>p[i])p[j]--;
		}
		p1/=(n-i);
		qnum+=((q[i]-1)*(q1/(n-i)));
		for(int j=i+1;j<n;j++){
			if(q[j]>q[i])q[j]--;
		}
		q1/=(n-i);
	}

	int ans = pnum-qnum;
	if(ans<0)cout<<ans*(-1);
	else cout<<ans;

	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys;sys.setrecursionlimit(9**9)
n,m=map(int,input().split())
dp=[0]*n;x=0
s=[set()for _ in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  s[a-1].add(b-1)
def topological_sort(s):
  v,a,b,c=len(s),0,[],[];x=[set()for _ in range(v)]
  for i in range(v):
    for j in s[i]:x[j].add(i)
  for i in range(v):
    l=len(x[i])
    if l==0:a+=1
    b.append([l,i])
  def d(i):
    b[i][0]-=1
    if b[i][0]==0:
      c.append(b[i][1])
      for j in s[b[i][1]]:d(j)
  for i in sorted(b)[:a]:
    c.append(i[1])
    for j in s[i[1]]:d(j)
  return c
for i in topological_sort(s):
  for j in s[i]:dp[j]=max(dp[j],dp[i]+1);x=max(x,dp[j])
print(x)

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

const int INF = 1000000;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}





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

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

class Item{
public:
	int n,c,s,g;
	Item(int n=0,int c=0,int s=0,int g=0):n(n),c(c),s(s),g(g){}
};

class State{
public:
	int x,y,cost,sum,visited;
	State(int x=0,int y=0,int c=0,int s=0,int v=0):x(x),y(y),cost(c),sum(s),visited(v){}
};

int main(){
	int h,w;
	while(cin >> w >> h && h && w){
		int a[20][20], n, ans = 0;
        bool G[20][20];
        int n_i[10]; //商品番号を配列の番号に変換
		bool f[20][20][(1<<8)];
		Item item[8];
		queue<State> Q;
		State u,v;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				for(int k=0;k<(1<<8);k++) f[i][j][k] = false;

				char c;
				cin >> c;
				G[i][j] = true;
				a[i][j] = -1;
				if(c == '.') G[i][j] = false;
				else if(c == 'P'){
					u.y = i;
					u.x = j;
					f[i][j][0] = true;
					G[i][j] = false;
				} else a[i][j] = c - '0';
			}
		}

		cin >> n;
		for(int i=0;i<n;i++){
			cin >> item[i].n >> item[i].c >> item[i].s >> item[i].g;
            n_i[item[i].n] = i;
		}

		Q.push(u);
		while(!Q.empty()){
			u = Q.front();
			Q.pop();
            
			for(int i=0;i<4;i++){
				v = u;
				v.y += dy[i];
				v.x += dx[i];
				v.cost++;
				if(v.y >= 0 && v.y < h && v.x >= 0 && v.x < w && !f[v.y][v.x][v.visited]){
                    if(!G[v.y][v.x]){
                        f[v.y][v.x][v.visited] = true;
                        Q.push(v);
                    }
                    else if((v.visited & (1<<n_i[a[v.y][v.x]])) == 0){
                        if(u.cost >= item[n_i[a[v.y][v.x]]].s && u.cost < item[n_i[a[v.y][v.x]]].g){
                            State v2 = u;
                            f[v2.y][v2.x][v2.visited] = true;
                            v2.visited = v2.visited | (1<<a[v.y][v.x]);
                            f[v2.y][v2.x][v2.visited] = true;
                            v2.sum += item[n_i[a[v.y][v.x]]].c;
                            ans = max(ans,v2.sum);
                            if(v2.visited != ((1<<n)-1)) Q.push(v2);
                        } else if(u.cost < item[n_i[a[v.y][v.x]]].s){
                            //変更点
                            State v2 = u;
                            v2.cost += item[n_i[a[v.y][v.x]]].s - v2.cost;
                            Q.push(v2);
                            //ここまで
                        }
                    }
                }
            }
            
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;
typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef map<int, int> M;
typedef pair<int, int> P;

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

    int d, g;
    cin >> d >> g;
    VI p = VI(d, 0);
    VI c = VI(d, 0);
    for (int i = 0; i < d; ++i)
    {
        cin >> p[i] >> c[i];
    }
    int minnum = 1e9;
    for (int i = 0; i < (1 << d); ++i)
    {
        int scr = 0;
        int num = 0;
        for (int j = 0; j < d; ++j)
        {
            if((i & (1<<j)))
            {
                scr += (100 * (j + 1) * p[j] + c[j]);
                num += p[j];
            }
        }
        if (g > scr)
        {
            int sub = g - scr;
            int cnt;
            for (cnt = d-1; cnt >= 0; --cnt)
            {
                if(!(i & (1<<cnt))) break;
                else continue;
            }
            ++cnt;
            if (((sub + 100 * cnt - 1) / (100 * cnt)) < p[cnt-1])
            {
                num += (sub + 100 * cnt - 1) / (100 * cnt);
            } 
            else
            {
                continue;
            }
        }
        minnum = min(minnum, num);
    }
    cout << minnum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h> 

typedef struct _double {
    unsigned char *digits;
    unsigned int precision;
} Double;
 
void double_construct(Double *e, unsigned int precision) {
    e->precision = precision;
    e->digits = (unsigned char*)malloc(sizeof(unsigned char) * precision);
 
    memset(e->digits, '\0', precision);
    return ;
}
 
void double_add(Double *e1, Double *e2) {
    unsigned int i;
    unsigned int precision = (e1->precision > e2->precision) ? e2->precision : e1->precision;
    unsigned char *tmp;
 
    for (i=precision-1; i != 0; i--) {
        e1->digits[i] += e2->digits[i];
        if (i != 0 && e1->digits[i] > 99) {
            e1->digits[i] %= 100;
            e1->digits[i-1] += 1;
        }
    }
 
    e1->precision = precision;
    tmp = (unsigned char *)realloc(e1->digits, sizeof(unsigned char) * precision);
    if (tmp != NULL) e1->digits = tmp;
 
    return ;
}
         
void double_div(Double *e, unsigned int dividend, unsigned int divisor) {
    unsigned int i;
    int ratio = 0;
 
    while (dividend/10 > divisor) {
        divisor *= 10;
        ratio--;
    }
 
    if (ratio >= 2) {
        puts("Error"); return ;
    }
 
    for (i=ratio+1; i < e->precision*2; i++) {
        unsigned int j;
        unsigned int quotient = dividend / divisor;
 
        if (quotient >= 10) {
            puts("Error::");
            return ;
        }
 
        if (i%2 == 0) e->digits[i/2] += quotient * 10;
        else e->digits[i/2] += quotient;
 
        dividend -= divisor * quotient;
        dividend *= 10;
    }
 
    return ;
}
 
void double_print(Double *e, unsigned int digit_num) {
    unsigned int i;
 
    printf("%u.", e->digits[0]);
 
    for (i=2; i<digit_num; i++) {
        if (i%2 == 0) printf("%u", e->digits[i/2]/10);
        else printf("%u", e->digits[i/2]%10);
    }
 
    puts("");
 
    return ;
}
 
void double_destruct(Double *e) {
    free(e->digits);
 
    return ;
}
 
int main() {
    while (1) {
        unsigned int n, k, m,r;
        Double p;
 
        scanf("%d %d %d %d", &n, &k, &m, &r);
        if (n == 0 && k == 0 && m == 0 && r == 0) return 0;
 
        double_construct(&p, r);
        double_div(&p, 1, n);
 
        if (m == 1) {
            for (unsigned int g=2; g<=n; g++) {
                Double tmp;
 
                double_construct(&tmp, r);
                double_div(&tmp, 1, n * (g-1));
                double_add(&p, &tmp);
                double_destruct(&tmp);
            }
        }
 
        double_print(&p, r+2);
    }
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e7;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int r[MAX],c[MAX];
int arr[MAX],segment_tree[MAX],sz[MAX];
vector<int>v[MAX];
void Construct_Tree(int low,int high,int pos)
{
    if(low==high)
    {
        segment_tree[pos]=arr[low];
        return ;
    }
    int mid=(low+high)/2;
    Construct_Tree(low,mid,pos*2+1);
    Construct_Tree(mid+1,high,pos*2+2);
    segment_tree[pos]=max(segment_tree[2*pos+1],segment_tree[2*pos+2]);
}
int Range_min_query(int st,int en,int low,int high,int pos)
{

    if(st<=low && en>=high)
        return segment_tree[pos];//total overlap

    if(st>high || en<low)
        return INT_MAX;// no overlap

    int mid=(low+high)/2;

    return max(Range_min_query(st,en,low,mid,2*pos+1),Range_min_query(st,en,mid+1,high,2*pos+2));
}
void update(int low,int high,int pos,int idx,ll val)
{
    if(low>high || idx<low || idx>high)
        return;
    if(low==high && low==idx)
    {
        segment_tree[pos]+=val;
        return ;
    }
    int a,b,mid;
    mid=(low+high)/2;
    update(low,mid,pos*2+1,idx,val);
    update(mid+1,high,pos*2+2,idx,val);
    a=pos*2+1;
    b=pos*2+2;
    segment_tree[pos]=max(segment_tree[a],segment_tree[b]);
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m,t,tot=0,mx=0,cur;
    int lim=3*100000;
    cin>>n>>m>>t;
    for(int i=0; i<t; i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        arr[b]++;
        sz[a]++;
        mx=max(mx,a);
    }
    Construct_Tree(0,lim,0);
    int ans=0;
    for(int i=1; i<=mx; i++)
    {
        for(int j=0; j<sz[i]; j++)
        {
            update(0,lim,0,v[i][j],-1);
        }
        ans=max(ans,sz[i]+Range_min_query(0,lim,0,lim,0));
        for(int j=0; j<sz[i]; j++)
        {
            update(0,lim,0,v[i][j],1);
        }

    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 253828
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

typedef pair<string,int> P;

int main() {
  int n,h;
  cin >> n >> h;
  P a[n];
  for(int i=0; i<n; i++) {
    char c[20];
    scanf("%s",c);
    scanf("%d",&a[i].S);
    stringstream ss;
    ss << c;
    ss >> a[i].F;
  }
  int x=0,y=0,i;
  for(i=0; i<n; i++) {
    string s=a[i].F;
    int d=a[i].S,k=0;
    d++;
    while(k<s.size()) {
      char ch[20];
      stringstream ss;
      ss << s;
      ss >> ch;
      printf("? %s\n",ch);
      fflush(stdout);
      char c[2];
      scanf("%s",c);
      if(tolower(s[k])==c[0]) {
	s[k]='_';
	k++;
	x++;
      } else d--;
      y++;
      if(!d) {
	h--;
	break;
      }
    }
    if(!h) break;
  }
  if(i==n) {
    double ans=(double)x/(double)y*1000;
    ans=floor(ans);
    ans/=10;
    printf("! Game Clear %.1lf\n",ans);
  } else printf("! Game Over\n");
  fflush(stdout);
  return 0;
}


Measured memory_bytes: 1316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
vector<pair<ll, ll>>prime_factorize(ll n) {
	vector<pair<ll, ll>>res;
	for (ll p = 2; p*p <= n; ++p) {
		if (n%p != 0)continue;
		int num = 0;
		while (n%p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1)res.push_back(make_pair(n, 1));
	return res;
}
const int MAX = 210000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}
ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	COMinit();
	ll ans = 0;
	ans += COM(H + W - 2, H - 1);
	ll key = 0;
	for (int i = 1; i <= A; ++i) {
		key += COM(H - A - 1 + i + B - 1, B - 1)*COM(A - i + W - B - 1, W - B - 1);
		key %= INF;
	}
	if (ans - key < 0) {
		cout << INF + ans - key << endl;
	}
	else {
		cout << ans - key << endl;
	}
	return 0;
}

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

int main(void){
    int n,u,v;
    cin>>n>>u>>v;
    
    vector<vector<int>> po(n);
    
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        po[a-1].push_back(b-1);
        po[b-1].push_back(a-1);
    }
    
    vector<int> distv(n,-1);
    queue<int> quev;
    distv[v-1] = 0;
    quev.push(v-1);
    
    while (!quev.empty()) {
        int v = quev.front();
        quev.pop();
        for (int nv : po[v]) {
            if (distv[nv] != -1) continue;
            distv[nv] = distv[v] + 1;
            quev.push(nv);
        }
    }
    
    vector<int> distu(n,-1);
    queue<int> queu;
    distu[u-1] = 0;
    queu.push(u-1);
    
    while (!queu.empty()) {
        int u = queu.front();
        queu.pop();
        for (int nu : po[u]) {
            if (distu[nu] != -1) continue;
            distu[nu] = distu[u] + 1;
            queu.push(nu);
        }
    }

    int max=0,min;
    for(int i=0;i<n;i++){
        int ui=distu[i];
        int vi=distv[i];
        if(vi>ui){
            if(max<vi) max=vi;
        }
        if(vi==ui){
            min=n;
            if(min>v) min=v;
        }
    }
    
    if(max!=0) cout<<max-1<<endl;
    else cout<<min-1<<endl;
    
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  vector<ll> b(n+1);
  rep(i, n) {
    b[i+1] = b[i] + a[i];
  }
  map<ll, ll> mp;
  rep(i, n+1) mp[b[i]]++;

  ll ans = 0;
  for (auto v:mp) {
    ll t = v.second;
    ans += t*(t-1)/2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18692
import numpy as np

def count(V, V_dic):
    for v in V:
        if v in V_dic.keys():
            V_dic[v] += 1
        else:
            V_dic[v] = 1
    return

N = int(input())
V = [int(i) for i in input().split(' ')]
V1 = []
V2 = []
for i in range(N//2):
    V1.append(V[i*2])
    V2.append(V[i*2+1])
V1_dic = {1000000:0}
V2_dic = {1000000:0}
count(V1, V1_dic)
count(V2, V2_dic)
sort_V1 = sorted(V1_dic.items(), key=lambda V: V[1], reverse=True)
sort_V2 = sorted(V2_dic.items(), key=lambda V: V[1], reverse=True)

if sort_V1[0][0] == sort_V2[0][0]:
    im1 = sort_V1[0][1] + sort_V2[1][1]
    im2 = sort_V1[1][1] + sort_V2[0][1]
    if im1 >= im2:
        print(N - im1)
    else:
        print(N - im2)
else:
    print(N - (sort_V1[0][1] + sort_V2[0][1]))


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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  // true:高橋 false:青木
  bool turn = true;

  while (true) {

    if (turn) {
      // 高橋のターン
      C = C - B;
      turn = !turn;
    } else {
      // 青木のターン
      A = A - D;
      turn = !turn;
    }

    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=4e5+100;
int main()
{
    FASTINOUT;
    int r,c;
    cin>>r>>c;
    int ans[r][c];
    int m;
    cin>>m;
    pair<int,int>p[m];
    for (int i=0;i<m;i++)
    {
        cin>>p[i].first;
        p[i].second=i+1;
    }
    sort(p,p+m);
    reverse(p,p+m);
    int pos=0,i=0,j=0;
    while (pos<m){
        int cnt=0;
        while (cnt<p[pos].first){
            if (i%2==0)
            {
                ans[i][j++]=p[pos].second;
            }
            else{
                ans[i][j--]=p[pos].second;
            }
            if (j==-1 ||j==c){
                i++;
                if (j==c)
                    j--;
                if (j==-1)
                    j++;
            }
            cnt++;
        }
        pos++;
    }
    for (int i=0;i<r;i++){
        for (int j=0;j<c;j++)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

const int LIM = 1e+5 + 100;

int len[LIM];

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

  for (int i = 0; i < n; ++i)
    cin >> len[i];

  int id = -1;
  for (int i = 1; i < n; ++i)
    if (len[i - 1] + len[i] >= l)
      id = i;

  if (id == -1) {
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << '\n';
  for (int i = 1; i < id; ++i)
    cout << i << '\n';
  for (int i = n - 1; i >= id + 1; --i)
    cout << i << '\n';
  cout << id << '\n';

  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

ll f(ll x, ll y){
	return max(to_string(x).length(), to_string(y).length());
}


int main(){
	ll n, ans = 1e15; 
	cin >> n;
	for (ll i = 1; i*i <= n; i++){
		if (n%i == 0) ans = min(ans, f(n%i, n/i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
    int N, M;
    scanf ("%d%d",&N ,&M);
    int PREF[100001];
    int YEAR[100001];
    vector<int> MAP[100001];
    rep(i,M) {
        scanf ("%d%d", &PREF[i], &YEAR[i]);
        MAP[PREF[i]].push_back(YEAR[i]);
    }
    rep(i,N) {
        sort(MAP[i+1].begin(), MAP[i+1].end());
    }

    rep(i, M) {
        int P, Y;
        P = PREF[i];
        Y = YEAR[i];
        auto B = MAP[P].begin();
        auto j = lower_bound(B, end(MAP[P]), Y);
        printf("%012ld\n", (ll)P * 1000000 + (int)(j-B)  + 1);
    }
}

Measured memory_bytes: 7808
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author koneko096
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    DIHateFactorization solver = new DIHateFactorization();
    solver.solve(1, in, out);
    out.close();
  }

  static class DIHateFactorization {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int x = in.nextInt();
      for (int i = 200; i >= -200; i--) {
        for (int j = -200; j <= 200; j++) {
          long ii = pow5(i);
          long jj = pow5(j);
          if (ii - jj == x) {
            out.printf("%d %d\n", i, j);
            return;
          }
          if (jj - ii == x) {
            out.printf("%d %d\n", j, i);
            return;
          }
        }
      }
    }

    private long pow5(int c) {
      return (long) c * c * c * c * c;
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

  }
}



Measured memory_bytes: 26128
# https://atcoder.jp/contests/abc045/tasks/abc045_b

sa = input()
sb = input()
sc = input()

target = 'a'

while True:
    if target == 'a':
        if len(sa) == 0:
            print('A')
            exit()

        target = sa[0]
        sa = sa[1:]


    elif target == 'b':
        if len(sb) == 0:
            print('B')
            exit()
        target = sb[0]
        sb = sb[1:]

    else:
        if len(sc) == 0:
            print('C')
            exit()
        target = sc[0]
        sc = sc[1:]

    


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

const int MAXN = 1005;

int h, w, ci, cj, di, dj;
char g[MAXN][MAXN];
int d[MAXN][MAXN];
bool vis[MAXN][MAXN];

int Di[] = {-1, 1, 0, 0};
int Dj[] = {0, 0, 1, -1};

int main(){
	scanf("%d %d %d %d %d %d", &h, &w, &ci, &cj, &di, &dj);
	for(int i = 0; i < h; i++)
		scanf("%s", g[i]);
		
	ci--, cj--, di--, dj--;
	
	memset(d, -1, sizeof d);
	deque < pair <int, int> > q;
	
	q.push_front(make_pair(ci, cj));
	d[ci][cj] = 0;
	
	while(!q.empty()){
		pair <int, int> t = q.front();
		q.pop_front();
		
		if(vis[t.first][t.second])continue;
		vis[t.first][t.second] = true;
		
		for(int dir = 0; dir < 4; dir++){
			int ni = t.first + Di[dir], nj = t.second + Dj[dir];
			
			if(ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
			if(g[ni][nj] == '#')continue;
			
			if(d[ni][nj] == -1 || d[t.first][t.second] < d[ni][nj]){
				d[ni][nj] = d[t.first][t.second];
				q.push_front(make_pair(ni, nj));
			} 
		}
		
		for(int xi = -2; xi <= 2; xi++)
		for(int yi = -2; yi <= 2; yi++){
			int ni = t.first + xi, nj = t.second + yi;
			
			if(ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
			if(g[ni][nj] == '#')continue;
			
			if(d[ni][nj] == -1 || d[t.first][t.second] + 1 < d[ni][nj]){
				d[ni][nj] = d[t.first][t.second] + 1;
				q.push_back(make_pair(ni, nj));
			}
		}
	}
	
	printf("%d\n", d[di][dj]);

	return 0;
}


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

using namespace std;

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

using ll = long long;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	
    return 0;
}


Measured memory_bytes: 3608