akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - YYMM or MMYY
            var s = Console.ReadLine();

            var left = s.Substring(0, 2);
            var right = s.Substring(2, 2);

            string result = IdentifyPattern(left);
            result += IdentifyPattern(right);

            if (result == "MMMM")
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (result.Contains("NA") | result == "YYYY")
            {
                Console.WriteLine("NA");
            }
            else
            {
                Console.WriteLine(result);
            }
        }

        static string IdentifyPattern(string s)
        {
            int n = int.Parse(s);

            if (n >= 1 && n <= 12)
            {
                return "MM";
            }else if (n >= 0 && n <= 99)
            {
                return "YY";
            }
            else
            {
                return "NA";
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13140
a,b=map(int, input().split())
c=list(map(int, input().split())) 
 
l = [1]
f = [0]*a
f[0] += 1
tmp = 1
s = 0
for i in range(b):
    l.append(c[tmp-1])
    tmp = c[tmp-1]
    if f[tmp-1] != 0:
        s = c[tmp-1]
        t = len(l)+1
        break
    f[tmp-1] += 1

#print(l)
if a > b:
    print(l[b])
    exit()

h = l.index(s) + 1

#print(s,h,t)
l2 = l[h-1:t-1]
#print(l2)
if s == 1:
    id = b % (t - 1)
    print(l2[id])
else:
    id = (b - h + 1) % (t - h)
    print(l2[id])

Measured memory_bytes: 32392
N = 5
lst = []
for e in range(N):
    lst.append(int(input()))
k = int(input())
flag = True
for i,a in enumerate(lst):
    if not flag:
        break
    l = lst[i:]
    for b in l:
        if abs(a-b) > k:
            flag = False
            break
if flag:
    print('Yay!')
else:
    print(':(')

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

int main(){
  int c[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }
  bool iscorrect=true;
  for(int i=0; i<2; i++){
    for(int j=0; j<2; j++){
      if(c[i][j]+c[i+1][j+1]!=c[i+1][j]+c[i][j+1]){
        iscorrect=false; break;
      }
    }
  }
  cout << (iscorrect?"Yes":"No") << endl;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    ll V = 0;
    for (int i=1;i<=N;i++) V += 1LL*i*(N+1-i);
    ll E = 0;
    for (int i=0;i<N-1;i++){
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u,v);
        E += 1LL*u*(N-v+1);
    }
    ll ans = V - E;
    cout << ans << "\n";
}

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

int main()
{
    int a,b;
    cin >> a;
    b = a%100;
    a -=b;
    a /= 100;

    string ans;
    bool yymm=true;
    bool mmyy=true;
    if(b==0 || b>12) yymm=false;
    if(a==0 || a>12) mmyy=false;
    if(yymm&&mmyy) ans="AMBIGUOUS";
    else if(yymm) ans="YYMM";
    else if(mmyy) ans="MMYY";
    else ans="NA";

    cout << ans << endl;
    return 0;
}

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

int main()
{
    int x, a;
    cin >> x >> a;
    int ans = 0;
    if (x - a >= 0)
        ans = 10;
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	int p = abs(a-b), q = abs(b-c), r = abs(c-a);
	cout << min(p+q,min(q+r,r+p)) << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
nodes = gets.chomp.split(' ').map(&:to_i)
nodes.each_with_index do |node, i|
  parent_i = (i + 1) / 2 - 1
  left_child_i = (i + 1) * 2 - 1
  right_child_i = (i + 1) * 2
  parent_k = (parent_i >= 0 && parent_i <= n - 1) ? nodes[parent_i] : nil
  left_child_k = (left_child_i >= 0 && left_child_i <= n - 1) ? nodes[left_child_i] : nil
  right_child_k = (right_child_i >= 0 && right_child_i <= n - 1) ? nodes[right_child_i] : nil
  s =  "node #{i + 1}: key = #{node}, "
  s += "parent key = #{parent_k}, " if parent_k
  s += "left key = #{left_child_k}, " if left_child_k
  s += "right key = #{right_child_k}, " if right_child_k
  puts s
end


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

int main(){
    vector<long long> s(5);
    cin >> s[0] >> s[1] >> s[2] >> s[3] >> s[4];
    long long minv = 10000;
    do{
        long long order_time = 0;
        long long come_time = 0;
        for(long long i = 0; i < 5; i++){
            come_time = order_time + s[i];
            if(come_time % 10 == 0){
                order_time = come_time;
            }
            else{
                order_time = (come_time/10 + 1) * 10;
            }
        }
        minv = min(minv, come_time);
    }while(next_permutation(s.begin(), s.end()));

    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 3596
import queue
import sys
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
readline = sys.stdin.readline


class UnionFind():
    def __init__(self, n=0):
        # 負なら根、非負なら親IDの情報を持たせる。負の値の絶対値で連結成分のサイズを表す（-2なら連結成分サイズ2の根）
        self.d = [-1]*n

    def find(self, x):
        """
        根のIDを返す
        """
        if self.d[x] < 0:
            return x  # 今の頂点が根なら頂点番号を返す
        # 今の頂点が根でないなら親についてfindクエリを投げる. d[x] = find(d[x])で経路縮約できる
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        """
        根同士をくっつける
        """
        x = self.find(x)
        y = self.find(y)  # 根同士をくっつける
        if x == y:
            return False  # 根が同じなら何もする必要はない。Falseを返しているのは、くっつけられたかどうかを返した方が便利なときがあるから（MSTなど）
        if self.d[x] > self.d[y]:
            x, y = y, x  # 小さい方の部分木を大きい方の部分木にくっつけるためにswap。dがマイナスなので不等号が逆になる点に注意
        self.d[x] += self.d[y]  # 連結成分サイズを更新
        self.d[y] = x  # 根をyからxに張り替える
        return True

    def same(self, x, y):
        """
        同じ集合に所属しているかどうか
        """
        return self.find(x) == self.find(y)

    def size(self, x):
        """
        連結成分サイズを返す
        """
        return -self.d[self.find(x)]


uf = UnionFind(n)

for _ in range(m):
    a, b = [int(i) for i in readline().split()]
    a -= 1
    b -= 1
    uf.unite(a, b)

ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))

print(ans)


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

int main(){
  int X;
  cin >> X;
  int A;
  if(X % 8 == 0){
    A = 8;
  }
  else if(X % 4 == 0){
    A = 4;
  }
  else if(X % 2 == 0){
    A = 2;
  }
  else{
    A = 1;
  }
  if(X % 9 == 0){
    A = A * 9;
  }
  else if(X % 3 == 0){
    A = A * 3;
  }
  if(X % 5 == 0){
    A = A * 5;
  }
  cout << 360 / A << endl;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int Mod = 1e9 + 7;
const int inv2 = (Mod + 1) >> 1;

const int maxn = 200100;

int n;
pair<int, int> a[maxn + 5];

int pos[maxn + 5];

int dp[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n) scanf("%d%d", &a[i].x, &a[i].y);
	sort(a, a + n);
	REP(i, 0, n) pos[i] = i;
	sort(pos, pos + n, [&](int x, int y) { return a[x].y > a[y].y; });
	dp[n] = 1;
	int lst = n;
	int sum = 1;
	int ptr = n;
	int Min = oo;
	REP(i, 0, n)
	{
		int x = pos[i];
		if (x < lst)
		{
			int cur = sum;
			while (lst > x)
			{
				--lst;
				(sum += cur) %= Mod;
				dp[lst] = cur;
				(cur <<= 1) %= Mod;
			}
		}
		while (ptr > x)
		{
			if (ptr < n) chkmin(Min, a[ptr].y);
			if (a[x].y > Min) break;
			(sum -= dp[ptr]) %= Mod;
			dp[ptr] = 0;
			--ptr;
		}
	}
	int ans = 0;
	REP(i, 0, n + 1) (ans += dp[i]) %= Mod;
	(ans += Mod) %= Mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3456
using System;
using System.Linq;

class prog{
  static void Main(){
    
    string O = Console.ReadLine();
    string E = Console.ReadLine();
    
    if(O.Length > E.Length) E += " ";
    
    string ans = "";
    for(int i = 0; i < O.Length; i++){
      ans += "" + O[i] + E[i];
    }
    
    Console.WriteLine(ans);
    
  }
}

Measured memory_bytes: 11092
#include <iostream>
#define REP(i,n) for(int i=0; i<n; ++i)
using namespace std;
int wall[101]; // id

int possiblePos(int W, int w){
	int count = 0;
	REP(pos, W){
		count = (wall[pos] == -1) ? 1 + count : 0;
		if (count == w) return pos;
	}
	return -1;
}

int main(){
	while (true){
		int W, q;
		cin >> W >> q;
		if (W == 0) break;
		REP(i, 101) wall[i] = -1;
		REP(i, q){
			char c;
			int id;
			cin >> c >> id;
			if (c == 's'){
				int w;
				cin >> w;
				int pos = possiblePos(W, w);
				if (pos == -1){
					cout << "impossible" << endl;
				}else{
					REP(j, w) wall[pos - j] = id;
					cout << pos - w + 1 << endl;
				}
			} else {
				REP(pos, W) if (wall[pos] == id) wall[pos] = -1;
			}
		}
		cout << "END" << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#define N 200005
#define LL long long
#define PI asin(1)*2
using namespace std;

struct point{
    int x,y;
    point(){};
    point(int x,int y){
        this->x=x;
        this->y=y;
    }
};

point s,t;
int n; 
int dp[N],x[N];
vector<point> p;

int cmp(point a,point b)
{
    return a.x<b.x;
}

int main()
{
    //cout<<PI<<endl;
    while(~scanf("%d%d%d%d",&s.x,&s.y,&t.x,&t.y))
    {
        if(s.x>t.x) swap(s,t);
        point ld=point(s.x,min(s.y,t.y));
        point ru=point(t.x,max(t.y,s.y));
        scanf("%d",&n);
        point tmp;
        while(n--)
        {
            scanf("%d%d",&tmp.x,&tmp.y);
            if(tmp.x>=ld.x&&tmp.x<=ru.x&&tmp.y>=ld.y&&tmp.y<=ru.y)
                p.push_back(tmp);
        }
        sort(p.begin(),p.end(),cmp);
        double ans;
        ans=abs(s.x-t.x)+abs(s.y-t.y);
        ans*=100;
        if(s.x==t.x||s.y==t.y)
        {
            if(p.size()!=0) 
                ans=ans-10*2+10*PI;
        }
        else if(s.y<t.y&&p.size()>0)
        {
            int maxn;
            x[1]=p[0].y;
            int k=1;
            dp[0]=1;
            for(int i=1;i<p.size();i++)
            {
                if(x[k]<p[i].y)
                {
                    x[++k]=p[i].y;
                    dp[i]=k;
                }
                else
                {
                    int l=1,r=k;
                    while(l<=r)
                    {
                        int mid=(l+r)/2;
                        if(x[mid]<=p[i].y)
                            l=mid+1;
                        else
                            r=mid-1;
                    } 
                    dp[i]=l;
                    x[l]=p[i].y;
                }
            }
            maxn=k;
            if(maxn==abs(s.x-t.x)+1||maxn==abs(s.y-t.y)+1)
                ans+=5*PI;
            ans=ans-20*maxn+5*PI*maxn;
        }
        else if(s.y>t.y&&p.size()>0)
        {
            int maxn;
            x[1]=p[p.size()-1].y;
            int k=1;
            dp[p.size()-1]=1;
            for(int i=p.size()-2;i>=0;i--)
            {
                if(x[k]<p[i].y)
                {
                    x[++k]=p[i].y;
                    dp[i]=k;
                }
                else
                {
                    int l=1,r=k;
                    while(l<=r)
                    {
                        int mid=(l+r)/2;
                        if(x[mid]<=p[i].y)
                            l=mid+1;
                        else
                            r=mid-1;
                    } 
                    dp[i]=l;
                    x[l]=p[i].y;
                }
            }
            maxn=k;
            if(maxn==abs(s.x-t.x)+1||maxn==abs(s.y-t.y)+1)
                ans+=5*PI;
            ans=ans-20*maxn+5*PI*maxn;
        }
        printf("%.15lf\n",ans);
        p.clear();
    }
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef pair<int,int> P;
int N;
vector<P> ps;
int dp[5010][5010];
int inf = 1e18;
signed main(){
	rep(i,5010) rep(j,5010) dp[i][j] = inf;
	cin>>N;
	rep(i,N){
		int a,b;
		cin>>b>>a;
		ps.pb(P(b+a,a));
	}
	N = ps.size();
	sort(all(ps));
	dp[0][0] = 0;
	rep(i,N) rep(j,i+1) if(dp[i][j]!=inf){
		int a = ps[i].sc;
		int b = ps[i].fs;
		chmin(dp[i+1][j],dp[i][j]);
		if(dp[i][j]+a<=b) chmin(dp[i+1][j+1],dp[i][j]+a);
	}
	int ans = 0;
	rep(j,N+1) if(dp[N][j]!=inf) ans = j;
	cout<<ans<<endl;
}


Measured memory_bytes: 196608
#include <stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int baisu[3]={};
    int kari;
    for(int i=0;i<N;i++){
        scanf("%d",&kari);
        if(kari%4==0)baisu[2]++;
        else if(kari%2==0)baisu[1]++;
        else baisu[0]++;
    }
    if(baisu[1]==0&&baisu[0]-baisu[2]<=1)printf("Yes");
    else if(baisu[1]!=0&&baisu[0]-baisu[2]<=0)printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
N = gets.to_i
T, A = gets.chomp.split(' ').map(&:to_i)
hlist = gets.chomp.split(' ').take(N).map(&:to_i)
answer = hlist.map.with_index.min_by do |(h, _)|
  (A - (T - h * 0.006)).abs
end[1] + 1
puts answer


Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

const ll MOD = 1000000007;
const int MAX = 2000001;

// fac[n]: n!
// finv[n]: (n!)^-1
// inv[n]: nの逆元
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算 (combination)
// nCk = (n!) * (k!)^-1 * ((n-k)!)^-1 として計算
ll comb(int n, int k) {
  if (n < k) {
    return 0;
  }
  if (n < 0 || k < 0) {
    return 0;
  }
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll X, Y;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> X >> Y;
  if ((X + Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  comb_init();

  ll ans = 0;
  ll num = (X + Y) / 3;
  for (int i = 0; i <= num; i++) {
    int j = num - i;
    if (i + 2 * j == X && 2 * i + j == Y) {
      ans += comb(i + j, i);
      ans %= MOD;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 50076
import java.util.*;
class Main{
    public static void main(String[] args){
        int a,b,area,perimeter;
        Scanner scanner=new Scanner(System.in);
        a=scanner.nextInt();
        b=scanner.nextInt();
        area=a*b;
        perimeter=2*(a+b);
        
        System.out.printf("%d %d\n",area,perimeter);
    }
}





Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int ct = 0 ;
	int n , k; cin >> n >> k ;
	rep(i,0,n){
		int a ;
		cin >> a ;
		if(a>=k) ct++;
	}
	cout << ct << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main() {
    SS(ll,N,A,B);
    if(A%2==0&&B%2==0||A%2!=0&&B%2!=0)p((B-A)/2);
    else p(min(A-1,N-B)+1+(B-A-1)/2);
}

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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] bLeft = new int[n+2], wRight = new int[n+2];
        for(int i=0;i<n;i++) bLeft[i+1] = bLeft[i]+(s[i]=='#'?1:0);
        for(int i=n-1;i>=0;i--) wRight[i+1] = wRight[i+2]+(s[i]=='.'?1:0);
        int ans = n;
        for(int i=1;i<=n;i++){
            int cur = bLeft[i-1]+wRight[i];
            ans = Math.min(ans,cur);
        }
        ans = Math.min(ans,bLeft[n]);
        System.out.println(ans);
    }
}


Measured memory_bytes: 28344
#include<stdio.h>
#include<string.h>
int c[400],t[200],n,m,k,i;
int main()
{
	scanf("%d%d",&n,&m);
	for(i=0;i<2*n;i++)
		c[i]=i+1;
	for(;m--;)
	{
		scanf("%d",&k);
		if(!k)
		{
			for(i=0;i<n;i++)
			{
				t[2*i]=c[i];
				t[2*i+1]=c[n+i];
			}
		}
		else
		{
			memcpy(t,c+k,4*(2*n-k));
			memcpy(t+2*n-k,c,4*k);
		}
		memcpy(c,t,8*n);
	}
	for(i=0;i<2*n;i++)
		printf("%d\n",c[i]);
	return 0;
}

Measured memory_bytes: 616
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r==-1:break
 if m==-1 or f==-1 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')

Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100001],ans=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ans+=a[i];
    }
    if(ans%2==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    ll n;
    cin>>n;
    ll A[n+5],B[n+5];
    for(int i=0;i<n+1;i++)
        cin>>A[i];

    for(int i=0;i<n;i++)
        cin>>B[i];
    ll sum=0;ll aa=0;
    for(int i=0;i<n;i++)
    {
       aa=A[i]+A[i+1];
       if(aa>=B[i])
       {
           sum=sum+B[i];
           if(B[i]>A[i])
              A[i+1]=A[i+1]-(B[i]-A[i]);
       }
       else
       {
           sum+=aa;
           A[i+1]=0;
       }
    }
    cout<<sum<<endl;
     memset(A,0,n+1);
     memset(B,0,n);
}


Measured memory_bytes: 1792
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static class pair implements Comparable<pair> {
		int id;
		int ans;

		pair(int x, int y) {

			id = x;
			ans = y;

		}

		public pair() {

		}

		public int compareTo(pair o) {
			// TODO Auto-generated method stub

			return this.id - o.id;
		}
	}

//	static int mod = (int) 998244353.;
	static int mod = (int) 1e9 + 7;
	static ArrayList<Integer> gr[];
	static long ar[];
	static Scanner sc = new Scanner(System.in);
	static int pri[] = new int[(int) 1e6 + 5];
	static StringBuilder out = new StringBuilder();

	// static long dp[];

	public static void main(String[] args) throws IOException {
		int t = 1;// sc.nextInt();

		while (t-- > 0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int k=sc.nextInt();
			int val=Math.min(a, k);
			long ans=0;
			ans+=val;
			k-=val;
			val=Math.min(b, k);
			k-=val;
			val=Math.min(c, k);
			ans-=val;
			out.append(ans);

		}

		System.out.println(out);
	}
}

Measured memory_bytes: 39712
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;

const double eps = 1e-8;

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

P project(P s1, P s2, P p) {
  P base = s2 - s1;
  double t = dot(p - s1, base)/norm(base);
  return s1 + base * t;
}

P reflect(P s1, P s2, P p) {
  return p + (project(s1, s2, p) - p) * 2.0;
}

P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

struct Elm {
  bool isPoint;
  P p1, p2;
  Elm(P p1) : isPoint(true), p1(p1), p2(0, 0) {}
  Elm(P p1, P p2) : isPoint(false), p1(p1), p2(p2) {}
};

string s;
int p;

Elm exp();
Elm fact();

Elm exp() {
  Elm x = fact();
  while(s[p] == '@') {
    ++p;
    Elm y = fact();
    if(x.isPoint && y.isPoint) {
      x = Elm(x.p1, y.p1);
    } else if(x.isPoint && !y.isPoint) {
      x = Elm(reflect(y.p1, y.p2, x.p1));
    } else if(!x.isPoint && y.isPoint) {
      x = Elm(reflect(x.p1, x.p2, y.p1));
    } else {
      x = Elm(getCrossP(x.p1, x.p2, y.p1, y.p2));
    }
  }
  return x;
}

Elm fact() {
  if(isdigit(s[p+1]) || s[p+1] == '-') {
    ++p;
    string t;
    while(s[p] != ')') t += s[p++];
    ++p;
    replace(t.begin(), t.end(), ',', ' ');
    stringstream ss(t);
    int a, b;
    ss >> a >> b;
    Elm x(P(a, b));
    return x;
  } else {
    ++p;
    Elm x = exp();
    ++p;
    return x;
  }
}

int main() {
  while(cin >> s && s != "#") {
    p = 0;
    Elm res = exp();
    printf("%.10f %.10f\n", res.p1.real(), res.p1.imag());
  }
  return 0;
}

Measured memory_bytes: 1324
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

uint64_t dec_dig(uint64_t num) {
  uint64_t res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

uint64_t gcd(uint64_t a, uint64_t b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

uint64_t lcm(uint64_t a, uint64_t b) { return a * b / gcd(a, b); }

int main() {
  uint32_t N;
  cin >> N;
  vector<uint32_t> P(N);
  ArrayInput(P);
  uint32_t Min = P[0];
  uint32_t res = 0;
  for (uint32_t i = 0; i < N; ++i) {
    if (Min >= P[i]) res++;
    if (Min > P[i]) Min = P[i];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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 factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, k; cin >> n >> k;
    double ans = 0;
    rep1(i, n) {
        int e = 0;
        for (int j=i; j<k; j*=2) e++;
        ans += ((double)1/(double)n) * pow(0.5, e);
    }
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;

    vector<pair<ll, ll>> key;
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        ll s = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            s |= 1<<c;
        }
        key.emplace_back(s, a);
    }

    const ll N = 1<<n;

    vl dp(N, INF);
    dp[0] = 0;
    rep(s, N) {
        rep(i, m) {
            ll t = s | key[i].first;
            ll cost = dp[s] + key[i].second;
            chmin(dp[t], cost);
        }
    }

    ll ans = dp[N-1];
    if(ans == INF) {
        ans = -1;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
from math import sqrt
x = int(input())
l = []
if x == 1:
    print(1)
    exit()
for i in range(1, int(sqrt(x))+1):
    for j in range(2, x+1):
        if 1 <= i**j <= x:
            l.append(i**j)
print(max(l))

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long N = 1e5+200,OO=1e15;
int n,arr[N],k;
int dp[N];
ll solve(int i){
    if(i==n)return 0;
    if(i>=n+1) return OO;

    if(~dp[i])return dp[i];

    ll choice1=abs(arr[i]-arr[i+1])+solve(i+1);
    ll choice2=abs(arr[i]-arr[i+2])+solve(i+2);
    //ll choice3=abs(arr[i]-arr[i+k])+solve(i+k);

    return dp[i]=min(choice1,choice2);
}
int main()
{
    memset(dp,-1,sizeof dp);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",arr+i);
    cout<<solve(1)<<endl;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> v(n),w(n);
  for(Int i=0;i<n;i++) cin>>v[i]>>w[i];
  
  const Int INF = 1e8;
  vector<Int> dp(m+1,-INF);
  dp[0]=0;
  for(Int i=0;i<n;i++)
    for(Int j=0;j+w[i]<=m;j++)
      if(j+w[i]<=m) chmax(dp[j+w[i]],dp[j]+v[i]);
  
  Int ans=0;
  for(Int i=0;i<=m;i++) chmax(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}



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

int main()
{
  int a, b;
  cin >> a >> b;
  int cnt = a >= b ? a : b;
  string s = to_string(a >= b ? b : a);
  for(int i=0; i<cnt; i++)
    cout << s;
  
  cout << endl;
  return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

int main() {
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(u==s) cout<<a-1<<' '<<b<<endl;
  else cout<<a<<' '<<b-1<<endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio : readln, writeln;
import std.string : split;
import std.conv : to;
import std.algorithm : sort;
import std.container : Array, BinaryHeap, RedBlackTree;
import std.typecons : Tuple;

void main()
{
    long X, Y, Z, K;
    {
        auto tmp = readln().split().to!(long[])();
        X = tmp[0];
        Y = tmp[1];
        Z = tmp[2];
        K = tmp[3];
    }
    auto A = readln().split().to!(long[])();
    auto B = readln().split().to!(long[])();
    auto C = readln().split().to!(long[])();
    A.sort!"b<a"();
    B.sort!"b<a"();
    C.sort!"b<a"();

    alias vec3 = Tuple!(long, long, long);
    alias cake = Tuple!(long, vec3);

    auto PQ = BinaryHeap!(Array!cake)();
    PQ.insert(cake(A[0] + B[0] + C[0], vec3(0, 0, 0)));

    auto set = new RedBlackTree!vec3();
    set.insert(vec3(0, 0, 0));

    foreach (_; 0 .. K)
    {
        auto c = PQ.front;
        PQ.removeFront();

        writeln(c[0]);
        auto v = c[1];

        if (v[0] + 1 < X && vec3(v[0] + 1, v[1], v[2]) !in set)
        {
            PQ.insert(cake(A[v[0] + 1] + B[v[1]] + C[v[2]], vec3(v[0] + 1, v[1], v[2])));
            set.insert(vec3(v[0] + 1, v[1], v[2]));
        }

        if (v[1] + 1 < Y && vec3(v[0], v[1] + 1, v[2]) !in set)
        {
            PQ.insert(cake(A[v[0]] + B[v[1] + 1] + C[v[2]], vec3(v[0], v[1] + 1, v[2])));
            set.insert(vec3(v[0], v[1] + 1, v[2]));
        }

        if (v[2] + 1 < Z && vec3(v[0], v[1], v[2] + 1) !in set)
        {
            PQ.insert(cake(A[v[0]] + B[v[1]] + C[v[2] + 1], vec3(v[0], v[1], v[2] + 1)));
            set.insert(vec3(v[0], v[1], v[2] + 1));
        }

    }
}


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

using namespace std;
map<int, int> mp;

int main(){
	int num, tc, res = 0; scanf("%d", &tc);
	while(tc--){
		scanf("%d", &num);
		if(mp.find(num) == mp.end() || mp[num] == 0){
			mp[num] = 1; res++;
		}else{
			mp[num] = 0; res--;
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main()
{
    int $=1;
    ll MOD=1e9+7;
    //cin>>$;
    while($--)
    {
        ll n,ans=0,i;
        cin>>n;
        ll a[n],b[n];
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
            a[i]%=MOD;
        }
        b[n-1]=a[n-1];
        for(i=n-2; i>=0; i--)
            b[i]=(b[i+1]+a[i])%MOD;

        for(i=0; i<n-1; i++)
        {
            ans+=(b[i+1]*a[i])%MOD;
            ans%=MOD;
        }
        cout<<ans<<endl;
    }
}


/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/


Measured memory_bytes: 6724
num = int(input())
number_list = list(map(int, input().split(" ")))


for i in range(num):
    v = number_list[i]
    j = i - 1
    while j >= 0 and number_list[j] > v:
        number_list[j + 1] = number_list[j]
        j -= 1
    number_list[j + 1] = v
    print(*number_list)


Measured memory_bytes: 5980
#include <stdio.h>

int main(void){
	int n,a[10000],t,i,k,m,l;
	
	while(1){
	scanf("%d",&n);
		if(n==0){
			return 0;
		}
	for(t=0;t<n;t++){
		scanf("%d",&a[t]);
	}
	k=0;
	m=0;
	for(t=1;t<n;t++){
		for(i=1;i<n-m;i++){
			if(a[i-1]>a[i]){
				l=a[i];a[i]=a[i-1];a[i-1]=l;
				k++;
			}
		}
		m++;
	}
		printf("%d\n",k);
	}
}

Measured memory_bytes: 608
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
#include<stack>
#define eps 1e-9
using namespace std;
typedef long long ll;
const int maxn = 105;
const int maxm = 1000005;
const int inf = 0x3f3f3f3f;

char s[200005];
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>(s+1);
    int n = strlen(s+1);
    stack<char>sta;
    for(int i = 1;i<=n;i++) {
        if(sta.empty()) sta.push(s[i]);
        else {
            if(s[i]=='S') sta.push(s[i]);
            else 
                if(sta.top()=='S') sta.pop();
            else sta.push(s[i]);
        }
    }
    cout<<sta.size()<<'\n';
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	
int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);
if(a>c){
d=a;
a=c;
c=d;
}
if(a>b){
d=a;
a=b;
b=d;
}
if(b>c){
d=b;
b=c;
c=d;
}
	
printf("%d %d %d\n",a,b,c);
return 0;
}


Measured memory_bytes: 2044
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

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

using namespace std;

typedef pair<int, int> pii;

int a[100010];

int main() {
	int N, S;
	scanf("%d %d", &N, &S);

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

	int l = 0, r = 0, L = 10000000, t = a[0];
	while (r < N)
	{
		if (t >= S)
		{
			L = min(L, (r - l) + 1);
			if (L == 1)
			{
				break;
			}
			t -= a[l];
			l++;
		}
		else
		{
			r++;
			t += a[r];
		}
	}

	printf("%d\n", L == 10000000 ? 0 : L);
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
	int i = 0;
	while(true){
		i++;
		int temp;
		scanf("%d", &temp);
		if(temp == 0){
			break;
		}else{
			printf("Case %d: %d\n", i, temp);
		}
	}
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;

  int x = 0, ans = 0;

  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'I') x++;
    else x--;
    ans = max(ans, x);
  }

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

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        
        int[][][] count = new int[4][3][10];
        for (int i =-0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k =0; k < 10; k++) {
                    count[i][j][k] = 0; 
                }
            }
        }
        for (int i = 0; i < n; i++) {
            String str = br.readLine();
            String[] strs = str.split(" ");
            int b = Integer.parseInt(strs[0]) - 1;
            int f = Integer.parseInt(strs[1]) - 1;
            int r = Integer.parseInt(strs[2]) - 1;
            int v = Integer.parseInt(strs[3]);
            count[b][f][r] += v;
        }
        for(int i = 0; i < 4; i++){
            if(i != 0){
                System.out.println("####################");
            }
            for(int l = 0; l < 3; l++){
                for(int k = 0; k < 10; k++){
                    System.out.print(" ");
                    System.out.print(count[i][l][k]);
                }
                System.out.println();
            }
        }
    }
}

Measured memory_bytes: 24320
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    vector<vector<int>> dp(n,vector<int>(3,0));
    rep(i,3) cin>>dp[0][i];
    for(int i=1;i<n;i++){
        int a,b,c; cin>>a>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
}

Measured memory_bytes: 5760
from itertools import permutations

a = []
for _ in range(5):
    a.append(int(input()))
k = int(input())

ans = True
for p, q in permutations(a, 2):
    if q - p > k:
        ans = False
        break

if ans:
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 3060
import numpy as np

N,D = list(map(int,input().split()))
X = []
for n in range(N):
    X.append(list(map(int,input().split())))
#N個のリスト入力を受け取る

cnt = 0

for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d += (X[i][k]-X[j][k])**2
        d = d**0.5
        if d.is_integer() :
            cnt += 1

print(cnt)

Measured memory_bytes: 12488
a,b,c,x,y = map(int,input().split())

mid = min(x,y)
rest = max(x,y)-mid
if x>y: a_b = a
else: a_b = b

total = 0
# until mid
if 2*c <  a+b:
    total += mid*2 *c
else:
    total += mid   *(a+b)
    
#until end
if 2*c < a_b:
    total += rest*2 *c
else:
    total += rest   *a_b

print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a;string s;
    cin>>a>>s;
    cout<<(a<3200?"red":s)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll x,y;
  cin >> x >> y;
  ll ans = 999999999999;
  if (y - x >= 0) {
    ans = min(ans,y-x);
  }
  if ((-y) - x >= 0) {
    ans = min(ans,(-y)-x+1);
  }
  if (y - (-x) >= 0) {
    ans = min(ans,y-(-x)+1);
  }
  if ((-y) - (-x) >= 0) {
    ans = min(ans,(-y) - (-x)+2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
input = gets.split
enemy_count = input[0].to_i
attack_count = input[1].to_i
enemies = gets.split
afterenemies = enemies.sort_by{|x| x.to_i }
afterenemies.pop(attack_count)
count = 0
afterenemies.each do |enemy|
  count += enemy.to_i
end
puts count


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

int main() {
  int n,m;
  cin>>n>>m;
  int a[m];
  string b[m];
  bool c[n+1],d[n+1];
  for(int i=0;i<m;i++){
    int l;
    string s;
    cin>>l>>s;
    a[i]=l;
    b[i]=s;
  }
  for(int i=1;i<n+1;i++)c[i]=false,d[i]=false;
  int ac=0,wa=0;
  for(int i=0;i<m;i++){
    if(b[i]=="AC")d[a[i]]=true;
  }
  for(int i=0;i<m;i++){
    if(c[a[i]]==false&&d[a[i]]==true){
      if(b[i]=="WA")wa++;
      else {
        ac++;
        c[a[i]]=true;
      }
    }
  }
  cout<<ac<<' '<<wa<<endl;
}


Measured memory_bytes: 6272
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int a, b, c, d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f){
		int num_x = c * e - b * f, den_x = a * e - b * d;
		int num_y = c * d - a * f, den_y = b * d - a * e;
		long double X, Y;
		if(num_x == 0)X = 0.0;
		else X = num_x / (long double)den_x;
		if(num_y == 0)Y = 0.0;
		else Y = num_y / (long double)den_y;
		cout << fixed << setprecision(3);
		cout << X << ' ' << Y << '\n';
	}
	return 0;
}
// Write Here



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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    char a;cin >>a;
 
    if(a=='A'){
        cout<<'T'<<endl;
    }
    else if(a=='T'){
        cout<<'A'<<endl;
    }
    else if(a=='C'){
        cout<<'G'<<endl;
    }
    else {
        cout<<'C'<<endl;
    }  
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int w = sc.nextInt();
        int[] weight = new int[n];
        int[] value  = new int[n];
        for (int i = 0; i < n; i++) {
            weight[i] = sc.nextInt();
            value[i]  = sc.nextInt();
        }
        // Let's think about dp[n][v] = mini-weight to get value 'v' of n madeno things
        
        long[][] dp = new long[n][100001];
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 100001; j++) {
                if (i == 0) {
                    if (value[i] < j) {
                        dp[i][j] = Integer.MAX_VALUE - 10000;
                    }else if(j == 0){
                        dp[i][j] = 0;
                    } else {
                        dp[i][j] = weight[i];
                    }
                } else {
                    if (j - value[i] < 0) {
                        dp[i][j] = dp[i-1][j];
                    } else {
                        dp[i][j] = Math.min(dp[i-1][j-value[i]] + weight[i], dp[i-1][j]); // add or not 
                    }      
                }
            }    
        }
        for (int i = 100000; i >= 0 ; i--) {
            if (dp[n-1][i] <= w) {
                System.out.println(i);
                break;
            } else {
                continue;
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 127572
while True:
  n=int(input())
  if n == 0:
    break
  A = list(map(int,input().split()))
#  print(A)
  a =sum(A)
  bar = a/n
#  print(bar)
  count=0
  for i in A:
    if i<=bar:
      count+=1
  print(count)


Measured memory_bytes: 6608
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};

int main(void){
    //////////////////////////
    // 入力
    int H, W; 
    scanf("%d", &H);
    scanf("%d", &W);
    string field[H];
    queue<P> que;
    int dist[H][W];
    memset(dist, -1, sizeof(dist));
    for (int h = 0; h < H; ++h){
        cin >> field[h];
    }

    for (int h = 0; h < H; ++h){
        for (int w = 0; w < W; ++w){
            if (field[h][w] == '#'){
                que.push(P(h, w));
                dist[h][w] = 0;
            }
        }
    }

    while (!que.empty()){
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; ++i){
            int nh = p.first + dh[i];
            int nw = p.second + dw[i];
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (field[nh][nw] == '#') continue;
            if (dist[nh][nw] == -1){
                que.push(P(nh, nw));
                dist[nh][nw] = dist[p.first][p.second] + 1;
            }
        }
    }
    int ans = 0;
    for (int h = 0; h < H; ++h){
        for (int w = 0; w < W; ++w){
            ans = max(ans, dist[h][w]);
        }
    }

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



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

Measured memory_bytes: 13456