akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
S = ""
K = 0


def set_inputs():
    global S, K
    S = get_str()
    K = get_int()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    d = defaultdict(list)
    for i, s in enumerate(S):
        d[s].append(i)
    cnt = 0
    for s in sorted(d.keys()):
        substrings = set(s)
        for i in d[s]:
            for ss in [S[i:i+k] for k in range(2, K + 1)]:
                substrings.add(ss)
        if cnt + len(substrings) >= K:
            print(list(sorted(substrings))[K-1-cnt])
            return
        cnt += len(substrings)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5960
#include <iostream>
using namespace std;
int shou (int N,int R);
int ta (int N,int R); 
int main(void){
    int N,R;
    cin>>N>>R;
    if(N<10)cout<<shou(N,R)<<endl;
    else cout<<ta(N,R)<<endl;
    return 0;
}
int ta (int N,int R){
    return R;
}
int shou (int N,int R){
    return R+100*(10-N);
}

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

struct Unionfind {
	vector<int> parent;

	Unionfind(int N) {
		parent = vector<int>(N, -1);
	}

	int root(int x) { //親の番号を検索する
		if (parent[x] < 0) return x;
		return parent[x] = root(parent[x]);
	}

	int size(int x) { //自分のグループの大きさを返す
		return -parent[root(x)];
	}

	bool unite(int x, int y) { //XとYを同じグループにする
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (size(x) < size(y)) swap(x, y);
		parent[x] += parent[y];
		parent[y] = x;
		return true;
	}
	bool same(int x, int y) {
		if (root(x) == root(y)) return true;
		return false;
	}
};
int fri[100005];
vector<int> bl[100005];

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	Unionfind uni(N);
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		fri[a]++; fri[b]++;
		uni.unite(a, b);
	}
	rep(i, K) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		bl[a].push_back(b);
		bl[b].push_back(a);
	}
	rep(i, N) {
		int ans;
		ans = uni.size(i) - 1 - fri[i];
		for (int u : bl[i]) {
			if (uni.same(i, u)) ans--;
		}
		cout << ans << " ";
	}
}


Measured memory_bytes: 6784
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main()
{
	stack<int> S;

	char item[10];
	int op1, op2;
	while ( cin >> item)
	{
		switch (item[0])
		{
		case '+':
			op1 = S.top(); S.pop();
			op2 = S.top(); S.pop();
			S.push(op2 + op1);
			break;

		case '-':
			op1 = S.top(); S.pop();
			op2 = S.top(); S.pop();
			S.push(op2 - op1);
			break;

		case '*':
			op1 = S.top(); S.pop();
			op2 = S.top(); S.pop();
			S.push(op2 * op1);
			break;

		default:
			S.push(atoi(item));
			break;
		}
	}
	cout << S.top() << endl;

	return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

/** AOJ_No.1173 ICPC_2011_B */
public class Main {
	public static int pos;
	public static String str;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			str = sc.nextLine();
			if(str.equals(".")) break;
			
			System.out.println(isBalanced());			
		}
	}

	public static String isBalanced() {
		pos = 0;
		
		boolean _return = true, _break = false;
		while(true) {
			char c = str.charAt(pos++);
			switch(c) {
			case '(':
				if(! (_return = paren()) ) _break = true;
				break;
			case '[':
				if(! (_return = bracket()) ) _break = true;
				break;
			case ')':
			case ']': return "no";
			default:
				if(c == '.') {
					return "yes";/* 正しい文章は必ずここを通る */
				} else {
					if(pos >= str.length()) return "no";
				}
				break;
			}
			if(_break) break;
		}
		
		if(_return)
			return "yes";/* this line is for compile */
		else
			return "no";
	}
	
	public static boolean paren() {
		if(pos >= str.length()) return false;
		
		boolean _return = true, _break = false;
		while(true) {
			char c = str.charAt(pos++);
			switch(c) {
			case '(':
				if(! (_return = paren()) ) return _return;
				break;
			case '[':
				if(! (_return = bracket()) ) return _return;
				break;
			case ')': return true;
			case ']': return false;
			default:
				if(pos >= str.length()) return false;
			}
			if(_break) break;
		}
		
		return _return;
	}
	
	public static boolean bracket() {
		if(pos >= str.length()) return false;
		
		boolean _return = true, _break = false;
		while(true) {
			char c = str.charAt(pos++);
			switch(c) {
			case '(':
				if(! (_return = paren()) ) return _return;
				break;
			case '[':
				if(! (_return = bracket()) ) return _return;
				break;
			case ')': return false;
			case ']': return true;
			default:
				if(pos >= str.length()) return false;
			}
			if(_break) break;
		}
		
		return _return;
	}
}



Measured memory_bytes: 44744
#include<cstdio>
#include<cstring>
#include<iostream>

#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)

using namespace std;

int a,b,c,x,y;

int calc1(int t)
{
	return min(a+b,2*c)*t; 
}

int calc2(int t)
{
	return min(2*c*t,b*t);
}

int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	
	if(x>y)swap(x,y),swap(a,b);
	printf("%d",calc1(x)+calc2(y-x));
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

ll n, m;

int main () {
	scanf("%lld %lld", &n, &m);

	if (n == 1) {
		if (m == 1) printf("1\n");
		else printf("%lld\n", m-2);
	} else {
		if (m == 1) printf("%lld\n", n-2);
		else printf("%lld\n", (n-2)*(m-2));
	}
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
	for j in range(b+1):
		if 500 * i + 100 * j > x:
			continue
		if (x-(500 * i + 100 * j)) % 50 == 0 and (x-(500 * i + 100 * j)) // 50 <= c:
			count += 1

print(count)

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) ll((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=1e9+7;
const ll N=1e6+10;

ll gcd(ll a, ll b)
{
	ll m=min(a, b), M=max(a, b);
	if(m==0) return M;
	return gcd(m, M%m);
}

vector<ll> spf(N+1, 1);

void sieve(){
	for(ll i=2; i<N+1; i+=2) spf[i]=2;
	for(ll i=3; i<N+1; i+=2){
		spf[i]=i;
	}
	for(ll i=3; i*i<N+1; i+=2){
		if(spf[i]!=i) continue;
		for(ll j=i*i; j<N+1; j+=i){
			if(spf[j]==j) spf[j]=i;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	ll a, b, c, d;
	cin>>a>>b>>c>>d;
	on(max(a*c, max(b*d, max(a*d, b*c))));
	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

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

typedef unsigned long long ull;

ull nCr(ull n, ull r){
  if(r == 0) return 1;

  bool used[r+1];
  ull res = 1;
  fill(used,used+r+1,false);
  for(ull i=n,i2=0; i2<r; i--,i2++){
    res *= i;
    for(ull j=1; j<=r; j++){
      if(used[j])continue;
      if(res % j == 0){res /= j, used[j] = true;}
    }
  }
  return res;
}


ull d[64];

int countBit(ull n){
  int ret = 0;
  for(int i = 60 ; i > 0 ; i--){
    if(n >= d[i]){
      ret++;
      n -= d[i];
    }
  }
  return ret;
}

string toBit(ull n, int m){
  string ret = "";
  for(int i = m ; i > 0 ; i--){
    if(n >= d[i]){
      ret += '1';
      n -= d[i];
    }
    else ret += '0';
  }
  return ret;
}

ull getValue(ull a, ull N){
  ull value = 0;
  for(ull i=0; i<N; i++) if((1ull<<i) & a) value += (1ull<<i);
  return value;
}

int main(){
  ull N,M;
    
  for(int i = 0 ; i < 64 ; i++) d[i] = 1;
  for(int i = 2 ; i < 64 ; i++) d[i] = d[i-1]*2;
  
  while(cin >> N >> M,N|M){

    if(M == 1){ cout << toBit(0,N) << endl; continue; }


    vector<ull>v;
    for(int i=0; i<=N; i++){
      if(i == 0)
	v.push_back(nCr(N,i));
      else v.push_back(nCr(N,i)+v[i-1]);
    }

    int bit = 0;
    ull cnt = 0;
    for(int i=0; i<=N; i++){
      if(v[i] >= M){bit = i; cnt = v[i-1]; break;}
    }
    //    cout << "bit = " << bit << " cnt = " << cnt << endl;

    ull value = 0;
    for(ull i=0; i<bit; i++) value += (1ull<<i);

    //    cout << "value = " << value << endl;
    cnt++;

    int C = 0;
    while(true){
      //      C++;
      //      if(C == 20)break;
      for(ull i=N; i>=0; i--){
	if(cnt == M)goto end;
	if(!(value & (1ull<<i)))continue;
	//	cout << "i = " << i << endl;
	//	cout << "value = " << value << endl;
	ull n = i, c = countBit(getValue(value,i));
	//	cout << "value = " << value << endl;
	//	cout << "value2 = " << value-(1<<i) << endl;
	//	cout << "n = " << n << " c = " << c << endl;
	//	cout << "nCr = " << nCr(n,c) << endl;
	if(cnt+nCr(n,c) <= M){
	  cnt += nCr(n,c);
	  value -= (1ull<<i);
	  value += (1ull<<(i+1));
	  //	  cout << "enter" << endl;
	  break;

	}
      }
    }
    
  end:
    cout << toBit(value,N) << endl;
    //    cout << "C = " << C << endl;

  }
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / __gcd(a, b); }
bool isPrime(int n) {if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)cout<<'1';
    else if(b==0)cout<<'2';
    else if(c==0)cout<<'3';
    else if(d==0)cout<<'4';
    else if(e==0)cout<<'5';
    cout<<endl;
	return 0;
}


Measured memory_bytes: 3612
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int res = 0;
  while(s.size() > 1){
    if(s[0] == s[s.size() - 1]){
      s = s.substr(1, s.size() - 2);
    }else{
      if(s[0] == 'x'){
        res++;
        s = s.substr(1, s.size() - 1);
      }else if(s[s.size() - 1] == 'x'){
        res++;
        s = s.substr(0, s.size() - 1);
      }else{
        cout << - 1 << endl;
        return 0;
      }
    }
  }
  cout << res << endl;
	return 0;
}


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

int n, m, s[400], l[400], p[400];
// dp[i][j] := i番目までのメロディを使っていて長さがjのときの最高点数
int dp[400][400];

int main(){
	for(int i = 0; i < 400; i++){
		for(int j = 0; j < 400; j++){
			dp[i][j] = -1;
		}
	}
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i] >> l[i] >> p[i];
	}
	
	dp[0][0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 400; j++){
			if( dp[i][j] == -1 ) continue;
			
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			for(int k = j + s[i]; k <= j + l[i]; k++){
				if( 400 <= k ) continue;
				dp[i][k] = max(dp[i][k], dp[i][j] + p[i]);
				dp[i+1][k] = max(dp[i+1][k], dp[i][j] + p[i]);
			}
		}
	}
	
	vector<int> ans;
	bool flag = false;
	cin >> m;
	for(int i = 0; i < m; i++){
		int w;
		cin >> w;
		if( dp[n][w] == -1 ){
			flag = true;
		}else{
			ans.push_back(dp[n][w]);
		}
	}
	if( flag ){
		cout << -1 << endl;
	}else{
		for(int i = 0; i < ans.size(); i++){
			cout << ans[i] << endl;
		}
	}
}

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

int main()
{
    int s, h, m;

    cin >> s;

    h = s / 3600;
    s = s % 3600;
    m = s / 60;
    s = s % 60;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string a;
    cin>>a;
    if(a[0] =='R'&&a[0] == a[1] &&a[1] == a[2]){cout<<3;}
	else if(a[0]== 'R'&&a[1] == 'R'||a[1]== 'R'&&a[2] == 'R'){cout<<2;}
    else if(a[0] =='S'&&a[0] == a[1] &&a[1] == a[2]){cout<<0;}
    else{cout<<1;}
    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define ll long long int 
#define PI 3.1415926535897932384626

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
     vector<int>a;
     vector<int>b;
     vector<int> v;
     for(int i=0;i<n;i++)
     {
          v.push_back(i);
     }
     for(int i=0;i<n;i++)
     {
          int x,y;
          cin>>x>>y;
          a.push_back(x);
          b.push_back(y);
     }
     long double res=0;
     int c=0;
     do{
          for(int i=0;i<n-1;i++)
          {
               res+=sqrt(pow((a[v[i+1]]-a[v[i]]),2)+pow((b[v[i+1]]-b[v[i]]),2));
          
              // deb(res);
          }
          
           c++;
     }while(next_permutation(v.begin(),v.end()));

     cout<<fixed<<setprecision(10)<<res/(double)c;
	return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

vector<vector<pair<int,int>>>g;
vector<int>res;
void dfs(int v,int p,int c) {
    res[v] = c;
    for(auto e : g[v]) {
        if(e.first == p) continue;
        if(e.second % 2==0) dfs(e.first,v,c%2);
        else dfs(e.first,v,(c+1)%2);
    }
}
int main() {
    int n;
    cin >> n;
    g.resize(n);
    rep(i,n-1) {
        int v,u,w;
        cin >> v >> u >> w;
        v--;u--;
        g[v].push_back({u,w});
        g[u].push_back({v,w});
    }
    res.resize(n);
    dfs(0,-1,0);
    rep(i,n) {
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 11520
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 3e3 + 5, mod = 1e9 + 7, inv2 = (mod + 1) / 2;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
LL ans, f[N][N];
int n, m, a[N];
LL ksm(LL x, LL y) {
	LL res = 1;
	for( ; y; x = x * x % mod, y >>= 1) {
		if(y & 1) res = res * x % mod;
	}
	return res;
}
int main() {
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); m = read();
	for(int i = 1; i <= n; ++ i) a[i] = read();
	for(int i = 1; i <= n; ++ i) for(int j = 1; j <= n; ++ j) f[i][j] = a[i] < a[j];
	for(int i = 1, x, y; i <= m; ++ i) {
		x = read(); y = read();
		f[x][y] = f[y][x] = (f[x][y] + f[y][x]) * inv2 % mod;
		for(int j = 1; j <= n; ++ j) {
			if(j == x || j == y) continue;
			f[x][j] = f[y][j] = (f[x][j] + f[y][j]) * inv2 % mod;
			f[j][x] = f[j][y] = (f[j][x] + f[j][y]) * inv2 % mod;
		}
	}
	for(int i = 1; i <= n; ++ i) for(int j = 1; j < i; ++ j) ans = (ans + f[i][j]) % mod;
	printf("%lld\n", ans * ksm(2, m) % mod);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 70784
S = input()
T = input()

matched_index = -1
for i in range(len(S)-len(T)+1) :
    s = S[i:i+len(T)]
    for j in range(len(T)) :
        if (s[j] != "?" and s[j] != T[j]) :
            break
    else :
        # 複数マッチの場合は後ろのほうがいいのでこうする
        matched_index = i

if (matched_index > -1) :
    out_str = S[0:matched_index] + T + S[matched_index+len(T):]
    out_str = out_str.replace("?", "a")
    print(out_str)
else :
    print("UNRESTORABLE")

            

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
A = list(map(int, input().split()))

ng = 0
ok = 10 ** 9

# able(X) を、すべての丸太を X 以下の長さに切れる場合 1 , そうでない場合 0 を返す関数とする
# 二分探索によって、able(X) が 1 に切り替わる X 点を見つける


def able(x):
    count = 0
    for i in range(N):
        if A[i] % x:
            count += A[i] // x
        else:
            count += A[i] // x - 1

    if count <= K:
        return True
    else:
        return False


while ok - ng > 1:
    mid = ng + (ok - ng) // 2
    if able(mid):
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 31080
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	map<string, int> mp;
	cin >> n;
	string s;
	for(int i = 0; i < n; i++)
	{
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> s;
		mp[s]--;
	}
	int ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++)
	{
		int tmp = itr->second;
		ans = max(tmp, ans);
		//cout << itr->second << endl;
	}
	cout << ans << endl;
	return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
int N;
	pairs(XY)
		cin >> N;
	fx(N) {
		pairsp(XY)
	}
	sorts(XY)

		int ans = INT_MAX;
	for (int x = 0; x < N; x++) {

		for (int y = x + 1; y < N; y++) {
			pair<int, int> J;
			if (XY.at(x).first > XY.at(y).first) {
				J = make_pair(XY.at(x).first - XY.at(y).first, XY.at(x).second - XY.at(y).second);
			}
			else {
				J = make_pair(XY.at(y).first - XY.at(x).first, XY.at(y).second - XY.at(x).second);
			}
			int mini = 0;
			int check[50];
			fw(N) {
				check[w] = 0;
			}
			for (int z = 0; z < N; z++) {
				if (check[z] == 1) { continue; }
				mini++;
				check[z] = 1;
				int x1 = XY.at(z).first, y1 = XY.at(z).second;
				for (int w = z + 1; w < N; w++) {
					if (x1 + J.first == XY.at(w).first
						&&y1 + J.second == XY.at(w).second) {
						x1 = XY.at(w).first;
						y1 = XY.at(w).second;
						check[w] = 1;
					}
				}

			}
			ans = min(ans, mini);
		}
	}
	if (N==1) {
		ce(1)
	}
	else {
		ce(ans)
	}
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 505
#define inf 1000000007
using namespace std;
typedef long long ll;
ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,s,t;
struct P{
    int x,y;
    ll v;
}p[85];
struct X{
    char d;
    int a,b;
}co[325];
int Lx[85],Rx[85],Ly[85],Ry[85];
int head[325],nxt[140010],to[140010],c[140010],tot;
ll v[140010];
void add(int x,int y,int z,ll u)
{
    tot++;
    nxt[tot]=head[x];
    head[x]=tot;
    to[tot]=y;
    c[tot]=z;
    v[tot]=u;
}
void addx(int x,int y,int z,ll u)
{
    add(x,y,z,u);
    add(y,x,0,-u);
}
ll ans,res,dis[325];
int vis[325],pre[325],pre_num[325];
queue<int>q;
int spfa()
{
    for(int i=1;i<=t;i++)  dis[i]=-1e18;
    dis[s]=0;q.push(s);vis[s]=1;
    while(q.size())
    {
        int now=q.front();q.pop();vis[now]=0;
        for(int i=head[now];i;i=nxt[i])
        {
            if(dis[to[i]]<dis[now]+v[i]&&c[i])
            {
                dis[to[i]]=dis[now]+v[i];
                pre[to[i]]=now;
                pre_num[to[i]]=i;
                if(!vis[to[i]])  q.push(to[i]),vis[to[i]]=1;
            }
        }
    }
    if(dis[t]==-1e18)  return 0;
    int di=inf;
    for(int i=t;i!=s;i=pre[i])  di=min(di,c[pre_num[i]]);
    for(int i=t;i!=s;i=pre[i])  c[pre_num[i]]-=di,c[pre_num[i]^1]+=di;
    ans+=dis[t]*di;
    return di;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  p[i].x=read(),p[i].y=read(),p[i].v=read();
    m=read();
    for(int i=1;i<=m;i++)  co[i].d=getchar(),co[i].a=read(),co[i].b=read();
    for(int k=1;k<=n;k++)
    {
        tot=1;memset(head,0,sizeof(head));
        s=2*k+2*n+1;t=s+1;
        for(int i=1;i<=k;i++)  addx(s,i,1,0);
        for(int i=k+2*n+1;i<=2*n+2*k;i++)  addx(i,t,1,0);
        for(int i=k+1;i<=k+n;i++)  addx(i,i+n,1,p[i-k].v);
        for(int i=1;i<=k;i++)  Lx[i]=Ly[i]=0,Rx[i]=Ry[i]=inf;
        for(int i=1;i<=m;i++)
        {
            if(co[i].d=='U')
            {
                for(int j=1;j<=k-co[i].b;j++)  Ry[j]=min(Ry[j],co[i].a-1);
            }
            if(co[i].d=='D')
            {
                for(int j=co[i].b+1;j<=k;j++)  Ly[j]=max(Ly[j],co[i].a+1);
            }
            if(co[i].d=='L')
            {
                for(int j=co[i].b+1;j<=k;j++)  Lx[j]=max(Lx[j],co[i].a+1);
            }
            if(co[i].d=='R')
            {
                for(int j=1;j<=k-co[i].b;j++)  Rx[j]=min(Rx[j],co[i].a-1);
            }
        }
        for(int i=1;i<=k;i++)
          for(int j=1;j<=n;j++)
            if(Lx[i]<=p[j].x&&p[j].x<=Rx[i])  addx(i,k+j,1,0);
        for(int i=1;i<=k;i++)
          for(int j=1;j<=n;j++)
            if(Ly[i]<=p[j].y&&p[j].y<=Ry[i])  addx(k+n+j,k+2*n+i,1,0);
        ans=0;
        while(spfa()){};
        res=max(res,ans);   
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>

using namespace std;

//降順ソート、末尾までの総和が末尾よりも大きいならばYesそうでないならNo
void solve(int N, vector<int> v){
    sort(v.begin(), v.end());

    int sum = 0;
    for(int i=0; i<(int)v.size()-1; i++){
        sum += v[i];
    }
    if(sum > v[N-1])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0 ; i < N ; i++){
        cin >> v[i];
    }
    solve(N, move(v));
    return 0;
}


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

const int N = pow(10,6);

vector<bool> isp(N+1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}

int main() {
  long long N,a,b=0;
  long long counter=0;
  cin>>N;
  long long counter1=0;
  vector<long long>vec(100005);
  vector<long long>ves(100005);
  // N以下の整数に対して素数判定をしてくれます。
  // nが素数ならば isp(n)=true、そうでなければ isp(n)=false
  sieve();
  // ex. 51から80までの素数を出力
  for (long long i=N; i>0; i++){
  if (isp[i]) {counter1=i;
  break;}}
  cout<<counter1<<endl;}


Measured memory_bytes: 1920
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
char s[MAXN];
int main()
{
	int sum=0;
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
	{
		int x=s[i]-'0';
		sum+=x;
	 } 
	 if(sum%9) printf("No\n");
	 else printf("Yes\n");
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std ;
#define eps 1e-10
#define equals(a , b) (fabs((a) - (b)) < eps)

class Point
{
public:
    double x , y;

    Point(double x = 0 ,double y = 0):x(x) , y(y) {}

    Point operator +(Point p){return Point(x + p.x , y + p.y) ;}
    Point operator -(Point p){return Point(x - p.x , y - p.y) ;}
    Point operator *(double a){return Point(a * x , a * y) ;}
    Point operator /(double a){return Point(x / a , y / a) ;}

    double abs() {return sqrt(norm()) ;}
    double norm() {return x * x + y * y ;}

    bool operator < (const Point &p) const
    {
        return x != p.x ? x < p.x : y < p.y ;
    }

    bool operator == (const Point &p) const
    {
        return fabs(x - p.x) < eps && fabs(y - p.y) < eps ;
    }

};

typedef Point Vector;

struct Segment  //表示线段结构体
{
    Point p1 , p2 ;
};

double dot(Vector a , Vector b)  // 向量a,b的内积
{
    return a.x * b.x + a.y * b.y ;
}

double cross(Vector a, Vector b)  //向量a,b外积
{
	return a.x * b.y - a.y * b.x ;
}

bool isOrthogonal(Vector a , Vector b)  //判断是否正交
{
    return equals(dot(a , b) , 0.0) ;
}

bool isOrthogonal(Point a1 , Point a2 , Point b1 , Point b2)
{
    return isOrthogonal(a1 - a2 , b1 - b2) ;
}

bool  isOrthogonal(Segment s1 , Segment s2)
{
    return equals(dot(s1.p2 - s1.p1 , s2.p2 - s2.p1) , 0.0) ;
}

bool isParallel(Vector a, Vector b)  //判断是否平行
{
	return equals(cross(a, b), 0.0) ;
}

bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
	return isParallel(a1 - a2, b1 - b2) ;
}

bool isParallel(Segment s1, Segment s2)
{
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0) ;
}

Point project(Segment s, Point p)  //p在s上的投影
{
    Point base = s.p2 - s.p1 ;
    double r = dot(p - s.p1 , base) / base.norm() ;
    return s.p1 +base * r ;
}

/*
求垂足x：对于给定的三点p1,p2,p从点p向通过p1,p2的直线引一条垂线
base=p2-p1;
hypo=p-p1;
 x=s.p1+base*(hypo*base/|base|^2); hypo*base 可以用向量内积求 
*/
int main()
{
    Point p1 , p2 ;
    cin >> p1.x >> p1.y >> p2.x >> p2.y ;
    int q ;
    Segment s ;
    s.p1 = p1 ;
    s.p2 = p2 ;
    cin >> q ;
    while(q --)
    {
        Point p ;
        cin >> p.x >> p.y ;
        Point w = project(s , p) ;
        printf("%.10lf %.10lf\n" , w.x , w.y) ;
    }
    return 0 ;
}



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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<ll> A(N); cin >> A;
        sort(all(A));
        reverse(all(A));

        vector<ll> a;
        rep(i, N - 1) {
            if(A[i] == A[i + 1]) {
                a.push_back(A[i++]);
                if(a.size() == 2) {
                    cout << a[0] * a[1] << endl;
                    return 0;
                }
            }            
        }
        cout << 0 << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 1660
#include<stdio.h>
int main()
{
    char c;
    scanf("%s",&c);
    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u')
    {
        printf("vowel\n");
    }
    else
    {
        printf("consonant\n");
    }
    return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	string ans = "Yes";
	int turn = 0;
	while(1) {
		if(!turn) c -= b;
		else a -= d;
		if(a<=0) {
			ans = "No";
			break;
		}
		if(c <= 0) break;
		turn ^= 1;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int group_id, group_size[MAXN], group[MAXN];
bool vis[MAXN];
vector<int> G[MAXN];

void dfs(int v) {
    vis[v] = 1;
    group[v] = group_id;
    group_size[group_id]++;

    for (int u : G[v]) {
        if (!vis[u]) {
            dfs(u);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int res = 0;
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            group_id++;
            dfs(i);
            res = max(res, group_size[group_id]);
        }
    }

    cout << res << "\n";
}


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

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ;
    cin >> N;
    
    ll day, ans;
    cin >> day >> ans ;
    
    rep(i,N){
        ll inp;
        cin >> inp;
        ans += (1+day/inp);
        if(day%inp == 0) ans --;
    }
    cout << ans << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define N '\n'
#define S ' '
#define Z '0'
#define RT return
#define elif else if
#define W(a) while(a)
#define RP(a,b,c) for(ll a=(b);a<(c);++a)
#define R(a,b) for(ll a=0;a<(b);++a)
#define RD(a,b) for(ll a=(b);a>=0;++a)
#define LI(a) for(auto &x:a)I(x)
#define P(a) cout<<"a"<<N
#define F(a) cout<<fixed<<setprecision(10)<<a
#define D(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define V cin.tie(0);ios::sync_with_stdio(false)
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,s,t,u,v,w,x,y,z;
const int P[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
inline void I(){}
template<class T,class...A>inline void I(T&&t,A&&...a){cin>>t;I(move(a)...);}
template<class T>inline void O(T t){cout<<t<<N;}
template<class T,class...A>inline void O(T t,A...a){cout<<t<<S;O(move(a)...);}
inline ll dig(ll a){ll d=1;W(a/=10)++d;RT d;}
inline ll GCD(ll a,ll b){ll c;W(a){c=a;a=b%a;b=c;}RT b;}
inline bool isp(ll a){if(a<48){RP(i,0,15)if(P[i]==a)RT 1;}
    elif(a<2809)RT GCD(614889782588491410,a)==1;
    else {O("Error:Argument is Over-2808!");exit(1);}RT 0;}

int main(){
    V;
    string A,B;
    I(A,B);
    a=A.size();
    R(i,a){
        A.push_back(A[0]);
        A.erase(A.begin());
        if(A==B){O("Yes");RT 0;}

    }
    O("No");















}


Measured memory_bytes: 256
MOD = pow(10,9)+7
N = int(input())
S = str(input())
T = str(input())
if N == 1:
  print(3)
  exit()
now = 0
if S[now] != T[now]: #横
  now = 2
  ans = 6
  Flag = True
else: #縦
  now = 1
  ans = 3
  Flag = False

while now <= N-1:
  if S[now] != T[now]: #横
    if Flag: #前が横
      ans = 3*ans%MOD
    else: #前が縦
      ans = 2*ans%MOD
    Flag = True
    now += 2
  else: #縦
    if Flag: #前が横
      ans *= 1
    else: #前が縦
      ans = 2*ans%MOD
    Flag = False
    now += 1
print(ans)

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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	while (cin >> N, N) {
		vector<string> L(N);
		vector<int> a(N), b(N);
		for (int i = 0; i < N; i++) {
			int P, A, B, C, D, E, F, S, M;
			cin >> L[i] >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			a[i] = F * S * M - P;
			b[i] = A + B + C + (D + E) * M;
		}
		vector<int> id(N);
		for (int i = 0; i < N; i++) id[i] = i;
		sort(id.begin(), id.end(), [&](int l, int r) {
			return a[l] * b[r] != a[r] * b[l] ? a[l] * b[r] > a[r] * b[l] : L[l] < L[r];
		});
		for (int i = 0; i < N; i++) {
			cout << L[id[i]] << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}



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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	ll a[n];
	for (int i = 0; i<n; i++) cin >> a[i];
	ll curr = 1000;
	for (int i = 0; i<n-1; i++) {
		if (a[i] < a[i+1]) curr = curr%a[i] + (curr / a[i]) * a[i+1];
	}
	cout << curr << '\n';
}



Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a > 12)cout << b << endl;
	else if (a > 5)cout << b / 2 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
a,b,k = input().split()
A = int(a)
B = int(b)
K = int(k)

nums = []
for i in range(K):
	if(A+i <= B):
		nums.append(A+i)
	if(B-i >= A):
		nums.append(B-i)
nums_unique = list(set(nums))
nums_unique.sort()
for j in range(len(nums_unique)):
	print(nums_unique[j])

Measured memory_bytes: 3064
///                                   ahmocs
#include <bits/stdc++.h>
typedef long long ll;
#define ahmocs  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll N=1e3+5, OO=1e18;
using namespace std;
char g[N][N];
int mem[N][N];
int n,m;
int solve(int h, int w)
{
    if(h>=n || w>=m || h<0 || w<0 || g[h][w] == '#') return 0;
    if (h==n-1 && w==m-1) return 1;
    if (mem[h][w]!=-1) return mem[h][w];
    int cnt=0;
    cnt = (solve(h, w + 1) + solve(h + 1, w)) % 1000000007;
    mem[h][w] = cnt;
    return cnt;
}
int main()
{
    ahmocs
    cin>>n>>m;
     /*for (int i=0; i<n; ++i)
        for (int j=0; j<m; ++j)
            mem[i][j]=-1;*/
    memset(mem,-1,sizeof(mem));
    for (int i=0; i<n; ++i)
        for (int j=0; j<m; ++j)
            cin>>g[i][j];
    cout<<solve(0,0);
    return 0;
}


Measured memory_bytes: 5248
#include<stdio.h>
#include<math.h>
int main(){
	double ax,ay,bx,by,cx,cy,ix,iy,r;
	double abx,aby,acx,acy;
	double fb,fc;
	double ffb,ffc,aaby,aacy;
	int n,a;
	scanf("%d",&n);
	for(a=0;a<n;a++){
		scanf("%lf %lf",&ax,&ay);
		scanf("%lf %lf",&bx,&by);
		scanf("%lf %lf",&cx,&cy);
		abx=bx-ax;
		aby=by-ay;
		acx=cx-ax;
		acy=cy-ay;
		fb=abx*abx+aby*aby;
		fc=acx*acx+acy*acy;
		ffb=fb*acx;
		ffc=fc*abx;
		aaby=aby*acx;
		aacy=acy*abx;
		iy=(ffc-ffb)/((aacy-aaby)*2);
		if(abx!=0){ix=(fb-(2*iy*aby))/(abx*2);}
		if(acx!=0){ix=(fc-(2*iy*acy))/(acx*2);}
		r=sqrt(ix*ix+iy*iy);
		ix=ix+ax;
		iy=iy+ay;
		printf("%.3lf %.3lf %.3lf\n",ix,iy,r);
	}
	return 0;
}

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

int main(){

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

    vector< vector<int> > dp;
    dp.assign(n, vector<int>(3,0));

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i=1; i<n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";

    return 0;
}


Measured memory_bytes: 9848
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, m, k;
ll a[210000], b[210000];
int main() {
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= n; i++)
		scanf("%lld", a + i);
	for (int i = 1; i <= m; i++)
		scanf("%lld", b + i);
	for (int i = 1; i <= n; i++)
		a[i] += a[i - 1];
	for (int i = 1; i <= m; i++)
		b[i] += b[i - 1];
	int maxc = 0;
	for (int i = 0; i <= n && a[i] <= k; i++) {
		int cnt = upper_bound(b, b + m + 1, k - a[i]) - b;
		maxc = max(maxc, cnt + i - 1);
	}
	printf("%d\n", maxc);
}

Measured memory_bytes: 4864
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def func(X, Y, D):
    ans = ""
    x, y = 0, 0
    for i in range(len(D)):
        d = D[i]

        best_j = 0
        best = INF
        for j in range(4):
            nx, ny = x + dx4[j] * d - X, y + dy4[j] * d - Y
            if abs(nx) + abs(ny) < best:
                best = abs(nx) + abs(ny)
                best_j = j

        x, y = x + dx4[best_j] * d, y + dy4[best_j] * d
        ans += "RULD"[best_j]

    assert(x == X and y == Y)
    return ans


def main():
    N = int(input())
    points = []
    for i in range(N):
        X, Y = map(int, input().split())
        points.append((X, Y))

    for i in range(len(points) - 1):
        x1, y1 = points[i]
        x2, y2 = points[i + 1]
        if (x1 + y1) % 2 != (x2 + y2) % 2:
            print("-1")
            return

    D = [2 ** i for i in range(33)][::-1]
    if sum(points[0]) % 2 == 0:
        D.append(1)

    print(len(D))
    print(*D)

    for x, y in points:
        print(func(x, y, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
a,b = input().split()
a = int(a)
s = a*int(b[0])
g = a*int(b[2])
d = a*int(b[3])
s = str(s)+'00'
g = str(g)+'0'
d = str(d)
#print(s,g,d)
ans = int(s)+int(g)+int(d)
print(ans // 100)


Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
    int key;
    Node *r, *l, *p;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) x = x->l;
        else x = x->r;
    }
    z->p = y;
    if(y == NIL) {
        root = z;
    } else {
        if(z->key < y->key) y->l = z;
        else y->r = z;
    }
}

void inorder(Node *u) {
    if(u != NIL) {
        inorder(u->l);
        cout << ' ' << u->key;
        inorder(u->r);
    }
}

void preorder(Node *u) {
    if(u != NIL) {
        cout << ' ' << u->key;
        preorder(u->l);
        preorder(u->r);
    }
}

Node *find(Node *u, int k) {
    while(u != NIL && k != u->key) {
        if(k <u->key) u = u->l;
        else u = u->r;
    }
    return u;
}

int main(void) {
    int n, x;
    string order;
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> order;
        if(order == "insert") {
            cin >> x;
            insert(x);
        } else if(order == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if(order[0] == 'f') {
            cin >> x;
            Node *t = find(root,x);
            if(t != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    
    return 0;
    
}


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

int main(){
  string s;
  cin>>s;
  vector<int>ans(s.size()-2);
  int sum;
  for(int i=0;i<s.size()-2;i++){
    sum=(s.at(i)-'0')*100+(s.at(i+1)-'0')*10+(s.at(i+2)-'0');
    ans[i]=abs(sum-753);
  }
  sort(ans.begin(),ans.end());
  
  cout<<ans[0]<<endl;

}



Measured memory_bytes: 256
/*
* @Author: Samson
* @Date:   2018-05-04 10:11:57
* @Last Modified by:   Samson
* @Last Modified time: 2018-05-04 11:46:26
*/
//   @URL : 
#include<bits/stdc++.h>
#include<algorithm>
#include <cstdlib>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 2*1e5+10;

int a[MAXN],n,L[MAXN/2],R[MAXN/2];

LL merge(int a[],int n,int left,int mid,int right)
{
	int i,j,k;
	LL cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for(i = 0; i < n1; ++i)	L[i] = a[left+i];
	for(i = 0; i < n2; ++i)	R[i] = a[mid+i];
	L[n1] = R[n2] = INF;
	i = j = 0;
	for(k = left; k < right; ++k)
	{
		if(L[i] <= R[j])
		{
			a[k] = L[i++];
		}
		else
		{
			a[k] = R[j++];
			cnt += n1-i;
		}
	}
	return cnt;
}
LL mergesort(int a[],int n,int left,int right)
{
	int mid;
	LL v1,v2,v3;
	if(left + 1 < right)
	{
		mid = (left+right)/2;
		v1 = mergesort(a,n,left,mid);
		v2 = mergesort(a,n,mid,right);
		v3 = merge(a,n,left,mid,right);
		return v1+v2+v3;
	}
	else
		return 0;
}
int main(void)
{
	ios::sync_with_stdio(false); 
	//cin.tie(0);
	cin>>n;
	for(int i = 0; i < n; ++i)
		cin>>a[i];
	LL ans = mergesort(a,n,0,n);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a,b;
	cin>>a>>b;
	int c,d;
	if(a=='H') c=1;
	else c=0;
	if(b=='H') d=1;
	else d=0;
	if(c+d==1) cout<<'D';
	else cout<<'H';
	return 0;
}


Measured memory_bytes: 256
import re
s = input()

def check(s):
    if len(re.findall('[A-Z]', s)) != 2:
        return False
    if s.find('A') != 0:
        return False
    if s.find('C') < 2 or s.find('C') >= len(s) - 1:
        return False
    return True

if check(s):
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3316
#include <iostream>
#include <string>

using namespace std;

int main ( void )
{
	string in;
	while ( cin >> in )
	{
		int jcount = 0, icount = 0;
		for ( int i = 1, len = in.size(); i < len; ++i )
		{
			if ( in[i] == 'O' )
			{
				in[i] = in[i-1] + 0x20;
			}
			else if ( in[i] == 'I' )
			{
				if		( in[i-1] == 'j' ) ++jcount;
				else if	( in[i-1] == 'i' ) ++icount;
			}
		}
		cout << jcount << endl
			 << icount << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    ll n; cin >> n;
    ll ans = LLINF;
    FOR(i,1,1000000+1) {
        if (n % i == 0) {
            ans = min(ans,(ll)i + (n / i) - 2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>           // printf(), scanf()
#include <vector>
#include <queue>
#include <list>

using namespace std;
static const int MAX_V = 10000;

vector<int> G[MAX_V];
list<int> out;
bool visited[MAX_V];
int indeg[MAX_V];
int V;

void
bfs(int s)
{
	queue<int> q;

	q.push(s);
	visited[s] = true;
	while (!q.empty())
	{
		int u = q.front(); q.pop();
		out.push_back(u);
		for (unsigned int i = 0; i < G[u].size(); ++i)
		{
			int v = G[u][i];
			indeg[v]--;

			if (indeg[v] == 0 && !visited[v])
			{
				visited[v] = true;
				q.push(v);
			}
		}
	}
}

void
tsort()
{
	for (int i = 0; i < V; ++i)
		indeg[i] = 0;

	for (int u = 0; u < V; ++u)
	{
		for (unsigned int i = 0; i < G[u].size(); ++i)
		{
			int v = G[u][i];
			indeg[v]++;
		}
	}

	for (int u = 0; u < V; ++u)
	{
		if (indeg[u] == 0 && !visited[u])
			bfs(u);
	}

	for (list<int>::iterator it = out.begin(); it != out.end(); ++it)
		printf("%d\n", *it);
}

int
main(int argc, char** argv)
{
	int E;
	int s, t;

	scanf("%d %d", &V, &E);
	for (int i = 0; i < V; ++i)
		visited[i] = false;

	for (int i = 0; i < E; ++i)
	{
		scanf("%d %d", &s, &t);
		G[s].push_back(t);
	}

	tsort();
	return 0;
}

Measured memory_bytes: 2048