akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int mxN = 2e5 + 9;
vector<int> adj[mxN];
vector<int> ans;

void dfs(int i = 0, int pre = -1) {
    for(auto v: adj[i]) {
        if(v != pre) {
            ans[v] = ans[v] + ans[i];
            dfs(v, i);
        }
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    ans.resize(n, 0);
    for(int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    while(q--) {
        int v, x;
        cin >> v >> x;
        v--;
        ans[v] += x;
    }
    dfs(0);
    for(int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

void func(long long X, long long K, long long D){

    X = abs(X);
    lli temae = X /D;
    if(temae <= K){
        lli lef = K-temae;
        if(lef%2==0){
            cout<<abs(X-temae*D)<<endl;
        }
        else{
            cout<<abs(X-(temae+1)*D)<<endl;
        }
    }
    else{
        cout<<abs(X-K*D)<<endl;
    }
}

int main(){
    // cout << fixed << setprecision(5);

    long long X;
    scanf("%lld",&X);
    long long K;
    scanf("%lld",&K);
    long long D;
    scanf("%lld",&D);
    func(X, K, D);
    return 0;
}


Measured memory_bytes: 3800
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
map<int,int> app;
int differ;
int flag=1;
int flag2=0;
int main(){
	int n;
	int ai;
	cin>>n;
	rb(i,1,n){
		cin>>ai;
		if(ai==0) flag2=1;
		if(ai) flag=0;
		if(app[ai]==0){
			app[ai]=1;
			differ++;
		}
		else{
			app[ai]++;
		}
	}
	if(flag){
		cout<<"Yes";
		return 0;
	}
	map<int,int> :: IT ite;
	ite=app.begin(); 
	if(differ==3&&!flag2){
		mp a,b,c;
		a=II(ite->FIR,ite->SEC);
		ite++;
		b=II(ite->FIR,ite->SEC);
		ite++;
		c=II(ite->FIR,ite->SEC);
		int resflag=0;
		if((a.FIR^b.FIR)==c.FIR){
			swap(b,c);
			resflag=1;
		}
		if((a.FIR^c.FIR)==b.FIR){
			resflag=1;
		}
		if((b.FIR^c.FIR)==a.FIR){
			swap(b,a);
			resflag=1;
		}
		if(resflag)
		if(a.SEC==c.SEC&&b.SEC==a.SEC){
			cout<<"Yes";
			return 0;
		}
	}
	if(differ==2&&flag2){
		mp a,zer;
		zer=II(ite->FIR,ite->SEC);
		ite++;
		a=II(ite->FIR,ite->SEC);
		if(a.SEC==zer.SEC*2){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

#define ll long long
#define ld long double
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll i;
  for(i = 0; i < n; i++)
    cin >> a[i];
  ll count = 0;
  ll buf = -1;
  ll result = 0;
  
  for(i = 0; i < n; i++){
    if(buf == a[i]){
      count++;
    }
    else {
      buf = a[i];
      result += count / 2;
      count = 1;
    }
  }
  result += count / 2;
      
  cout << result << endl; 
  return 0;
}

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

int main() {
  string s;
  int a = 0;
  cin >> s;
  
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'x') a++;
  }
  
  if (a <= 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    int n=0;
    for(;;){
        scanf("%d",&n);
        if(n == -1)break;
        int now[7] = {0,0,0,0,0,0,0};
        const int a[][7]= {{0,1,1,1,1,1,1},
                       {0,0,0,0,1,1,0},
                       {1,0,1,1,0,1,1},
                       {1,0,0,1,1,1,1},
                       {1,1,0,0,1,1,0},
                       {1,1,0,1,1,0,1},
                       {1,1,1,1,1,0,1},
                       {0,1,0,0,1,1,1},
                       {1,1,1,1,1,1,1},
                       {1,1,0,1,1,1,1}};
        int m=0;
        for(int i = 0;i < n; i++){
            scanf("%d",&m);
            
            for(int j = 0;j < 7; j++){
                if(now[j] != a[m][j]){
                        now[j] = 1;
                }
                else now[j] = 0;
                printf("%d",now[j]);
            }
            printf("\n");
            for(int j = 0;j < 7; j++)now[j] = a[m][j];
        }
    }
    return 0;
}

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;

ll powmod(ll a, ll b) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


int main()
{
	FAST_IO;
	ll k;
	cin >> k;
	ll ans = 0;
	for (ll a = 1; a <= k; ++a) {
		for (ll b = 1; b <= k; ++b) {
			for (ll c = 1; c <= k; ++c) {
				ans += gcd(a, gcd(b, c));
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;
public class Main {
  public static void main(String args[]) {
    final Scanner scanner = new Scanner(System.in);
    final String helix = scanner.next();
    scanner.close();
    switch(helix) {
      case "A":
        System.out.println("T");
        break;
      case "T":
        System.out.println("A");
        break;
      case "C":
        System.out.println("G");
        break;
      case "G":
        System.out.println("C");
        break;
    }
  }
}

Measured memory_bytes: 21332
def solve(n, s, t):
    if s == t:
        return n
    for common in range(n - 1, 0, -1):
        if s[-common:] == t[:common]:
            return 2 * n - common
    return 2 * n


n = int(input())
s = input()
t = input()
print(solve(n, s, t))


Measured memory_bytes: 2940
n=int(input())
s={}
for i in range(n):
  tmp=list(input().strip())
  tmp.sort()
  tmp="".join(tmp)
  s[tmp]=s.get(tmp,0)+1
  
ans=0
for key in s.keys():
  v=s[key]
  if v<2:
    continue
  cmb=v*(v-1)
  cmb=cmb//2
  ans+=cmb
print(ans)


Measured memory_bytes: 22184
import math

def main():
    N, M = map(int, input().split())
    divs = sorted(divisors(M), reverse = True)
    for d in divs:
        if M // d >= N:
            return d
    return -1


def divisors(i):
    ans = set()
    for j in range(1, int(math.sqrt(i))+1):
        if i % j == 0:
            ans.add(j)
            ans.add(i // j)
    return list(ans)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 38640
/*input
4
2 5 2 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int a[maxn];

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	sort(a,a+n);
	ll ans=1;
	REP(i,n) ans=ans*__gcd(i,a[i])%MOD;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>


using namespace std;
#define MAX 100000

int main(){
    int N, K;

    scanf("%d%d", &N, &K);

    if (0 == N % K){
        printf("0");
    }
    else{
        printf("1");
    }
    return 0;
}

Measured memory_bytes: 256
while True:

    H, W = [int(x) for x in input().split()]
    if H == 0 and W == 0 : break


    for i in range(H):
        for j in range(W):
            if i == 0 or i == (H-1) or j == 0 or j == (W-1):
                print("#", end = '')
            else:
                print(".", end='')
        print("\n", end="")
    print("\n", end="")

Measured memory_bytes: 9016
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define mod 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
}
vector<ll>v;
ll mem[3001][3001][3];
ll solve(int i, int j, int c)
{
	if (i > j)return 0;
	ll& ret = mem[i][j][c];
	if (~ret)return ret;
	return ret = (c == 1 ? max(solve(i + 1, j, 2)+v[i], solve(i, j - 1, 2)+v[j]): min(solve(i + 1, j, 1)-v[i], solve(i, j - 1, 1)-v[j]));
}
int main()
{
	Mohammed_Atef_Hassan
		clr(mem, -1);
		int n;
	cin >> n;
	v = vector<ll>(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	cout << solve(0, n - 1, 1);
}

Measured memory_bytes: 211584
#include<iostream>
#include<queue>
using namespace std;
typedef pair<pair<int,int>,int> pa;
#define ff first.first
#define fs first.second

int h,w,sx,sy,gx,gy;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
int co[21][21];
char ma[21][21];
bool visited[21][21];
string pat;
int m = 999999;

int main(){
    while(cin>>h>>w,h){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                co[i][j]=m;
                cin>>ma[i][j];
                if(ma[i][j]=='A')
                    sx=j,sy=i;
                else if(ma[i][j]=='B')
                    gx=j,gy=i;
            }
        }
        queue<pa>q;
        q.push(make_pair(make_pair(sx, sy), 0));
        while(q.size()){
            pa p = q.front();
            q.pop();
            if(co[p.fs][p.ff]!=m)
                continue;
            co[p.fs][p.ff]=p.second;
            for(int i=0;i<4;i++){
                int nx=p.ff+dx[i];
                int ny=p.fs+dy[i];
                if(nx>=0&&nx<w&&ny>=0&ny<h&&ma[ny][nx]!='#'&&co[ny][nx]==m)
                    q.push(make_pair(make_pair(nx, ny), p.second+1));
            }
        }
        cin>>pat;
        for(int j=0,go=0;;j++,go++){
            int i=j%pat.length();
            if(co[gy][gx]<=go){
                cout<<go<<" "<<gy<<" "<<gx<<endl;
                break;
            }
            if(go>100000){
                cout<<"impossible"<<endl;
                break;
            }
            if(pat[i]=='8')
                gy--;
            else if(pat[i]=='6')
                gx++;
            else if(pat[i]=='4')
                gx--;
            else if(pat[i]=='2')
                gy++;
            gy=max(0,min(h-1,gy));
            gx=max(0,min(w-1,gx));
        }
    }
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++) cin >> X.at(i), Y.at(i) = X.at(i);
  sort(Y.begin(), Y.end());

  for (int i = 0; i < N; i++) {
    cout << ((X.at(i) < Y.at(N / 2)) ? Y.at(N / 2) : Y.at(N / 2 - 1)) << "\n";
  }
}

Measured memory_bytes: 3840
//package abc175;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		
		String[] ip = br.readLine().split(" ");
		
		int[]ary = new  int[N];
		
		for(int i = 0 ; i < N ;i ++) {
			ary[i] = Integer.parseInt(ip[i]);
		}
		
		Arrays.sort(ary);
		
		long ans = 0;
		
		for(int i = 0 ; i < N ; i++) {
			for(int j = i+1 ; j < N ; j++) {
				for(int k = j+1 ; k < N ; k++) {
					long a = ary[i];
					long b = ary[j];
					long c = ary[k];
					
					if(a!=b && b!=c && c != a) {
						if(a+b > c && b+c > a && a+c > b)
							ans++;
					}
				}
			}
		}
		
		System.out.println(ans);
	}
	
}


Measured memory_bytes: 33556
K, A, B = map(int,input().split())
if A+1 >= B:
    print(K+1)
elif A >= K:
    print(K+1)
else:
    # biscuit = 1
    # Yen = 0
    # for i in range(0,K):
    #     if biscuit >= A and i != K-1:
    #         biscuit -= A
    #         Yen += 1
    #     elif Yen >= 1:
    #         biscuit += B
    #         Yen -= 1
    #     else:
    #         biscuit += 1
    #     print(biscuit, Yen)
    # print(biscuit)
    # 遅すぎる
    K -= A-1
    biscuit = A
    if K % 2 == 0:
        excnt = int(K/2)
        biscuit += excnt * (B-A)
    else:
        excnt = int(K/2)
        biscuit += excnt * (B-A)+1
    print(biscuit)


Measured memory_bytes: 3060
def ncr(n, r):
    ans = 1
    if r * 2 > n:
        return ncr(n, n - r)
    for i in xrange(n - r + 1, n + 1):
        ans *= i
    for i in xrange(1, r + 1):
        ans //= i
    return ans


def main():
    n, p = [int(_) for _ in raw_input().split()]
    o = 0
    e = 0
    for ai in (int(_) for _ in raw_input().split()):
        if ai % 2 == 1:
            o += 1
        else:
            e += 1
    t = 2 ** e
    ans = 0
    for q in xrange(p, o + 1, 2):
        ans += t * ncr(o, q)
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2692
#include <stdio.h>

int main()
{
  int a,b,i;
  scanf("%d%d",&a,&b );
  if(a < b){
    for(i=0; i<b; i++)
      printf("%d",a);
  }
  else{
    for(i=0; i<a; i++)
      printf("%d",b);
  }
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep2(i, N, M) for (int i = N; i < M; i++)
#define pb push_back



typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<pll, vector<pll>, greater<pll>> greater_pq ;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(a, max(b, c)) - min(a,min( b, c))<<endl;

	return 0;
}



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 sc = new Scanner(System.in);

		String line = sc.nextLine().trim();
		int count = 0;
		char current = line.charAt(0);
		
		for (int i = 1; i < line.length(); i++) {
			if (current == line.charAt(i)) {
				continue;
			} else {
				count++;
				current = line.charAt(i);
			}
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 26032
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n,a[200000],sum=0,result=0;
cin>>n;
for(ll i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    sum%=(1000000000+7);
}
sum-=a[0];

for(ll i=0;i<n-1;i++){
    result+=a[i]*sum;
    result%=(1000000000+7);
    sum=(sum-a[i+1]+1000000000+7)%(1000000000+7);

}
  if(result<0)result+=(1000000000+7);
cout<<result;

return 0;
}






ll gcd(ll a, ll b){

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

}

Measured memory_bytes: 5188
import java.util.*;


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

        int N = sc.nextInt();
        int R = sc.nextInt();

        if(N >= 10) {
            System.out.println(R);
        } else {
            System.out.println(R + 100*(10-N));
        }
    }
}

Measured memory_bytes: 21204
n, k = gets.chop.split(" ").map(&:to_i)
ans =
    Array.new(n) do
      Array.new(2)
    end
n.times do |i|
  ans[i][0], ans[i][1] = gets.chop.split(" ").map(&:to_i)
end

ans.sort!

n.times do |i|
  k = k - ans[i][1]
  if k <= 0
    puts ans[i][0]
    break
  end
end

Measured memory_bytes: 10128
#coding: utf-8
from collections import defaultdict
import sys

N, M = (int(x) for x in input().split())
freq = defaultdict(int)

for i in range(M):
    a, b = (int(x) for x in input().split())
    freq[a] += 1
    freq[b] += 1

for k in freq:
    if freq[k] % 2 == 1:
        print ("NO")
        sys.exit(0)

print ("YES")


Measured memory_bytes: 14552
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;

char a[100010];

int main()
{
    char c[7]={"eraser"},b[8]={"dreamer"};
    int i,j,flag=0,e;
    scanf("%s",a);
    e=strlen(a);
    for(i=0;i<e;i++)
    {
        if(a[i]=='e')
        {
            for(j=0; j<5; j++)
            {
                if(a[j+i]!=c[j])
                {
                    flag=1;
                    break;
                }
            }
            if(a[i+j]==c[j]) i+=5;
            else i+=4;
        }
        else if(a[i]=='d')
        {
            for(j=0; j<5; j++)
            {
                if(a[j+i]!=b[j])
                {
                    flag=1;
                    break;
                }
            }
            if(a[i+j]==b[j]&&a[i+j+1]==b[j+1])
            {
                if(a[i+j+2]=='a') i+=4;
                else i+=6;
            }
            else i+=4;
        }
        else
        {
            flag=1;
            break;
        }
    }
    if(flag==0)
    printf("YES");
    else
    printf("NO");
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // StringTokenizer st = new StringTokenizer(br.readLine());
        // int N = Integer.parseInt(st.nextToken());
        
        String s = br.readLine();
        String[] sa = s.split(" ");
        System.out.println("A"+sa[1].charAt(0)+"C");

        
    }
}


Measured memory_bytes: 21332
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      	String s = sc.next();
      	if (a%2==0)
        {
          String tmp = s.substring(0,a/2);
          
          if (s.equals(tmp+tmp))
          {
            System.out.println("Yes");
          }
          else
          {
          	System.out.println("No");
          }
        }
      	else
        {
          System.out.println("No");
        }
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
using namespace std;
char s[30];
int main(){
    cin>>s[0]>>s[1]>>s[2];
    if(s[1] == s[2] && s[2] == s[0]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int p, q, r;
  cin >> p >> q >> r;
  if (p + q < p + r) {
    if (p + q < q + r) {
      cout << p + q << endl;
    } else {
      cout << ((p + r < q + r) ? p + r : q + r) << endl;
    }
  } else {
    cout << ((p + r < q + r) ? p + r : q + r) << endl;
  }
}

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

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] wa = new int[n + 1];
		int correct = 0, penalty = 0;
		while (m-- > 0) {
			int p = sc.nextInt();
			String s = sc.next();
			if (wa[p] == -1)
				continue;
			if (s.equals("WA"))
				wa[p]++;
			else {
				correct++;
				penalty += wa[p];
				wa[p] = -1;
			}
		}
		println(correct + " " + penalty);
	}
}


Measured memory_bytes: 66096
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro xor (form1 form2)
  (let ((f1 (gensym)) (f2 (gensym)))
    `(let ((,f1 ,form1)
           (,f2 ,form2))
       (if ,f1 (not ,f2) ,f2))))

;; Scheme-style named let
(defmacro nlet (name args &body body)
  (labels ((ensure-list (x) (if (listp x) x (list x))))
    (let ((args (mapcar #'ensure-list args)))
      `(labels ((,name ,(mapcar #'car args) ,@body))
         (,name ,@(mapcar #'cadr args))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (table (make-array n :element-type 'bit)))
    (labels ((query (pos)
               (println pos)
               (let ((answer (read-line)))
                 (cond ((string= answer "Male")
                        (setf (aref table pos) 1))
                       ((string= answer "Female")
                        (setf (aref table pos) 0))
                       ((string= answer "Vacant")
                        (return-from main))
                       (t (error "Huh?"))))))
      (query 0)
      (nlet bisect ((l 0) (r n))
        (let ((mid (ash (+ l r) -1)))
          (query mid)
          (if (xor (evenp (- mid l))
                   (= (aref table l) (aref table mid)))
              (bisect l mid)
              (bisect mid r)))))))

#-swank(main)


Measured memory_bytes: 11196
#include<stdio.h>
#include<math.h>
long long int prime[100000099]={0};
int main()
{
    long long int input;
    while(scanf("%lld",&input)!=EOF)
    {
        int counter=0;

        int i,j;
        for(i=4;i<=input;i+=2)
            prime[i]=1;
        for(i=3;i<=sqrt(input);i+=2)
        {
            if(prime[i]==0)
            {
                for(j=i*i;j<=input;j+=i*2)
                    prime[j]=1;
            }
        }
        for(i=2;i<=input;i++)
        {
            if(prime[i]==0)
            counter++;
        }

        printf("%d\n",counter);

    }
    return 0;
}

Measured memory_bytes: 8780
import sys

N = int(input())
tasks = []

for i in range(N):
    (A, B) = (int(i) for i in input().split())
    tasks.append((A, B))


sorted_tasks = sorted(tasks, key=lambda k: k[1])

time = 0

for i in range(N):
    time += sorted_tasks[i][0]
    if time > sorted_tasks[i][1]:
        print("No")
        sys.exit()
        
print("Yes")


Measured memory_bytes: 33464
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b;
    cin >> a >> b;
    if(a >= 13) cout << b;
    else
    {
        if(a < 6) cout << 0;
        else
        {
            cout << b/2;
        }
    }
    return 0;
}

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 50

int main() {
	int N;

	cin >> N;

	int ans = (N + 1) * N / 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 764
n, m = gets.split.map(&:to_i)

edge = Array.new(n+1) {[]}
m.times do
    l, r, d = gets.split.map(&:to_i)
    edge[l] << [r, d]
    edge[r] << [l, -d]
end

c = Array.new(n+1)
1.upto(n) do |i|
    next if c[i]

    que = [i]
    c[i] = 0
    while now = que.shift
        edge[now].each do |r, d|
            if c[r].nil?
                c[r] = c[now] + d
                que << r
            elsif c[r] - c[now] != d
                puts "No"
                exit
            end
        end
    end
end

puts "Yes"

Measured memory_bytes: 49760
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())

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
uf = UnionFind(n)
for i in range(m):
    x, y = ab[i][0], ab[i][1]
    x -= 1
    y -= 1
    uf.union(x, y)
print(uf.group_count()-1)




Measured memory_bytes: 29332
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  ll s;
  cin >> s;
  ll x1 = 1e9, x2 = 1;
  ll y2 = dup(s, x1);
  ll y1 = x1*y2 - s;
  cout << 0 << " ";
  cout << 0 << " ";
  cout << x1 << " ";
  cout << y1 << " ";
  cout << x2 << " ";
  cout << y2 << endl;
}

Measured memory_bytes: 3624
while True:
    a,en,b=input().split()
    if en=='?':
        break
    else:
        a=int(a)
        b=int(b)
        if en=='+':
            print(a+b)
        elif en=='-':
            print(a-b)
        elif en=='*':
            print(a*b)
        elif en=='/':
            print(int(a/b))


Measured memory_bytes: 5596
/*
    Problem 10
    https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_5_A
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 40001;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int n, q;
vector<int> a, m;
/* function */
void input() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> q;
    m.resize(q);
    for (int i = 0; i < q; i++) cin >> m[i];
}
void solve1() {
    // bit exhausive search
    vector<bool> s(MAX);
    for (int b = 0; b < (1 << n); b++) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if ((b >> i) & 1)
                sum += a[i];
        }
        s[sum] = true;
    }
    for (int mi : m) cout << (s[mi] ? "yes" : "no") << '\n';
}
void solve2() {
    // dpでとく
    vector<bool> dp(MAX);
    dp[0] = true;
    for (int i = 0; i < n; i++)
        for (int j = MAX; j >= a[i]; j--) // 大きい方から順にやる
            if (dp[j - a[i]]) dp[j] = true;
    for (int mi : m) cout << (dp[mi] ? "yes" : "no") << '\n';
}
/* main */
int main(){
    input();
    solve1();
    // solve2();
}


Measured memory_bytes: 3072
dp = [[0]*3001 for _ in range(3001)]
n,s = (int(num) for num in input().split())
a = [int(num) for num in input().split()]
MOD = 998244353
dp[0][0] = 1
for i in range(1,n+1):
    for j in range(s+1):
        dp[i][j] = (dp[i-1][j] * 2) % MOD
        if j >= a[i-1]:
            dp[i][j] = (dp[i][j] + dp[i-1][j-a[i-1]])%MOD
            
print(dp[n][s])

Measured memory_bytes: 134092
# -*- conding:utf-8 -*-


se = set()
n = int(input())
tmp = [input().split() for i in range(n)]


for i in tmp:
    cmd, v = i
    if cmd == "find":
        if v in se:
            print("yes")
        else:
            print ("no")
    else:
        se.add(v)

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

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        ans += min(k-x, x) * 2;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n,m = MI()

A = LI()

sum = np.sum(A)

if n - sum < 0:
    print("-1")
else:
    print(n-sum)

Measured memory_bytes: 27908
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

ll mod = 998244353;
const ld error = 1e-5;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod)
{
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 50+10;
///===========================================  template  =======================================================



int main(){
    FASTIO;
    string s;
    cin>>s;
    int ans = 0;
    for(int i = 0, j = (int)s.size()-1; i<=j; i++, j--){
        if(s[i] != s[j]) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n; string s="on";
  set<int>a={2,4,5,7,9},b={0,1,6,8};
  n=n%10;
  if(a.count(n)) s="h"+s;
  else if(b.count(n)) s="p"+s;
  else s="b"+s;
  cout<<s<<endl;
}


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

int main(){
    int n, k, i, l[50], ans = 0;
    scanf("%d %d", &n, &k);
    for(i = 0; i < n; i++) scanf("%d", &l[i]);
    for(i = 0; i < n; i++){
        for(int j = n - 1; j > i; j--){
            if(l[i] < l[j]) {
                int an = l[i];
                l[i] = l[j];
                l[j] = an;
            }
        }
    }
    for(i = 0; i < k; i++) ans += l[i];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=1e5+5;
int n,k;
int h[maxn],f[maxn];
void Input()
{
    cin >> n >> k;
    FOR(i,1,n) cin >> h[i];
    f[1]=0;
    f[0]=1e9;
    FOR(i,2,n) {
        f[i]=1e9;
        FOR(j,1,min(k,i-1))
            f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
    }
    cout << f[n];
}
void Solve()
{

}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node{
  int key;
  struct node *parent, *left, *right;
};
typedef struct node * Node;
Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node,int);

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
  {
    scanf("%s", com);
    if ( com[0] == 'f' )
    {
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    if ( com[0] == 'i' )
    {
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' )
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  Node y = NIL; 
  Node x = root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x != NIL)
  {
    y = x; 
    if( z->key < x->key) x = x->left; 
    else x = x->right; 
  }
  z->parent = y;
  if (y == NIL) 
    root = z;
  else if (z->key < y->key)
    y->left = z; 
  else 
    y->right = z; 
}
void inorder(Node u)
{
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u)
{
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node treeSearch(Node u, int k)
{
  while(u != NIL && k != u->key)
  {
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}


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

vector<pair<double, double>> crosspoint(double x1, double y1, double r2, double x2, double y2, double r1){
    x1 -= x2;
    y1 -= y2;
    double S = x1*x1 + y1*y1;
    double a = (S + r1*r1 - r2*r2) / 2;
    double D = S*r1*r1-a*a;
    if(D < 0) return {};

    double A1 = a * x1;
    double B1 = y1 * sqrt(D);
    double A2 = a * y1;
    double B2 = x1 * sqrt(D);
    return {
        {(A1+B1)/S+x2, (A2-B2)/S+y2},
        {(A1-B1)/S+x2, (A2+B2)/S+y2}
    };
}

double EPS = 1e-9;

int main(){
    int N, K;
    cin >> N >> K;
    vector<double> X(N), Y(N), C(N);
    for(int i=0; i<N; i++) cin >> X[i] >> Y[i] >> C[i];


    auto check = [&](double T)->bool{
        vector<double> R(N);
        for(int i=0; i<N; i++) R[i] = T/C[i];
        vector<pair<double, double>> cand;
        for(int i=0; i<N; i++) cand.emplace_back(X[i], Y[i]);
        for(int i=0; i<N; i++) for(int j=i+1; j<N; j++){
            auto res = crosspoint(X[i], Y[i], R[i], X[j], Y[j], R[j]);
            for(auto& p : res) cand.push_back(p);
        }
        for(auto& p : cand){
            double x = p.first, y = p.second;
            int num = 0;
            for(int i=0; i<N; i++) if(hypot(x-X[i], y-Y[i]) <= R[i] + EPS) num++;
            if(num >= K) return true;
        }
        return false;
    };

    double ok = 1e9, ng = 0;
    for(int t=0; t<100; t++){
        double mid = (ok+ng)/2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << fixed << setprecision(10) << ok << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string a,b;
  cin>>a>>b;
  int hoge=stoi(a+b);
  bool ok=false;
  for(int i=1; i<=1000; i++){
    if(hoge==i*i){
      ok=true;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL inf = 1123456789012345;
LL N, ans;

int main()
{
	in >> N;
	std::vector<LL>A(N);
	rep(i, N)
	{
		in >> A[i];
		if (i > 0) A[i] += A[i - 1];
	}
	ans = inf;
	for (LL i = 1; i < N - 2; ++i)
	{
		LL min = inf, max = -inf;
		auto it1 = std::lower_bound(A.begin(), A.end(), A[i] / 2);
		if (it1 - A.begin() == 0)
		{
			min = std::min({ min,A[it1 - A.begin()], A[i] - A[it1 - A.begin()] });
			max = std::max({ max,A[it1 - A.begin()], A[i] - A[it1 - A.begin()] });
		}
		else if (it1 - A.begin() == i)
		{
			min = std::min({ min,A[it1 - A.begin() - 1], A[i] - A[it1 - A.begin() - 1] });
			max = std::max({ max,A[it1 - A.begin() - 1], A[i] - A[it1 - A.begin() - 1] });
		}
		else if (abs(A[it1 - A.begin()] - (A[i] - A[it1 - A.begin()])) <= abs(A[it1 - A.begin() - 1] - (A[i] - A[it1 - A.begin() - 1])))
		{
			min = std::min({ min,A[it1 - A.begin()], A[i] - A[it1 - A.begin()] });
			max = std::max({ max,A[it1 - A.begin()], A[i] - A[it1 - A.begin()] });
		}
		else
		{
			min = std::min({ min,A[it1 - A.begin() - 1], A[i] - A[it1 - A.begin() - 1] });
			max = std::max({ max,A[it1 - A.begin() - 1], A[i] - A[it1 - A.begin() - 1] });
		}
		auto it2 = std::lower_bound(A.begin(), A.end(), (A[N - 1] - A[i]) / 2 + A[i]);
		if (it2 - A.begin() == i + 1)
		{
			min = std::min({ min,A[it2 - A.begin()] - A[i], A[N - 1] - A[it2 - A.begin()] });
			max = std::max({ max,A[it2 - A.begin()] - A[i], A[N - 1] - A[it2 - A.begin()] });
		}
		else if (it2 - A.begin() == N - 1)
		{
			min = std::min({ min,A[it2 - A.begin() - 1] - A[i], A[N - 1] - A[it2 - A.begin() - 1] });
			max = std::max({ max,A[it2 - A.begin() - 1] - A[i], A[N - 1] - A[it2 - A.begin() - 1] });
		}
		else if (abs((A[it2 - A.begin()] - A[i]) - (A[N - 1] - A[it2 - A.begin()])) <= abs((A[it2 - A.begin() - 1] - A[i]) - (A[N - 1] - A[it2 - A.begin() - 1])))
		{
			min = std::min({ min,A[it2 - A.begin()] - A[i], A[N - 1] - A[it2 - A.begin()] });
			max = std::max({ max,A[it2 - A.begin()] - A[i], A[N - 1] - A[it2 - A.begin()] });
		}
		else
		{
			min = std::min({ min,A[it2 - A.begin() - 1] - A[i], A[N - 1] - A[it2 - A.begin() - 1] });
			max = std::max({ max,A[it2 - A.begin() - 1] - A[i], A[N - 1] - A[it2 - A.begin() - 1] });
		}
		ans = std::min(ans, max - min);
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const ll MOD = 998244353;

ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

const int MX = 2e6;

ll fc[MX];
ll bfc[MX];

void init() {
	fc[0] = 1;
	for (int i = 1; i < MX; ++i)
		fc[i] = (fc[i - 1] * i) % MOD;
	bfc[MX - 1] = pw(fc[MX - 1], MOD - 2);
	for (int i = MX - 2; i >= 0; --i)
		bfc[i] = (bfc[i + 1] * (i + 1)) % MOD;
}

ll cnk(int n, int k) {
	if (k > n)
		return 0;
	return fc[n] * bfc[k] % MOD * bfc[n - k] % MOD;
}

int n, m;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cout.setf(ios::fixed), cout.precision(20);
	init();
	cin >> n >> m;
	ll ans = 0;
	for (int i = m; i >= 0; i -= 2) {
		ans = (ans + cnk(n, i) * cnk((3 * m - i) / 2 + n - 1, n - 1)) % MOD;
	}
	ll go = 0;
	for (int i = 2 * m + 1; i <= 3 * m; ++i) {
		go = (go + cnk(3 * m - i + n - 2, n - 2)) % MOD;
	}
	go = (go * n) % MOD;
	ans = (ans - go + MOD) % MOD;
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    ll ans = a;
    k -= a-1;
    if(a+1 < b){
        if(k%2 == 0) cout << k/2*(b-a)+ans << endl;
        else cout << k/2*(b-a)+1+ans << endl;
    }
    else{
        cout << ans+k << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> p, m;
    p.push_back(0); m.push_back(0);
    for(ll i = 0; i < n; i++){
        ll a;
        cin >> a;
        if(a>0) p.push_back(a);
        else m.push_back(-1*a);
    }
    sort(m.begin(), m.end());
    ll ans = 0;
    if(p.size()==1) ans = m[k];
    else if(m.size()==1) ans = p[k];
    else {
        ans = 1e+15;
        for(ll i = 1; i < p.size(); i++){
            if(i==k) break;
            if(k-i>=m.size()) continue;
            ans = min(ans, p[i]*2+m[k-i]);
          //  cout << i << " " << k-i << " " << ans << endl;
        }
        for(ll i = 1; i < m.size(); i++){
            if(i==k) break;
            if(k-i>=p.size()) continue;
            ans = min(ans, m[i]*2+p[k-i]);
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1656