akhauriyash/Code-Regression huggingface dataset:
ns = 3.times.map { gets.split.map(&:to_i) }

(1..4).each do |i|
  cnt = 0
  ns.each do |n|
    cnt += 1 if n.include?(i)
    if cnt > 2
      puts 'NO'
      exit 0
    end
  end
end
puts "YES"

Measured memory_bytes: 1916
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = [INT() for _ in range(m)]

# 高速版
def fib(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]

start = 0
ans = 1

for k in a:
    tmp = k-start
    if tmp==0:
        print(0)
        exit(0)
    ans *= fib(tmp)
    ans%=MOD
    start = k+1

ans*=fib(n-start+1)
ans%=MOD

print(ans)

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


int main(){
    int n,x,t;
    cin>>n>>x>>t;
    int ans=0;
    while(n>0){
        ans+=t;
        n-=x;
    }
    
    cout<<ans<<endl;
    }

Measured memory_bytes: 3628
import numpy as np
W, H, N = map(int, input().split())

z = np.zeros( (H, W) )
#print(z)

for n in range(N):
  x,y,a = map(int, input().split())

  if a == 1:
    z[:, :x] = 1

  if a == 2:
    z[:, x:] = 1

  y = H - y
  if a == 3:
    z[y:,:] = 1
  
  if a == 4:
    z[:y,:] = 1
#print(z)

ans = int(W*H - z.sum())
print(ans)

Measured memory_bytes: 12488
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);

  puts(s.substr(0, 4) == "YAKI" ? "Yes" : "No");

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

string s;

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> s;
	fill( s.begin(), s.end(), 'x' );
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        if (N % 2 == 0) {
            System.out.printf("%.10f\n", 1 / (double)2);
            return;
        }
        System.out.printf("%.10f\n", 1 - (N / 2 / (double)N));
    }

}


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

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  // calc min
  ll ok = 1LL << 62, ng = 0;
  while(ok - ng > 1) {
    ll c = (ok + ng) / 2;
    ll now = c;
    for(int i = 0; i < N; i++) {
      now = now / A[i] * A[i];
    }
    if (now >= 2) ok = c;
    else ng = c;
  }
  ll mi = ok;
  
  // calc max
  ok = 0, ng = 1LL << 62;
  while(ng - ok > 1) {
    ll c = (ok + ng) / 2;
    ll now = c;
    for(int i = 0; i < N; i++) {
      now = now / A[i] * A[i];
    }
    if (now <= 2) ok = c;
    else ng = c;
  }
  ll ma = ok;
  
  if (ma < mi) {
    cout << "-1" << endl;
  } else {
    cout << mi << " " << ma << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
    double xa,ya,xb,yb,xc,yc,xd,yd;
    double t1,t2,t3,t4;
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
    t1=(xa-xc)*(yb-ya)+(ya-yc)*(xa-xb);
    t2=(xa-xc)*(yd-ya)+(ya-yc)*(xa-xd);
    t3=(xb-xd)*(ya-yb)+(yb-yd)*(xb-xa);
    t4=(xb-xd)*(yc-yb)+(yb-yd)*(xb-xc);

    if(t1*t2<0&&t3*t4<0) printf("YES\n");
    else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 604
l,r = map(int, input().split())
min1 = 2019
for i in range(l, min(r+1, l+2020)):
    for j in range(i+1, min(r+1, l+2020)):
        candidate = ((i%2019)*(j%2019))%2019
        if candidate < min1:
            min1 = candidate
print (min1)

Measured memory_bytes: 9172
#include<iostream>
using namespace std;
int p[100000]={0};
int main()
{
	long long n;
	int k;
	bool ok=1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>k;
		p[k]++;
	}
	if(n%2==0)
	{
		for(int i=1;i<n;i+=2)
		{
			if(p[i]!=2)
			{
				ok=0;
				break;
			}
		}
	}
	else
	{
		for(int i=2;i<n;i+=2)
			if(p[0]!=1||p[i]!=2)
			{
				ok=0;
				break;
			}
	}
	if(ok)
	{
		long long m=1;
		for(int j=0;j<n/2;j++)
			m=(m*2)%1000000007;
		cout<<m;
	}
	else
	    cout<<0;
	return 0;
}

Measured memory_bytes: 888
# coding: utf-8
import sys

n = int(input())

for line in sys.stdin.readlines():
    i = line.rstrip().split(' ')
    a = pow(int(i[0]),2)
    b = pow(int(i[1]),2)
    c = pow(int(i[2]),2)
    if ((a+b) == c) or ((b+c)==a) or ((c+a)==b):
        print("YES")
    else:
        print("NO")


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    x--;
    y--;

    vector<int> ans(n);
    for (int j = 0; j < n; j++)
    {
        for (int i = 0; i < j; i++)//i<j
        {
            int d = min(j-i,abs(i-x)+abs(j-y)+1);
            ans[d]++;
        }
    }

    for (int i = 1; i < n; i++)
    {
        cout<<ans[i]<<endl;
    }
        
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> h(N);
    for (auto &i : h) {
        cin >> i;
    }

    vector<int> dp(N);
    dp[0] = 0;
    FOR(i, 1, N) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i > 1) {
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }

    std::cout << dp[N - 1] << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int n,a[202020],mi[202002][20],ma[202020][20],l,k,t[202020];
inline int getmin(int st) {
	return min(mi[st][l],mi[st+k-(1<<l)][l]);
}
inline int getmax(int st) {
	return max(ma[st][l],ma[st+k-(1<<l)][l]);
}
int main() {
	scanf("%d%d",&n,&k);
	for (int i = 1;i <= n; i++) {
		scanf("%d",&a[i]);
		mi[i][0] = ma[i][0] = a[i];
		if (a[i] > a[i-1])
			t[i] = 1;
	}
	for (int i = 1;i <= n; i++)
		t[i] += t[i-1];
	for (int i = 1;i < 20; i++) {
		for (int j = 1;j <= n; j++) {
			mi[j][i] = min(mi[j][i-1],mi[min(j+(1<<(i-1)),n)][i-1]);
			ma[j][i] = max(ma[j][i-1],ma[min(j+(1<<(i-1)),n)][i-1]);
		}
	}
	int ans = 1,flag = 1;
	if (t[k]-t[1] != k-1)
		ans++;
	else
		flag = 0;
	l = 0;
	while ((1<<l) < k)
		l++;
	l--;
	for (int i = 2;i+k-1 <= n; i++) {
		if (t[i+k-1]-t[i] == k-1) {
			flag = 0;
			continue ;
		}
		//cout << getmin(i-1) << " " << getmax(i) << endl;
		if (getmin(i-1) == a[i-1] && getmax(i) == a[i+k-1])
			ans--;
		ans++;
	}
	printf("%d\n",ans-flag);
	return 0;
}

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

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

class ABC128D
{
public:
	ABC128D()
	{
		cin >> n >> k;
		k++;
		v.resize(n);
		rep(i, 0, n)
			cin >> v[i];
		copy(all(v), back_inserter(vr));
		reverse(all(vr));
	}
	void Run(void)
	{
		ll best = 0;
		ll solve = 0;
		rep(li, 0, k)
		{
			rep(ri, 0, k - li)
			{

				solve = Solve(li, ri, k - li - ri - 1);
				if (best < solve)
					best = solve;

			}
		}

		cout << best;

	}
private:
	ll Solve(ll lmax, ll rmax, ll dmax)
	{
		ll sum = 0;
		vector<ll> ans(n);

		lmax = (n < lmax) ? n : lmax;
		rep(i, 0, lmax)
			ans.push_back(v[i]);

		rmax = (n - lmax < rmax) ? n - lmax : rmax;
		rep(i, 0, rmax)
			ans.push_back(vr[i]);
	
		sum = accumulate(all(ans), 0);
		sort(all(ans));

		dmax = (ans.size() < dmax) ? ans.size() : dmax;
		rep(i, 0, dmax)
		{
			if (ans[i] < 0)
				sum -= ans[i];
		}

		return sum;
	}
	ll n;
	ll k;
	vector<ll> v;
	vector<ll> vr;
};

int main(void)
{
	ABC128D abc128d;
	abc128d.Run();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 4e5+5;
const int mod = 1e9 + 7;

vector<int> G[maxn];
int dp[maxn][2] = {};

void dfs(int now,int fa) {
	dp[now][0] = dp[now][1] = 1;
	for (int k:G[now]) {
		if (k ^ fa) {
			dfs(k, now);
			dp[now][1] = (dp[k][0] * dp[now][1]) % mod;
			dp[now][0] = ((dp[k][1] + dp[k][0]) * dp[now][0]) % mod; 
		}
	}
}

main() {
	int n;
	cin >> n;
	
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	
	dfs(1, 0);
	cout << (dp[1][1] + dp[1][0]) % mod << "\n";

}


Measured memory_bytes: 24604
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
    
    public static void main (String[] args) {
        int a,b,c,d,e;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
         b = sc.nextInt();
        float f = (float)(a+b)/2;
       float s = f*10;
      // System.out.println(f);
    //System.out.println(s);
     //   System.out.println(s%10);
       if(s%10<5){
           System.out.println((int) f);
       }else{
           System.out.println((int) f +1);
       }
        //c = sc.nextInt();
        //int t = a+b+c;
       // String ss = sc.next();
        //System.out.println(t+" "+ss);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main(){
  string s;
  cin>>s;
  int zero = 0,one = 0;
  rep(i,s.size()){
    zero += s[i] == '0';
    one += s[i] == '1';
  }
  int ans = min(zero,one)*2;
  
  print(ans)
  return 0;
}


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

int main(){
        int n;
        scanf("%d", &n);
        std::vector<std::vector<int>> dp(n+1, std::vector<int>(3, 0));

        for(int i=1; i<=n; i++){
                int a, b, c;
                scanf("%d %d %d", &a, &b, &c);
                dp[i][0] = std::max({dp[i][0], dp[i-1][1]+a, dp[i-1][2]+a});
                dp[i][1] = std::max({dp[i][1], dp[i-1][0]+b, dp[i-1][2]+b});
                dp[i][2] = std::max({dp[i][2], dp[i-1][1]+c, dp[i-1][0]+c});
        }

        printf("%d\n", *std::max_element(dp[n].begin(), dp[n].end()));
        return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
int main()
{
  int N;
  int a[100000];
  int b[100000];
  int i;
  scanf("%d", &N);
  for(i = 0; i < N ; i++)
  {
    scanf("%d", a+i);
  }
  b[0] = 0;
  for(i = 0 ; i < N; i++)
  {
    b[i+1] = a[i] - b[i];
  }
  int x = (b[N-1] - a[N-1])/2;
  for(i = 0 ; i < N; i+=2)
  {
    b[i] -= x;
    b[i+1] += x;
  }
  for(i = 0 ; i < N ; i++)
  {
    printf("%d\n", b[i]*2);
  }
  
  return 0;
  
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

using  point=complex<double>;
struct circle{point p; double r;};
bool check(circle c1,circle c2){
   if(c1.r<c2.r)swap(c1,c2);
   double d=abs(c1.p-c2.p); if(c1.r+c2.r<d)return 0;
   if(abs(c1.r+c2.r-d)<eps||c1.r-c2.r<d||abs(c1.r-c2.r-d)<eps)return 1;
   return 0;
}
vector<point> intersect(circle c1,circle c2){
   if(!check(c1,c2))return {};
   double d=abs(c1.p-c2.p);
   double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
   double t=atan2(c2.p.imag()-c1.p.imag(),c2.p.real()-c1.p.real());
   auto r1=polar(c1.r,t+a)+c1.p,r2=polar(c1.r,t-a)+c1.p;
   return {r1,r2};
}

int n,k; double x[61],y[61],c[61];
circle cs[61];
int cnt(point p){
   int res=0;
   rep(i,0,n){if(abs(cs[i].p-p)<=cs[i].r+eps)res++;}
   return res;
}

int main(){
   scanf("%d%d",&n,&k);
   rep(i,0,n)scanf("%lf%lf%lf",&x[i],&y[i],&c[i]);
   double lb=0,rb=1e6;
   rep(_,0,100){
      double mid=(lb+rb)/2.0;
      rep(i,0,n)cs[i].p=point(x[i],y[i]),cs[i].r=mid/c[i];
      auto f=[&](){ 
         vector<point> cand;
         rep(i,0,n){
            cand.push_back(cs[i].p);
            rep(j,i+1,n){
               auto v=intersect(cs[i],cs[j]);
               for(auto p:v)cand.push_back(p);
            }
         }
         for(point p:cand)if(cnt(p)>=k)return 1;
         return 0;
      };
      if(f())rb=mid; else lb=mid;
   }
   printf("%.12f\n",rb);
   return 0;
}

Measured memory_bytes: 512
import itertools
from operator import add

n, m, x = map(int,input().split())

l = []

for _ in range(n):
    l.append(list(map(int,input().split())))

min_cost = -1

can = False

for buy_or_not in itertools.product(range(2), repeat=n):
    cost = 0
    m_list = [0] * m
    
    for i, j in enumerate(buy_or_not):
        if j:
            cost += l[i][0]
            m_list = list(map(add, m_list, l[i][1:]))

    m_check = [True if temp_m >= x else False for temp_m in m_list]

    if all(m_check):
        if min_cost == -1:
            min_cost = cost
        elif cost <= min_cost:
            min_cost = cost
    
print(min_cost)

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);

			long sum = 0;
			for (int i = 0; i < n-1; i++) {
				sum += a[i]/2;
				a[i] -= (a[i]/2) * 2;
				if (a[i+1] >= 1 && a[i] == 1) {
					sum++;
					a[i+1]--; a[i]--;
				}
			}
			sum += a[n-1]/2;

			out.println(sum);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 36676
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
   int n , k;
   cin >> n >> k; 
   int sum = 0;
   while(n > 0){
      n /= k;
      sum++;
   }
   cout << sum << endl;
  }



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n;
    cin>>n;
    n*=2;
    vi l(n);
    REP(i,n){
        cin>>l[i];
    }
    sort(all(l),greater<int>());
    int ans=0;
    for(int i=1;i<n;i+=2){
        ans+=l[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
int n;
struct block{
int w,s, v;
bool operator <(block o){
	return s+w>o.s+o.w;
}
};
block b[1005];
LL dp[1005][10005];
LL solve(int i,int S){
	LL &ret=dp[i][S];
	if(i==n||S==0) return 0;
	if(ret!=-1) return ret;
	ret=solve(i+1,S);
	if(b[i].w>S) return ret;
	ret=max(ret,b[i].v+solve(i+1,min(S-b[i].w,b[i].s)));
	return ret;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++) scanf("%d%d%d",&b[i].w,&b[i].s,&b[i].v);
	sort(b,b+n);
	/*
	 *for(auto t:b)
	 *    cout<<t.w<<"\n";
	 */
	memset(dp,-1,10000005*sizeof(dp[0][0]));
	cout<<solve(0,50003);
	return 0;
}


Measured memory_bytes: 78464
// https://atcoder.jp/contests/

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int x;
  string r;

  cin >> x;

  r = x < 1200 ? "ABC" : "ARC";

  cout << r << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>
 
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
 
const int INF = 0x3c3c3c3c;
const ll LINF = 1ll*INF*INF*2;
 
const int MAX_N = 1001;
int n;
int x[MAX_N];
int y[MAX_N];
 
void solve(int a, int b, int x) {
	if(x==0) {
		if(a==2) {printf("RR\n"); return;}
		if(a==-2) {printf("LL\n"); return;}
		if(b==2) {printf("UU\n"); return;}
		if(b==-2) {printf("DD\n"); return;}
		if(a==0 && b==0) {printf("LR\n"); return;}
 
		if(a==1) printf("R");
		if(a==-1) printf("L");
		if(b==1) printf("U");
		if(b==-1) printf("D");
		printf("\n");
		return;
	}
 
	int d = 1<<x;
	bool t1 = (a+b)>0, t2=(a-b)>0;
 
	if(t1) {
		if(t2) {
			printf("R");
			solve(a-d, b, x-1);
		} else {
			printf("U");
			solve(a, b-d, x-1);
		}
	} else {
		if(t2) {
			printf("D");
			solve(a, b+d, x-1);
		} else {
			printf("L");
			solve(a+d, b, x-1);
		}
	}
}
 
int main(void) {
	scanf("%d", &n);
	for(int i=0; i<n; i++) scanf("%d%d", x+i, y+i);
 
	int k = !!((x[0]+y[0])%2);
 
	for(int i=1; i<n; i++) {
		int temp = !!((x[i]+y[i])%2);
		if(k != temp) {
			printf("-1");
			return 0;
		}
	}
 
	if(k) {
		printf("31\n");
		for(int i=30; i>=0; i--) printf("%d ", 1<<i);
		printf("\n");
	} else {
		printf("32\n");
		for(int i=30; i>=0; i--) printf("%d ", 1<<i);
		printf("1\n");
	}
 
	for(int i=0; i<n; i++) solve(x[i], y[i], 30);
}

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

int main(){
 
  int N, i;
  map<string, bool> Kei;
  string kei;
  cin >> N;
  for (i = 0; i < N; i++){
    
    cin >> kei;
    Kei[kei] = true;
  }
  
  cout << Kei.size() << endl;
  return 0;
}

Measured memory_bytes: 19224
import sys

sys.setrecursionlimit(5 * 10**5)
input=sys.stdin.readline

N, Q = list(map(int, input().split()))

M = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map(int, input().split()))
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans = [0] * N
for _ in range(Q):
    p, x = list(map(int, input().split()))
    ans[p-1] += x

Q = [0]

while Q:
    current = Q.pop()

    for i in M[current]:
        ans[i] += ans[current]
        M[i].remove(current)

    Q += M[current]

print(' '.join(map(str, ans)))

Measured memory_bytes: 71772
# Swap function
def swapPositions(list, pos1, pos2):

    list[pos1], list[pos2] = list[pos2], list[pos1]
    return list


box_list = input().split()

swapPositions(box_list, 0, 1)
swapPositions(box_list, 0, 2)

for item in box_list: print(item,end = " ")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,mi=INT_MAX,x,ans;
int main(){
    scanf("%d",&n);
    while(n--){
        scanf("%d",&x);
        if(x<mi)ans++,mi=x;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        s: chars,
        gx: i64, gy: i64
    }
    let fs = split(&s, 'T') .into_iter()
        .map(|v| v.len())
        .collect::<Vec<_>>();
    let mut dpx = vec![false;16001];
    let mut dpy = vec![false;16001];
    dpx[8000] = true;
    dpy[8000] = true;
    for i in 0..fs.len() {
        let d = fs[i];
        let dpx_p = dpx.clone();
        let dpy_p = dpy.clone();
        if i % 2 == 0 {dpx = vec![false;16001];}
        else {dpy = vec![false;16001];}
        for j in 0..16000 {
            if i % 2 == 0 {
                if j >= d && i != 0 {
                    dpx[j - d] |= dpx_p[j];
                }
                if j + d < dpx.len() {
                    dpx[j + d] |= dpx_p[j];
                }
            } else {
                if j >= d {
                    dpy[j - d] |= dpy_p[j];
                }
                if j + d < dpy.len() {
                    dpy[j + d] |= dpy_p[j];
                }
            }
        }
    }
    let gxu = (gx + 8000) as usize;
    let gyu = (gy + 8000) as usize;
    println!("{}", if dpx[gxu] && dpy[gyu] {"Yes"} else {"No"});
}

#[allow(dead_code)]
fn split<T: PartialEq + Clone>(slice: &[T], sep: T) -> Vec<Vec<T>> {
    slice.iter().fold(vec![vec![]], |mut acc, x| {
        if x == &sep {
            acc.push(vec![]);
            acc
        } else {
            let last = acc.len() - 1;
            acc[last].push(x.clone());
            acc
        }
    })
}

Measured memory_bytes: 4352
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))



n=input1()
flag=False
for i in range(1,10):
	ans=n/i
	if ans<10 and n%i==0:
		flag=True
		break
if flag:
	print("Yes")
else:
	print("No")









Measured memory_bytes: 13792
n = int(input())
A = list(map(int, input().split()))

def counting_sort(arr):
	max_num = max(arr)
	min_num = min(arr)
	count = [0] * (max_num - min_num + 1)
	for ele in arr:
		count[ele - min_num] += 1
	return [ele for ele, cnt in enumerate(count, start=min_num) for _ in range(cnt)]


AA = counting_sort(A)
print(*AA)


Measured memory_bytes: 224388
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 1e7+35;
int main(){
    int k; cin >> k; int p = 1,x = 0,ans = -1;
    for(int i = 1;i <= maxn; ++i){
        x = (x+7*p)%k;
        p = p*10%k;
        if(x == 0){
            ans = i;
            break;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>

int main(){
	char contest[450];
	scanf("%s",contest);
	if (contest[1]=='B'){
		contest[1]='R';
		printf("%s\n",contest);
	}
	else if (contest [1]=='R'){
		contest[1]='B';
		printf("%s\n",contest);
	}
	return 0;
}

Measured memory_bytes: 1612
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int h,w,n;
	cin>>h>>w>>n;
	int sr,sc;cin>>sr>>sc;sr--;sc--;
	string s,t;cin>>s>>t;
	int now=sc; //try making it negative or >=w by R,L
	
	for(int i=0;i<n;i++)
	{
		if(s[i]=='L')now--;
		if(now<0)
		{
			puts("NO");return 0;
		}
		if(t[i]=='R' and now<w-1)now++;
	}
	now=sc;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')now++;
		if(now>=w)
		{
			puts("NO");return 0;
		}
		if(t[i]=='L' and now>=1)now--;
	}

	now=sr;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='U')now--;
		if(now<0){puts("NO");return 0;}
		if(t[i]=='D' and now<h-1)now++;
	}
	now=sr;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='D')now++;
		if(now>=h){puts("NO");return 0;}
		if(t[i]=='U' and now>=1)now--;
	}

	puts("YES");


}


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

RL = [0] * (10 ** 7 + 10)
for i in range(1, 10 ** 7 + 10):
    RL[i] = RL[i-1] + i

#print("step")

ans = 0
for i in range(1, N+1):
    a = N // i
    #print(i, a)
    ans += RL[a] * i

print(ans)

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

int main(){
    int k ,a, b;
    scanf("%d", &k);
    scanf("%d%d", &a, &b);

    if(b-a > k){
        printf("OK");
    }else{
        bool flag = false;
        for(int i=a; i<=b; i++){
            if(i%k == 0)flag = true;
        }
        if(flag)printf("OK");
        else printf("NG");
    }

}

Measured memory_bytes: 3828
n = int(input())
alph = "abcdefghijklmnopqrstuvwxyz"
num = 0
now = 1
keta = 0
while True:
    now *= 26
    keta += 1
    if num + now >= n:
        break
    num += now
ban = n - num - 1 
ans = ""
for i in range(keta):
    ban, mod = divmod(ban, 26)
    ans = alph[mod] + ans
print(ans)


Measured memory_bytes: 9196
from collections import Counter


N = int(input())
list = [input() for _ in range(0,N)]
counted = Counter(list)
res_max= counted.most_common()[0][1]
ans = []
for k, v in counted.items():
    if v == res_max:
        ans.append(k)

ans.sort()
print(*ans, sep="\n")

Measured memory_bytes: 45040
x1, x2, x3, x4, x5 = map(int, input().split())

if x1 == 0:
  print(1)

elif x2 == 0:
  print(2)

elif x3 == 0:
  print(3)
  
elif x4 == 0:
  print(4)
  
elif x5 == 0:
  print(5)


Measured memory_bytes: 9052
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	for(int i = 0; i < k; i++){
		int a,b;
		scanf("%d%d", &a, &b);
		printf("%d\n", min(min(a-1,n-a),min(b-1,n-b))%3+1);
	}
}

Measured memory_bytes: 1024
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    REP(i, N) {
        H -= A[i];
        if(H <= 0){
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
int main(void){
    // Your code here!
map<string , int> mp;
int n;
cin>>n;

for(int i=0;i<n;i++){
 string s;
 cin>>s;
 mp[s]++;
}
int minv=1e9, maxv=-1;
for(auto it=mp.begin();it!=mp.end();it++){
    maxv= max(it->second, maxv);
        
}

for (auto p : mp) {
    auto k = p.first;
    auto v = p.second;
    if(v==maxv)
    cout << k << endl;
  }
}



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

int main() {
    long long int n, t;
    std::cin >> n;
    std::vector<long long int> v(n, 0), calc(n,0);
    for (long long int i = 0; i < n; i++) {
        std::cin >> t;
        v[i] = t;
    }

    std::sort(v.begin(), v.end());
    calc[0] = v[0];
    long long int j = 0;
    for (long long int i = 1; i < n; i++) {
        calc[i] = calc[i-1] + v[i];
        if (v[i] > 2*calc[i-1]) j = i;
    }

    std::cout << n - j << std::endl;

    return 0;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  if(n < 26) {
    bool alpha[26] = {0};
    rep(i, n) alpha[(s[i] - 'a')] = true;
    rep(i, 26) {
      if(alpha[i] == false) {
        cout << s << (char)('a' + i) << endl;
        return 0;
      }
    }
  }
  vector<string> ans;
  for(int i = n - 1; i >= 0; i--) {
    for(int j = i - 1; j >= 0; j--) {
      if(s[i] > s[j]) {
        swap(s[i], s[j]);
        ans.push_back(s.substr(0, j + 1));
        swap(s[i], s[j]);
      }
    }
  }
  if(ans.size() == 0) {
    cout << -1 << "\n";
  } else {
    sort(all(ans));
    cout << ans[0] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,x,ans;
int main(){
	cin >> n >> x;
	ans = n;
	n-=x;
	while (n){
		if (n < x)
		swap(n,x);
		ans += (n/x)*x*2;
		n = n%x;			
	}
	ans-=x;
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string x;
    cin >> x;
    stack<char> s;
    int n = x.size();
    rep(i, n) {
        if (x[i] == 'S') {
            s.push(x[i]);
        }
        else if (x[i] == 'T') {
            if (s.empty() || s.top() != 'S') {
                s.push(x[i]);
            }
            else {
                s.pop();
            }
        }
    } 
    cout << (int)s.size() << endl;
    return 0;
}


Measured memory_bytes: 3784
n=int(input())
A=list(map(int, input().split()))

buy=[]
i=0
while(i<=n-2):
    if A[i]<A[i+1]: #株が値上がったとき
        buy.append(i)
    i=i+1
money=1000
stock=0
for i in buy:
    #株を買う
    count=money//A[i]
    money=money-count*A[i]
    stock=stock+count
    #株をうる
    rieki=stock*A[i+1]
    money=money+rieki
    stock=0
print(money)


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

long long solve(long long x[]){
  long long ans = 0;
  ans += x[0] * x[1] * x[2];
  ans += x[0] * x[1] * x[3];
  ans += x[0] * x[1] * x[4];
  ans += x[0] * x[2] * x[3];
  ans += x[0] * x[2] * x[4];
  ans += x[0] * x[3] * x[4];
  ans += x[1] * x[2] * x[3];
  ans += x[1] * x[2] * x[4];
  ans += x[1] * x[3] * x[4];
  ans += x[2] * x[3] * x[4];
  return ans;
}

int main(){
  int n;
  long long march[5];
  for(int i=0; i<5; i++){
    march[i] = 0;
  }
  string s;
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> s;
    if(s[0] == 'M') {
      march[0]+=1;
    }
    else if(s[0] == 'A'){
      march[1] += 1;
    }
    else if(s[0] == 'R'){
      march[2] += 1;
    }
    else if(s[0] == 'C'){
      march[3] += 1;
    }
    else if(s[0] == 'H'){
      march[4] += 1;
    }
    else{
      continue;
    }
  }
  long long ans = solve(march);
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[1] == 'B')
        s[1] = 'R';
    else
        s[1] = 'B';
    cout << s << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3616
#include<iostream> 
using namespace std; 
int main(){ 
  int n; 
  int t[100],mx,mn,sum; 
  while(1){ 
    cin>>n; 
    if(n==0)break; 
    mx=sum=0; 
    mn=1000; 
    for(int i=0;i<n;i++){ 
      cin>>t[i]; 
      if(mn>t[i])mn=t[i]; 
      if(mx<t[i])mx=t[i]; 
      sum+=t[i]; 
    } 
    sum-=mn; 
    sum-=mx; 
    cout<<sum/(n-2)<<endl; 
      
  } 
  return 0; 
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int compare(const void* x, const void* y){
  if(*(int*)x<*(int*)y) return -1;
  else if(*(int*)x>*(int*)y) return 1;
  return 0;
}

int main(){
  int N,M;
  scanf("%d%d",&N,&M);
  int *x;//訪れる点の座標
  x=(int*)malloc(M*sizeof(int));
  for(int i=0;i<M;i++) scanf("%d",&x[i]);
  if(N>=M){
    printf("0\n");
    return 0;
  }
  qsort(x,M,sizeof(int),compare);
  //for(int i=0;i<M;i++) printf("x[%d]=%d\n",i,x[i]);
  int *L; //訪れない開区間の長さ
  L=(int*)malloc((M-1)*sizeof(int));
  for(int i=0;i<M-1;i++){
    L[i]=x[i+1]-x[i];
  }
  //for(int i=0;i<M-1;i++) printf("L[%d]=%d\n",i,L[i]);
  qsort(L,M-1,sizeof(int),compare);
  //for(int i=0;i<M-1;i++) printf("L[%d]=%d\n",i,L[i]);
  int ans=0;//訪れていない開区間の長さの合計
  for(int i=0;i<N-1;i++){
    ans+=L[M-2-i];
  }
  printf("%d\n",x[M-1]-x[0]-ans);
  return 0;
}


Measured memory_bytes: 1396
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int M, N;
	static int[] a;
	public static void main(String[] args) {
		read();
		solve();
	}
	static void read(){
		M = sc.nextInt(); N = sc.nextInt();
		a = new int[M];
		for(int i = 0; i < M; i++){
			for(int j = 0; j < N; j++ ){
				a[i] = a[i] + sc.nextInt();
			}
		}
	}
	static void solve(){
		java.util.Arrays.sort(a);
		System.out.println(a[M-1]);
	}
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    int x[n], sum = 0;

    for (size_t i = 0; i < n; i++)
    {
        cin >> x[i];

        if (x[i] < k - x[i])
        {
            sum += 2 * x[i];
        }
        else
        {
            sum += 2 * (k - x[i]);
        }
    }

    cout << sum << endl;
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)



signed main(){

	int N, M;
	cin >> N >> M;
	int c[200001] = { 0 };
	for (int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		if (a == 1 || a==N) c[b]++;
		if (b == 1 || b==N) c[a]++;
	}
	for (int i = 0; i < N; i++)
		if (c[i] == 2){
			cout << "POSSIBLE" << endl; return 0;
		}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline


def main():
    N, W = [int(i) for i in input().strip().split()]
    items = [[int(i) for i in input().strip().split()] for _ in range(N)]

    dp = [[0 for _ in range(N)] for _ in range(W + 1)]

    for i in range(N):
        for capacity in range(W + 1):
            if i == 0:
                if capacity >= items[i][0]:
                    dp[capacity][i] = items[i][1]
                else:
                    dp[capacity][i] = 0
            else:
                if capacity >= items[i][0]:
                    dp[capacity][i] = max(
                        dp[capacity][i - 1], dp[capacity - items[i][0]][i - 1] + items[i][1])
                else:
                    dp[capacity][i] = dp[capacity][i-1]

    return dp[-1][-1]


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 130268
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;

bool vis[200000];
int par[200000];
void bfs(int s, vector<vector<int> >&edges, stack<int>&order){
   queue<int> q;
   q.push(s);
   vis[s]=1;
   while(!q.empty()){
      int t = q.front();
      order.push(t);
      q.pop();
      for(auto x : edges[t]){
        if(vis[x]==0){
            q.push(x);
            vis[x]=1;
            par[x]=t;
        }
      }
   }
}
void bfs2(stack<int>&q, vector<set<int> >& ans){
    while(!q.empty()){
        int t = q.top();
        q.pop();
        if(par[t]==-1)continue;
        if(ans[t].size()%2==0){
            ans[par[t]].insert(t);
        }else{
            ans[t].insert(par[t]);
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   // freopen("input.txt", "r", stdin);
    int n, e;
    cin >> n >> e;
    vector<vector<int> > edges(n);
    vector<set<int> > ans(n);
    int f, s;
    FOR(i, 0, e){
        cin >> f >> s;
        f--; s--;
        edges[f].push_back(s);
        edges[s].push_back(f);
    }

    FOR(i, 0, n){
        vis[i]=false;
    }
    if(e%2!=0){
        cout << "-1" << endl;
        return 0;
    }
    par[0]=-1;
    stack<int> ord;

    bfs(0, edges, ord);
    FOR(i, 0, n){
        for(int x : edges[i]){
            if(par[i]!=x&&par[x]!=i&&ans[x].find(i)==ans[x].end()){
                ans[i].insert(x);
            }
        }
    }
    FOR(i, 0, n){
        vis[i]=false;
    }
    bfs2(ord, ans);

    FOR(i, 0, n){
        for(auto it : ans[i]){
            cout << i+1 << " " << it+1 << "\n";
        }
    }

}



Measured memory_bytes: 16896
#include<stdio.h>
#include<stdlib.h>
int main(void){
char s[8];
  scanf("%s",&s);
  if(strcmp(s,"SUN")==0){
    printf("7");
    return 0;
  }
  char t[8][8]={{"MON"},{"TUE"},{"WED"},{"THU"},{"FRI"},{"SAT"},{"SUN"}};
  int i=0;
  while(strcmp(s,t[i])!=0){
   // printf("%s\n",t[i]);
    i++;
  }
  int j=0;
  while(strcmp(t[i],"SUN")!=0){
    i++;
    j++;
  }
  
  
  printf("%d",j);
  return 0;
}

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

int n;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<int> a(n), l(n), r(n);
    for (auto& i : a) cin >> i;
    
    for (int i = 0; i < n - 1; ++i) {
		l[i + 1] = __gcd(l[i], a[i]);
	}
	for (int i = n - 1; i >= 1; --i) {
		r[i - 1]  = __gcd(r[i], a[i]);
	}
	
	int ans = 1;
	for (int i = 0; i < n; i++) ans = max(ans, __gcd(l[i], r[i]));
	cout << ans;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long n ,m,ans;
    cin >> n >> m;
    
    if(n==1 && m == 1) {
        cout << 1;
    }else if (n==1) {
        cout << m-2;
    }else if (m==1) {
        cout << n-2;
    }else {
        cout << (n-2)*(m-2);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>


using std::cout;
using std::cin;
using namespace std;

void oneCase () {
   int n;
   cin >> n;
   vector<vector<pair<int, int>>> edges(n);
   vector<int> colors(n - 1, -1);

   for (int i = 0; i  + 1 < n; ++i) {
       int f, t;
       cin >> f >> t;
       --f;
       --t;
       edges[f].emplace_back(t, i);
       edges[t].emplace_back(f, i);
   }

   int k = 0;
   int mxn = 0;
   for (int p = 0; p  < edges.size(); ++p) {
       if (edges[p].size() > k) {
           k = edges[p].size();
           mxn = p;
       }
   }


   stack<pair<int, int>> nodes;
   nodes.emplace(mxn, -1);
   while (!nodes.empty()) {
       auto c = nodes.top().first;
       auto f = nodes.top().second;
       nodes.pop();
       int wu = 0;
       for (auto& ed : edges[c]) {
           if (colors[ed.second] == -1) {
               auto edn = ed.second;
               if (wu == f) {
                   ++wu;
               }
               colors[edn] = wu;


               nodes.emplace(ed.first, wu);
               ++wu;
           }
       }
   }


   cout << k << "\n";
   for (int p = 0; p < colors.size();++p) {
       cout << colors[p] + 1 << "\n";
   }

}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 6912
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
B = [abs(i-maxA/2) for i in A]
mid_pA = int(min(B) + maxA/2)
mid_mA = int(-min(B) + maxA/2)
A.sort()
for i in A[:N]:
    if i == mid_pA:
        print(maxA,mid_pA)
        break
    elif i == mid_mA:
        print(maxA,mid_mA)
        break

Measured memory_bytes: 14052