akhauriyash/Code-Regression huggingface dataset:
n=int(input())
x=list(map(int, input().strip().split()))
X=0
for i in range(n):
    X+=x[i]
XX=0
for i in range(n):
    XX+=(x[i])**2
s=X//n
t=s+1
S=n*(s**2)-2*s*X+XX
T=n*(t**2)-2*t*X+XX
print(min(S,T))

Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;

const ll N = 2e5 + 10;

int n;
vector <int> adj[N];
int a[N];

int dfs(int v, int p) {
	int ans = 0;
	for (auto u : adj[v]) {
		if(u == p)	continue;
		if(0 < a[v] - a[u])
			ans = max(ans, dfs(u, v) ^ 1);
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)	cin	>> a[i];
	for (int i = 0; i < n - 1; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		adj[v].push_back(u), adj[u].push_back(v);
	}
	vector <int> ans;
	for (int i = 0; i < n; i++) {
		if(dfs(i, i))	ans.push_back(i);
	}
	for (auto u : ans)
		cout << u + 1 << " ";
	cout << "\n";
}

Measured memory_bytes: 5120
/* package whatever; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int[] arr = new int[3];
		for(int i = 0; i < 3; ++i)
			arr[i] = in.nextInt();
			
		Arrays.sort(arr);
		if(arr[0] == arr[1]) System.out.println(arr[2]);
		else System.out.println(arr[0]);
	}
}

Measured memory_bytes: 22484
import sys
import math

primes = [2]
for line in sys.stdin:
  try:
    n = int(line)
    for i in range(max(primes) + 1, n):
      if i % 2 == 0:
        continue
      elif math.sqrt(i) == 0:
        continue
      elif len([j for j in primes if i % j == 0]) > 0:
        continue
      primes.append(i)
    if n == 3:
      print(2, end=" ")
    else:
      for i in range(n - 1, 1, -1):
        if i % 2 == 0:
          continue
        elif math.sqrt(i) == 0:
          continue
        elif len([j for j in primes if i % j == 0 and i != j]) > 0:
          continue
        print(i, end=" ")
        break
    for i in range(n + 1, n + 1000):
      if i % 2 == 0:
        continue
      elif math.sqrt(i) == 0:
        continue
      elif len([j for j in primes if i % j == 0 and i != j]) > 0:
        continue
      print(i)
      break
  except:
    break

Measured memory_bytes: 5704
fun main(args: Array<String>) {
    val list = readLine()!!.split(" ").map(String::toLong)
    val n = list[0]
    val a = list[1]
    val b = list[2]
    val sum = a + b
    val rem = n % sum
    val ans = n / sum * a + if (rem > a) a else rem
    println(ans)
}


Measured memory_bytes: 38200
a, b = input().split()

list_a = [0]*int(b)
list_b = [0]*int(a)

for i in range(0,int(b)):
    list_a[i] = int(a)*10**i

for i in range(0,int(a)):
    list_b[i] = int(b)*10**i
    
a_r = sum(list_a) 
b_r =sum(list_b)

if(a<b):
    print(str(a_r))
elif(a>b):
    print(str(b_r))
else:
    print(str(a_r))

Measured memory_bytes: 3064
L=list(input())
mod=10**9+7
N=len(L)
data=[0]*N
data[0]=1
for i in range(1,N):
    data[i]=data[i-1]*3%mod
    
ans=0
num=1
for i in range(N):
    if L[i]=="0":
        continue
    else:
        #直前まで一緒でこの位で０にするとこれ以降自由に選べる
        ans=(ans+num*data[N-1-i])%mod
        num=num*2%mod

ans=(ans+num)%mod
print(ans)

Measured memory_bytes: 50544
def solve():
    n = int(input())
    s = input()
    q = int(input())
    ks = list(map(int, input().split()))

    for k in ks:
        ans = 0
        cnt = 0
        d = 0
        m = 0
        for i in range(n):
            if s[i] == 'D':
                d += 1
            elif s[i] == 'M':
                m += 1
                cnt += d
            elif s[i] == 'C':
                ans += cnt

            if i >= k - 1:
                if s[i - k + 1] == 'D':
                    cnt -= m
                    d -= 1
                elif s[i - k + 1] == 'M':
                    m -= 1

        print(ans)


if __name__ == '__main__':
    solve()

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

int main() {
    int i = 0, j = 0, x, y[10000];
    while (1) {
        cin >> x;
        if (x == 0) break;
        y[i] = x;
        i++;
    }
    while (j != i) {
        cout << "Case " << j+1 << ": " << y[j] << endl;
        j++;
    }
    return 0;
}



Measured memory_bytes: 3044
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
const int maxn = 50+10;
using namespace std;

int n;
int a[maxn];

void solve(){
    sort(a+1, a+1+n);
    double mid = (a[1] + a[2])/2.0;
    //printf("%.5f\n",mid);
    for(int i = 3 ; i <= n ; i++){
        mid = (mid + a[i])/2.0;
    }
    printf("%.6f\n",mid);
}

int main(){
    while(~scanf("%d",&n)){
        for(int i = 1 ; i <= n ;i++){
            scanf("%d",&a[i]);
        }
        solve();
    }
    return 0;
}


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

struct p
{
    int a,pos;
}b[200005];
int a[200005];
bool cmp(p b,p c)
{
    return b.a<c.a;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&b[i].a);
        b[i].pos=i;
    }
    sort(b,b+n,cmp);
    int len=n/2;
    for(int i=0;i<len;i++)
        a[b[i].pos]=b[len].a;
    for(int i=len;i<n;i++)
        a[b[i].pos]=b[len-1].a;
    for(int i=0;i<n;i++)
        printf("%d\n",a[i]);
    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define rsort_v(v) std::sort(v.rbegin(), v.rend())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, N, H, W);
	out((N - H + 1)*(N - W + 1));
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
  while(1){
    int data[10001][4]={0};
    int n,p;
    int max=0,maxn;
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin >> p;
      data[i][0]=p;
      cin >> data[i][1] >> data[i][2];
      data[i][3]=data[i][1]+data[i][2];
    }
    for(int i=0;i<n;i++){
      if(max<data[i][3]){
	max=data[i][3];
	maxn=i;
      }
    }
    cout << data[maxn][0] << " " << max << endl;
  }
}

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

using namespace std;
int main()
{
    // 整数の入力
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> arriveAt(N);
    for( int i = 0;i < N;++i )
        cin >> arriveAt[i];
    std::sort(arriveAt.begin(),arriveAt.end());

    int total = 0;
    int current = 0;
    int start = 0;
    for( int i = 0;i < N;++i )
    {
        int arrive = arriveAt[i];
        if( start == 0 || current >= C || start + K < arrive )
        {
            ++total;
            start = arrive;
            current = 0;
        }
        ++current;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int w;
    bool y=1;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='C'&&y) {w=i;y=0;}
        if(s[i]=='F'&&w<i) {cout<<"Yes";return 0;}
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>
#define LL long long
#define PP std::pair<int,int>
#define TT std::tuple<int,int,int>
LL N, T;
LL A[100010];
LL M[100010];
LL m[100010];
int main() {
	std::cin >> N >> T;
	for (LL i = 1; i <= N; i++) {
		std::cin >> A[i];
	}
	m[1] = A[1];
	for (LL i = 2; i <= N; i++) {
		m[i] = std::min(m[i - 1], A[i]);
	}
	M[N] = A[N];
	for (LL i = N - 1; i >= 1; i--) {
		M[i] = std::max(M[i + 1], A[i]);
	}
	LL dif = 0;
	LL ans = 0;
	for (int i = 1; i <= N; i++) {
		if (dif == M[i] - A[i]) {
			ans++;
		}
		else if (dif < M[i] - A[i]) {
			ans = 1;
			dif = M[i] - A[i];
		}
	}
	dif = 0;
	LL sum = 0;
	for (int i = 1; i <= N; i++) {
		if (dif == A[i] - m[i]) {
			sum++;
		}
		else if (dif < A[i] - m[i]) {
			sum = 1;
			dif = A[i] - m[i];
		}
	}
	std::cout << std::min(ans, sum) << std::endl;
	return 0;
}

Measured memory_bytes: 2560
import sys
mod = 998244353
input = sys.stdin.readline
N, M, K = map(int, input().split())
fact = [1] * (N + 1)
for i in range(1, N + 1): fact[i] = (fact[i-1] * i) % mod
revfact = [1] * (N + 1)
revfact[N] = pow(fact[N], mod - 2, mod)
for i in reversed(range(1, N)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod

def comb(n, r):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

def solve():
    ans = 0
    for k in range(K + 1):
        ans += (M * pow(M - 1, N - 1 - k, mod) * comb(N - 1, k)) % mod
        ans %= mod
    print(ans)


    return  0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 24576
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  sm=sum(l)

  c=0
  i=0
  while True:
    if l[i]>0:
      l[i]-=1
      sm-=1

      if i+1==n or l[i+1]==0:
        c+=1

    i+=1
    if i>=n:
      i=0

    if sm==0:
      return c

print(main())


Measured memory_bytes: 5420
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]

d=[['#']*(w+2) for i in range(h+2)]
for i in range(h):
  for j in range(w):
    d[i+1][j+1]=a[i][j]
for i in range(h+2):
  print(*d[i],sep='')

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

int N;
std::vector<int> a;
std::vector<int> b;
std::vector<int> c;

// i日目で
//  - 最後にAを選んだ最大値を memo[i][0]
//  - 最後にBを選んだ最大値を memo[i][1]
//  - 最後にCを選んだ最大値を memo[i][2]
// とする
std::vector<std::vector<int>> dp(100000 + 1, std::vector<int>(3, -1));

int main()
{
    // 入力
    std::cin >> N;
    for (int i = 0; i < N; i++)
    {
        int a_in, b_in, c_in;
        std::cin >> a_in >> b_in >> c_in;
        a.push_back(a_in);
        b.push_back(b_in);
        c.push_back(c_in);
    }

    // 問題を解く
    for (int i = 0; i <= N; i++)
    {
        // 0日目は何も選んでいないのですべて0
        if (i == 0)
        {
            dp[i][0] = dp[i][1] = dp[i][2] = 0;
            continue;
        }

        // 1日目以降
        if (i > 0)
        {
            dp[i][0] = std::max(dp[i - 1][1] + a[i - 1], dp[i - 1][2] + a[i - 1]);
            dp[i][1] = std::max(dp[i - 1][0] + b[i - 1], dp[i - 1][2] + b[i - 1]);
            dp[i][2] = std::max(dp[i - 1][0] + c[i - 1], dp[i - 1][1] + c[i - 1]);
        }
    }
    int ans = *max_element(dp[N].begin(), dp[N].end());
    std::cout << ans << std::endl;
    return 0;
}

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

int asc(const void *x, const void *y) {
	const int* a=(const int*)x;
	const int* b=(const int*)y;
	if(*a>*b)return 1;
	if(*a<*b)return -1;
	return 0;
}

int main(){

    int kids;
    int candy_max;
    int array[128] = {0};
    int happy = 0;
    int pointer = 0;
    int num;

    scanf("%d %d\n",&kids,&candy_max);
    int candy = candy_max;

    for(int i=0; i<kids; i++){
        scanf("%d",&array[i]);
    }

    //sort
    qsort( array, kids, sizeof(array[0]), asc);

    //degug
    //printf("degug:");
    //for(int i=0; i<kids; i++){
    //    printf("%d ", array[i]);
    //}
    //printf("\n");

    //candyを小さいほうから割り当てる
    for(int i=0; i < kids; i++){
        candy -= array[i];
        if(candy == 0){
            happy++;
            printf("%d",happy);
            return 0;
        } 
        if(candy <= 0){
            printf("%d",happy);
            return 0;
        }
        happy++;
    }
    
    if(candy > 0 && candy != candy_max){
        happy--;
        printf("%d",happy);
        return 0;
    }

    printf("0");
    return 0;
}


Measured memory_bytes: 128
def solve():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))

    left = 0
    right = 10 ** 9
    while right - left > 1:
        mid = (right+left) // 2
        cnt = 0
        for a in A:
            cnt += (a-1) // mid
        
        if cnt <= K:
            right = mid
        else:
            left = mid

    print(right)
    
if __name__ == '__main__':
    solve()


Measured memory_bytes: 104080
mod = 10**9+7
N = int(input())
s1 = input()
s2 = input()
ans = 1
cur = 0
i = 0
while i < N:
    if s1[i] == s2[i]:
        ans *= 3-cur
        ans %= mod
        i += 1
        cur = 1
    else:
        if cur == 2:
            ans *= 3
        else:
            ans *= (3-cur)*(2-cur)
        ans %= mod
        i += 2
        cur = 2
print(ans)

Measured memory_bytes: 61624
#include<bits/stdc++.h>
using namespace std;
int dis[100005];
int n;
vector<int>vec[100005];
void dfs(int i)
{
	dis[i]=1;
	for(int j=0;j<vec[i].size();j++)
		if(dis[vec[i][j]]==0)
		{
			dfs(vec[i][j]);
			dis[i]+=dis[vec[i][j]];
		}
}
vector<int>ans;
bool vis[100005],ok;
void dfs2(int x)
{
	vis[x]=1;
	if(!ok)ans.push_back(x);
	if(x==n)
	{
		ok=1;
		return;
	}
	for(int i=0;i<vec[x].size();i++)
		if(!vis[vec[x][i]])
			dfs2(vec[x][i]);
	if(!ok)ans.pop_back();
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	dfs(1);
//	for(int i=1;i<=n;i++)
//		cout<<dis[i]<<' ';
//	cout<<endl;
	dfs2(1);
	int x=ans[(ans.size()+1)/2];
//	for(int i=0;i<ans.size();i++)
//		cout<<ans[i]<<' ';
//	cout<<endl;
	x=dis[x];
	if(x>=n-x)cout<<"Snuke";
	else cout<<"Fennec";
	return 0;
}


Measured memory_bytes: 11516
#include <stdio.h>

#define fd(type, fn)	type fn(P a, P b
#define ifd(type, fn)	inline fd(type, fn)

typedef double frac;

typedef struct { frac x, y; } Point, P;

ifd(frac, cross))	{ return (a.x * b.y - a.y * b.x); }
ifd(frac, dot))	{ return (a.x * b.x + a.y * b.y); }
ifd(P, plus))		{ P r = {a.x + b.x, a.y + b.y}; return r;}
ifd(P, minus))		{ P r = {a.x - b.x, a.y - b.y}; return r;}
ifd(frac, norm)) { return (a.x * a.x + a.y * a.y); }

fd(int, ccw), P c){
	b = minus(b, a), c = minus(c, a);
	if (cross(b, c) > 0) return +1;			// ccw
	if (cross(b, c) < 0) return -1;			// cw
	if (dot(b, c) < 0)	 return +2;			// c-a-b
	if (norm(b, b) < norm(c, c)) return -2;	// a-b-c
	return 0;
}

int main(void)
{
	P ps[4];
	frac x, y;
	while (~scanf("%lf %lf", &x, &y)){
		int i;

		*ps = (P){x, y};
		for (i = 1; i < 4; i++){
			scanf("%lf %lf", &x, &y);
			ps[i] = (P){x, y};
		}

		if (ccw(ps[0], ps[1], ps[3]) == ccw(ps[1], ps[2], ps[3]) && ccw(ps[1], ps[2], ps[3]) == ccw(ps[2], ps[0], ps[3])){
			puts("YES");
		}
		else puts("NO");
	}
	return (0);
}

Measured memory_bytes: 612
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long a,b,c,d=0,e=0;
    cin>>a>>b>>c;
    if(a==b && b==c || a!=b && b!=c && a!=c){cout<<"No";return 0;}
    else{cout<<"Yes";}
    return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  string s;
  cin >> s;

  REP(i, s.size()) {
    if (s[i] == s[i - 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CHSI solver = new CHSI();
        solver.solve(1, in, out);
        out.close();
    }

    static class CHSI {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt(), m = in.nextInt();

            long oneTry = m * 1900 + (n - m) * 100;
            long numTries = 1L << m;

            long answer = oneTry * numTries;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define int long long
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B, class C> A power ( A x, B n, C mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A> A lcm ( A x, A y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A> inline boolean chmax ( A &a, const A &b ) { return b > a ? a = b, true : false; }
    template<class A> inline boolean chmin ( A &a, const A &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int H, W;
        int h, w;
        read H >> W >> h >> w;
        echo ( H-h ) * (W-w) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>

struct P{
	double x, y;
};

struct Triangle{
	P A, B, C;
};

double distance(P p1, P p2){
	double dx = p1.x - p2.x,
		dy = p1.y - p2.y;
	return sqrt(dx*dx+dy*dy);
}

double getArea(Triangle t){
	double a = distance(t.B, t.C),
		b = distance(t.A, t.C),
		c = distance(t.A, t.B),
		s = (a+b+c) / 2;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main(){
	P ps[21];
	int n = 0;
	for(;~scanf("%lf,%lf", &ps[n].x, &ps[n].y);n++){}
	double S = 0;
	for(int i=2;i<n;i++){
		Triangle t = {ps[0], ps[i-1], ps[i]};
		S += getArea(t);
	}
	printf("%.6f\n", S);
}

Measured memory_bytes: 1240
using System;
class Program
{
  static void Main(string[] args)
  {
    int a, b, k;
    string[] s = Console.ReadLine().Split(' ');
    a = int.Parse(s[0]);
    b = int.Parse(s[1]);
    k = int.Parse(s[3]);
    if (k <= a)
    {
      Console.WriteLine(k);
    }
    else if (k - a < b)
    {
      Console.WriteLine(a);
    }
    else
    {
      Console.WriteLine(2 * a - k + b);
    }
  }
}

Measured memory_bytes: 27432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s1;
    string s2;
    cin >> s1;
    cin >> s2;
    if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])cout << "YES" << endl;
    else cout << "NO" << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
	int n;
	while(cin>>n,n){
		string name[11];
		int	w[11],s[11];
		REP(i,n)cin>>name[i]>>w[i]>>s[i];
		vector<int> seq(n);
		REP(i,n)seq[i] = i;
		int minG = INF;
		vector<int> ans;
		do{
			int sum = 0;
			int G = 0;
			bool ng = false;
			REP(i,n){
				int j = seq[i];
				if(s[j] < sum)ng = true;
				sum += w[j];
			}
			if(ng)continue;
			REP(i,n){
				int j = seq[i];
				G += (n - i) * w[j];
			}
			if(G < minG){
				minG = G;
				ans = seq;
			}
		}while(next_permutation(seq.begin(), seq.end()));
		REP(i,n){
			int j = ans[n - 1 - i];
			cout<<name[j]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
 
	//multiset<int> bag;
        int n = 0;
        int res = 0;
        
        for(int i=0;i<A;i++){
            
            if(n >= K){
                cout << res << endl;
              	return 0;
                //break;
            }
            res++;
            n++;
            //cout << res << endl;
        }
        n = n +B;
        for(int i=0;i<C;i++){
            //cout << res << " " << n << endl;
            if(n >= K){
                cout << res << endl;
              	return 0;
                //break;
            }
            res--;
            n++;
        }
        
        
        
        
        cout << res << endl;
 
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    ll A[X], B[Y], C[Z];
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];

    // check 1 and 2
    ll sumAB[X * Y];
    int itr = 0;
    REP(i, X) {
        REP(j, Y) {
            sumAB[itr] = A[i] + B[j];
            itr++;
        }
    }
    sort(sumAB, sumAB + X * Y, greater<ll>());

    int abK = min(X * Y, K);
    ll s[abK * Z];
    itr = 0;
    REP(i, abK) {
        REP(j, Z) {
            s[itr] = sumAB[i] + C[j];
            itr++;
        }
    }
    sort(s, s + abK * Z, greater<ll>());
    REP(i, K) {
        cout << s[i] << endl;
    }

    return 0;
}


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

using lint = long long;
int main() {
	lint q, h, s, d;
	scanf("%lld%lld%lld%lld", &q, &h, &s, &d);
	lint n;
	scanf("%lld", &n);
	h = std::min(h, q * 2);
	s = std::min(s, h * 2);
	d = std::min(d, s * 2);
	lint ans = (n / 2)*d;
	if (n % 2 == 1)ans += s;
	printf("%lld", ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int Dishes[5], min_min=10, min_i=0, s=0;
  for (int i = 0; i < 5; i++){
    cin >> Dishes[i];
    if (Dishes[i]%10 != 0 && Dishes[i]%10 < min_min){
      min_min = Dishes[i]%10;
      min_i = i;
    }
  }

  for (int i = 0; i < 5; i++){
    if (i!=min_i && Dishes[i]%10 != 0){
      Dishes[i] = (Dishes[i] / 10 + 1) * 10;
    }
    s += (Dishes[i]);
  }
  printf("%d\n", s);
  
}


Measured memory_bytes: 3764
N,H,W=list(map(int,input().split()))
A=[]
B=[]
for i in range(N):
	a,b=list(map(int,input().split()))
	A.append(a)
	B.append(b)


c=0
for i in range(N):
	if A[i]>=H and B[i]>=W: c+=1

print(c)

Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;

int main(void) {
    ll N, D, X;
    cin >> N;
    cin >> D >> X;
    ll a;
    ll i, j;
    ll ans=0;
    
    for(i=0; i<N; i++) {
        cin >> a;
        for(j=0; j*a+1<=D; j++) {
            ans++;
        }
    }
    
    cout << ans+X << endl;
}


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

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

    int n;
    cin >> n;
    vector<int> L(n);
    REP(i, n) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    REP(b, n) REP(a, b) {
        int ab = L[a] + L[b];
        int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
        int l = b + 1;
        ans += r - l;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = a; i < (int)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
  int n, d ;
  cin >> n >> d ;
  vector<vector<int>> poi(n,vector<int>(d)) ;
  int dis, sum ;
  int count = 0 ;
  dis = 0 ;
  sum = 0 ;
  
  
  REP(i,n){
    REP(j,d){
      cin >> poi.at(i).at(j) ;
  //    cout << poi.at(i).at(j) <<endl;
    }
  }
  REP(i,n-1){
    FOR(j,i+1,n){
      REP(k,d){
        dis = poi.at(i).at(k)-poi.at(j).at(k) ;
        sum += dis*dis ;
  //      cout << sum << endl ;
      }
        REP(l,sum+1){
          if(l*l==sum){
            count++ ;
            break ;
          }
        }
      sum = 0 ;
    }
  }
  
  cout << count <<endl ;
      
  

  return 0 ;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Tiles t = new Tiles(sc.nextLine());
		System.out.println(t.check101());
	}

}
class Tiles{
	char[] chars;
	Tiles(String s){
		chars = s.toCharArray();
//		System.out.println(chars.length);

	}
	int check101(){
		char c = '1';
		int count =0;
//		System.out.println(chars.length);
		for(int i = 0; i < chars.length; i++) {
			if(chars[i] == c) {
				count++;
//				System.out.println(count);
			}
			if(c == '1') {
				c = '0';
			}else {
				c = '1';
			}
//			System.out.println(c);
		}
		if(count <= chars.length / 2) {
			return count;
		}else {
			return chars.length -count;
		}
	}
}


Measured memory_bytes: 28084
n=int(input())
dp=[[0for _ in range(3)]for _ in range(n)]
for i in range(n):
  a,b,c=map(int,input().split())
  if i==0:dp[i]=[a,b,c]
  else:
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))

Measured memory_bytes: 24308
while True:
    n=int(input())

    if n==0:
        break
    a=[]
    for i in range(n):
        a=a+[int(input())]
    sum=0
    for i in range(n):
        sum+=a[i]

    score=int((sum-max(a)-min(a))/(n-2))
    print(score)

Measured memory_bytes: 7532
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;

    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    vector<int> B(N, 0);
    for (int i = 0; i < N; i++) cin >> B[i];
    sort(B.begin(), B.end());

    vector<int> C(N, 0);
    for (int i = 0; i < N; i++) cin >> C[i];
    sort(C.begin(), C.end());

    ll total = 0;
    for (int i = 0; i < N; i++) {
        auto it_c = upper_bound(C.begin(), C.end(), B[i]);
        if (it_c == C.cend()) continue;
        ll bc = distance(it_c, C.end());
        
        auto it_a = lower_bound(A.begin(), A.end(), B[i]);
        if (it_a == A.cbegin()) continue;
        ll ab = distance(A.begin(), it_a);
        total += ab * bc;
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define len(a) (int)a.size()
using namespace std;
const int INF = 1e9;

int main() {
    string s, t; cin >> s >> t;
    int n = len(s)-len(t)+1;
    int ans = INF;
    rep(i, n) {
        int cost = 0;
        rep(j, len(t)) {
            if (t[j] != s[i+j]) cost++;
        }
        ans = min(cost, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
fn main() {
    input! {
        mut a: isize, b: isize,
        mut c: isize, d: isize
    }

    let mut i = 0;

    loop {
        if i % 2 == 0 {
            c -= b;
        } else {
            a -= d;
        }

        i += 1;

        if a <= 0 {
            println!("No");
            break;
        }
        if c <= 0 {
            println!("Yes");
            break;
        }
    }
}


Measured memory_bytes: 2140
fn b() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("input error");
    let s: Vec<char> = input.trim_right().chars().collect();

    let end = (s.len() - 1)/2;
    for i in 0..(end / 2 + 1) {
        if s[i] != s[end - i - 1] {
            println!("No");
            return;
        }
    }

    let begin = (s.len() + 3) / 2;
    for i in (begin - 1)..s.len() {
        if s[i] != s[s.len() - i - 1] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn main() {
    b();
}

Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll A[200010];
ll sum[200010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++) cin>>A[i];
    sum[0]=A[0];
    for(ll i=1;i<N;i++){
        sum[i]=(sum[i-1]+A[i])%MOD;
    }
    ll ans=0;
    for(ll i=0;i<N-1;i++){
        ans=(ans+A[i]*(sum[N-1]-sum[i]+MOD)%MOD)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

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

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    n = int(input())
    s = input()
    t = input()

    # See:
    # https://www.youtube.com/watch?v=VX8cGy7kNTE
    for l in range(n, 2 * n + 1):
        s_end = s[-(2 * n - l):]
        t_start = t[:2 * n - l]

        if s_end == t_start:
            print(len(s) + len(t) - len(s_end))
            exit()

    print(len(s) + len(t))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = 417;
const int mod = (int)1e9 + 7;

int n, c;
int a[MAXN];
int b[MAXN];

void read()
{
	cin >> n >> c;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
}

int dp[MAXN][MAXN];

int rec(int pos, int c)
{
	if(pos == n) return c == 0;

	int &memo = dp[pos][c];
	if(memo != -1) return memo;
	memo = 0;

	for(int v = a[pos]; v <= b[pos]; v++)
	{
		int curr = 1;
		for(int cc = 0; cc <= c; cc++)
		{
			memo = (memo + curr * 1ll * rec(pos + 1, c - cc)) % mod;
			curr = (curr * 1ll * v) % mod;
		}
	}

	return memo;
}

int sum[MAXN][MAXN];

void solve()
{
	for(int v = 1; v < MAXN; v++)
	{
		int p = 1;
		for(int i = 0; i <= c; i++)
		{
			sum[v][i] = (sum[v - 1][i] + p) % mod;
			p = (p * 1ll * v) % mod;
		}
	}

	dp[n][0] = 1;
	for(int i = n; i >= 1; i--)
		for(int C = 0; C <= c; C++)
			if(dp[i][C])
				for(int cc = 0; cc + C <= c; cc++)
					dp[i - 1][cc + C] = (dp[i - 1][cc + C] + (sum[b[i - 1]][cc] - sum[a[i - 1] - 1][cc] + mod) * 1ll * dp[i][C]) % mod;
	
	cout << dp[0][c] << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
double maxvolume(double s) 
{ 
    double length = s / 3; 
    s -= length; 
    double breadth = s / 2;  
    double height = s - breadth; 
  
    return length * breadth * height; 
} 
int32_t main(){
	cout<<setprecision(6)<<fixed;
  	double d;
  	cin>>d; 
  	cout<<maxvolume(d)<<endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  int K;
  cin >> K >> S;

  if ((int)S.length() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K) << "..." << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define msi map<string,int>
#define si set<int>
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define hell 1000000007
#define mp make_pair
#define	endl '\n'

using namespace std;
void solve()
{
int a,b,c;
cin>>a>>b>>c;
if(a+b+c>=22)
	cout<<"bust";
else
	cout<<"win";
} 



signed main()
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
    return 0;
}

Measured memory_bytes: 256
X = int(input())

if X == 2:
    ans = X
else:
    d = X + 1 if X % 2 == 0 else X
    while True:
        i = 3
        while i * i <= d:
            if d % i == 0:
                break
            i += 2
        else:
            ans = d
            break
        d += 2

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    string s; cin >> s;
    vector<int> east(n,0), west(n,0), cnt(n, 0);
    for (int i = 0; i < n-1; i++){
        if (s[i] == 'E') east[i+1] = east[i] + 1;
        else east[i+1] = east[i];
    }
    for (int i = n-1; i > 0; i--){
        if (s[i] == 'W') west[i-1] = west[i] + 1;
        else west[i-1] = west[i];
    }
    for (int i = 0; i < n; i++) cnt[i] = east[i] + west[i];
    sort(cnt.begin(), cnt.end());
    cout << n - *(cnt.end()-1) - 1 << endl;
    return 0;
}

Measured memory_bytes: 4228
#include <cstdio>

int main(){
    int S;
    scanf("%d",&S);
    int h,m,s;
    h = S / (60 * 60);
    m = (S / 60) % 60;
    s = S % 60 % 60;
    printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 2712
# AOJ 0084 Search Engine

require "strscan"

s = StringScanner.new(gets.chomp)
words = []

until s.eos?
  s.skip /[ \.,]+/
  if s.scan(/[^ \.,]+/)
    words << s[0] if (3..6).include?(s[0].length)
  end
end

puts words.join(" ")

Measured memory_bytes: 6132
N = int(input())

M = N - 1 if N % 2 == 1 else N

A = []
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i < j and j != M:
            A.append((i, j))
    M -= 1

print(len(A))
for a in A:
    print(*a)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, N; cin >> N >> A;
    if(N % 500 <= A) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,w;
ll we,v;
ll dp[N][102];
int main(){
scanf("%d%d",&n,&w);
for(int i=0;i<N;++i)
for(int j=0;j<=n;++j)
dp[i][j]=1e10;
dp[0][0]=0;
for(int i=0;i<n;++i)
{
scanf("%d%d",&we,&v);
for(int j=0;j<N;++j)
{
if(dp[j][i]==1e10) continue;
dp[j][i+1]=min(dp[j][i+1],dp[j][i]);
dp[j+v][i+1]=min(dp[j+v][i+1],dp[j][i]+we);
}
} 
for(int j=N-1;j>=0;--j)
if(dp[j][n]<=w)
{cout<<j; return 0;}


}

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

int main(){

    int n;
    cin>>n;
    bool flag=false;
    for(int i=0;i<n;i++){
        char c; cin>>c;
        if(c=='Y') flag=true;
    }
    cout<<(flag?"Four":"Three")<<endl;

    return 0;
}

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

int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    ll arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    ll sum = 0;
    for (int i = 1; i < n; i++)
    {
        if (arr[i] < arr[i - 1])
        {
            sum += arr[i - 1] - arr[i];
            arr[i] = arr[i - 1];
        }
    }
    cout << sum << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int D, c[30], s[400][30];
int ans[400];

// 乱数
unsigned int xor32() {
  static unsigned int x = 2463534242;
  x = x ^ (x << 13); x = x ^ (x >> 17);
  return x = x ^ (x << 15);
}

int val(){
  int last[30];
  REP(i, 26){
    last[i]=0;
  }
  int res=0;
  FOR(i, 1, D+1){
    last[ans[i]]=i;
    res+=s[i-1][ans[i]];
    REP(j, 26){
      res-=c[j]*(i-last[j]);
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  time_t start=clock();
  cin>>D;
  REP(i, 26){
    cin>>c[i];
  }
  REP(i, D){
    REP(j, 26){
      cin>>s[i][j];
    }
  }
  REP(i, D){
    ans[i]=xor32()%26;
  }
  int score=val();
  while(true){
    time_t end=clock();
    if((double)(end-start)/CLOCKS_PER_SEC*1000>1950){
      break;
    }
  }
  REP(i, D){
    cout<<ans[i]+1<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long



int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
#define MAX 10
typedef long long ll;
 
ll d[MAX], v[MAX];
 
ll gcd(ll a, ll b)
{
    return __gcd(a, b);
}
 
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
 
int main()
{
    int n;
 
    while (scanf("%d", &n), n) {
	for (int i = 0; i < n; i++) {
	    scanf("%lld %lld", &d[i], &v[i]);
	    ll a = gcd(d[i], v[i]);
	    d[i] /= a;
	    v[i] /= a;
	}       
     
	ll T = d[0], V = v[0];
	for (int i = 1; i < n; i++) {
	    T = lcm(T, d[i]);
	    V = gcd(V, v[i]);
	}
     
	for (int i = 0; i < n; i++) {
	    ll div = T / d[i];
	    printf("%lld\n", div*v[i]/V);
	}
    }
    return 0;
}

Measured memory_bytes: 2732
import sys
n, m = map(int, input().split())

array = [-1] * n

for i in range(m):
  s,c = map(int, input().split())
  
  s -= 1
  
  if n != 1 and s == 0 and c == 0:
    print(-1)
    sys.exit(0)
  
  if array[s] == -1:
    array[s] = c
    
  elif array[s] == c:
    pass
    
  else:
    print(-1)
    sys.exit(0)
    
if array[0] == -1:
  array[0] = 1
  
for i in range(n):
  if array[i] == -1:
    array[i] = 0
    
if n == 1 and m == 0:
  array[0] = 0

array = map(str, array)
print(''.join(array))

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A + 3);
  int ans = abs(A[1] - A[0]);
  ans += abs(A[2] - A[1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

ll how_many_decendable(const vector<vector<ll>>&tree,vector<ll>&res,ll start,ll parent)
{
    ll ans=0;
    for(auto c:tree[start]){
        if(c!=parent){
            ans=max(ans,how_many_decendable(tree,res,c,start));
        }
    }
    return (res[start]=ans)+1;
}
void tree_distance(const vector<vector<ll>>&tree,vector<ll>&res,ll from,ll parent,ll dist=0)
{
    res[from]=dist;
    for(auto c:tree[from]){
        if(c!=parent){
            tree_distance(tree,res,c,from,dist+1);
        }
    }
}
void get_parent(const vector<vector<ll>>&tree,vector<ll>&res,ll from,ll parent)
{
    for(auto c:tree[from]){
        if(c!=parent){
            get_parent(tree,res,c,from);
        }
    }
    res[from]=parent;
}
int main()
{
    ll n=in(),u=in()-1,v=in()-1;
    vector<vector<ll>>tree(n);
    for(ll i=0;i<n-1;++i){
        ll a=in()-1,b=in()-1;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<ll>decendable(n);how_many_decendable(tree,decendable,v,-1);
    vector<ll>dist(n);      tree_distance(tree,dist,v,-1);
    vector<ll>parent(n);    get_parent(tree,parent,v,-1);
    ll upto=u,up=0,dist_dead_end=-1;
    ll ans=-1;
    do{
        dist_dead_end=max(dist_dead_end,up+decendable[upto]);
        ans=max(ans,dist[upto]+decendable[upto]-1);
        upto=parent[upto];
        ++up;
    }while(up<dist[upto]);
    cout<<ans<<endl;
}


Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    int arr[10];
    cin>>a;
    cin>>b;
    for(int i=0;i<3;i++)
    {
        arr[i]=i+1;
    }
    int i=0;
    while(i<3)
    {
       if(arr[i]!=a&&arr[i]!=b)
       {
           cout<<arr[i];
       }
       i++;
    }
}


Measured memory_bytes: 256