akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //System.out.print("入力してください > ");
        //int    x = Integer.parseInt(scanner.nextLine());
        //int n = Integer.parseInt(scanner.nextLine());
        //String d = scanner.nextLine();
       
        double n    =  Double.parseDouble(scanner.nextLine());
        //String[] s1 =  scanner.nextLine().split(" ");
        //int m1 = Integer.parseInt(s1[0]);
        //int d1 = Integer.parseInt(s1[1]);
        
        
        double kouho = n / 1.08;
        
      //  System.out.println(kouho);
        
        int kouho1 = (int) (Math.floor(kouho) * 1.08);
        int kouho2 = (int) (Math.ceil(kouho) * 1.08);
        
       // System.out.println(kouho1);
       // System.out.println(kouho2);
        
        if( kouho1 == n){
            System.out.println((int) Math.floor(kouho));
        }
        else if( kouho2 == n){
            System.out.println((int) Math.ceil(kouho));
        }
        else{
           System.out.println(":(");
        }
        
        
        
        // Scannerクラスのインスタンスをクローズ
        scanner.close();
    }
    private static boolean kaeru(int a, int b,long x, int n){
        
        return kakaku(a, b, n) <= x;
    }
    private static int kakaku(int a, int b,int n){
        
        return a*n + b*keta(n);
    }
    private static int keta(int n){
        
        int keta = 1;
        double nn = n;
        while(nn >= 10){
            nn = nn/10.0;
            keta++;
        }
        return keta;
        
    }
}

Measured memory_bytes: 23380
input_first = input().split()
input_second = input().split()
S = input_first[0]
T = input_first[0]
A = input_second[0]
B = input_second[1]

A = int(A)
B = int(B)

input_U = input()

if input_U ==S:
    print(A-1," ",B)
else:
    print(A," ",B-1)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main() {
	cout << fixed << setprecision(10);
	int n;
	cin >> n;

	vector<int> a(n);
	int sum = 0;
	REP(i, n)cin >> a[i];
	REP(i, n)sum += a[i] - 1;

	cout << sum;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
A = np.empty(6,dtype=np.int)

for i in range(3):
  A[i],A[i+3] = map(int,input().split())

for i in range(1,5):
  n = len(np.where(A==i)[0])
  if n==0 or n>2:
    print('NO')
    exit()
print('YES')

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

using namespace std;

map<int, int> num, pos;
set<int> s;
vector<int> v;

const int N = 1e5+10;
const int k = 30;

int up[N][k];
int L;
void calc(int i) {
	//cout << "this->" << *s.lower_bound(-(v[i]+L)) << endl;
	up[i][0] = num[*s.lower_bound(-(v[i]+L))];
	//cout << up[i][0] << endl;
	for(int j = 1; j < k; j++) {
		up[i][j] = up[up[i][j-1]][j-1];
	}
	/*cout << "i=" << i << ": " <<  endl;
	for(int j = 0; j < k; j++) cout << "k=" << j << " " << up[i][j] << endl;
	cout << endl;
	*/
}

int solve(int a, int b) {
	if(a>b) swap(a, b);
	int sum = 0;
	int cur = a;
	while(cur != b) {
		for(int j = 0; j < k-1; j++) {
			if(up[cur][j] >= b) {
				if(j==0) {
					sum++;
					cur = b;
				} else {
					cur = up[cur][j-1];
					sum += (1<<(j-1));
				}
				break;
			}
		}
	}

	return sum;
}

int main() {
	int n; cin >> n;
	v.resize(n+1);
	int cnt = 1;
	for(int i = 1; i <= n; i++) {
		int xi; cin >> xi;
		num[-xi] = cnt;
		pos[cnt] = xi;
		cnt++;
		s.insert(-xi);
		v[i] = xi;
	}
	cin >> L;
	for(int i = 0; i < k; i++) up[n+1][i] = n; 
	for(int i = n; i > 0; i--) {
		calc(i);
	}

	int q; cin >> q;
	while(q--) {
		int a, b; cin >> a >> b;
		cout << solve(a, b) << "\n";
	}
}

Measured memory_bytes: 29432
#include <iostream>

int main(){
    
    int max = -1000001;
    int min = 1000001;
    long int sum = 0;
    int a = 0;
    int b = 0;
    
    std::cin >> a;
    
    for(int i = 1; i <= a; i++){
        std::cin >> b;
        if(b > max)max = b;
        if(b < min)min = b;
        sum += b;
    }
    
    std::cout << min << " " << max << " " << sum << "\n";

    return 0;
}



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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((abs(b - a) <= d && abs(c - b) <= d) || abs(c - a) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();

		long sum = 0;

		for(int i = 1; i <= A; i++){
			if(i % 3 == 0 || i % 5 == 0){
			} else {
				sum += i;
			}
		}

		System.out.print(sum);

	return;

	}
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  vector<int> D(N+1);
  
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  
  D.at(0) = 0;
  for(int i=1;i<N+1;i++){
    D.at(i) = D.at(i-1) + L.at(i-1);
  }
  
  int ans = 0;
  
  for(int i=0;i<N+1;i++){
    if(D.at(i) <= X){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
//abc109c
#include <stdio.h>
#define ABS(x) (x>=0?x:-x)

int gcd(int a,int b) {
	int r = 1;
	while (r!=0) {
		r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main(void) {
	int n;
	long pos;
	long r;
	scanf("%d %ld",&n,&pos);
	long city[n];
	long buf;
	for (int i=0;i<n;i++) {
		scanf("%ld",&buf);
		city[i] = buf - pos;
//		printf("%ld\n",city[i]);
	}
	r = ABS(city[0]);
	for (int i=1;i<n;i++) {
		r = gcd(r,ABS(city[i]));
	}
	printf("%ld\n",r);
	
	return 0;
}

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

int main(){
  int N,M,d,i,j,a,b;
  cin >> N >> M;
  vector<vector<int>> c(N+1);
  vector<int> H(N+1);

  for(i=1;i<=N;i++)
    cin >> H[i];
  for(i=0;i<M;i++){
    cin >> a >> b;
    c[a].push_back(b);
    c[b].push_back(a);
  }
  
  int ct = 0;
  bool f;
  for(i=1;i<=N;i++){
    if (c[i].size()==0){
      ct++;
    }
    else {
      f = true;
      for(auto x:c[i]){
        if (H[x] >= H[i]){
          f = false;
          break;
        }
      }
      if (f) {
        ct++;
      }
    }
  }
   
  
  cout << ct << endl;

  return 0;
}

Measured memory_bytes: 8720
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(100100,0),dp(100100,0);
  rep(i,n){cin>>a[i];}
  dp[1]=abs(a[0]-a[1]);
  REP(i,2,n){ll l=100000000000000;
             REP(j,1,min(k,i)+1){l=min(l,dp[i-j]+abs(a[i]-a[i-j]));}
             dp[i]=l;}
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
unsigned long long a, b, c;
int main()
{
	cin >> a >> b >> c;
	if (c < b || c < a) {
		cout << "No";
		return 0;
	}
	if (4*a*b < (c-a-b)*(c-a-b)) cout << "Yes";
		else
			cout << "No";
	
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,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;}
int main() {
  vector<ll> tbl={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll K; cin>>K;
  ll ans= tbl.at(K-1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n) {
  if (n == 0) return 1;
  ll r = powMod(x, n / 2);
  if (n % 2 == 0) return (r * r) % MOD;
  return (r * r % MOD) * x % MOD;
}

int main(void) {

  int n, k;
  ll s;
  cin >> n >> k >> s;

  if (s == 2 || s == 1) {
    rep(i, k) cout << s << " ";
    rep(i, n - k - 1) cout << s + 1 << " ";
    if (n != k) cout << s + 1 << endl;
  } else {
    rep(i, k) cout << s << " ";
    rep(i, n - k - 1) cout << s - 1 << " ";
    if (n != k) cout << s - 1 << endl;
  }

  return 0;

}


Measured memory_bytes: 1280
n,x=map(int,input().split())
l=list(map(int,input().split()))

#バウンド回数
cnt=0
#X以下の領域でボールが跳ねる回数
ans=1

for i in l:
  cnt += i
  if cnt <= x:
    ans += 1
  else:
    break
print(ans)

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main() {

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;

    while(true) {
        int a = s.find("ABC");

        if (a == string::npos) {
            break;
        }

        ans++;

        s.replace(a, 3, "1");
    }

    AA(ans);
}

Measured memory_bytes: 3560
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a = [int(item) - 1 for item in input().split()]
visited = [0] * n

v = 0
visited[0] = 1
pre = [0]
loop = []
start = False
while True:
    v = a[v]
    if visited[v] == 1:
        start = True
    if visited[v] == 2:
        break
    if not start:
        pre.append(v)
    else:
        loop.append(v)
    visited[v] += 1 

if k < len(pre):
    print(pre[k] + 1)
    exit()
k -= len(pre)
print(loop[k % len(loop)] + 1)

Measured memory_bytes: 105680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define sz(x) x.size()
#define tr(it,x) for(it = x.begin();it != x.end();it++)
#define fir first
#define sec second

map<char,int> st;

int main() {
	string s;
	cin >> s;
	rep(i,sz(s)) {
		if(st.count(s[i]) == 0) st[s[i]] = 1;
		else st[s[i]]++;
	}
	map<char,int>::iterator it;
	int ans = INT_MAX;
	tr(it,st) {
		char temp1 = it->fir;
		int num = 0; string t = s;
		while(true) {
			string temp(sz(s)-num,temp1);
			if(temp == t) break;
			string r(sz(t)-1,'a');
			if(temp1 == 'a') {
				rep(i,sz(r)) r[i] = 'b';
			}
			rep(i,sz(t)) {
				if(t[i] == temp1) {
					if(i != sz(t)-1) r[i] = temp1;
					if(i != 0) r[i-1] = temp1;
				}
			}
			t = r;
			num++; 
		}
		ans = min(ans,num);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

class UnionFind {
public:
    vector<int> parent;  //親ノード
    vector<int> Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(int n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(int n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[root(x)];
    }
};

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

    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    } 

    UnionFind Uni(n);
    Uni.init(n);

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--;  y--;
        Uni.unite(x, y);
    }

    int ans = 0;
    rep(i, n) {
        if(Uni.same(i, p[i])) {
            ans++;
        }
    }

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

Measured memory_bytes: 1408
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [False] * (4800 // 400 + 1)
    d = [0] * (4800 // 400 + 1)
    for a in A:
        c[a // 400] = True
        d[a // 400] += 1
    mn = 1 if c[:8].count(True) == 0 else c[:8].count(True)
    mx = c[:8].count(True) + sum(d[8:])
    print(mn, mx)


main()


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


int main(){
	long long int a,b,c;
	cin >> a >> b >> c;
	if(a%2==0||b%2==0||c%2==0){
		cout << 0 << endl;
	}else{
		if(a>=b&&a>=c){
			cout << b*c << endl;
		}else if(b>=a&&b>=c){
			cout << a*c << endl;
		}else{
			cout << a*b << endl;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vint a(s.size() + 1, 0);
	vint b(s.size() + 2, 0);
	rep(i, s.size()) {
		if (s[i] == 'W') {
			a[i + 1] = a[i] + 1;
		}
		else {
			a[i + 1] = a[i];
		}
	}
	drep(i, s.size()) {
		if (s[i] == 'E') {
			b[i + 1] = b[i + 2] + 1;
		}
		else {
			b[i + 1] = b[i + 2];
		}
	}
	int ans = 600000;
	int cnt;
	rep(i, s.size()) {
		cnt = a[i] + b[i + 2];
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	int change = 0;
	rep(i, n - 1) {
		if (s[i + 1] != s[i])change++;
	}

	if (2 * k >= change)cout << n-1 << endl;
	else cout << n -1 - change + 2 * k << endl;
}

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

int main() {
  int n; cin >> n;
  // char com[9]
  string com, key;
  map<string, bool> dict;
  for(int i = 0; i < n; i ++) {
    cin >> com >> key;
    if (com[0] == 'i') dict[key] = true;
    else if (com[0] == 'f') {
      if(dict[key]) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
}


Measured memory_bytes: 52592
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans="";
    for(int i=0;i<ty-sy;i++)ans+="U";
    for(int i=0;i<tx-sx;i++)ans+="R";
    for(int i=0;i<ty-sy;i++)ans+="D";
    for(int i=0;i<tx-sx;i++)ans+="L";
    ans+="L";
    for(int i=0;i<ty-sy+1;i++)ans+="U";
    for(int i=0;i<tx-sx+1;i++)ans+="R";
    ans+="D";
    ans+="R";
    for(int i=0;i<ty-sy+1;i++)ans+="D";
    for(int i=0;i<tx-sx+1;i++)ans+="L";
    ans+="U";
    cout<<ans<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int t[30000];
		int sgn[30000];
		for(int i = 0;i < n;i++){
			int h,m,s;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			t[2 * i] = h*60*60+m*60+s;
			sgn[2 * i] = 1;
			scanf("%02d:%02d:%02d",&h,&m,&s);
			t[2 * i + 1] = h*60*60+m*60+s;
			sgn[2 * i + 1] = -1;
		}
		for(int i = 0;i < 2*n;i++){
			for(int j = i+1;j < 2*n;j++){
				if(t[i] == t[j] ? sgn[i] > sgn[j] : t[i] > t[j]){
					swap(t[i],t[j]);
					swap(sgn[i],sgn[j]);
				}
			}
		}
		int cnt = 0;
		int ma = 0;
		for(int i = 0;i < 2*n;i++){
			//cout<<t[i]<<" "<<sgn[i]<<endl;
			cnt += sgn[i];
			ma = max(cnt,ma);
		}
		cout<<ma<<endl;
	}
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int n,a,b;
    cin>>n>>a>>b;

    cout<<  min(a,b)<< " " << max(((a+b) - n), 0) << endl;
}


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

//    cout << (solve() ? "Yes" : "No") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
//    cout << solve() << endl;
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vi p(n);
  int res = 0, c = 0;
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    --p[i];
    if (p[i] == i) {
      ++c;
    } else {
      res += (c + 1) / 2;
      c = 0;
    }
  }
  res += (c + 1) / 2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    S1 = list(input())
    S2 = list(input())

    if S1[0] == S2[0]:
        ans = 3
        i = 1
    else:
        ans = 3 * 2
        i = 2
    mod = 10 ** 9 + 7
    while i < N:
        if S1[i] == S2[i]:
            if S1[i - 1] == S2[i - 1]:
                ans *= 2
            else:
                ans *= 1
            i += 1
        else:
            if S1[i - 1] == S2[i - 1]:
                ans *= 2
            else:
                ans *= 3
            i += 2
    print(ans % mod)


resolve()

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

int a, q, l, r, h, w, d;

struct S{
	int x;
	int y;
	int d;
}s[90010];

int abs(int x){
	return x>0? x:-x;
}

int dis(int x1, int y1, int x2, int y2){
	return abs(y1-y2) + abs(x1-x2);
}

int main(){
	int n;
	
	scanf("%d %d %d", &h, &w, &d);
	
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			scanf("%d", &a);
			s[a].x = i;
			s[a].y = j;
		}
	}
	
	for(int i=d+1; i<=h*w; i++){
		s[i].d = s[i-d].d + dis(s[i].x, s[i].y, s[i-d].x, s[i-d].y);
	}
	
	scanf("%d", &q);
	
	for(int k=0; k<q; k++){
		scanf("%d %d", &l, &r);
		
		printf("%d\n", s[r].d - s[l].d);
	}
	
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(void)
{
	int i,a,gokei;
	char b,suti[1000];
	while(1){
		gokei = 0;
		scanf("%s",suti);
		if(suti[0] == '0'){
			break;
		}
		a = strlen(suti);
		for(i=0 ; i<a ; i++){
			b= suti[i];
			gokei += atoi(&b);
		}
		printf("%d\n",gokei);
	}
	return 0;
}

Measured memory_bytes: 544
/* Author : Alokit Kumar */
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int t,n,i,j,k,x,y;
  cin>>x>>y;
  if((y>=2*x)&&(y-2*x)%2==0)
  {
    if((4*x>=y)&&(4*x-y)%2==0)
     cout<<"Yes";
    else
     cout<<"No";
  }
  else
   cout<<"No";
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n), b(n);
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for(int i = 0; i < n - 2; i++) {
    if(a[i] == b[i] and a[i + 1] == b[i + 1] and a[i + 2] == b[i + 2]) {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
}

Measured memory_bytes: 3624
from collections import deque
H, W = map(int,input().split())
S = [input() for _ in range(H)]

Q = deque([[0,0]])
dist = [[-1] * W for _ in range(H)]
dist[0][0] = 0

while Q:
    h, w = Q.popleft()

    for nh, nw in [[h+1,w],[h-1,w],[h,w-1],[h,w+1]]:
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == "." and dist[nh][nw] == -1:
            dist[nh][nw] = dist[h][w] + 1
            Q.append([nh,nw])

if dist[H-1][W-1] == -1:
    print(-1)
else:
    ans = 0
    for s in S: ans += s.count(".")
    print(ans - dist[H-1][W-1] - 1)



Measured memory_bytes: 9328
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	vector<int>A(N), B(N), C(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> B[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> C[i];
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	sort(C.begin(), C.end());
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		ll a = distance(A.begin(), lower_bound(A.begin(), A.end(), B[i]));
		ll b = distance(upper_bound(C.begin(), C.end(), B[i]),C.end());
		sum += a * b;
	}
	cout << sum << endl;
	return 0;
}

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

int g[15][15];

int main(){
    int n;
    cin >> n;
    rep(i,n)rep(j,n) g[i][j] = -1;
    rep(i,n) {
        int m;
        cin >> m;
        rep(j,m) {
            int a ,x;
            cin >> a >> x;
            --a;
            g[i][a] = x;
        }
    }
    int ans = 0;
    rep(i,1<<n) {
        vector<int> d(n);
        rep(j,n) if(i>>j&1) {
            d[j] = 1;
        }
        bool ok = true;
        rep(j,n) {
            if(d[j]) {
                rep(k,n) {
                    if(g[j][k] == -1) continue;
                    if(g[j][k]!= d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using i64 = long long;

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

    int N;
    cin >> N;
    i64 res = 1LL * N * (N - 1) / 2;
    cout << res << "\n";

    return 0;
}

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

const int MAXD = 10;
const int MAXP = 1000;
int dp[MAXD + 10][MAXP + 10];

int main() {
    fill(dp[0], dp[MAXD + 1], -1);
    int D, G; cin >> D >> G;

    dp[0][0] = 0;
    for(int i=0; i<D; i++) {
        int p, c; cin >> p >> c;

        for(int j=0; j<=MAXP; j++) {
            if(dp[i][j] < 0) continue;

            for(int k=0; k<=p; k++) {
                if(j + k > MAXP) continue;
                int point = 100 * (i+1) * k + (k == p ? c : 0);
                dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + point);
            }
        }
    }

    for(int i=0; i<=MAXP; i++) {
        if(dp[D][i] >= G) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

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

  int n = 0;
  for (char c : N) n += c - '0';
  if (stoi(N) % n == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
h,w = rl()
s = [list(rs()) for i in range(h)]
u=[[0]*w for i in range(h)]
b=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]

#縦方向
for i in range(w):
    if s[0][i]==".":
        u[0][i]=1
for i in range(w):
    for j in range(1,h):
        if s[j][i]==".":
            u[j][i]=u[j-1][i]+1
for i in range(w):
    if s[-1][i]==".":
        b[-1][i]=1
for i in range(w):
    for j in range(1,h):
        if s[-j-1][i]==".":
            b[-j-1][i]=b[-j][i]+1            
            

#横方向
for i in range(h):
    if s[i][0]==".":
        l[i][0]=1
for i in range(1,w):
    for j in range(h):
        if s[j][i]==".":
            l[j][i]=l[j][i-1]+1
for i in range(h):
    if s[i][-1]==".":
        r[i][-1]=1
for i in range(1,w):
    for j in range(h):
        if s[j][-i-1]==".":
            r[j][-i-1]=r[j][-i]+1
ans=0
for i in range(w):
    for j in range(h):
        ans=max(u[j][i]+b[j][i]+l[j][i]+r[j][i]-3, ans)
print(ans)            
    

Measured memory_bytes: 359888
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = long long;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;


int main(){
      int a,b;
      cin>>a>>b;
      cout<<max({a*b,a-b,a+b})<<endl;
      return 0;
}

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

void chmin(double &a, double b){
  if( a > b){ swap(a,b);} return;}

int main(){
int N; cin >> N;
  vector<int> t(N); vector<int> v(N); int time = 0;
  for(int i = 0; i < N; i++){ cin >> t[i]; time += t[i];}
  for(int i = 1; i < N; i++){ t[i] += t[i-1];}
  for(int i = 0; i < N; i++){ cin >> v[i];}
  
  vector<double> speed(2*time+10,0.0);
  //speed[i]は、 i/2秒における速度の上限に他ならない
  for(int i = 0; i < N; i++){
    int res;
    if(!i){ res = 0;} else{ res = t[i-1];}
    for(int j = 2*res; j <= 2*t[i]; j++){
      
      if( j == 2*res){  int res1;
        if(!i){ res1 = 0;} else{ res1 = v[i-1];}
          speed[j] = min(res1, v[i]);}
      
      else if( j == 2*t[i]){
          speed[j] = min(v[i],v[i+1]);}
      else{
       speed[j] = v[i];}}
  }
  speed[0] = 0.0; speed[2*time] = 0.0;

  for(int i = 1; i < 2*time; i++){
    chmin( speed[i], speed[i-1]+0.5);}

  for(int j = 2*time-1; j >= 0; j--){
    chmin( speed[j], speed[j+1]+0.5);}
  
  double area = 0.0;
  
  for(int i = 0; i < 2*time; i++){
    area += 0.5*(speed[i]+speed[i+1])*0.5;} //高さ*(上底+下底)/2
  
  cout << fixed << setprecision(5) << area << endl;
    

 return 0;}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int a, b, c; cin >> a >> b >> c;
  cout << min({a+b,b+c,c+a}) << endl;
}


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

int n, xi, x, d1, d2;

int gcd(int u, int v){
	int r;
	while (v != 0){
		r = u % v;
		u = v;
		v = r;
	}
	return u;
}

int main(){
	cin >> n >> xi;
	d1 = 0;
	for (int i = 0; i < n; ++i){
		cin >> x;
		d2 = abs(x - xi);
		d1 = gcd(d1, d2);
	}
	cout << d1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    vector<vector<int>> cnt(H, vector<int>(W, INF));
    vector<vector<int>> flag(H, vector<int>(W, 0));
    REP(h, H)
    REP(w, W) {
        cin >> s[h][w];
    }
    queue<pair<int, pair<int, int>>> q;
    q.push({0, {0, 0}});
    if (s[0][0] == '#') {
        cnt[0][0] = 1;
    } else {
        cnt[0][0] = 0;
    }
    while (!q.empty()) {
        auto now = q.front();
        int dist = now.first;
        dump(dist);
        auto pos = now.second;
        q.pop();
        REP(i, 2) {
            int h = pos.first + dx[i];
            int w = pos.second + dy[i];
            if (h >= H || w >= W) {
                continue;
            }
            if (s[h][w] == '#') {
                if (s[pos.first][pos.second] == '#') {
                    cnt[h][w] = min(cnt[h][w], cnt[pos.first][pos.second]);
                } else {
                    cnt[h][w] = min(cnt[h][w], cnt[pos.first][pos.second] + 1);
                }
            } else {
                cnt[h][w] = min(cnt[h][w], cnt[pos.first][pos.second]);
            }
            if (flag[h][w]) {
                continue;
            }
            flag[h][w] = 1;
            q.push({dist - 1, {h, w}});
        }
    }
    cout << cnt[H - 1][W - 1] << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
  long sum = 0;
  int count;
  scanf("%d", &count);
  long prev;
  scanf("%ld", &prev);
  for(int i = 1;i < count;i++) {
    long a;
    scanf("%ld", &a);
    if(a < prev) {
      sum += prev - a;
    } else {
      prev = a;
    }
  }
  printf("%ld\n", sum);
  return 0;
}

Measured memory_bytes: 2108
s = str(input())
q = int(input())

front_s = ''
back_s = ''
rev_flg = False

for i in range(q):
    query = list(map(str, input().split())) 
    if query[0] == '1':
        rev_flg = not rev_flg
    else:
        if not rev_flg:
            if query[1] == '1':
                front_s += query[2]
            else:
                back_s += query[2]
        else:
            if query[1] == '1':
                back_s += query[2]
            else:
                front_s += query[2]
    
res = front_s[::-1] + s + back_s
if rev_flg: res = res[::-1]
print(res) 

Measured memory_bytes: 4468
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
//#define MOD 1000000007 //10^9+7
#define MOD 2019

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main(void){

  ll n, x, y;
  cin>>n>>x>>y;
  vector<ll> v(n);
  REP(i, n) v[i] = 0;

  FOR(i, 1, n){
    FOR(j, i+1, n){
      ll ans = min(abs(j-i), abs(x-i)+1+abs(j-y));
      ans = min(ans, abs(x-j)+1+abs(i-y));
      //cout<<ans<<" ";
      v[ans-1]++;
    }
    //cout<<endl;
  }

  REP(i, n-1){
    cout<<v[i]<<endl;
  }
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
int main(){
	int n; cin >>n;
	set <int>s;
	int x = n;
	// 8 
	while(s.count(x) == 0){
		s.insert(x);
		if(x % 2 == 0)
			x/=2;
		else
			x = x * 3 + 1;
	}
	cout << s.size()+1;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<ll>teams(3*n);
  for(int i=0;i<3*n;i++){
  	cin>>teams[i];
  }
  ll tot = 0;
  sort(teams.begin(),teams.end());
  int p1=0,p2=(3*n)-1,p3=(3*n)-2;
  for(int i=0;i<n;i++){
  	tot+=teams[p3];
  	p3-=2,p2-=2,p1++;
  }
  cout<<tot<<endl;
}



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

int q,np[1000000]={1,1},a,b,c,ans[1000000];

int main(){
	for(int i=2; i<1000000; i++)
		if(!np[i]) for(int j=2*i; j<1000000; j+=i) np[j] = 1;
	for(int i=1; i<1000000; i++){
		if(i%2 && !np[i] && !np[(i+1)/2]) ans[i] = 1;
		ans[i] += ans[i-1];
	}
	cin >> q;
	while(q--){
		cin >> a >> b;
		cout << ans[b]-ans[a-1] << endl;
	}
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>
#include <climits>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for(long long i = (long long)(n - 1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	ll x;
	cin >> x;

	vector<ll> A, B;
	for (ll i = 0; pow(i, 5) <= LLONG_MAX; i++)
	{
		A.push_back(pow(i, 5));
	}
	int n = A.size();
	rep(i, n)
	{
		B.push_back(-A[i]);
	}

	auto solve = [&](ll a, vector<ll>& x)
	{
		auto p = find(all(x), a);
		if (p != x.end())
		{
			return (int)distance(x.begin(), p);
		}

		return -1;
	};

	auto check = [&](ll a, ll b)
	{
		if (a == -1) return false;

		return pow(a, 5) - pow(b, 5) == x;
	};

	rep(i, n)
	{
		ll a = x + B[i];

		ll s = solve(a, A);
		if (check(s, -i))
		{
			cout << s << " " << -i << endl;
			return 0;
		}

		s = solve(a, B);
		if (check(s, -i))
		{
			cout << s << " " << -i << endl;
			return 0;
		}
	}

	rep(i, n)
	{
		ll a = x + A[i];

		ll s = solve(a, A);
		if (check(s, i))
		{
			cout << s << " " << i << endl;
			return 0;
		}

		s = solve(a, B);
		if (check(s, i))
		{
			cout << s << " " << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 4300
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
double f(double x){
    return exp(x);
}
int main(){
    int x,y;
    cin>>x>>y;
    if(y%2==0&&y/2-x>=0&&-y/2+2*x>=0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String X = scanner.next();
		String Y = scanner.next();

		if(X.charAt(0)<Y.charAt(0)) {
			System.out.println("<");
		}else if(X.charAt(0)==Y.charAt(0)){
			System.out.println("=");
		}else{
			System.out.println(">");
		}
	}
}

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

int main(void){
    // Your code here!
    int N, M;
    cin >> N >> M;
    
    int a[2][M];
    int b[60] = {};
    for (int i = 0; i < M; ++i) {
        cin >> a[0][i] >> a[1][i];
    }
    
    for (int j = 0; j < M; ++j){
        b[a[0][j] - 1]++;
        b[a[1][j] - 1]++;
    }
    
    for (int i = 0; i < N; ++i)
        cout << b[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long lli;
const int maxn = 1e5 + 5;
const int K = 26;
int n, Q;
string s[maxn];

struct TNode
{
    int sz;
    bool ed;
    TNode *nxt[K];

    TNode()
    {
        sz = 0;
        ed = false;
        fill(begin(nxt), end(nxt), nullptr);
    }
};

TNode root;

void Add(string&s)
{
    TNode *p = &root;
    for(int i = 0; i < (int)s.length(); ++i)
    {
        int k = s[i] - 'a';
        if(p -> nxt[k] == nullptr)
            p -> nxt[k] = new TNode();
        p = p -> nxt[k];
        (p -> sz)++;
    }
    p -> ed = true;
}

int cnt[maxn][K][K];
int pre[maxn];

void Count(string&s, int id)
{
    TNode *p = &root;
    for(int i = 0; i < (int)s.length(); ++i)
    {
        int k = s[i] - 'a';
        if(p -> ed) ++pre[id];
        for(int j = 0; j < K; ++j)
        {
            if(j == k) continue;
            if(p -> nxt[j] != nullptr)
                cnt[id][j][k] += p -> nxt[j] -> sz;
        }
        p = p -> nxt[k];
    }
}

void ReadInput()
{
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> s[i];
        Add(s[i]);
    }
}

void Solve()
{
    for(int i = 0; i < n; ++i)
        Count(s[i], i);
    cin >> Q;
    for(; Q > 0; --Q)
    {
        int k;
        string t;
        cin >> k >> t;
        --k;
        int ans = pre[k] + 1;
        for(int i = 0; i < K; ++i)
            for(int j = i + 1; j < K; ++j)
                ans += cnt[k][t[i] - 'a'][t[j] - 'a'];
        cout << ans << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


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

int main()
{
    int num[3] = {0};
    string ans = "No";

    for (int i = 0; i < 3; i++)
    {
        cin >> num[i];
    }

    sort(num, num + 3);

    if (num[0] == num[1])
    {
        if (num[1] == num[2])
            ans = "No";
        else
            ans = "Yes";
    }
    else if (num[1] == num[2])
    {
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
adan = input().split()
bdan = input().split()
cdan = input().split()
aken = int(int(adan[int(1)])-int(bdan[int(1)]))
bken = int(int(adan[int(2)])-int(bdan[int(2)]))
cken = int(int(adan[int(0)])-int(bdan[int(0)]))
dken = int(int(adan[int(1)])-int(cdan[int(1)]))
eken = int(int(adan[int(2)])-int(cdan[int(2)]))
fken = int(int(adan[int(0)])-int(cdan[int(0)]))
if aken == bken == cken:
    if dken == eken == fken:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int A, B, X;
	cin >> A >> B >> X;
	if (A == X) {
		cout << "YES" << endl;
	}
	else if (A < X && X <= A + B) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d",$n,$y);

$check = 0;
for($i=0; $i<=$n; $i++){
    for($s=0; $s<=$n; $s++){
        $a = $n - ($i + $s);
        if($y == (10000*$i)+(5000*$s)+(1000*$a) && $a >= 0){
            echo $i." ".$s." ".$a;
            $check++;
            exit;
        }
    }
}
if($check == 0){
    echo "-1 -1 -1";
}
?>

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

int n , m , q , ans , a[20][20][20];
vector<int> v;

void solve(int i , int lst)
{
    if (i==n+1)
    {
        int res=0;
        for(int j=0; j<v.size(); j++)
        {
            for(int jj=j+1; jj<v.size(); jj++)
            {
                res += a[j+1][jj+1][v[jj]-v[j]];
            }
        }
        ans = max(ans , res);
        return;
    }

    for(int j=1; j<=m; j++)
    {
        if (j>=lst)
        {
            v.push_back(j);
            solve(i+1 , j);
            v.pop_back();
        }
    }
}

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

    cin >> n >> m >> q;
    for(int i=1; i<=q; i++)
    {
        int aa,b,c,d;
        cin >> aa >> b >> c >> d;
        a[aa][b][c] = d;
    }

    solve(1,0);
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  vector<int> A(3);
  for(int i = 0; i < 3; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[2] - A[0] << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()

def exammonth(c):
    if 0 < c and c < 13:
        return 1
    else:
        return 0

# def examyear(c):
#     if c == 0:
#         return 0
#     else:
#         return 1

# print(int(S[0:2]))
# print(int(S[2:4]))


if exammonth(int(S[2:4])) == 1:
    if exammonth(int(S[0:2])) == 1:
        print('AMBIGUOUS')
    else:
        print('YYMM')
else:
    if exammonth(int(S[0:2])) == 1:
        print('MMYY')
    else:
        print('NA')

Measured memory_bytes: 3060
n=int(input())
l=[]
for i in range(n):
    A=int(input())
    p=[]
    for i in range(A):
        x,y=map(int,input().split())
        p.append([x-1,y])
    l.append(p)    

ans=0
for i in range(2**n):
    flag=0
    for j in range(n):
        if (i>>j)&1:
            for k in l[j]:
                if (i>>k[0])&1 != k[1]:
                    
                    flag=1
                    break
    if flag==0:
        ans=max(ans,bin(i)[2:].count("1"))

print(ans)        

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 500001
using namespace std;
#define int long long
int n,X[N];

int ans;
void update(int a,int i){
  int len = X[n-1];  
  int la = X[a]-X[i];
  int b = lower_bound(X+a,X+3*n,X[a]+(len-la)/2)-X;
  int lb = X[b] - X[a];
  int lc = len-la-lb;
  ans = max(ans,min(la,min(lb,lc)));
}

signed main(){

  cin>>n;
  int A[N];
  for(int i=0;i<n;i++)cin>>A[i];
    
  X[0] = A[0];
  for(int i=1;i<3*n;i++) X[i] += A[i%n] + X[i-1];

  int len = X[n-1];
  for(int i=0;i<=n;i++){
    int au = upper_bound(X+i,X+3*n,X[i]+len/3) - X;
    update(au,i),update(au-1,i);
 }
 cout<< ans << endl;
  return 0;
}

Measured memory_bytes: 6204