akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(),a.end()
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

int n,x,y,a[N];

int dis(int a,int b){
	return min(b-a,abs(b-y)+abs(a-x)+1);
}

int main()
{
	cin >> n >> x >> y;
	for(int i = 1;i <= n;i++)
		for(int j = i + 1;j <= n;j++)
			a[(dis(i,j))]++;
	
	for(int i = 1;i <= n - 1;i++) cout << a[i] << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define RED 3
vector<int> C[100005]; 

int main(void){
 int N,M;
 int p,y;
 vector<int> A;
 vector<int> B;

 cin>>N>>M;
 for(int i=0; i<M; i++){
  cin>>p>>y;
  A.push_back(p);
  B.push_back(y);
  C[p].push_back(y);
 }

 for(int i=0; i<100005; i++)sort(C[i].begin(),C[i].end());
 for(int i=0; i<M; i++){
    cout<<setfill('0')<<setw(6)<<A[i];
    cout<<setfill('0')<<setw(6)<<lower_bound(C[A[i]].begin(),C[A[i]].end(),B[i])-C[A[i]].begin()+1;
    cout<<endl;
 }

 return 0;
}


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

#define vi vector<int>
#define ll long long int
#define vll vector<ll>

int main() {

    int N;
    cin >> N;

    vll A, B;
    ll a, b;
    for (int i = 0; i < N+1; i++) {
        cin >> a;
        A.push_back(a);
    }

    for (int i = 0; i < N; i++) {
        cin >> b;
        B.push_back(b);
    }

    ll count = 0;
    ll left = 0;
    ll c;
    for (int i = 0; i < N; i++) {
        c = min(A[i], B[i]);
        count += c;
        if (B[i] > c) {
            left = B[i] - A[i];
            c = min(A[i+1], left);
            A[i+1] -= c;
            count += c;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 2676
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] p = new int[n];
		for(int i = 0; i < q; i++){
		    int ans = sc.nextInt();
		    p[ans - 1]++;
		}
		
		// 計算
		String[] result = new String[n];
		for(int i = 0; i < n; i++){
		    if(k - q + p[i] > 0){
		        result[i] = "Yes";
		    }else{
		        result[i] = "No";
		    }
		}
		// 出力
		for(int i = 0; i < n; i++){
		    System.out.println(result[i]);
		}
		//System.out.println(result);
		
	}
}


Measured memory_bytes: 54812
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b)	for(int  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
#define mod  1000000007
const int MAX= 1e5+5;
using namespace std;


//ll gcd(int a, int b)
//{ 
//    if (a == 0) 
//        return b;  
//    return gcd(b % a, a);  
// } 
// 
//ll lcm(int a, int b)  
// {  
//    return a/gcd(a, b) *b;  
// }
//  
//int prime(int n)
//{
//	rep(i,2,n+1)
//	{
//		if(n%i==0)return i;
//	}
//	
//vector<unordered_set<int> > prime_factors(MAX,unordered_set<int>());
//int primes[MAX];
//int prefix[MAX][6];
//void sieve(){
//    //primes i stores the largest prime factor of a number....
//    for(int i=2;i<MAX;++i){
//        if(primes[i]!=0){
//            continue;
//        }
//        primes[i] = i;
//        for(int j=2*i;j<MAX;j+=i){
//            primes[j] = i;
//        }
//    }
//    
//    for(int i=2;i<MAX;++i){
//        int current = i;
//        
//        while(current!=1){
//            prime_factors[i].insert(primes[current]);
//            current = current/primes[current];
//        }
//    }
//    
//    for(int i=1;i<MAX;++i){
//        for(int k=1;k<=5;++k){
//            prefix[i][k] = prefix[i-1][k] + (prime_factors[i].size()==k);
//        }
//    }
//    
//}
void solve() 
{
   long long n,q,sum=0; cin>>n;
   vector<long long> v;
	for(long long i=0;i<n;i++){
	    cin>>q;
	    sum+=q;
	    v.push_back(q);
	}
	q=0;
	for(long long i=0;i<n;i++){
	    long long el=v[i];
	    sum-=el;
	   q+=el*(sum%mod);
	   q%=mod;
	}
	cout<<q<<'\n';
}



int main()
{
	hello777;

	int q=1;
	
//    cin>>q;
    while(q--)
    {   
      solve();
    }
}

 

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

int to[310][310];
int dist[310][310];

const int INF = 1LL << 60;

signed main(void){
  
  int n,m,l; cin >> n >> m >> l;
  for(int i = 0; i < n; i++){ 
    for(int j = 0; j < n; j++){ 
      if(i==j){to[i][j] = 0; dist[i][j] = 0;}
      else{to[i][j] = INF; dist[i][j] = INF;}
    }
  }
  
  for(int i = 0; i < m; i++){ 
    int a,b,c; cin >> a >> b >> c; a--; b--;
    to[a][b] = c;  to[b][a] = c;
  }
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){ 
        to[j][k] = min(to[j][k],to[j][i]+to[i][k]);
      }
    }
  }
  
  for(int i = 0; i < n; i++){ 
    for(int j = 0; j < n; j++){ 
      if( i != j && to[i][j] <= l ){ //補給なしでいける
        dist[i][j] = 1;
      }
    }
  }
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){ 
        
        dist[j][k] = min(dist[j][k],dist[j][i]+dist[i][k]);
      }
    }
  }
  
  int Q; cin >> Q;
  while(Q--){ 
    int s,t; cin >> s >> t; s--; t--;
    int ans = dist[s][t];
    if( ans == INF ){ cout << "-1" << endl; continue;}
    
    cout << ans-1 << endl;
    
  }

  return 0;
}
    

Measured memory_bytes: 2048
H, W = map(int, input().split())
a = [input() + '.' for _ in range(H)]
a.append('.' * W)

seen = [[False for i in range(W)] for j in range(H)]
h, w = 0, 0
while h < H and w < W:
    seen[h][w] = True

    if a[h][w + 1] == a[h + 1][w]:
        print('Impossible')
        exit()

    if a[h][w + 1] == '#':
        w += 1
    else:
        h += 1

    if a[h - 1][w] == '#' and a[h][w - 1] == '#':
        print('Impossible')
        exit()

    if h == H - 1 and w == W - 1:
        print('Possible')
        exit()
print('Impossible')


Measured memory_bytes: 9204
function main(arg) {
	var tmp = arg.split("\n")[0]
	// tmp = tmp

	var k = "keyence".split("")

	var h = []

	var t = false

	do {
        t = /keyence$/.test(tmp);
        if (t) break
        t = /^keyence/.test(tmp);
        if (t) break
        t = /^k.*eyence$/.test(tmp);
        if (t) break
        t = /^ke.*yence$/.test(tmp);
        if (t) break
        t = /^key.*ence$/.test(tmp);
        if (t) break
        t = /^keye.*nce$/.test(tmp);
        if (t) break
        t = /^keyen.*ce$/.test(tmp);
        if (t) break
        t = /^keyenc.*e$/.test(tmp);
        if (t) break
        t = /^keyence$/.test(tmp);
        if (t) break
        t = /^keyence$/.test(tmp);
        if (t) break

	} while (0)

	if (t) {
		console.log("YES")

	} else {
		console.log("NO")

	}
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll K;
  cin >> K;
  
  cout << a[K-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int n;
vector<vector<int>> G;
vector<double> dp;
double dfs(int x,int parent){
    double res=0;
    int cnt=0;
    for(int i=0;i<G[x].size();i++){
        if(G[x][i]!=parent){
            res+=dfs(G[x][i],x)+1;
            cnt++;
        }
    }
    if(!cnt){
        return 0;
    }
    return dp[x]=res/cnt;
}
vector<double> dp2;
double dfs2(int x,int parent){
    if(parent==-1){
        dp2[x]=dp[x];
    }else{
        int d=G[x].size();
        double dif;
        if(G[parent].size()==1){
            dif=1;
        }else{
            dif=(dp2[parent]*G[parent].size()-(dp[x]+1))/(G[parent].size()-1)+1;
        }
        dp2[x]=(dp[x]*(d-1)+dif)/d;
    }
    for(int i=0;i<G[x].size();i++){
        if(G[x][i]!=parent){
            dfs2(G[x][i],x);
        }
    }
}
int main(){
    cin>>n;
    G.resize(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dp.resize(n);
    dp2.resize(n);
    dfs(0,-1);
    dfs2(0,-1);
    for(int i=0;i<n;i++){
        printf("%.10f\n",dp2[i]);
    }
    return 0;
}

Measured memory_bytes: 18560
#include <iostream>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    int l[2*n], tmp;
    for(int i=0; i<2*n; ++i)
        cin >> l[i];
    for(int i=0; i<2*n-1; ++i){
        for(int i=0; i<2*n-1; ++i)
            if(l[i]>l[i+1]){
                tmp = l[i];
                l[i] = l[i+1];
                l[i+1] = tmp;
            }
    }
    tmp = 0;
    for(int i=0; i<n; ++i)
        tmp += l[2*i];
    cout << tmp << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
fn mod_pow(x: usize, n: usize, mod_: usize) -> usize {
    if n > 0 {
        mod_pow(x * x % mod_, n >> 1, mod_) * if n & 1 == 1 { x } else { 1_usize } % mod_
    } else {
        1_usize
    }
}

struct ModCulc {
    fact: Vec<usize>,
    fact_inv: Vec<usize>,
    mod_: usize,
}

impl ModCulc {
    fn new(n: usize, mod_: usize) -> Self {
        let mut f: Vec<usize> = vec![1; n];
        let mut f_i: Vec<usize> = vec![1; n];
        for i in 1..n {
            f[i] = (f[i - 1] * i as usize) % mod_;
            f_i[i] = mod_pow(f[i], mod_ - 2, mod_);
        }
        ModCulc {
            fact: f,
            fact_inv: f_i,
            mod_: mod_,
        }
    }

    fn nCr(&self, n: usize, r: usize) -> usize {
        if n < r { 0 }
        else {
        (((self.fact[n] * self.fact_inv[r]) % self.mod_) * self.fact_inv[n - r]) % self.mod_
        }
    }
}

fn main() {
    let n: usize = read();
    let k: usize = read();

    let mod_ = 1_000_000_007;
    let mc = ModCulc::new(n+1, mod_);

    for i in 1..k+1 {
        let po = mc.nCr(n-k+1, i) * mc.nCr(k-1, i-1);
        println!("{}", po % mod_);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))
money = 1000
kabu = 0
for i in range(n - 1):
    if a[i] < a[i + 1]:
        kabu += money // a[i]
        money = money % a[i]
    if a[i] > a[i + 1]:
        money += kabu * a[i]
        kabu = 0
money += kabu * a[n - 1]
print(money)

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

int main()
{	
	int n, p, r, t;
	bool f;
	
	while(cin >> n >> p, n) {
		t = p;
		f = 0;
		vector<int> v(n);
		for (int i = 0; i < n; i++) v[i] = 0;
		
		while (1) {
			for (int i = 0; i < n; i++) {
				if (!t) {
					t += v[i];
					v[i] = 0;
				} else {
					v[i] ++;
					t--;
					if (v[i] == p) {
						f = 1;
						r = i;
						break;
					}
				}
			}
			if (f) break;
		}
		
		cout << r << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
def main():
    x, n = map(int, input().split())
    p = set(map(int, input().split()))
    diff = float("inf")
    answer = 0
    for i in range(102):
        if i not in p:
            if abs(i - x) < diff:
                diff = abs(i - x)
                answer = i
    print(answer)


if __name__ == '__main__':
    main()



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-5; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

R Lagrange_interpolation(vector<R> xi,vector<R> fi,R x){
	const int n=xi.size();
	R f=0.0;
	rep(i,n){
		R li=1.0;
		rep(j,n){
			if(i==j) continue;
			li*=(x-xi[j])/(xi[i]-xi[j]);
		}
		f+=fi[i]*li;
	}
	return f;
}

int main(void){
	int d;
	while(cin >> d,d){
		vector<R> v(d+3);
		rep(i,d+3) cin >> v[i];
		
		int ans=-1;
		rep(j,d+3)rep(i,j){
			vector<R> x,f;
			rep(k,d+3){
				if(k==i||k==j) continue;
				x.push_back(k);
				f.push_back(v[k]);
			}

			R fi=Lagrange_interpolation(x,f,i);
			R fj=Lagrange_interpolation(x,f,j);

			if(sgn(v[i]-fi)==0) ans=j;
			if(sgn(v[j]-fj)==0) ans=i;
		}

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

Measured memory_bytes: 3252
# -*- coding: utf-8 -*-

N = int(input())
A = [int(a) for a in input().split()]

# かっこいい解法版
# Ai, Ai+1を反転して-Ai,-Ai+1であるが、これを繰り返すことで、
# -Ai, Ai+1, Ai+2,....,Aj-1, -Aj というように、
# i < jとなるi,jのみを反転させ、間はそのままという操作が可能。
# ここから、負の数が偶数個であれば、全てを正にすることができる
# 負の数が奇数個であれば、絶対値が一番小さい数を残して残りを正にすればよい

ng = [a for a in A if a < 0]    # 負の数の抽出
ab = [abs(a) for a in A]    # 絶対値の和

if len(ng) % 2 == 0:
    print(sum(ab))
else:
    mn = min(ab)
    print(sum(ab)-2*mn)



Measured memory_bytes: 14208
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>
#include<list>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1e9+7;


/******************************************************************************************/


int partition(vector<int>& a, int p, int r) {

	int x, i, j, t;

	x = a.back();
	i = p - 1;
	for (int j = p; j < r; j++)
	{
		if (a[j] <= x) {
			i++;
			swap(a[i], a[j]);

		}
	}


	return i;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	int q = partition(a, 0, n);

	for (int i = 0; i < n; i++)
	{
		if (i)cout << " ";
		if (i == q) {
			cout << '[';
		}
		cout << a[i];
		if (i == q) {
			cout << ']';
		}
	}
	cout << endl;
	


	return 0;
}



Measured memory_bytes: 3228
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

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

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

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

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


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

    A, B = fl()
    A = int(A)
    B = int(B * 1000)
    print((A * B) // 1000)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10556
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%d",&i)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>s
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<int,int> :: iterator mi
#define 	yes 	    cout<<"Yes"<<endl
#define 	no 	        cout<<"No"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  // freopen ("(input).txt" , "r",  stdin) ;
  // string st,stt ;
  // int low=0,high=0;
  // int l,r;
    int n,k,t,b,c,x,y,z,d=0,temp=-1,cnt=mx,sum=0,f=0;
    cin>>n>>k  ; vect v(n) ,a  ; sett ; set_it ; mapp m,mp; pairr p; map_it;
    loop(i,n)
    {
        cin>>v[i];
        if(i>0&&v[i]+v[i-1]>=k)
        {
            temp=i;
            cnt=i-1;
        }
    }
    if(temp==-1)
        cout<<"Impossible"<<endl;
    else
    {
        cout<<"Possible"<<endl;
        for(int i=0;i<cnt;i++)
            cout<<i+1<<endl;
        for(int i=n-1;i>cnt;i--)
            cout<<i<<endl;
    }




}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    } else if ((i + 1) == n && S != "Y") {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
/*
	Name: None
	Copyright: zhangjingcanËùÓÐ£¬Î´¾­ÔÊÐí²»µÃ×ªÔØ
	Author: zhangjingcan
	Date:
	Description: C++ÎÄ¼þ
*/
#include <bits/stdc++.h>
using namespace std;
string s;
int ans;
int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans-1<<"\n";
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    cout << 24 - x + 24;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string retValue = string.Empty;

        //
        bool S1isMM = true;
        bool S2isMM = true;

        // 文字列の入力
        string S = Console.ReadLine();

        //前半と後半に分ける
        int S1 = int.Parse(S.Substring(0, 2));
        int S2 = int.Parse(S.Substring(2, 2));

        if (S1 >= 1 && S1 <= 12)
        {
            S1isMM = true;
        }
        else
        {
            S1isMM = false;
        }

        if (S2 >= 1 && S2 <= 12)
        {
            S2isMM = true;
        }
        else
        {
            S2isMM = false;
        }

        if (S1isMM && S2isMM)
        {
            retValue = "AMBIGUOUS";
        }
        else if (S1isMM)
        {
            retValue = "MMYY";
        }
        else if (S2isMM)
        {
            retValue = "YYMM";
        }
        else
        {
            retValue = "NA";
        }

        //出力
        Console.WriteLine(retValue);
    }
}

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

using ll=long long;
const ll INF=1LL<<60;
const ll MOD=1e9+7;

int main(){
    vector<vector<char>> board(8, vector<char>(8));
    vector<vector<bool>> check(8, vector<bool>(8, true));
    int k; cin >> k;
    vector<int> r(k), c(k);
    for(int i=0; i<k; i++){
        cin >> r[i] >> c[i];
    }
    vector<int> order(8);
    for(int i=0; i<8; i++) order[i]=i;
    do{
        bool ok=true;
        for(int i=0; i<k; i++){
            if(order[c[i]] != r[i]) ok=false;
        }
        if(!ok) continue;
        for(int i=0; i<7; i++){
            for(int j=1; i+j<8; j++){
                if(order[i+j] == order[i]+j || order[i+j] == order[i]-j) ok=false;
            }
        }
        if(ok) break;
    }while(next_permutation(order.begin(), order.end()));
    for(int i=0; i<8; i++){
        for(int j=0; j<8; j++){
            if(order[j] == i) cout << "Q";
            else cout << ".";
        }
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 3120
#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>
using namespace std;
#define FOR(i, a, b) for (int 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 int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


int main() {
	char a; cin >> a;
	cout << char(int(a) + 1) << endl;
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<ll> pos = { 0 };
	for (int i = 0; i < N * 3; i++) {
		pos.push_back(pos.back() + A[i % N]);
	}
	ll lb = 1, ub = 1e17;
	while (ub - lb > 1) {
		ll m = (lb + ub) / 2;
		bool ok = false;
		for (int i = 0; i < N; i++) {
			bool f = true;
			int p = i;
			for (int j = 0; j < 3; j++) {
				p = lower_bound(pos.begin(), pos.end(), pos[p] + m) - pos.begin();
				if (p == (int)pos.size()) {
					f = false;
					break;
				}
			}
			if (f && p - i <= N) {
				ok = true;
				break;
			}
		}
		if (ok) {
			lb = m;
		}
		else {
			ub = m;
		}
	}
	cout << lb << endl;
	return 0;
}



Measured memory_bytes: 7860
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n,p[60],q[60],i,tmp,cnt_flag=0,cnt=0;
	scanf("%d",&n);
	
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&p[i]);
		q[i] = p[i];
	}
	
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			if (q[i] > q[j])
			{
				tmp = q[i];
				q[i] = q[j];
				q[j] = tmp;
			}
		}
	}
	
	//for (int i = 0; i < n; ++i) printf("%d ",q[i]);
	//printf("\n");
		
	for (int i = 0; i < n; ++i)
	{
		if (abs(p[i] - q[i]) != 0)
		{
			cnt++;
		}
		if (p[i] == q[i])
		{
			cnt_flag++;
		}
	}
	if (cnt == 2 || cnt_flag == n)
	{
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int32_t main(){
  DESYNC;
  int n;
  cin >> n;
  cout << n*n*n << endl;
}



Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,a = lr()
x = lr()
sub = [x[i]-a for i in range(n)]
dp = [[0 for i in range(5001)] for j in range(n+1)] # 合計がi-2500となる数
# dp[0][2500] = 1 # 0となる数
for j,num in enumerate(sub):
    for i in range(5001):
        dp[j+1][i] = dp[j][i]
    dp[j+1][num+2500] += 1
    for i in range(5001):
        if dp[j][i] >= 1:
            dp[j+1][i+num] += dp[j][i]
print(dp[n][2500])

Measured memory_bytes: 79804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i) res.push_back(N / i);
    }
  }
  return res;
}

int main() {
  ll N;
  cin >> N;
  ll cnt = 0;
  for (ll i = 1; i*i< N; i++){
    for (ll j = 1; j < N; j++){
      //cout << i << j << i * j << endl;
      if (i * j < N) {
        if (i == j) {
          cnt++;
          //cout << 'a' << endl;
        } else if (j * j >= N) {
          cnt += 2;
          //cout << 'b' << endl;
        }
        else{
          cnt++;
          //cout << 'c' << endl;
        }
      }
    } }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<(b-a)*(b-a-1)/2-a;
}

Measured memory_bytes: 256
#include <stdio.h>
int a[5];
int main(){
	int n,m,i,s,c;
	scanf("%d%d",&n, &m);
	for(i=1;i<=n;i++)a[i]=-1;
	for(i=1;i<=m;i++){
		scanf("%d%d",&s,&c);
		if(a[s]!=-1&&a[s]!=c){//同一位上有不同数值
			printf("-1\n");
			return 0;
		}else{
			a[s]=c;
		}
	}
	if(n>1&&a[1]==0)printf("-1\n");//至少两位数，首位是0
	else if(n==1){//只有一位数
		if(a[1]==-1)printf("0\n");
		else printf("%d\n",a[1]); 
	}
	else{//多位数
		for(i=1;i<=n;i++)
			if(i==1&&a[i]==-1)printf("1");//若对首位没有说明，那么设置为1
			else if(a[i]==-1)printf("0");
			else printf("%d",a[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define watch(x); cout<<#x<<"="<<x<<endl;
#define watch2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define endl "\n"
#define int long long
using namespace std;    

long long inverseMod(long long x,long long mod);
long long nCr(long long n,long long r,long long mod){
    //when r is lesser and is greater
    long long res=1;
    if(r>n-r)r=n-r;
    long long div=1;
    for(long long  i=0;i<r;i++){
        res=(res*(n-i))%mod;
    }

    for(long long i=1;i<=r;i++){
        div=(div*i)%mod;
    }
    return (res*inverseMod(div,mod))%mod;
}


long long power(long long x,long long n,long long mod){
//(x^n)%mod
long long result=1;

    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

long long inverseMod(long long x,long long mod){

return power(x,mod-2,mod);
}



int32_t main(){

    fast
    int n,m;
    cin>>n>>m;
    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int u,v;
    set<int>s;
    while(m--){
        cin>>u>>v;
        u--;v--;
        if(arr[u]<arr[v]){
            s.insert(u);
        }
        else if(arr[u]>arr[v]){
            s.insert(v);
        }
        else{
            s.insert(u);
            s.insert(v);
        }

    }
    cout<<(n-s.size());


    return 0;
}



Measured memory_bytes: 6632
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

al = ['a','b','c','d','e','f','g','h','i','j']

import copy
n = ni()

def f(a,b,m):
  if a == n:
    print(''.join([al[i] for i in b]))
  else:
    for i in range(m+2):
      c = copy.copy(b)
      c.append(i)
      f(a+1,c,max(m,i))

f(1,[0],0)

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	print(N / 2 + (N % 2));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int a;

int beki(int b, int c){
	int d = b;
	for(int i = 1; i < c; i++){
		d *= b;
		if(d > a) return 0;
	}
	return d;
}

int main(){
	cin >> a;
	
	int b = 0;
	for(int i = 1; i < 333; i++){
		for(int j = 2; j < 100; j++){
			int c = beki(i, j);
			b = max(b, c);
		}
	}
	
	cout << b << endl;
	
	return 0;
}

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

using namespace std;

int n,l,i;
string s[105];

bool cmp(string u, string v){
	return u + v < v + u;
}

int main(){
	scanf("%d%d", &n, &l);
	for(i = 0; i < n; i++)
	cin >> s[i];
	sort(s, s + n, cmp);
	for(i = 0; i < n; i++)
	cout << s[i];
	cout << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int countA = 0;
		int countB = 0;
		int countAB = 0;
		int countO = 0;
		List<String> bloodList = new ArrayList<String>();
		while(stdIn.hasNext()){
			bloodList.add(stdIn.nextLine());
		}
		for(String i:bloodList){
			String[] temp = i.split(",");
			if("A".equals(temp[1])){
				countA++;
			}else if("B".equals(temp[1])){
				countB++;
			}else if("AB".equals(temp[1])){
				countAB++;
			}else if("O".equals(temp[1])){
				countO++;
			}
		}
		System.out.println(countA + "\n" + countB + "\n" + countAB + "\n" + countO);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  double a, b, c;
  cin >> a >> b >> c;
  double l = sqrt(a * a + b * b - 2.0 * a * b * cos(c * M_PI / 180.0));
  double x = (a + b + l) / 2;
  double s = sqrt(x * (x - a) * (x - b) * (x - l));
  double h = s * 2 / a;

  cout << fixed << setprecision(5) << s << endl;
  cout << a + b + l << endl;
  cout << h << endl;
}



Measured memory_bytes: 3508
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

const double pi = atan(1) * 4;

int main ()
{
	double r;
	cin >> r;
	cout << setprecision(20) << r*r*pi << " " << r *2*pi;
	return 0;
 } 


Measured memory_bytes: 3272
def ok(h, w, grid):
    for r in range(h):
        for c in range(w):
            if grid[r][c] == '#':
                cnt = 0
                for dr, dc in [(1,0),(0,1),(-1,0),(0,-1)]:
                    nr, nc = r+dr, c+dc
                    if (0 <= nr < h) and (0 <= nc < w) and (grid[nr][nc] == '#'):
                        cnt += 1
                if cnt == 0:
                    return False
    return True
h, w = map(int, raw_input().split())
grid = [raw_input() for r in range(h)]
print "Yes" if ok(h, w, grid) else "No"

Measured memory_bytes: 2820
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] card = new int[2*n];
			for(int i = 0;i < n;i++){
				card[scan.nextInt()-1] = 1;
			}
			int[] count = {n,n};
			int now = 1;
			boolean sw = true;
			while(sw){
				for(int i = 0;i < 2*n;i++){
					if(card[i] == now){
						card[i] = -1;
						count[now]--;
						now ^= 1;
					}
					if(count[0] == 0 || count[1] == 0){
						sw = false;
						break;
					}
				}
				now ^= 1;
			}
			count[0] = 0;
			count[1] = 0;
			for(int i = 0;i < 2*n;i++){
				if(card[i] < 0){
					continue;
				}
				count[card[i]]++;
			}
			System.out.println(count[0] + "\n" + count[1]);
		}
	}
}

Measured memory_bytes: 20412
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long int a,b,x;
    cin >> a >> b >> x;
    long int count=0;

    long int fb= b/x + 1;
    long int fa;
    if(a != 0) fa = ((a - 1) / x) + 1;
    else fa = 0;
    //f(n) = n/x +1 　+ 1 はn=0である場合
    //answer -> f(b) - f(a-1)
    count = fb - fa; 

    cout << count <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

void solve(double r,int n){
    vector<int> xl(n),xr(n),h(n);
    map<int,int> H;
    rep(i,n){
        cin >> xl[i] >> xr[i] >> h[i];
        for(int j=xl[i];j<xr[i];j++){
            H[j] = max(h[i],H[j]);
        }
    }

    double ans = 100;
    for(int x=-r;x<=r;x++){
        double y = min(H[x-1],H[x]);
        if(x == -r) y = H[x];
        if(x == r) y = H[x-1];
        double t = y + r - sqrt(r*r-x*x);
        ans = min(ans,t);
    }
    cout << Double(ans) << endl;
}


int main(){
    int r,n;
    int cnt = 0;
    while(1){
        cin >> r >> n;
        if(!r and !n) break;
        solve(r,n);
    }
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
int rt(int *uf,int i)
{
  return uf[i]<0?i:uf[i]=rt(uf,uf[i]);
}

void con(int *uf,int a,int b)
{
  a=rt(uf,a);
  b=rt(uf,b);
  if(a!=b){
    if(-uf[a]<-uf[b]){
      uf[a]=b;
    }
    else if(-uf[a]>-uf[b]){
      uf[b]=a;
    }
    else{
      uf[a]=b;
      uf[b]--;
    }
  }
}

int main()
{
  int n,K,L;
  scanf("%d%d%d",&n,&K,&L);
  static int uf1[200000],uf2[200000];
  for(int i=0;i<n;i++){
    uf1[i]=uf2[i]=-1;
  }
  for(int i=0;i<K;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;
    b--;
    con(uf1,a,b);
  }
  for(int i=0;i<L;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;
    b--;
    con(uf2,a,b);
  }
  static pair<int,int> P[200000],XP[200000];
  for(int i=0;i<n;i++){
    P[i]=make_pair(rt(uf1,i),rt(uf2,i));
    XP[i]=P[i];
  }
  sort(XP,XP+n);
  for(int i=0;i<n;i++){
    printf("%d%c",upper_bound(XP,XP+n,P[i])-lower_bound(XP,XP+n,P[i]),i==n-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    vector<string> s(n); cin >> s;
    unordered_map<string, int> c;
    each(i, s)++c[i];
    int m = 0;
    each(i, c)chmax(m, i.second);
    set<string> ans;
    each(i, s)if (c[i] == m)ans.insert(i);

    auto itr = ans.begin();
    while (itr != ans.end()) {
        cout << *itr << "\n";
        ++itr;
    }
}

Measured memory_bytes: 33736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 500005;

int N, sqN, Q, curUnique;
int arr[MAXN], cnt[MAXN], ans[MAXN];
iii query[MAXN];

bool cmp(iii x, iii y) {
    return make_tuple(x.b/sqN, x.c) < make_tuple(y.b/sqN, y.c);
}

void inc(int idx) {
    if (cnt[arr[idx]] == 0) curUnique++;
    cnt[arr[idx]]++;
}

void dec(int idx) {
    cnt[arr[idx]]--;
    if (cnt[arr[idx]] == 0) curUnique--;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> N >> Q;
    sqN = sqrt(N);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }
    
    for (int i = 0; i < Q; i++) {
        query[i].a = i;
        cin >> query[i].b >> query[i].c;
        query[i].b--;
        query[i].c--;
    }
    
    sort(query, query+Q, cmp);
    
    int l = 0;
    int r = 0;
    cnt[arr[l]]++;
    curUnique = 1;
    for (int i = 0; i < Q; i++) {
        while (l < query[i].b) dec(l++);
        while (l > query[i].b) inc(--l);
        while (r < query[i].c) inc(++r);
        while (r > query[i].c) dec(r--);
        ans[query[i].a] = curUnique;
    }
    
    for (int i = 0; i < Q; i++) cout << ans[i] << "\n";
    
}


Measured memory_bytes: 15528
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def bfs(start):
        dist = [f_inf] * n
        dist[start] = 0
        que = deque([start])
        while que:
            v = que.popleft()
            for u in edge[v]:
                if dist[u] == f_inf:
                    dist[u] = dist[v] + 1
                    que.append(u)
        return dist

    n, u, v = map(int, input().split())
    edge = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)

    distT = bfs(u - 1)
    distA = bfs(v - 1)

    res = 0
    for i in range(n):
        if distT[i] < distA[i]:
            res = max(res, distA[i])
    print(res - 1)


if __name__ == '__main__':
    resolve()


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

using namespace std;

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

int main() {

    string s, t;
    getline(cin, s);
    getline(cin, t);

    if (sz(t) == sz(s) + 1 && t.substr(0, sz(s)) == s)
        puts("Yes");
    else
        puts("No");

    return 0;
}


Measured memory_bytes: 3576
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)
using ll = long long;
using ull = unsigned long long;
using llv = vector<long long>;


int main(void){
    ll n;
    cin >> n;
    llv a (n);
    rep(i,n) cin >> a[i];
    
    rep(i,n){
        if(a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0)){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 3052