akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}


int main()
{
    int k;
    cin >> k;
    int now=7;
    int ans=1;
    map<int,int> m;
    now%=k;
    m[now] = 1;
    while(1){
        if(now==0){
            cout << ans << endl;
            return 0;
        }
        now=now*10+7;
        now%=k;
        ans++;
        if(m[now]==1){
            cout << -1 << endl;
            return 0;
        }
        else{
            m[now]=1;
        }
    }
}


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

using namespace std;

int main() {
    int N, K, p = 0, ans = 0;
    cin >> N >> K;

    vector<int> vec;
    for (int i = 0; i < N; i++) {
        cin >> p;
        vec.push_back(p);
    }

    sort(vec.begin(), vec.end());

    for (int j = 0; j < K; j++) {
        ans += vec[j];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[110][100010];
ll sum[110][100010];

int main(){
  int n,k;
  cin>>n>>k;
  ll a[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }

  dp[0][0]=1;
  for(int i=0;i<=k;i++) sum[0][i]=1;

  for(int i=1;i<=n;i++){
    for(int j=0;j<=k;j++){
      dp[i][j]=sum[i-1][j];
      if(j-a[i]>0) dp[i][j]=(dp[i][j]-sum[i-1][j-a[i]-1]+MOD)%MOD;
      if(j>0) sum[i][j]=sum[i][j-1];
      sum[i][j]=(sum[i][j]+dp[i][j])%MOD;
      //cout<<dp[i][j]<<" "<<sum[i][j]<<endl;
    }
  }

  cout<<dp[n][k]<<endl;

  return 0;
}


Measured memory_bytes: 162048
n=int(input())
st=[]
for i in range(n):
    s,t=input().split()
    st.append((s,t))
x=input()
flg=False
ans=0
for i in range(n):
    if flg:
        ans+=int(st[i][1])
    if st[i][0]==x:
        flg=True
print(ans)

Measured memory_bytes: 62152
import itertools
n = int(input())
s = str(input())
r = {}
b = {}
g = {}
for i in range(len(s)):
    if s[i] == 'R':
        r[i+1] = s[i]
    elif s[i] == 'B':
        b[i+1] = s[i]
    else:
        g[i+1] = s[i]
ans = len(r) * len(b) * len(g)
for i in r.keys():
    for j in b.keys():
        diff = abs(j-i)
        minb = min(i,j)-diff
        maxb = max(i,j)+diff
        if maxb in g.keys():
            ans -= 1
        if minb in g.keys():
            ans -= 1
        if((i+j)%2==0):
            if((i+j)//2 in g.keys()):
                ans -=1
print(ans)

Measured memory_bytes: 9248
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
  int a[3];
  scanf("%d %d %d",&a[0],&a[1],&a[2]);
  for (int i=0;i<3;i++){
    for (int j=0;j<2;j++){
      if (a[j] > a[j+1])
      {
        int tmp = a[j];
        a[j]   = a[j+1];
        a[j+1] = tmp;
      }
    }
  }
  int ans=a[2]-a[0];
  printf("%d\n",ans);
  return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M, K;
    cin >> N >> M >> K;
    Vl A(N), B(M);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < M; i++) {
        cin >> B[i];
    }

    ll sa = 0, sb = 0;
    for (ll i = 0; i < M; i++) {
        sb += B[i];
    }
    ll idxb = M;

    ll ans = 0;
    for (ll i = 0; i <= N; i++) {
        if (sa > K) {
            break;
        }
        while (idxb > 0 && sa + sb > K) {
            sb -= B[--idxb];
        }
        ans = max(ans, i + idxb);
        if (i < N) {
            sa += A[i];
        }
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 6348
import sys
read = sys.stdin.read

T1, T2, A1, A2, B1, B2 = map(int, read().split())
answer = 0
v1 = A1 - B1
v2 = A2 - B2
d = v1 * T1 + v2 * T2

if d == 0:
    print('infinity')
    exit()
elif v1 * d > 0:
    print(0)
    exit()

if v1 * T1 % -d == 0:
    print(v1 * T1 // -d * 2)
else:
    print(v1 * T1 // -d * 2 + 1)

Measured memory_bytes: 3064
k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if a[i+1] - a[i] > ans:
        ans = a[i+1] - a[i]
if k + a[0] - a[n-1] > ans:
    ans = k + a[0] - a[n-1]
print(k - ans)

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

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

	int n;
	cin >> n;
	
	int ans = 0;
	
	for(int i = 1; i < n; i++)
	{
		for(int j = 1; i * j < n; j++) 
		{
			ans++;
		}
	}
	
	cout << ans << "\n";
	return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int a, b;
    cin >> a >> b;
    if (a < b) {
        rep(i, b) {
            cout << a;
        }
        cout << endl;
        return 0;
    } else {
        rep(i, a) {
            cout << b;
        }
        cout << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func geti() int {
	n, _ := strconv.Atoi(read())
	return n
}

// 10 11 12 => [10, 11, 12]
func getli(size int) []int {
	a := make([]int, size)
	list := strings.Split(read(), " ")
	for i, s := range list {
		n, _ := strconv.Atoi(s)
		a[i] = n
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func main() {
	tmp := getli(4)
	a, b, c, d := tmp[0], tmp[1], tmp[2], tmp[3]
	n := math.Ceil(float64(a) / float64(d))
	m := math.Ceil(float64(c) / float64(b))

	if n >= m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
long long n,a,b,f,x;
int main(){
	cin>>n;
	a=floor(sqrt(n));
	while(a){
		if(n%a==0){
			b=n/a;		
			x=0;
			while(a>=10){
				x++;
				a/=10;
			}
			f=x-1;
			x=1;
			while(b>=10){
				x++;
				b/=10;
			}
			f=max(f,x);
			break;
		}
		a--;
	}
	cout<<f;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200005
 
using namespace std;
typedef pair <int,int> P;
 
vector <int> vec[N];
int par[N],dep[N];
int pr[N],ng[N];
bool use[N];
int n;
 
int rev(int v)
{
	if(v>=n) return v-n;
	return v+n;
}
int dfs(int v,int d)
{
	dep[v]=d;
	int a=-1;
	for(int i=0;i<vec[v].size();i++)
	{
		int to=vec[v][i];
		int tg=dfs(to,d+1);
		if(tg!=-1)
		{
			if(a==-1) a=tg;
			else
			{
				//printf("%d %d\n",a,tg);
				pr[a]=tg;
				pr[tg]=a;
				a=-1;
			}
		}
	}
	if(a==-1) a=v;
	return a;
}
int LCA(int a,int b)
{
	while(a!=b)
	{
		if(dep[a]>dep[b]) swap(a,b);
		b=par[b];
	}
	return a;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<2*n;i++)
	{
		int p;
		scanf("%d",&p);p--;
		if(p<0) p=2*n;
		else if(i>=n) p+=n;
		par[i]=p;
		vec[p].push_back(i);
	}
	for(int i=0;i<n;i++)
	{
		if(vec[i].size()%2!=vec[i+n].size()%2)
		{
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	memset(pr,-1,sizeof(pr));
	dfs(2*n,0);
	for(int i=0;i<2*n;i++)
	{
		if(!use[i]&&pr[i]!=-1)
		{
			use[i]=true;
			int now=i;
			do
			{
				use[now]=true;
				int to=pr[now];
				int p=LCA(now,to);
				//if(now==i) printf("%d %d : %d %d\n",now,to,p,i);
				for(int j=now;j!=p;j=par[j]) ng[j]=1;
				for(int j=to;j!=p;j=par[j]) ng[j]=-1;
				now=rev(to);
			}while(now!=i);
		}
	}
	puts("POSSIBLE");
	for(int i=0;i<n;i++)
	{
		int ret=ng[i];
		for(int j=0;j<vec[i].size();j++)
		{
			int to=vec[i][j];
			ret-=ng[to];
		}
		if(i!=0) printf(" ");
		printf("%d",ret);
	}puts("");
	return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <iomanip>
#include <ios>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

	int a,b = 0;
	string s,r,h,k;
			
 
	cin >> a >> b;
	int i,c = 0;
	for(i = 1;i<=b-a;i++){
		c =  c + i;
	}
	
	int z = c - b;
	

	cout << z << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    ans = 0
    cnt = 0
    agct = ['A', 'G', 'C', 'T']
    for s in S:
        if s in agct:
            cnt += 1
            ans = max(ans, cnt)
        else:
            cnt = 0
    print(ans)


if __name__ == '__main__':
    main()


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

int main(void){
  int N, cnt = 0, ans = 0;
  cin >> N;

  for(int i = 1; i <= N; i++){
    if(i % 2 == 1){
      for(int j = 1; j <= i; j++){
	if(i % j == 0)
	  cnt++;
      }
      //printf("%d:%d\n",i,cnt);
      if(cnt == 8)
	ans++;
      cnt = 0;
    }
  }

  cout << ans << "\n";
  return 0;
}	  

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

void main_()
{
    int N, T, A;
    vector<int> Hs;
    cin >> N >> T >> A;
    copy_n(istream_iterator<int>(cin), N, back_inserter(Hs));

    int pos = -1;
    auto min_diff = numeric_limits<double>::max();
    for (int i = 0; i < N; ++i) {
        auto t = T - Hs[i] * 0.006;
        auto diff = abs(t - A);
        if (diff < min_diff) {
            min_diff = diff;
            pos = i + 1;
        }
    }

    cout << pos << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s= input()
ans  = 0
for i in range(n):
    x = list(set(s[:i]))
    y = list(set(s[i::]))
    k = x+y
    m = len(x)+len(y)
    ans = max(ans , m - len(set(k)))

    
print(ans)



Measured memory_bytes: 3060
#include"bits/stdc++.h"
#define endl '\n'

using namespace std;

long long int A, B, N;
int main(){
    cin >> A;
    cin >> B;
    cin >> N;

    if(N >= B)
        cout << A*(B-1)/B - A*(((B-1)/B));
    else
        cout << A*N/B - A*(N/B);

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>

template <typename T = long long>
constexpr T gcd(T a, T b){
    if(a%b == 0){
        return b;
    }else if(b%a == 0){
        return a;
    }
    if(a%b != 0 && a > b){
        return gcd(a - b, b);
    }else if(b%a != 0 && b > a){
        return gcd(a, b - a);
    }
    return 1;
}

template <typename T = long long>
constexpr T solve(T a, T b){
    T ans = -1;
    /*
    if(gcd(a,b) == 1){
        return a * 2;
    }
    */
    for(T i = a; i < (a * b) /gcd(a,b); i += a){
        if(i%b != 0){
            ans = i;
            break;
        }
    }
    return ans;
}

int main(){

    size_t a, b;
    std::cin >> a >> b;

    //std::cout << gcd<int>(a, b) << std::endl;
    std::cout << solve<long long>(a, b) << std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;

long long int N,res=0,L,R,d,T,a[200200];

int main(){

    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 1; i <= N; i++){
        cin>>a[i];
        if(i%2==1&&a[i]%2==1){res++;}
    }
    cout<<res<<endl;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String scStr = scanner.nextLine();
		int count = scStr.length() / 5;

		String dream = "dream";
		String dreamer = "dreamer";
		String erase = "erase";
		String eraser = "eraser";

		boolean result = false;
		boolean isEnd = false;

		for (int i = 0; i <= count; i++) {
			if (isEnd == true)
				break;
			if (scStr.endsWith(dreamer)) {
				scStr = scStr.substring(0,scStr.length()-7);
			} else if (scStr.endsWith(dream)) {
				scStr = scStr.substring(0,scStr.length()-5);
			} else if (scStr.endsWith(eraser)) {
				scStr = scStr.substring(0,scStr.length()-6);
			} else if (scStr.endsWith(erase)) {
				scStr = scStr.substring(0,scStr.length()-5);
			} else if (scStr.length() <= 7) {
				if (scStr.length() == 0) {
					result = true;
				} else if (scStr.length() == 7 && (scStr.endsWith(dreamer))) {
					result = true;
					isEnd = true;
				} else if (scStr.length() == 6 && (scStr.endsWith(eraser))) {
					result = true;
					isEnd = true;
				} else if (scStr.length() == 5 && (scStr.endsWith(dream) || scStr.endsWith(erase))) {
					result = true;
					isEnd = true;
				}else {
					isEnd = true;
				}
			}
		}
		if (result == true) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 56480
#include <stdio.h>
#include <string.h>
int main()
{   
    int n,k;
    scanf("%d%d",&n,&k);
    int arr[n+5];
    for(int i=1;i<=n;i++){
        scanf("%d",&arr[i]);
    }
    for(int i=k+1;i<=n;i++){
        if (arr[i-k]<arr[i]){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
}

Measured memory_bytes: 2364
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>

using namespace std;


int main() {
	long long int N, ans = 1;
	cin >> N;
	for (int i = 1; i <= N;i++) {
		ans *= i;
		ans %= 1000000007;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(b/a>=c) cout<<c<<'\n';
  else cout<<b/a<<'\n';
  return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
a = H.times.map { gets.chomp.split("") }
a.delete_if { |a_| a_.all? { |b| b == "." }  }
a = a.transpose
a.delete_if { |a_| a_.all? { |b| b == "." }  }
a = a.transpose
puts a.map { |a_| a_.join }


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll x, y;
    cin >> x >> y;

    ll absx = abs(x);
    ll absy = abs(y);

    if(absx < absy){
        if(x>0 && y>0){
            cout << absy-absx << endl;
            return 0;
        }
        if(x>0 && y<0){
            cout << absy - absx +1 << endl;
            return 0;
        }
        if(x<0 && y>0){
            cout << absy - absx +1 << endl;
            return 0;
        }
        if(x<0 && y<0){
            cout << absy - absx +2 << endl;
            return 0;
        }
        if(x==0 && y > 0){
            cout << absy << endl;
            return 0;
        }
        if(x==0 && y < 0){
            cout << absy + 1 << endl;
            return 0;
        }
        
    }
    if(absx > absy){
        if(x>0 && y>0){
            cout << absx - absy + 2 << endl;
            return 0;
        }
        if(x>0 && y<0){
            cout << absx - absy +1 << endl;
            return 0;
        }
        if(x<0 && y>0){
            cout << absx - absy +1 << endl;
            return 0;
        }
        if(x<0 && y<0){
            cout << absx - absy << endl;
            return 0;
        }
        if(x>0 && y == 0){
            cout << absx + 1 << endl;
            return 0;
        }
        if(x<0 && y == 0){
            cout << absx << endl;
            return 0;
        }
    }
    if(absx == absy){
        if(x == y){
            cout << 0 << endl;
            return 0;
        }
        else{
            cout << 1 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register int
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		re x=0,y=1;while(nc=gc(),(nc<48||nc>57)&&nc!=-1)if(nc==45)y=-1;Bi=1;
		x=nc-48;while(nc=gc(),47<nc&&nc<58)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*y;
	}
	in db gf() {re a=read(),b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi):a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		re y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {re l=strlen(s);for(re i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=2e2+5;
int n,g[N][N],du[N],vis[N],dfn[N],tim;
char sh[N];
void bfs(re s)
{
	memset(vis,0,sizeof(vis));vis[s]=1;
	for(re i=1;;i++) 
	{
		re op=0;
		for(re j=1;j<=n;j++) if(vis[j]==i)
		{
			for(re k=1;k<=n;k++) 
			if(g[j][k])
				if(!vis[k]) vis[k]=i+1;
				else if(vis[k]==i) return;
			op=1;
		}
		if(!op) return tim=max(tim,i),void();
	}
}
int main()
{
	n=read();
	for(re i=1;i<=n;i++) 
	{
		gs(sh+1);
		for(re j=1;j<=n;j++) 
		{
			g[i][j]=sh[j]-'0';
			if(g[i][j]&&i<j) du[i]++,du[j]++;	
		}
	}
	for(re i=1;i<=n;i++)
	{
		bfs(i);
	}
	write(tim-1,'\n');
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

Measured memory_bytes: 384
/*
* * * * * * * * * * * * * * * * * * *
*       Author : Ganzaki            *
*                                   *
*       language : c++              *
*                                   *
* * * * * * * * * * * * * * * * * * *
*/
#include <bits/stdc++.h>


#define FOR(i,j,k) for(ll i=j;i<k;i++)
#define FOR1(i,j,k) for(ll i=j;i<=k;i++)
#define FOR2(i,j,k) for(ll i=j;i>=k;i--)
#define FILL(a,i) memset(a,i,sizeof(a))
#define db(i) printf("lol %d \n",i)
#define el '\n'
#define dbg(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
#define MOD 1000000007


using namespace std;


typedef long long ll;
typedef unsigned long ul;
typedef std::string str;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef std::vector<str> vs;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<char> vc;
typedef map<int,int> mii;
typedef map<string,int> msi;
void desperate_optimization(int precision){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(precision);
}




void solve()
{
    ll n; ll k; ll q;
    cin>>n;
    cin>>k;
    cin>>q;
    ll a[n];
    ll t;
    FOR(i,0,n) a[i] = k;
    FOR(i,0,q)
    {
        cin>>t;
        a[t-1]++;
    }
    FOR(i,0,n)
    {
        if((a[i]-q)>0)
            cout<<"Yes"<<el;
        else
            cout<<"No"<<el;
    }
    cout<<el;
}




int main()
{
    desperate_optimization(10);
    solve();
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X;
	cin >> N >> X;
	vector<int> A(N);
	int res = 1;
	int cur = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cur += A[i];
		if (cur <= X) {
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int main () {
  cin >> N;
  int n = N;
  int r = 0;
  while(n) {
    r += n % 10;
    n /= 10;
  }
  if (N % r) {
    cout << "No";
  } else cout << "Yes";
  cout << endl;
}

Measured memory_bytes: 256
import math
serach_number = int(input())

def trial_division(target):
    dest = int(math.sqrt(target))
 
    for i in range(2,dest):
        if target % i == 0:
            return False
    return True

while True:
  if trial_division(serach_number):
    print(serach_number)
    break
  serach_number+=1

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

using namespace std;

int a[4][4];
bool mark[4][4];
int n;

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

	for (int i=1;i<=3;i++)
		for (int j=1;j<=3;j++)
			cin >> a[i][j];
	cin >> n;
	for (int i=1;i<=n;i++)
	{
		int x; cin >> x;
		for (int j=1;j<=3;j++)	
			for (int k=1;k<=3;k++)
				if (a[j][k] == x)
					mark[j][k] = true;
	}
	for (int i=1;i<=3;i++)
	{
		bool ok = true;
		for (int j=1;j<=3;j++)	
			if (!mark[i][j])
			{
				ok = false;
				break;
			}
		if (ok) 
		{
			cout << "Yes";
			return 0;
		}
	}
	for (int i=1;i<=3;i++)
	{
		bool ok = true;
		for (int j=1;j<=3;j++)	
			if (!mark[j][i])
			{
				ok = false;
				break;
			}
		if (ok) 
		{
			cout << "Yes";
			return 0;
		}
	}
	bool ok = true;
	for (int i=1;i<=3;i++)
		if (!mark[i][i])
		{
			ok = false;
			break;
		}
	if (ok) 
	{
		cout << "Yes";
		return 0;
	}
	ok = true;
	for (int i=1;i<=3;i++)
		if (!mark[i][3-i+1])
		{
			ok = false;
			break;
		}
	if (ok) 
	{
		cout << "Yes";
		return 0;
	}
	cout << "No";
}


Measured memory_bytes: 256
(setq a(read))
(setq b(read))
(setq c(read))
(setq d(read))
(setq e(read))
(setq f(read))
(setq g(read))
(setq h(read))
(setq i(read))
(setq x(+ a (* c -2) b))
(setq y(+ d (* f -2) e))
(setq z(+ g (* i -2) h))
(princ(if(=(- x y)(- y z))"Yes""No"))

Measured memory_bytes: 24336
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"

const int inf = (int)1e18 + 10;


signed main(){
  fast;
  
 int a , b , c;
 cin >> a >> b >> c;
 if(b + c > a)
 	cout << (b + c - a) << endl;
 else
 	cout << 0 << endl;

  
}	

Measured memory_bytes: 256
import collections
N = (int(input()))

ans = 0
counter_list = []

for _ in range(N):
    s = input()
    counter_list.append("".join(sorted(s)))

ans = 0
wordcount = {}
for word in counter_list:
    if word in wordcount:
        wordcount[word] += 1
        ans += (wordcount[word])
    else:
        wordcount[word] = 0

print(ans)

Measured memory_bytes: 19824
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        
        String xStr = scanner.nextLine();
        String yStr = scanner.nextLine();
            
        String xArr[] = xStr.split(" ");
        String yArr[] = yStr.split(" ");
          
        double p1 = 0;
        double p2 = 0;
        double p3 = 0; 
        double p9 = 0;
        
        for (int i=0; i<xArr.length;i++) {
                p1 += Math.abs( Double.parseDouble(xArr[i]) - Double.parseDouble(yArr[i]) );
                p2 += Math.pow( Math.abs( Double.parseDouble(xArr[i]) - Double.parseDouble(yArr[i]) ), 2);
                p3 += Math.pow( Math.abs( Double.parseDouble(xArr[i]) - Double.parseDouble(yArr[i]) ), 3);
                if( p9 <= Math.abs( Double.parseDouble(xArr[i]) - Double.parseDouble(yArr[i])) ) p9 = Math.abs( Double.parseDouble(xArr[i]) - Double.parseDouble(yArr[i]));
        }
        
        System.out.println(String.format("%.8f", p1));
        System.out.println(String.format("%.8f", Math.sqrt(p2)));
        System.out.println(String.format("%.8f", Math.cbrt(p3)));
        System.out.println(String.format("%.8f", Math.abs(p9)));
    }
}


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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    string a,b;
    cin >> a >> b;
    int num = stoi(a+b);
    int rt = sqrt(num);
    if (rt * rt == num) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


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

int main(){
  int N, W;
  cin >> N >> W;
  W++;
  
  vector<int> v(N), w(N);
  int mv = 0;
  
  for(int i=0; i<N; i++){
    cin >> w[i] >> v[i];
    mv += v[i];
  }
  mv++;
  
  vector<long> dp(mv, 100000000000);
  dp[0] = 0;
  
  for(int i=0; i<N; i++){
    for(int s=mv-1; s>v[i]; s--){
      dp[s] = min(dp[s], dp[s-v[i]] + w[i]);
    }
    for(int s=v[i]; s>=0; s--){
      dp[s] = min(dp[s], (long)w[i]);
    }
  }
  
  int ans = mv;
  while(dp[--ans] >= W) ;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hope the code can get more points.

	Algorithm: 

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const string S4[4] = {"abcc", "abdd", "ccab", "ddab"};
const string S5[5] = {"abbcc", "ad..a", "bd..a", "b.eez", "oorrz"};
const string S6[6] = {"oorrzz", ".a.b.c", ".a.b.c", "d.e.f.", "d.e.f.", "oorrzz"};
const string S7[7] = {".oorrzz", "oabb...", "oa.c...", "rddc...", "r...abb", "z...a.c", "z...ddc"};

char s[1010][1010];

inline void solve(int&n, int x) {
	if(x == 4)
		for(int i = 0; i < x; i++)
			for(int j = 0; j < x; j++)
				s[n + i][n + j] = S4[i][j];
	if(x == 5)
		for(int i = 0; i < x; i++)
			for(int j = 0; j < x; j++)
				s[n + i][n + j] = S5[i][j];
	if(x == 6)
		for(int i = 0; i < x; i++)
			for(int j = 0; j < x; j++)
				s[n + i][n + j] = S6[i][j];
	if(x == 7)
		for(int i = 0; i < x; i++)
			for(int j = 0; j < x; j++)
				s[n + i][n + j] = S7[i][j];
	n += x;
}

int main() {
	int n = ri;
	if(n <= 2) return puts("-1"), 0;
	if(n == 3) {
		puts("a..");
		puts("a..");
		puts(".bb");
		return 0;
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			s[i][j] = '.';
	int x = n % 4, N = 1;
	if(x == 0) solve(N, 4);
	if(x == 1) solve(N, 5);
	if(x == 2) solve(N, 6);
	if(x == 3) solve(N, 7);
	while(N <= n) solve(N, 4);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++)
			putchar(s[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2176
x = int(input())
c = int(x**(1/3))
if c == x**(1/3):
    print(0, -1*c)
else:
    for a in range(-1000, 1000):
        for b in range(-1000, 1000):
            if a**5 - b**5 == x:
                print(a, b)
                exit()


Measured memory_bytes: 66144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "ARC";
            if (int.Parse(Console.ReadLine()) < 1200)
            {
                s = "ABC";
            }

            Console.WriteLine(s);
            Console.ReadLine();

        }
    }
}


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

int main(void) {
    map<char,int> a = {{'I', 1}, {'V', 5}, {'X', 10}, {'L', 50}, {'C', 100}, {'D', 500}, {'M', 1000}};
    string str;
    while(getline(cin, str)) {
        int b = 0, c = a[str[0]], d = a[str[0]]; 
        for(int i = 1; i < str.length(); ++i) {
            int e = a[str[i]];
            if (e == d) {
                c += e;
            }
            else if (d < e) {
                b  -=  (c);
                c = e;
            }
            else if (e < d) {
                b += (c);
                c = e;
            }
            d = e;
        }
        b += c;
        cout << b << endl;;
    }
    return 0;
}



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

yn=1
a=2
while True:
    if n==yn:
        print('Yes')
        break
    elif yn>n:
        print('No')
        exit()
    else:
        yn+=a
        a+=1

a-=1
k=n*2//a
s=[[a] for i in range(k)]

l = [0]*n

for i in range(a):
    s[0].append(i+1)
    l[i]+=1

for i in range(1,k):
    for j in range(i):
        s[i].append(s[j][i])
    while len(s[i]) - 1 != s[i][0]:
        for m in range(s[i-1][-1]-1,n):
            if l[m] == 0:
                s[i].append(m + 1)
                l[m] += 1
                if len(s[i]) - 1 == s[i][0]:
                        break
        if len(s[i]) - 1 != s[i][0]:
            for m in range(s[i-1][-1]-1,n):
                if l[m] == 1:
                    s[i].append(m + 1)
                    l[m] += 1
                    if len(s[i]) - 1 == s[i][0]:
                        break
        break

print(k)

for i in range(len(s)):
    for j in range(len(s[i])):
        if j==len(s[i])-1:
            print(s[i][j])
        else:
            print(s[i][j], end=' ')

Measured memory_bytes: 10112
N, K = map(int, input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())
h.sort()
#h_distance = [0]*(N-1)
ans = min(h[i+K-1]- h[i] for i in range(N-K+1))
print(ans)

Measured memory_bytes: 7472
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
int ans = INT_MAX;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
const int MAX = 404 ;
const ll INF = 1e18+1;
ll dp[MAX][MAX];
void solve(){
		int n ; 
		cin >> n ;
		vector < int > a(n);
		for( int i = 0 ; i < n; i++) cin >> a[i] ;
		ll s= 0 ;
		for( int l = n-1 ; l>=0 ; l--){
			for( int r = l ; r < n ; r++){
				if(l==r){
					dp[l][r] = 0 ;
				}
				else{
					dp[l][r] = INF;
					s = 0;
					for( int i = l ; i <= r ; i++) s+=a[i];
					//cout << s << "\n";
					for( int i = l ; i < r  ; i++){
						dp[l][r] = min(dp[l][r] , dp[l][i]+dp[i+1][r]+s);
					}
				}
			}
		} 
		cout << dp[0][n-1] << " " ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 1536
#include <stdio.h>
 
struct Node { int o, p, q;};
struct Node x[10000];
int n;
void pre( int u) {
    if ( u == -1) {
        return ;
    }
    printf(" %d", u);
    pre( x[u].p);
    pre( x[u].q);
     
}
 
void in( int u) {
    if ( u == -1) {
        return ;
    }
    in( x[u].p);
    printf(" %d", u);
    in( x[u].q);
     
}
 
void post( int u) {
 
    if ( u == -1){
        return ;
    }
    post( x[u].p);
    post( x[u].q);
    printf(" %d", u);
     
}
 
int main() {
    int i, v, p, q, way;
     
    scanf("%d", &n);
    for ( i = 0; i < n; i++) {
        x[i].o = -1;
    }
     
    for ( i = 0; i < n; i++) {
        scanf("%d %d %d", &v, &p, &q);
        x[v].p = p;
        x[v].q = q;
        if ( p != -1) {
            x[p].o = v;
        }
        if ( q != -1) {
            x[q].o = v;
        }
    }
     
    for ( i = 0; i < n; i++) {
        if ( x[i].o == -1) {
            way = i;
        }
    }
    printf("Preorder\n");
    pre(way);
    printf("\n");
    printf("Inorder\n");
    in(way);
    printf("\n");
    printf("Postorder\n");
    post(way);
    printf("\n");
     
    return 0;
}



Measured memory_bytes: 2056
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}


void solve() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if (U == S) A--;
    if (U == T) B--;

    print(A, B);
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

long long n;
long long x[105];
long long y[105];
long long h[105];

int main()
{
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld %lld", &x[i], &y[i], &h[i]);
    }

    for (long long cx = 0; cx <= 100; cx++) {
        for (long long cy = 0; cy <= 100; cy++) {

            //h[i] = H - (x - cx) - (y - cy)
            //H = (x - cx) + (y - cy) + h[i]

            long long H = 1;
            for (int i = 0; i < n; i++) {
                if (h[i] > 0) {
                    H = llabs(x[i] - cx) + llabs(y[i] - cy) + h[i];
                }
            }

            long long i = 0;
            while (i < n &&
                   max(H - llabs(x[i] - cx) - llabs(y[i] - cy), 0) == h[i]) {
                i++;
            }

            if (i == n) {
                printf("%lld %lld %lld\n", cx, cy, H);

                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 128
s = input()
t = input()

s_len = len(s)
t_len = len(t)

result = ''
match = False
for i in range(s_len - t_len, -1, -1):
    match = False
    s_part = s[i:i + t_len]
    for j in range(t_len + 1):
        if j == t_len:
            result = (s[0:i] + t + s[i + t_len:]).replace('?', 'a')
            match = True
            break
        if s_part[j] == '?':
            continue
        if s_part[j] != t[j]:
            match = False
            break
    if match:
        break

print(result if match else 'UNRESTORABLE')

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define int long long

typedef struct {
	int x;
	int y;
}pos;

typedef struct {
	int N;
	pos *ps;
}convex_hull;

//(x, y)の辞書順比較
signed compare_ch(const void *a_sub, const void *b_sub){
	pos a = *(pos *)a_sub, b = *(pos *)b_sub;
	if(a.x != b.x){
		return a.x - b.x;
	}
	else{
		return a.y - b.y;
	}
}

//aからbへのベクトル
pos vec(pos a, pos b){
	pos ans;
	ans.x = b.x - a.x;
	ans.y = b.y - a.y;
	return ans;
}

//外積のz座標
int cross_product_z(pos a, pos b){
	return a.x * b.y - a.y * b.x;
}

double arg(pos a, pos b){
	if(a.y == b.y){
		return M_PI / 2;
	}
	else{
		return atan((double)(a.x - b.x) / (b.y - a.y));
	}
}

double ABS(double x){
//	printf("x = %.12lf\n", x);
	x = x >= 0 ? x : x + M_PI;
	return x;
}

convex_hull *build_convex_hull(int N, pos *ps){
	int i, j;
	pos *psub = (pos *)malloc(sizeof(pos) * N);
	for(i = 0; i < N; i++){
		psub[i] = ps[i];
	}
	qsort(psub, N, sizeof(pos), compare_ch);
	convex_hull *ch = (convex_hull *)malloc(sizeof(convex_hull));
	ch->ps = (pos *)malloc(sizeof(pos) * (N + 1));
	ch->ps[0] = psub[0];
	pos a, b;
	for(i = 1, j = 1; i < N;){
		if(j <= 1){
			ch->ps[j] = psub[i];
			i++;
			j++;
		}
		else{
			a = vec(ch->ps[j - 1], ch->ps[j - 2]);
			b = vec(ch->ps[j - 1], psub[i]);
			if(cross_product_z(a, b) >= 0){
				j--;
			}
			else{
				ch->ps[j] = psub[i];
				i++;
				j++;
			}
		}
	}
	int h = j - 1;
	for(i = N - 1; i >= 0;){
		if(j <= h + 1){
			ch->ps[j] = psub[i];
			i--;
			j++;
		}
		else{
			a = vec(ch->ps[j - 1], ch->ps[j - 2]);
			b = vec(ch->ps[j - 1], psub[i]);
			if(cross_product_z(a, b) >= 0){
				j--;
			}
			else{
				ch->ps[j] = psub[i];
				i--;
				j++;
			}
		}
	}
	ch->N = j - 1;
	return ch;
}

signed main(){
	int N, i, j, k;
	scanf("%lld", &N);
	pos *ps = (pos *)malloc(sizeof(pos) * N);
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &ps[i].x, &ps[i].y);
	}
	convex_hull *ch = build_convex_hull(N, ps);
	for(i = 0; i < N; i++){
		k = -1;
		for(j = 0; j < ch->N; j++){
			if(ps[i].x == ch->ps[j].x && ps[i].y == ch->ps[j].y){
				k = j;
				break;
			}
		}
		if(k == -1){
			printf("0\n");
		}
		else{
			if(ch->N == 2){
				printf("0.5\n");
			}
			else{
				printf("%.12lf\n", ABS(arg(ch->ps[k], ch->ps[(k + 1) % ch->N]) - arg(ch->ps[(k - 1 + ch->N) % ch->N], ch->ps[k])) / (2 * M_PI));
			}
		}
	}
	return 0;
}

Measured memory_bytes: 380
S = input()
N = len(S)
P = 0
for i in range ((N-1)//2):
    if S[i] == S[N-1-i]:
        for k in range((N-1)//2):
            if S[k] == S[((N-3)//2)-k] and S[((N+1)//2)+k] == S[N-1-k]:
                P = P
            else:
                P += 1
    else:
        P += 1

if P == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string condition = "";
  cin >> condition;
  
  int a_cont = 0, b_cont = 0;
  for (char c : condition) {
    if (c == 'A') a_cont++;
    if (c == 'B') b_cont++;
  }
  
  if (a_cont == 0 || b_cont == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 256
hw = STDIN.gets
hw = hw.chomp
h = hw.split(" ")
N = h[0].to_i
C = h[1].to_i
r = 0
h = 0
u = 0
f = Array.new(N).map{Array.new(3, 0)}
fs = Array.new(N).map{Array.new(3, 0)}
p = Array.new(C).map{Array.new(10 ** 5 + 1, 0)}
#ps = Array.new(, Array.new(, 0))
#e = Array.new(10, 0)
for i in 0..(N - 1)
  	s = ""
	s = STDIN.gets
	s.chomp!
	fs[i] = s.split(" ")
  	f[i] = fs[i].map{|a|a.to_i}
end

#puts f.join(' ')
#puts C.class
#puts C
#puts p[1][6].class
#puts f[1][2].class

for n in 0..(N - 1)
  	u = f[n][2]
	for i in (f[n][0] - 1)..(f[n][1] - 1)
		p[u - 1][i] = 1
      	#puts p[u][i]
	end
end
#puts p[1].join(' ')
for t in 0..(10 ** 5)
	h = 0
	for c in 0..(C - 1)
		h = h + p[c][t]
	end
	if r < h
		r = h
		ti = t
	end
end
#puts ti
puts r

Measured memory_bytes: 66300
def main():
    altitude_lis = []
    for i in range(10):
        input_line = raw_input()
        altitude = int(input_line)
        altitude_lis.append(altitude)
        
    altitude_lis.sort()
    altitude_lis.reverse()
    for i in range(3):
        print(altitude_lis[i])
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 4200
#include <iostream>

using namespace std;

int main()
{
    long long n, last1 = 1, last2;
    cin >> n;
    last2 = n;
    for (long long i = 2; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            last1 = i; last2 = n / i;
        }
    }
    cout << last1 + last2 - 2;
    return 0;
}


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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define MOD ((long) 1e9 + 7)
#define mll map<long, long>
#define pll pair<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (i, 0, v.size()) cout << v[i] << " "; cout << "\n";

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

  string s;
  cin >> s;

  long total = 0;
  FOR (k, 0, 1LL << s.size()) {
    long x = k;
    long y = 0;
    long z = 0;
    FOR (i, 0, s.size()) {
      if (x % 2 == 1) {
        z += y;
        y = 0;
      } else {
        y *= 10;
        y += s[i] - '0';
      }
      x >>= 1;
    }
    z += y;
    total += z;
  }
  printf("%lld\n", total);

}


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

int main(){
  ll n;
  cin >> n;
  ll a[n], b[n];
  rep(i,n) cin >> a[i] >> b[i];
  sort(a,a+n);
  sort(b,b+n);
  ll xl , xr;
  if(n % 2 == 0) {
    xl = a[n/2-1] + a[n/2];
    xr = b[n/2-1] + b[n/2];
  } else {
    xl = a[n/2];
    xr = b[n/2];
  }
  cout << xr- xl + 1 << endl;
  return 0;
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
string w;
int main(){
  cin >> w;
  if(w.size()%2==1){
    cout << "No" << endl;
    return 0;
  }
  sort(w.begin(),w.end());
  for(int i=0;i<w.size();i+=2){
    if(w[i]==w[i+1]);
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
vector<int> v,nes;
vector<vector<int>> dp;
void dfs(int cur, int mn){
    for(auto i: dp[cur]){
        if(i > mn)nes[i] = true;
        dfs(cur-i,mn);
    }
    dp[cur].resize(0);
}
signed main(){
    int n, k;
    cin >> n >> k;
    dp.resize(2*k+1);
    nes.resize(k);
    dp[0].pb(0);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        v.pb(x);
    }
    sort(all(v));
    for(auto x: v){
        if(x >= k)break;
        for(int i = k; i >= 0; i--){
            if(dp[i].size() && !(dp[i+x].size() && dp[i+x].back()==x))dp[i+x].pb(x);
        }
    }
    dp[0].resize(0);
    for(int i = 0; i <= k; i++)dfs(i+k,i);
    int ans = n;
    for(auto x: v){
        if(x >= k || nes[x])ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 129664