akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	
	int n;
	
	cin >> n;
	
	vector <double> myVector(n);
	
	for (int i = 0; i < n; i++){
		
		cin >> myVector[i];
		
	}
	
	sort(myVector.begin(), myVector.end());
	
	//for (int i = 0; i < n; i++){
		
	//	cout << myVector[i] << " ";
		
	//}
	double ans = 0;
	double perm = 0;
	
	for (int i = 0; i < n-1; i++){
		perm = (myVector[0]+myVector[1])/2;
		//cout << perm << " ";
		myVector.erase(myVector.begin(), myVector.begin()+2);
		myVector.insert(myVector.begin(), perm);
	}
	
	
	//for (int i = 0; i < n; i++){	
	//	cout << myVector[i] << " ";		
	//}
	cout << myVector[0];
}

Measured memory_bytes: 256
Mod = 10**9+7
S = input()
N = len(S)
O = 1
A = [0]*N
AB = [0]*N
ABC = [0]*N

for i in range(N):
    A[i] = A[i-1]
    AB[i] = AB[i-1]
    ABC[i] = ABC[i-1]
    if S[i] == 'A':
        A[i] += O
    if S[i] == 'B':
        AB[i] += A[i-1]
    if S[i] == 'C':
        ABC[i] += AB[i-1]
    if S[i] == '?':
        A[i] *= 3
        A[i] += O
        AB[i] *= 3
        AB[i] += A[i-1]
        ABC[i] *= 3
        ABC[i] += AB[i-1]
        O *= 3
    A[i] %= Mod
    AB[i] %= Mod
    ABC[i] %= Mod
    O %= Mod
print(ABC[-1])

Measured memory_bytes: 15108
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
long int block = 0;
bool compare(pair<pair<long int,long int>,long int> a,pair<pair<long int,long int>,long int> b)
{
    if(a.ff.ff/block == b.ff.ff/block)
    {
        if(a.ff.ff/block % 2)
        return a.ff.ss<b.ff.ss;
        else
        return a.ff.ss>b.ff.ss;
    }
    return a.ff.ff<b.ff.ff;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	// your code goes 
	long long int n,q;
	cin>>n>>q;
	long long int a[n+1];
	for(long int i=1;i<=n;i++)
	{
	    cin>>a[i];
	}
	pair<pair<long int,long int>,long int> b[q];
	for(long int i=0;i<q;i++)
	{
	 cin>>b[i].ff.ff>>b[i].ff.ss;
	 b[i].ss=i;
	}
	block = sqrt(n)+3;
	sort(b,b+q,compare);
    long int l=1,r=0;
    long int c[n+1]={0};
    long int temp=0;
    long int d[q]={0};
    for(long int i=0;i<q;i++)
    {
        while(b[i].ff.ss>r)
        {
            r++;
            if(c[a[r]]==0)
            temp++;
            c[a[r]]++;
        }
        while(r>b[i].ff.ss)
        {
          if(c[a[r]]==1)
          {
              temp--;
          }
          c[a[r]]--;
          r--;
        }
        while(l<b[i].ff.ff)
        {
            if(c[a[l]]==1)
            {
                temp--;
            }
            c[a[l]]--;
            l++;
        }
        while(l>b[i].ff.ff)
        {
            l--;
            if(c[a[l]]==0)
            temp++;
            c[a[l]]++;
        }
        d[b[i].ss]=temp;
        //cout<<temp<<endl;
    }
    for(long int i=0;i<q;i++)
    cout<<d[i]<<endl;
	return 0;
}


Measured memory_bytes: 27204
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=100000000000000000;
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}

int main(){
int n;
cin>>n;
int ans=0;
vector<int> res;
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    ans+=a;
    if(a%10!=0)res.push_back(a);
}
sort(res.begin(),res.end());
if(ans%10==0){
   if(res.size()==0){  
    cout<<0<<endl;
    return 0;
 }
ans-=res.at(0);
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

ll N;
int query(ll x){
    cout<<x<<endl;
    string S; cin>>S;
    if(S=="Vacant") exit(1);
    if(S=="Male") return 1;
    if(S=="Female") return -1;
    return 0;
}

void saiki(ll L, ll R, int l, int r){
    ll MID=(L+R)/2;
    int t=query(MID);
    if(l==t && (MID-L)%2==1) saiki(L,MID,l,t);
    else if (l!=t && (MID-L)%2==0) saiki(L,MID,l,t);
    else saiki(MID,R,t,r);
    return;
}


int main(){
    cin>>N;
    ll n=N/2;
    int a=query(0);
    int b=query(n);
    if(a==b && n%2==1) saiki(0,n,a,b);
    else if(a!=b && n%2==0) saiki(0,n,a,b);
    else saiki(n,N,b,a);
}

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

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

    ll h;
    cin >> h;

    ll ans = 0;
    ll cnt = 0;
    while(h > 0){
        h /= 2;
        ans += pow(2,cnt);
        cnt++;
    }
    cout << ans << endl;
}



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

from collections import defaultdict
from heapq import heappush, heappop
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve(S, T):
    sizeS = len(S)
    sizeT = len(T)
    m = [[0] * (sizeT + 1) for _i in range(sizeS + 1)]
    for i in range(1, sizeS + 1):
        for j in range(1, sizeT + 1):
            m[i][j] = max(
                m[i - 1][j],
                m[i][j - 1],
                m[i - 1][j - 1] + 1 if S[i - 1] == T[j - 1] else 0
            )
    result = []
    i = sizeS
    j = sizeT
    while i > 0 and j > 0:
        if m[i][j] == m[i - 1][j]:
            i -= 1
        elif m[i][j] == m[i][j - 1]:
            j -= 1
        else:
            result.append(chr(S[i - 1]))
            i -= 1
            j -= 1
    print("".join(reversed(result)))


def main():
    S = input().strip()
    T = input().strip()
    solve(S, T)


def _test():
    """
    >>> solve("axyb", "abyxb")
    axb
    """
    global chr
    import doctest
    def chr(x): return x
    doctest.testmod()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 144292
import java.util.Scanner;

public class Main {

    public static String process(int A, int B) {
        int aTwice = A + A - 1;
        int bTwice = B + B - 1;
        int both = A + B;
        return String.valueOf(Math.max(aTwice, Math.max(bTwice, both)));
    }

    // Util func

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        final String result = process(A, B);

        output(result);
    }

    private static void output(String result) {
        System.out.println(result);
    }
}


Measured memory_bytes: 25172
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
ans = []
flag = False

for i in range(H):
    if i%2==0:
        for j in range(W):
            if flag:
                ans.append((pi, pj, i, j))
            
            if a[i][j]%2==1:
                flag = ~flag
            
            pi, pj = i, j
    else:
        for j in range(W-1, -1, -1):
            if flag:
                ans.append((pi, pj, i, j))
                
            if a[i][j]%2==1:
                flag = ~flag
            
            pi, pj = i, j

print(len(ans))

for a, b, c, d in ans:
    print(a+1, b+1, c+1, d+1)

Measured memory_bytes: 71644
package main

import (
	"fmt"
)

func main() {
	var n int
	var m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	var arr [50]int
	for i:=0;i < m; i++ {
		var x,y int
		fmt.Scan(&x)
		fmt.Scan(&y)
		x--;
		y--;
		arr[x]++;
		arr[y]++;
	}
	
	for i:=0; i<n;i++ {
		fmt.Println(arr[i]);
	}

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll S;
    cin >> S;
    const ll k = 1e9;
    ll q = S/k;
    ll X1 = k;
    ll Y2 = (S%k == 0 ? S/k : S/k+1);
    ll X2 = 1;
    ll Y1 = X1*Y2 - S;
    cout << 0 << " " << 0 << " " << X1 << " " << Y1 << " " << X2 << " " << Y2 << endl;
    //cerr << X1*Y2 - X2*Y1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAX_M 500
#define MAX_N 500
#define MAX_V (MAX_M + MAX_N + 2)

#define INF (1<<28)

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

struct edge {
    int to;
    int cap;
    int rev;
    edge() {}
    edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

vector<edge> G[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size()-1));
}

bool used[MAX_V];
int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    while (true) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int m, n;
int main() {
    while (cin >> m >> n, m || n) {
        for (int i = 0; i < m+n+2; i++) G[i].clear();
        int blue[MAX_M];
        int  red[MAX_N];
        for (int i = 0; i < m; i++) cin >> blue[i];
        for (int i = 0; i < n; i++) cin >>  red[i];

        for (int i =   1; i <=   m; i++) add_edge(0,     i, 1);
        for (int i = m+1; i <= m+n; i++) add_edge(i, m+n+1, 1);
        for (int i = 0; i < m; i++) 
            for (int j = 0; j < n; j++) 
                if (gcd(blue[i], red[j]) != 1) 
                    add_edge(i+1, m+j+1, 1);

        cout << max_flow(0, m+n+1) << endl;
    }
    return 0;
}

Measured memory_bytes: 7604
N = int(input())
li = []
for _ in range(N):
    r = int(input())
    li.append(r)
li_uniq = list(set(li))
li_uniq.sort(reverse = True)
if len(li_uniq) == 1:
    Max1 = li_uniq[0]
    Max2 = li_uniq[0]
else:
    Max1 = li_uniq[0]
    Max2 = li_uniq[1]
if li.count(Max1) > 1:
    for i in li:
        print(Max1)
else:
    for i in li:
        if i == Max1:
            print(Max2)
        else:
            print(Max1)

Measured memory_bytes: 17164
import sys
sys.setrecursionlimit(10**7)
M=10**9+7
N=10**6
fac=[0]*(N+1)
fac[0]=b=1
for i in range(1,N+1):fac[i]=b=b*i%M
inv=[0]*(N+1)
inv[N]=b=pow(fac[N],M-2,M)
for i in range(N,0,-1):inv[i-1]=b=b*i%M
def dfs1(v,p):
    s=1
    l=[]
    c1,c2=[1],[1]
    for w in e[v]:
        if w==p:continue
        l+=w,
        dfs1(w,v)
        u=sz1[w]
        c1+=c1[-1]*dp1[w]*inv[u]%M,
        s+=u
    for w in l[::-1]:
        c2+=c2[-1]*dp1[w]*inv[sz1[w]]%M,
    e[v]=l
    c[v]=c1,c2[::-1]
    sz1[v]=s
    dp1[v]=c1[-1]*fac[s-1]%M
n,*t=open(0).read().split()
n=int(n)
e=[[]for _ in range(n)]
for a,b in zip(*[map(int,t)]*2):
    e[a-1]+=b-1,
    e[b-1]+=a-1,
sz1,sz2=[0]*n,[0]*n
dp1,dp2=[0]*n,[0]*n
c=[[]for _ in range(n)]
dfs1(0,-1)
# print(dp1)
sz2[0]=1
dp2[0]=1
s=[0]
while s:
    v=s.pop()
    l=len(e[v])
    c1,c2=c[v]
    uv=sz2[v]-1
    tv=dp2[v]*inv[uv]
    for i,w in enumerate(e[v]):
        tw=c1[i]*c2[i+1]%M
        uw=uv+sz1[v]-sz1[w]-1
        dp2[w]=tv*tw*fac[uw]%M
        sz2[w]=uw+2
        s+=w,
# print(dp2)
for i in range(n):
    u1=sz1[i]-1
    u2=sz2[i]-1
    print(dp1[i]*dp2[i]*inv[u1]*inv[u2]*fac[u1+u2]%M)

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

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) cout << 1 << endl;
  else {
    if (a == b || b == c || c == a) cout << 2 << endl;
    else cout << 3 << endl;
  }
}

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

int main(void){
	int o,flag=1,i=0,p=0,n,j,temp;
	scanf("%d",&n);
	int a[100]={0};
	for(o=0;o<n;o++)
		scanf("%d",&a[o]);

	while(flag){
		flag=0;
		for(j=n-1;j>=i+1;j--){
			if(a[j] < a[j-1]){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;
				flag=1;p++;
			}
		}i++;
	}
	for(o=0;o<n;o++){
		printf("%d",a[o]);
		if(o != n-1)
			printf(" ");
	}
	printf("\n%d\n",p);
	return 0;
}

Measured memory_bytes: 604
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a, b, c; cin>>a>>b>>c;
    cout<<(a+b-1)/b*c;
}

Measured memory_bytes: 3620
#include<iostream>
#include<limits>

using namespace std;

bool is_prime(int n)
{
  if (n % 2 == 0 and n != 2)
    return false;
  if (n == 2)
    return true;
  for (int z = 3; z*z <= n; z += 2) {
    if (n % z == 0) return false;
  }
  return true;
}

int main()
{
  cin.ignore(numeric_limits<streamsize>::max(), '\n');

  int n;
  int count {0};

  while (cin >> n)
    count += is_prime(n);

  cout << count << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
/*
void erase(int *ptr, int *last)
{
    while ( ++ptr < last )
        *(ptr - 1) = *ptr;       //  要素をひとつ前にずらす
}

void insert(int *ptr, int *last, int val)
{
    for(int *dst = last - 1; --dst >= ptr; )
        *(dst + 1) = *dst;      // 要素をひとつ後ろにずらす
    *ptr = val;
}
*/

int main() {
  int N;
  cin >> N;
  int t[N], sorted[N];
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    t[i] = sorted[i] = tmp;
  }
  sort(sorted, sorted+N);
  
  int tmp = 0;
  int cnt = 0;
  for(int j = 1; j < N; j++){
    if(t[j-1] > t[j]){
//      cout << t[j-1] << endl;
      if(cnt%2 == 0){
        tmp = j-1;
//        cout << cnt << endl;
      }else if(cnt != 0){
//        cout << tmp << endl;
        std::swap(t[j], t[tmp]);
      }
      cnt++;
    }
  }

  if(cnt > 3){
    cout << "NO" << endl;
    return 0;
  }
  for(int k = 0; k < N; k++){
//    cout << t[k] << endl;
    if(t[k] != sorted[k]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}



Measured memory_bytes: 256
import sys
s0,t0=input(),input()
s,t=list(s0),list(t0)
n=len(s)
sn=set(s)
tn=set(t)
if len(sn)!=len(tn) or len(s)!=len(t):
  print('No')
  sys.exit()
for i in range(n):
  if s[i]!=t[i]:
    if s.index(s[i])!=t.index(t[i]):
      print('No')
      sys.exit()
print('Yes')

Measured memory_bytes: 6704
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){

	int n, score[40], h[21], cnt, frame, p, pre, tmp, index[40], sn[40];
	bool flg;
	
	while(cin >> n){
		if(n == 0) break;
		
		fill(score, score+40, 0);
		for(int i=0; i<40; i++){
			index[i] = i;
		}

		for(int i=0; i<n; i++){
			fill(h, h+21, 1);
			cnt = 0;
			frame = 1;
			flg = false;
			pre = 0;	
		
			cin >> sn[i];
			while(frame<10){
				cin >> p;
				if(flg == false){
					if(p != 10){
						pre = p;
						flg = true;
					}
					else {
						h[cnt+1]++;
						h[cnt+2]++;
						frame++;
					}
				}
				else {
					if(p + pre == 10) h[cnt+1]++;
					flg = false;
					frame++;
				}
				score[i] += p * h[cnt];
				cnt++;
			}
			for(int j=0; j<3; j++){
				cin >> p;
				score[i] += p * h[cnt];
				cnt++;
				if(j == 0) pre = p;
				else if(j == 1 && p + pre < 10) break;
			}
		}
		
		for(int i=n-1; i>0; i--){
			for(int j=0; j<i; j++){
				if(score[index[j]] > score[index[j+1]]){
					tmp = index[j];
					index[j] = index[j+1];
					index[j+1] = tmp;
				}
				else if(score[index[j]] == score[index[j+1]]){
					if(sn[index[j]] < sn[index[j+1]]){
						tmp = index[j];
						index[j] = index[j+1];
						index[j+1] = tmp;
					}
				}
			}
		}
		
		for(int i=n-1; i>=0; i--){
			cout << sn[index[i]] << " " << score[index[i]] << endl;
		}
		
	}

	return 0;
	
}

Measured memory_bytes: 1160
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/



main :-
    get_number(H, N),
    get_numbers(N, Xs),
    sum_list(Xs, S),
    (S >= H -> writeln("Yes") ; writeln("No")).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 11800
using System;

namespace _0222
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] prime = new bool[10000001];
            for (int i = 2; i < 10000001; i++)
            {
                prime[i] = true;
            }
            for (int i = 2; i < 3163; i++)
            {
                for (int j = i * 2; j < 10000001; j += i)
                {
                    prime[j] = false;
                }
            }
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                bool b = true;
                if (n % 2 == 0)
                {
                    n--;
                }
                for (int i = n; b; i -= 2)
                {
                    if (prime[i] && prime[i - 2] && prime[i - 6] && prime[i - 8])
                    {
                        Console.WriteLine(i);
                        b = false;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 19044
#include <cmath>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n; double x[100000], y[100000];
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)
    {
        scanf("%lf", &x[i]);
        scanf("%lf", &y[i]);
    }
    
    pair<double, double> p1[100000], p2[100000];
    
    for(int i = 0; i < n; i++)
    {
        p1[i] = make_pair(x[i], y[i]);
    }
    
    for(int i = 0; i < n; i++)
    {
        p2[i] = make_pair(y[i], x[i]);
    }
    
    sort(p1, p1 + n);
    sort(p2, p2 + n);
    
    double sqr_ans = 100000000.0;
    
    const int loops = 113;
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p1[i + j].first - p1[i].first) * (p1[i + j].first - p1[i].first) + (p1[i + j].second - p1[i].second) * (p1[i + j].second - p1[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    for(int i = 0; i < n - 1; i++)
    {
        int r = min(loops, n - i - 1);
        
        for(int j = 1; j <= r; j++)
        {
            double distance_ = (p2[i + j].first - p2[i].first) * (p2[i + j].first - p2[i].first) + (p2[i + j].second - p2[i].second) * (p2[i + j].second - p2[i].second);
        
            sqr_ans = min(distance_, sqr_ans);
        }
    }
    
    printf("%.9f\n", sqrt(sqr_ans));
    
    return 0;
}

Measured memory_bytes: 7360
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda x:x[0])
ans = 0
d = 0
i = 0
while d < m:
  ans += ab[i][0]*min(m-d,ab[i][1])
  d += ab[i][1]
  i += 1
print(ans)

Measured memory_bytes: 29796
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
multiset<ll,greater<ll>> st[200000];
multiset<ll> ss;
ll N,K;
ll A[200005];

int main() {
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N-K;i++){
        if(A[i]<A[i+K]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    
}


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

#define dbg(x) cerr<<#x": "<<x<<"\n"
#define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n"
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define DMAX 
#define NMAX 
#define MMAX 

using namespace std;

int n, k, x, a[43][120], dp[7][120];
string s;


template<class T>
ostream& operator<<(ostream& out, vector<T> v)
{
	out << v.size() << '\n';
	for(auto e : v)
		out << e << ' ';
	return out;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[0][i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> a[1][i];
	}

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

} 

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

int main()
{
    int A_1,A_2,A_3,num;
    scanf("%d%d%d",&A_1,&A_2,&A_3);
   //////// for(i=0;i<=10;i++)
    if( A_1+A_2+A_3>=22)
    {
        printf("bust");
    }
    else{
       printf("win");
    }


    return 0;/////////aishorjo
}


Measured memory_bytes: 128
import Foundation

var line = readLine()!.components(separatedBy: " ")
let H1 = Int(line[0])!
let M1 = Int(line[1])!
let H2 = Int(line[2])!
let M2 = Int(line[3])!
let K = Int(line[4])!

print((H2 - H1) * 60 + (M2 - M1) - K)

Measured memory_bytes: 14172
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
sys.setrecursionlimit(10 ** 6)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, q = MAP()
s = input()
p = [LIST() for i in range(q)]
l = [0]*n
r = [0]*n

for i in range(n-1):
    if s[i] + s[i+1] == "AC":
        l[i] += 1
        r[i+1] += 1

for i in range(1,n):
    l[i] += l[i-1]
    r[i] += r[i-1]

for i in range(q):
    print( r[p[i][1]-1] - r[p[i][0]-1] )

Measured memory_bytes: 36288
#include <iostream>
#include <algorithm>
#include <vector>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;

int main() {

    ll n,k ;
    cin >> n >> k ;
    vector<ll> vec(100001) ;
    for(int i=0;i<n;++i){
        ll a,b ;
        cin >> a >> b ;
        vec[a]+=b ;
    }
    
    ll sum = 0 ;
    for(int i=1;i<100001;++i){
        sum+=vec[i];
        //cout << sum << endl ;
        if(sum>=k){
            cout << i << endl ;
            break ;
        }
    }

    return 0 ;
}


Measured memory_bytes: 4044
#include<stdio.h>
#include<math.h>

int main(){
	int a,b,C;		//入力される整数
	double S,L,h;	//面積、周の長さ、高さ
	double PI = acos(-1);//円周率
	
	//入力
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&C);
	
	//ラジアンにする
	double Cr = C * (PI / 180);
	
	//Sの算出
	S = (double)(a * b * sin(Cr) / 2);
	
	//Lの算出
	double c = sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(Cr));//もう一本の辺
	L = (double)(a + b + c);
	
	//hの算出
	h = (double)(2 * S / a);
	
	//出力
	printf("%lf\n%lf\n%lf\n",S,L,h);
	
	return 0;
}



Measured memory_bytes: 2088
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        string s = Console.ReadLine();
        s = s.Replace(" ", "");
        char[] c = s.ToCharArray();
        int n = s.Length;
        int[] a = new int[n];


        for (int i = 0; i < 2; i++)
        {
            int count = 0;
            for (int j = 0; j < n; j++)
            {
                if (c[j]=='R') count++;
                else
                {
                    a[j] += count / 2;
                    a[j - 1] += (count + 1) / 2;
                    count = 0;
                }
                
            }

            Array.Reverse(c);
            Array.Reverse(a);

            for (int j = 0; j < n; j++)
            {
                if (c[j]=='R') c[j] = 'L';
                else c[j] = 'R';
            }
        }

        string ans = string.Join(" ", a);
        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 13380
if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    cnt = 1
    
    if 1 not in a:
        print(-1)
    else:
        for i in a:
            if i == cnt:
                cnt += 1
            else:
                ans += 1
        print(ans)

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

struct RSQ{
  int n=(1<<20),data[(1<<21)];
  RSQ(){memset(data,0,sizeof(data));}
  void add(int i,int v){
    while(i<=n){
      data[i]+=v;
      i+=i&-i;
    }
  }
  int sum(int i){
    int res=0;
    while(i>0){
      res+=data[i];
      i-=i&-i;
    }
    return res;
  }
  int sum(int x,int y){ return sum(y-1)-sum(x-1); }
};

int n,a[100009],L[100009],R[100009];
long long sum;

int main(){
  RSQ A,B;
  cin>>n;
  r(i,n)cin>>a[i];

  for(int i=0;i<n;i++){
    L[i] = i - A.sum(1,a[i]+1);
    R[n-1-i] = i - B.sum(1,a[n-i-1]+1);
    A.add(a[i],1);
    B.add(a[n-i-1],1);
  }

  r(i,n) sum += min(L[i],R[i]);
  cout<< sum <<endl;
}


Measured memory_bytes: 20680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int H, W; cin >> H >> W;
  vector<string> a(H);
  rep(i, H) cin >> a[i];
  
  int i=0, j=0;
  a[i][j] = '.';
  while(!(i==H-1&&j==W-1)) {
    if(i < H-1 && a[i+1][j] == '#') {
      a[i+1][j] = '.';
      i++;
    } else if(j < W-1 && a[i][j+1] == '#') {
      a[i][j+1] = '.';
      j++;
    } else {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  rep(i, H) rep(j, W) if(a[i][j] == '#') {
    cout << "Impossible" << endl;
    return 0;
  }
  
  cout << "Possible" << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans=0;
    if(k<a){
        ans = k;
    }else if(a<=k && k<=a+b){
        ans = a;
    }else{
        ans = a;
        k = k-a-b;
        ans -= k;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
import scala.io.StdIn

object Main{

  def main(args: Array[String]): Unit = {
    val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)
    val xs = StdIn.readLine().split(' ').map(_.toInt).toVector.sorted
    println(solve(n, m, xs))
  }

  def solve(n: Int, m: Int, xs: Vector[Int]): Int = {
    if (m <= n) {
      0
    } else {
      val dxs = xs.sliding(2).map(xx => xx(1) - xx(0)).toVector.sorted
      dxs.dropRight(n - 1).sum
    }
  }

}


Measured memory_bytes: 66364
N, L = map(int, input().split())

outputlist = []
for i in range(1,N+1):
  outputlist.append(i + L -1)

absout = []
for i in outputlist:
  absout.append(abs(i))

a = absout.index(min(absout))

output = sum(outputlist[:a] + outputlist[a+1:])

print(output)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int n = 0;
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
            n++;
    }
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 3088
import heapq

G = [{}]

def setNode(n):
  global G
  G = [{} for i in range(n)]
def solve(s, n):
  global G
  fixed = [None]*n
  q = []
  heapq.heappush(q, (0,s))
  while q:
    w,x = heapq.heappop(q)
    if fixed[x] is not None: continue
    fixed[x] = w
    for y in G[x]:
        if fixed[y] is None:
            heapq.heappush(q, (w + G[x][y], y))
  return fixed


n = int(input())
setNode(n)
for i in range(n-1):
  s,t,w = map(int,input().split())
  G[s-1][t-1] = w
  G[t-1][s-1] = w
Q, K = map(int, input().split())
dist = solve(K-1,n)
for i in range(Q):
    x, y = map(int,input().split())
    print(dist[x-1]+dist[y-1])

Measured memory_bytes: 58240
using System;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		
		int maxCount=0;
		int counter=0;
		
		for(int i=0; i<s.Length; i++) {
			if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T') {
				counter++;
			}
			else {
				if(counter>maxCount) {
					maxCount=counter;
				}
				counter=0;
			}
		}

		if(counter>maxCount) {
			maxCount=counter;
		}

		Console.WriteLine(maxCount);
	}
}

Measured memory_bytes: 11092
N = int(input())
A = [int(x) for x in input().split()]
B = [abs(x) for x in A]

cnt = len(list(filter(lambda x: x < 0, A)))


if cnt % 2 == 0:
    print(sum(B))
else:
    mi = min(B)
    print(sum(B) - 2*mi)



Measured memory_bytes: 14412
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	int X, N;
	std::cin >> X >> N;
	std::set<int> set;
	for (auto i : boost::irange(N))
	{
		int p;
		std::cin >> p;
		set.emplace(p);
	}
	for (auto i : boost::irange(100))
	{
		if (!set.count(X - i))
		{
			std::cout << X - i << std::endl;
			return;
		}
		if (!set.count(X + i))
		{
			std::cout << X + i << std::endl;
			return;
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3664
#include<stdio.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int L=128,C=62;
int s[C*2+2][C*4];int diff,edit[C+1]={0},sz[2*C+2]={0};
static inline int decode(int x){return x<=26?64+x:(x<=52?96-26+x:48+x-52-1);}
static inline int ask(int u,int i,int j)
{
  int len=diff;
  printf("? ");rep(k,sz[u]){len--;putchar(decode(s[u][k]));}len--;putchar(decode(s[u<<1][i]));
  rep(k,sz[u<<1|1]-j){len--;putchar(decode(s[u<<1|1][k+j]));}puts("");fflush(stdout);
  int res;if(scanf("%d",&res)!=0)return res==len;else return -1;
}
static inline void solve(int u,int le,int ri)
{
  if(le==ri){sz[u]=edit[le];rep(i,edit[le]){s[u][i]=le;}return;}
  int mid=(le+ri)>>1;
  solve(u<<1,le,mid);solve(u<<1|1,mid+1,ri);
  for(int i=0,j=0;i<sz[u<<1]||j<sz[u<<1|1];)
  {
    if(i<sz[u<<1]&&(j==sz[u<<1|1]||ask(u,i,j))){s[u][sz[u]++]=s[u<<1][i];i++;}
    else{s[u][sz[u]++]=s[u<<1|1][j];j++;}
  }
}
int main(void)
{
  rep(i,C)
  {
    printf("? ");rep(j,L){putchar(decode(i+1));}puts("");fflush(stdout);
    int res;if(!scanf("%d",&res))return -1;
    edit[i+1]=L-res;diff+=L-res;
  }
  solve(1,1,C);
  printf("! ");rep(i,sz[1])putchar(decode(s[1][i]));puts("");fflush(stdout);
  return 0;
}

Measured memory_bytes: 3776
#include <cstdio>

int main(){
    int W, H, x, y;
    scanf("%d %d %d %d", &W, &H, &x, &y);
    if( W == 2 * x && H == 2 * y ){
        printf("%lf %d\n", (double)W * (double)H / 2.0, 1);
    }else{
        printf("%lf %d\n", (double)W * (double)H / 2.0, 0);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

int n;
ll a[200005],b[200005];

P get(int pos){
	ll len=(b[(pos+1)%n]+b[(pos+n-1)%n]);
	ll rest=b[pos]-a[pos];
	ll l=1,r=(rest/len)+1;
	ll maxi=max(b[(pos+1)%n],b[(pos+n-1)%n]);
	while(l+1<r){
		ll mid=(l+r)/2LL;
		if(rest-len*mid>=maxi)l=mid;
		else{
			r=mid;
		}
	}
	return P(b[pos]-len*l,l);
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	priority_queue<P> que;
	for(int i=0;i<n;i++){
		scanf("%lld",&b[i]);
		if(b[i]!=a[i]){
			que.push(P(b[i],i));
		}
	}
	ll cnt=0;
	while(que.size()){
		P p=que.top();
		que.pop();
		ll nxt=b[p.second]-(b[(p.second+1)%n]+b[(p.second+n-1)%n]);
		if(nxt<a[p.second]){
			printf("-1\n");
			return 0;
		}
		P tmp=get(p.second);
		nxt=tmp.first;
		cnt+=tmp.second;
		b[p.second]=nxt;
		if(nxt>a[p.second]){
			que.push(P(nxt,p.second));
		}
	}
	printf("%lld\n",cnt);
	return 0;
}


Measured memory_bytes: 9072
///答え見ました
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  int k;
  cin >> k;
  
  queue <ll> a;
  if(k<10){
    cout << k << endl;
    return 0; 
  }
  for(int i=1; i<10; i++){
   a.push(i); 
  }
  
  ll x=0;
  while(k>0){
    x=a.front();
    a.pop();
    int d=x%10;
    for(int j=-1; j<2; j++){
      d+=j;
      if(d<0 || d>9){
        d-=j;
        continue;
      }
      ll nx = x*10+d;
      a.push(nx);
      d-=j;
    }
    k--;
  }  
  cout << x << endl;
}

Measured memory_bytes: 1792
n = int(input())
an = sorted([int(i) for i in input().split()])
bn = sorted([0]+[int(i) for i in input().split()])
cn = sorted([int(i) for i in input().split()])
dpb = [0]*(n+1)
dpc = [0]*n
cnt = 0
for i in range(n+1):
  while cnt < n and bn[i] > an[cnt]:
    cnt += 1
  dpb[i] = cnt
cnt = 0
temp = 0
for i in range(n):
  while cnt < n+1 and cn[i] > bn[cnt]:
    temp += dpb[cnt]
    cnt += 1
  dpc[i] = temp
print(sum(dpc))

Measured memory_bytes: 23460
#include <iostream>
#include <set>
using namespace std;
int main(){
	int n,k;
	set<int> a;
	cin >> n >> k;
	for(int i= 0;i < k;i++){
		int d;
		cin >> d;
		for(int j = 0;j < d;j++){
			int buf;
			cin >> buf;
			a.insert(buf);
		}
	}
	cout << (n - a.size());

	return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans =0;
    for(int i=0;i<n;i++){
        if(s[i] == 'A'){
            if(s[i+1] == 'B'){
                if(s[i+2] == 'C'){
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class DisjointSet{
    public:
    vi rank, p;
    
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        rep(i,size)makeSet(i);
    }
    
    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }
    
    bool same(int x,int y){
        return findSet(x)==findSet(y);
    }
    
    void unite(int x,int y){
        link(findSet(x),findSet(y));
    }
    
    void link(int x,int y){
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y]){
                rank[y]++;
            }
        }
    }
    
    int findSet(int x){
        if(x!=p[x]){
            p[x]=findSet(p[x]);
        }
        return p[x];
    }
};

void run(){
    int n,m;
    cin>>n>>m;
    DisjointSet uf(n+m);
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int l;
            cin>>l;
            uf.unite(i,n+l-1);
        }
    }
    rep(i,n-1){
        if(!uf.same(i,i+1)){
            cout<<"NO"<<endl;
            return;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int 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;
}

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 / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
}
if(s=="Rainy"){
    cout<<"Sunny"<<endl;
}
if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
}

}









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


int main(){
	int a,b,h,m;
	
	cin >> a >> b >> h >> m;
	long double alpha = 2*PI*((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);
	long double c =  (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(alpha);
	
	printf("%.20Lf", sqrt(c));
	
		
}



Measured memory_bytes: 4160
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<climits>
#include<set> 
#include<string> 
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 1000
#define E5 10000 
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,b) for(lld i=a;i<b;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,b) for(lld i=b-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector
const double EPS = 1e-6;
/*  //prime sieve if needed 
//prime factors of number
int prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}
*/
lld gcd(lld a,lld b)
{
    if(a==0)
     return b; 
    return gcd(b%a,a); 
}
//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
int main()
{
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld x; 
    cin>>x; 
   lld ans=1; 
    if(x>=400 &&x<=599) 
     ans=8; 
    if(x>=600 && x<=799) 
    ans=7; 
    if(x>=800 && x<=999) 
    ans=6; 
    if(x>=1000 && x<=1199) 
     ans=5; 
    if(x>=1200 && x<=1399) 
     ans=4; 
     if(x>=1400 && x<=1599) 
      ans=3; 
     if(x>=1600 && x<=1799) 
     ans=2; 
cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 3648
from bisect import bisect

A, B, Q = map(int, input().split())
INF = 10 ** 20
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
x = [int(input()) for _ in range(Q)]

for i in x:
    ans = INF
    idx_s = bisect(s, i)
    idx_t = bisect(t, i)
    for S in [s[idx_s - 1], s[idx_s]]:
        for T in [t[idx_t - 1], t[idx_t]]:
            d1 = abs(i - S) + abs(S - T)
            d2 = abs(i - T) + abs(S - T)
            ans = min(ans, d1, d2)
    print(ans)


Measured memory_bytes: 17664
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n;
    cin >> n ;
    int d[n]; 
    rep(i ,n){
        cin >> d[i];
    }
    int ans=1000000;
    rep(i,201){
        int cos =0;
        int g = i-100; 
        rep(j,n){
            cos+=(g-d[j])*(g-d[j]);
        }
        ans = min(cos,ans);
    }
    pri(ans);
    
    

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int k,x;
    cin >> k >> x;
    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256