akhauriyash/Code-Regression huggingface dataset:
/**
 *   author: sahushivam
 *   created: 01 March 2020 (Sunday)  17:31:43
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
	vector<vector<pair<int,int>>>a(3,vector<pair<int,int>>(3));
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j].first;
			a[i][j].second=false;
		}
	}
	int n; cin>>n;
	vector<int> te(n);
	for(int k=0;k<n;k++)
	{
		cin>>te[k];
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(a[i][j].first==te[k])
					a[i][j].second=true;
			}
		}

	}

	//row
	if(a[0][0].second && a[0][1].second && a[0][2].second) 
	{
		cout<<"Yes\n";
		return;
	}
	if(a[1][0].second && a[1][1].second && a[1][2].second) 
	{
		cout<<"Yes\n";
		return;
	}
	if(a[2][0].second && a[2][1].second && a[2][2].second) 
	{
		cout<<"Yes\n";
		return;
	}


	//col
	if(a[0][0].second && a[1][0].second && a[2][0].second) 
	{
		cout<<"Yes\n";
		return;
	}
	if(a[0][1].second && a[1][1].second && a[2][1].second) 
	{
		cout<<"Yes\n";
		return;
	}
	if(a[0][2].second && a[1][2].second && a[2][2].second) 
	{
		cout<<"Yes\n";
		return;
	}


	if(a[0][0].second && a[1][1].second && a[2][2].second) 
	{
		cout<<"Yes\n";
		return;
	}
	if(a[0][2].second && a[1][1].second && a[2][0].second) 
	{
		cout<<"Yes\n";
		return;
	}
	cout<<"No";
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}


Measured memory_bytes: 256
A,B,C = map(int,input().split())
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
	print(0)
else:
	S = A * B * C
	mi = min(A,min(B,C))
	ma = max(A,max(B,C))
	mid = S // ma // mi
	ma //= 2
	ans = ma * mi * mid
	print(abs(S - ans * 2))

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

int main()
{
	string s;
    cin>>s;
    int c=0,mx=0;
    for(int i=0; i<s.size(); i++)
    {
 
        if(s[i]=='R')
        {
            c++;
 
        }
        else
        {
            c=0;
        }
        mx=max(c,mx);
 
 
 
    }
    cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define sz(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define all(a) (a).begin(), (a).end()
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 

using namespace std;

void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(15);
    solve();
}

const int INF = 1e18, MAXN = 1e5 + 10;

void solve() {                         
	int n;
	cin >> n;
	double k = 0;
	for (int i = 0; i < n; ++i) {
	    double num;
	    cin >> num;
	    k += (1 / num);
	}	

	cout << 1. / k << endl;
}	


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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a+n);
	int d = 0;
	for (int i = 0; i < n-1; i++) {
		d += a[i+1] -a[i];
	}

	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement
n,m,q = map(int,input().split())
a=[0]*q
b=[0]*q
c=[0]*q
d=[0]*q
for i in range(q):
  a[i],b[i],c[i],d[i] = map(int,input().split())

ans = 0
for cmb in combinations_with_replacement(range(1,m+1),n):  
  tmp = 0
  for i in range(q):
    if cmb[b[i]-1] - cmb[a[i]-1] == c[i]:
      tmp += d[i]
  
  ans = max(ans,tmp)
  
print(ans)  

Measured memory_bytes: 9152
#include <iostream>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[5];
    for(int i=0;i<5;i++)
        cin>>a[i];
    for(int i=0;i<5;i++)
    {
        if(a[i]==0){
        cout<<i+1;
        break;
        }
    }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);;cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MAX 100000000
using namespace std;
int main()
{
   fastio;
   ll a,b,c;
   cin>>a>>b>>c;
   if((a+b+c)>=22)
    cout<<"bust"<<endl;
   else
    cout<<"win"<<endl;
   return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  !al <- replicateM h $ map (== '#') <$> getLine
  let
    red = flip map [1..h] $ \i -> flip map [1..w] $ \j -> (j == 1 || odd i) && j /= w
    blue = map (map not) red
    po = zipWith (zipWith (||)) al
    showColor = unlines . map (map (\b -> if b then '#' else '.'))
  putStrLn $ showColor (po red)
  putStrLn $ showColor (po blue)


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

long long gcd(long long a,long long b){
  long long r,tmp;

  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<long long> a(n);

  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    a[i] /= 2;
  }

  long long l = a[0];
  for (int i = 1; i < n; i++)
  {
    l = l/gcd(l,a[i]) * a[i];
  }

  bool ok = true;
  for(int i=0; i<n; i++){
      if(l%a[i] == 0 && (l/a[i])%2 == 0)
      ok = false;
  }
  if(ok){
    long long ans = m / l;
    ans = (ans+1) / 2;
    cout << ans << endl;
  }
  else{
      cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
n,x = map(int, input().split())
a = list(map(int, input().split()))

ans=0

if a[0] > x: # must eat a[0]
    eat=a[0] - x
    ans+=eat
    a[0] = x

for i in range(1,len(a)):
    sm = a[i-1]+a[i]
    if sm <=x:
        continue
    else:
        eat = sm-x
        a[i] -= eat
        ans+=eat
print(ans)

Measured memory_bytes: 63984
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] h = new long[n];

		for(int i = 0; i < n; i++)
			h[i] = sc.nextLong();

		Arrays.sort(h);

		long ans = 0;

		for(int i = 0; i < n - k; i++)
			ans += h[i];

		System.out.println(ans);

		return;

	}

}



Measured memory_bytes: 82620
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e2 + 10 ;
int arr[maxn] , brr[maxn] , x , y , n , m ;
void input() 
{
	cin >> n >> m >> x >> y ;
	for ( int i = 0 ; i < n ; i++ ) 
		cin >> arr[i] ;
	for ( int i = 0 ; i < m ; i++ ) 
		cin >> brr[i] ;
}
int main () 
{
	input();
	sort ( arr , arr + n ) ;
	sort ( brr , brr + m ) ;
	for ( int i = arr[n-1]+1 ; i < brr[0]+1 ; i++ ) 
		if ( x < i && y >= i ) 
		{
			cout << "No War" << endl;
			return 0 ;
		}	
	cout << "War" << endl;
}

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

int main(void){
    long long n, m;
    char s[100010], t[100010];
    cin >> n >> m;
    cin >> s;
    cin >> t;
    
    //GCD
    int a = n, b = m;
    if (a < b) {
	    int tmp = a;
	    a = b;
	    b = tmp;
    }
    int r = a % b;
    while (r != 0) {
	    a = b;
	    b = r;
	    r = a % b;
    }
    
    int gcd = b;
    bool exis = true;
//    if (gcd == 1) {
//        if (s[0] == t[0]) cout << n * m << endl;
//       else cout << -1 << endl;
//    }
//    else {
        for (int i = 0; i < gcd; i++) {
            if (s[i * (n / gcd)] != t[i * (m / gcd)]) exis = false;
        }
        if (exis == false) cout << -1 << endl;
        else cout << m * n / gcd << endl;
//    }

}


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

int W, a, b;

int main () {
	cin >> W >> a >> b;
	if (b>a+W) {
		cout << b-(a+W) << endl;
	} else if (b+W<a) {
		cout << a-(b+W) << endl;
	} else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
import Data.List -- sort
import Control.Monad -- replicateM

readInt = read <$> getLine :: IO Integer
arrayInt = map read . words <$> getLine :: IO [Integer]
writeln x = putStrLn $ unwords x :: IO ()

main = do
    [a,b] <- arrayInt
    print $ foldr max 0 [a+a-1,a+b,b+b-1]

Measured memory_bytes: 508
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

struct Point {
	int x, y;
};

const double EPS = 1E-9;
Point h, d, p[20];
int n;
bool flag[20];

bool dfs(double t, int s) 
{
	int i;
	for (i = 0; i < n; i++) {
		if (!flag[i]) break;
	}
	if (i == n) return true;
	
	Point pp = (s == -1) ? h : p[s];
	for (i = 0; i < n; i++) {
		if (flag[i]) continue;
		if (hypot(d.x - p[i].x, d.y - p[i].y) - hypot(pp.x - p[i].x, pp.y - p[i].y) - t < EPS) return false;
	}
	
	for (i = 0; i < n; i++) {
		if (flag[i]) continue;
		flag[i] = true;
		if (dfs(t + hypot(pp.x - p[i].x, pp.y - p[i].y), i)) return true;
		flag[i] = false;
	}
	
	return false;
}

int main()
{	
	while (cin >> n >> h.x >> h.y >> d.x >> d.y, n | h.x | h.y | d.x | d.y) {
		memset(flag, false, sizeof(flag));
		for (int i = 0; i < n; i++) {
			cin >> p[i].x >> p[i].y;
		}
		cout << (dfs(0, -1) ? "YES" : "NO") << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>

int a[3];
int main(){
  for(int i=0;i<3;++i)
    std::cin>>a[i];
  std::sort(a,a+3);
  
  auto result1=(a[2]-a[0])%2==0;
  auto result2=(a[2]-a[1])%2==0;
  int ans=0;
  ans+=(a[2]-a[0])/2;
  ans+=(a[2]-a[1])/2;
  
  if(result1&&!result2||!result1&&result2)
    ans+=2;
  else if(!result1&&!result2)
    ans+=1;
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

int N, K, S; cin >> N >> K >> S;

rep(_, 0, K) cout << S << ' ';
rep(_, 0, N - K) cout << min(2*S, 999999999) << ' ';

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 1280
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Collections;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// 標準入力の読み込み開始
        Scanner scanner = new Scanner(System.in);

        // 数列の長さ
        int n = scanner.nextInt();

        // 数列
        List<Integer> numList = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            numList.add(scanner.nextInt());
        }

        // 標準入力の読み込み終了
        scanner.close();
        
        int minj = 0;
        int cnt = 0;
		for (int i = 0; i < n; i++) {
			minj = i;
			
			for (int j = i; j < n; j++) {
				if (numList.get(j) < numList.get(minj)) {
					minj = j;
				}
			}
			//A[i] と A[minj] を交換
			if (i < minj) {
				Collections.swap(numList, i, minj);
				cnt++;
			}
		}
		
		// 出力
		for(int i = 0; i < n; i++){
			System.out.print(numList.get(i));
			if(i < n - 1){
	    		System.out.print(" ");
			}
        }
        System.out.println();
        
        System.out.println(cnt);
    }
}


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

using namespace std;

int main()
{
    string s;

    cin>>s;

    if(s[0]=='S')
    {
        cout<<"Cloudy"<<endl;
    }
    else if(s[0]=='C')
    {
        cout<<"Rainy"<<endl;
    }
    else
    {
        cout<<"Sunny"<<endl;
    }

    return 0;
}


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

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

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  cout << ((a*100+b*10+c)%4 ==0 ? "YES" : "NO") << endl;

}




Measured memory_bytes: 256
#include <cstdio>
const int mod = 1000000007;
char s[5010];
int e[5010][10010];
inline void add(int &x, int t) {
	x += t;
	if (x >= mod) x -= mod;
}
int r[5010];
int f[5010];
int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	int l;
	for (l = 0; s[l]; l++) ;
	e[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			add(e[i+1][j?j-1:0], e[i][j]);
			add(e[i+1][j+1], e[i][j]);
			add(e[i+1][j+1], e[i][j]);
		}
	}
	for (int i = 0; i <= n; i++) {
		if (i + l > n) break;
		r[n-i-l] = e[i][0];
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			e[i][j] = 0;
		}
	}
	e[0][0] = 1;
	for (int i = 0; i <= n; i += 2) {
		int ss = 0;
		for (int j = 0; j < l + i; j++) {
			add(ss, e[i][j]);
			add(e[i+2][j+1], (int)(ss * 2 % mod));
		}
		f[i] = ss;
	}
	for (int i = 0; i <= n; i++) {
		add(ans, (int)((long long)f[i] * r[i] % mod));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 141312
import math
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


A,B,C = LI()
ans = False

gcd = math.gcd(A,B)
if C % gcd ==0:
    ans = True

if ans:
    print('YES')
else:
    print('NO')

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

using namespace std;

int main() {
    int n; cin >> n;
    vector<string> s(n); for(int i = 0; i < n; ++i) cin >> s[i];
    int m; cin >> m;
    vector<string> t(m); for(int i = 0; i < m; ++i) cin >> t[i];
    int MAX = 0;
    for(auto hoge : s) {
       int diff = (int)count(s.begin(), s.end(), hoge) - (int)count(t.begin(), t.end(), hoge);
       if(MAX < diff) MAX = diff;
    }
    cout << MAX << endl;
    return 0;
}


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

int main() {
  int N ,M ;
  cin >> N >> M ;
  
  vector<int> vec(N);
  int sum=0;
  
  int i ;
  for(int i=0 ; i< N ; i++){
    cin >> vec.at(i);
    
    sum+=vec.at(i);
  }
  
  
  int c =0;
  for(int i=0 ; i< N ; i++){
    cin >> vec.at(i);
  
  if(sum%(4*M)==0){
    
  if(vec.at(i)>=sum/(4*M)){
    c++;
  }
  }
   if(sum%(4*M)!=0){
     if(vec.at(i)>=(sum/(4*M))+1){
    c++;
     }
   }
     
  }
  
  
  if(c>=M){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  string s;
  int K;
  cin>>s>>K;
  int n=s.size();
  map<string,int>f;
  for(int i=0;i<n;i++){
    for(int j=1;j<=K;j++){
      if(i+j<=n){
        string t=s.substr(i,j);
        f[t]++;
      }
    }
  }
  int i=1;
  for(auto c:f){
    if(i==K){cout<<c.first<<endl;return 0;}
    i++;
  }
  return 0;
}

Measured memory_bytes: 4720
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
 
int N;
int ans = 0;
set<int> s;
 
int main() {
    cin >> N;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        set<int>::iterator ite;
        ite = s.find(a);
        if(ite == s.end()){
            ans += 1;
            s.insert(a);
        }
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

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

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	double n, k;
	cin >> n >> k;
	double p = 0;
	for (int i = 1; i <= n; i++) {
		int tmp = i;
		int count = 0;
		while (tmp < k) {
			tmp *= 2;
			count++;
		}
		p += (1.0 / n) * (pow((1.0 / 2.0), count));
	}
	cout << fixed << setprecision(12) << p << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }

int main(){
    ll K,N,a=0;
    cin>>K>>N;
    ll A[N];
    for(ll i=0;i<N;i++) cin>>A[i];
    a=abs(A[0])+abs(K-A[N-1]);
    for(ll i=0;i<N-1;i++){
        a=max(a,abs(A[i]-A[i+1]));
    }
    cout<<K-a<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

 int main(){
     
     int b[10];
     int bingo = 0;
     scanf("%d %d %d", &b[0],&b[1],&b[2]);
     scanf("%d %d %d", &b[3],&b[4],&b[5]);
     scanf("%d %d %d", &b[6],&b[7],&b[8]);
     int times;
     int num[50] = {0};
     scanf("%d", &times);
     for(int i = 0; i<times;i++){
         scanf("%d", &num[i]);
     }
     for(int i = 0; i<times;i++){
         for(int j=0;j<9;j++){
             if(num[i] == b[j]){
                 b[j] = 777;
             }
         }
     }
    if(b[0] == 777 && b[1] == 777 && b[2] == 777){
        bingo++;
    }else if(b[3] == 777 && b[4] == 777 && b[5] == 777){
        bingo++;
    }else if(b[6] == 777 && b[7] == 777 && b[8] == 777){
        bingo++;
    }else if(b[3] == 777 && b[4] == 777 && b[5] == 777){
        bingo++;
    }else if(b[0] == 777 && b[3] == 777 && b[6] == 777){
        bingo++;
    }else if(b[1] == 777 && b[4] == 777 && b[7] == 777){
        bingo++;
    }else if(b[2] == 777 && b[5] == 777 && b[8] == 777){
        bingo++;
    }else if(b[0] == 777 && b[4] == 777 && b[8] == 777){
        bingo++;
    }else if(b[2] == 777 && b[4] == 777 && b[6] == 777){
        bingo++;
    }
    
    if(bingo > 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }     
 return 0;
 }

Measured memory_bytes: 1664
unittest
{
	assert( [ "5 3 3", "1 2 4" ].parse.expand.solve == 1 );
	assert( [ "7 3 2", "4 5 6" ].parse.expand.solve == 0 );
	assert( [ "10 7 5", "1 2 3 4 6 8 9" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nmx = input.front.split.to!( long[] );
	input.popFront;
	auto cs = input.front.split.to!( long[] );
	
	return tuple( nmx[ 0 ], nmx[ 2 ], cs );
}

auto solve( long n, long x, long[] cs )
{
	auto as = new long[ n + 1 ];
	
	foreach( c; cs )
	{
		as[ c ] = 1;
	}
	
	return min( as[ 0 .. x ].sum, as[ x + 1 .. $ ].sum );
}


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

int main() {
    int N, M, A;
    cin >> N >> M;
    priority_queue<int> pq;
    long ans = 0;
    rep(i, N) {
        cin >> A;
        pq.push(A);
        ans += A;
    }
    rep(i, M) {
        int X = pq.top();
        pq.pop();
        pq.push(X / 2);
        ans -= X - X / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  ll ans=0;
  ll kuti=1;
  while(kuti<B) {
kuti--;
    kuti+=A;
    ans++;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3568
#![allow(non_snake_case, unused_imports, deprecated, dead_code)]

// Input 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)*} }; }
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)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
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, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{VecDeque,HashSet,HashMap,BinaryHeap};
// Module for v1.15.1
use std::ascii::AsciiExt; // deprecated since 1.26.0: use inherent method instead

// Functions

// Main
fn main() {

    input! {
        A: usize,
        B: usize,
    }

    if A >= 13 {
        println!("{}", B);
    } else if A >= 6 {
        println!("{}", B/2);
    } else {
        println!("0");
    }

}

Measured memory_bytes: 4352
<?php
fscanf(STDIN, '%d %d', $n, $l);
$s_arr = [];
for($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%s', $s);
    $s_arr[] = $s;
}
sort($s_arr);
$result = '';
foreach($s_arr as $val) $result .= $val;
echo $result, PHP_EOL;

Measured memory_bytes: 4728
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
    let input1 = Console.ReadLine () |> Int32.Parse
    let input2 = Console.ReadLine () |> Int32.Parse
    printfn "%i" (6 - input1 - input2)
    0 // return an integer exit code


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
static const int MAX_H = 2000;
static const int MAX_W = 2000;
static const int INF = 0;

//int d[MAX_H][MAX_W];

int H, W;

int main(){
    cin >> H >> W;

    vector<vector<char>> S(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S.at(i).at(j);
        }
    }

    int ans = 0;

    vector<vector<int>> dp_w(H, vector<int>(W, 0)), dp_h(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S.at(i).at(j) == '.') {
                // H方向
                if (i > 0) dp_h.at(i).at(j) = dp_h.at(i - 1).at(j);
                if (dp_h.at(i).at(j) == 0) {
                    int k = i;
                    while (k < H && S.at(k).at(j) == '.') {
                        dp_h.at(i).at(j)++;
                        k++;
                    }
                }
                // W方向
                if (j > 0) dp_w.at(i).at(j) = dp_w.at(i).at(j - 1);
                if (dp_w.at(i).at(j) == 0) {
                    int k = j;
                    while (k < W && S.at(i).at(k) == '.') {
                        dp_w.at(i).at(j)++;
                        k++;
                    }
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S.at(i).at(j) == '.') ans = max(ans, dp_h.at(i).at(j) + dp_w.at(i).at(j) - 1);
        }
    }

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


Measured memory_bytes: 38632
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    long long N,T,Q;
    cin >> N >> T >> Q;

    vector<long long> A;
    vector<int> D;
    for(int i=0; i<N; ++i) {
        long long a;
        int d;
        cin >> a >> d;
        A.push_back(a);
        D.push_back(d);
    }

    for(int i=0; i<Q; ++i) {
        long long vip;
        long long pos;

        cin >> vip;
        if(D[vip-1]==1) {
            bool flag=false;
            for(int j=vip; j<N ; ++j) {
                if(D[j]==2) {
                    pos=A[j]/2+A[j-1]/2;
                    if(pos-A[vip-1]>T) break;
                    flag=true;
                    break;
                }
            }
            if(!flag) cout << A[vip-1]+T << endl;
            else cout << pos << endl;
        } else {
            bool flag=false;
            for(int j=vip-2; j>=0; --j) {
                if(D[j]==1) {
                    pos=A[j]/2+A[j+1]/2;
                    if(A[vip-1]-pos>T) break;
                    flag=true;
                    break;
                }
            }
            if(!flag) cout << A[vip-1]-T << endl;
            else cout << pos << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
ll n,k,ans=1;cin>>n>>k;
rep(i,n){
    if(ans*2<ans+k)ans *=2;
    else if(ans*2>ans+k)ans +=k;
    else ans +=k;
}
cout << ans << endl;

    return 0;
}





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

#define ll long long
const int mod = 1e9 + 7;

ll int dp[105][100005];
int wgt[105];
int val[105];

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

  int n, w;
  cin>>n>>w;

  for(int i=1;i<=n;i++)
    cin>>wgt[i]>>val[i];

  for(int i=1;i<=n;i++)
  {
    dp[i][wgt[i]] = val[i];
    for(int j=1;j<=w;j++)
    {
      dp[i][j] = max(dp[i][j], dp[i-1][j]);
      if(j - wgt[i] > 0)
        dp[i][j] = max(dp[i][j], dp[i-1][j-wgt[i]] + val[i]);
      dp[i][j] = max(dp[i][j], dp[i][j-1]);
    }
  }

  cout<<dp[n][w]<<endl;

  return 0;
}


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

using namespace std;

int left_first(string s) {
  int res=s[0]-'0';
  for(int i=1;i<s.size();i+=2) {
    if(s[i]=='*') res*=s[i+1]-'0';
    else res+=s[i+1]-'0';
  }
  return res;
}

int multi_first(string s) {
  stack<int> sdig;
  for(int i=0;i<s.size();++i) {
    if(s[i]=='*') {
      int tmp=sdig.top(); sdig.pop();
      sdig.push(tmp*(s[i+1]-'0'));
      i++;
    } else if(isdigit(s[i])) sdig.push(s[i]-'0');
  }
  int res=0;
  while(!sdig.empty()) {
    res+=sdig.top(); sdig.pop();
  }
  return res;
}

int main(){
  string s; cin >> s;
  int a; cin >> a;
  int le=left_first(s);
  int mu=multi_first(s);
  if(le==a&&mu==a) cout << "U";
  else if(le==a) cout << "L";
  else if(mu==a) cout << "M";
  else cout << "I";
  cout << endl;
  
  return 0;
}


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

int main() {
    string str1;
    getline(cin, str1);
    while(str1 != "-") {
        int m;
        cin >> m;
        int sum = 0;
        while (m) {
            int num;
            cin >> num;
            sum += num;
            m--;
        }
    int len = str1.length();
    int rest = sum % len;
    if (rest!=0) {
     cout << str1.substr(rest) + str1.substr(0, rest) << endl;
   } else {
     cout << str1 << endl;
   }
   cin >> str1;
  }
    return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long n;
int main()
{
    cin>>n;
    long long p=ceil(sqrt(n*1.0));
    for(long long i=p;i>=1;i--)
    {
        if(n%i==0)
        {
            cout<<(long long)i+(n/i)-2LL<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	N := 0
	if sc.Scan() {
		N, _ = strconv.Atoi(sc.Text())
	}
	A := make([]int, N)
	if sc.Scan() {
		for i, s := range strings.Fields(sc.Text()) {
			A[i], _ = strconv.Atoi(s)
		}
	}
	fmt.Println(String(A))
	insertionSort(A, N)
}

func insertionSort(A []int, N int) {
	for i := 1; i < N; i++ {
		v := A[i]
		j := i - 1
		for j >= 0 && A[j] > v {
			A[j+1] = A[j]
			j--
		}
		A[j+1] = v
		fmt.Println(String(A))
	}
}

func String(A []int) string {
	text := ""
	for i, val := range A {
		if i > 0 {
			text += " "
		}
		text += fmt.Sprint(val)
	}
	return text
}



Measured memory_bytes: 5328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 305
#define INT_MAX 1e14
#define f first
#define s second
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int no_of_vertex,no_of_edge,tank_size;
  int input1,input2,input3;
  int arr[maxn][maxn];
  vector<vector<pair<int,int> > > adj(maxn);
  int ar[maxn][maxn];
  for(int i=0;i<maxn;i++){
    for(int j=0;j<maxn;j++){
      arr[i][j] = INT_MAX;
      ar[i][j] = -1;
    }
  }
  cin >> no_of_vertex >> no_of_edge >> tank_size;
  for(int i=0;i<no_of_edge;i++){
    cin >> input1 >> input2 >> input3;
    if(input3>tank_size){
      continue;
    }
    adj[input1].push_back({input2,input3});
    adj[input2].push_back({input1,input3});
    arr[input1][input2] = input3;
    arr[input2][input1] = input3;
  }
  //makes answer
  for(int i=1;i<=no_of_vertex;i++){
    vector<pair<int,int> > visited(maxn,{INT_MAX,-1});
    vector<int> lastused(maxn,-1);
    priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > q1;//no_of_stop,left_fuel,node
    visited[i].first = 0;
    visited[i].second = tank_size;
    q1.push({0,{tank_size*(-1),i}});
    while(q1.size()!=0){
      pair<int,pair<int,int> > a = q1.top();
      q1.pop();
      a.s.f *= -1;
      if(visited[a.s.s].f!=a.first||visited[a.s.s].s!=a.s.f){
        continue;
      }
      for(auto k:adj[a.second.s]){
        int currused = 0,left = 0;
        if(k.second>a.s.f){
          currused = a.f+1;
          left = tank_size-k.second;
        }
        else{
          currused = a.f,left=a.s.f-k.second;
        }
        if(currused<visited[k.first].first){
          visited[k.first].first = currused;
          visited[k.first].second = left;
          left *= -1;
          q1.push({currused,{left,k.first}});
        }
        else if(currused==visited[k.first].first&&left>visited[k.first].second){
          visited[k.first].first = currused;
          visited[k.first].second = left;
          left *= -1;
          q1.push({currused,{left,k.first}});
        }
      }
    }
    for(int j=i+1;j<=no_of_vertex;j++){
      if(visited[j].first==INT_MAX){
        ar[i][j] = -1;
      }
      else{
        ar[i][j] = visited[j].first;
      }
    }
  }
  //process queries
  int no_of_queries;
  cin >> no_of_queries;
  for(int i=0;i<no_of_queries;i++){
    cin >> input1 >> input2;
    cout << ar[min(input1,input2)][max(input1,input2)] << "\n";
  }
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

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

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

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

t = Counter()
for _ in range(n):
    t += Counter([int(x) for x in input().split()][1:])

print(sum(v == n for v in t.values()))

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

int main()
{
	int a, b;
	string op;
	cin >> a >> op >> b;
	if (op == "-")
	{
		cout << (a - b) << endl;
	}
	else
	{
		cout << (a + b) << endl;
	}
}

Measured memory_bytes: 256
x=list(input().split())
x1=int(x[0])
y1=int(x[1])
x2=int(x[2])
y2=int(x[3])
xlength=x2-x1
ylength=y2-y1
x3=x2-ylength
y3=y2+xlength
x4=x1-ylength
y4=y1+xlength

  
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	if(s=="RRR") cout<<3<<'\n';
	else
	{
		if(s=="SSS") cout<<0<<'\n';
		else
		{
			if(s=="RRS"||s=="SRR") cout<<2<<'\n';
			else cout<<1<<'\n';
		}
	}
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    double exp_cycle = 1 / pow(0.5, M);
    double X = exp_cycle * (100 * (N - M) + 1900 * M);
    cout << round(X) << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;

const int maxn = 200005;
int a[maxn], last, n;
long long ans;

int main() {
	scanf("%d", &n);
	rep (i, 1, n) scanf("%d", &a[i]);
	if (a[1]) return puts("-1"), 0;

	per (i, n, 1) {
		if (a[i] < a[i+1] - 1)
			return puts("-1"), 0;
		if (a[i] > a[i+1] - 1)
			ans += a[i];
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL X, Y, A, B ,C;
	cin >> X >> Y >> A >> B >> C;

	vector<LL> P, Q, R;
	for(int i=0; i<A; i++){ LL p; cin >> p; P.push_back(p); }
	for(int i=0; i<B; i++){ LL q; cin >> q; Q.push_back(q); }
	for(int i=0; i<C; i++){ LL r; cin >> r; R.push_back(r); }

	sort(P.begin(), P.end(), std::greater<LL>() );
	sort(Q.begin(), Q.end(), std::greater<LL>() );
	sort(R.begin(), R.end(), std::greater<LL>() );

	vector<LL> T;

	//Pの中で上位X個をTに入れる
	for(int i=0; i<X; i++){
		T.push_back(P[i]);
	}
	//Qの中で上位X個をTに入れる
	for(int i=0; i<Y; i++){
		T.push_back(Q[i]);
	}
	//RはすべてTに入れる。
	for(int i=0; i<R.size(); i++){
		T.push_back(R[i]);
	}

	sort(T.begin(), T.end(), std::greater<LL>() );

	//上位X+Y個を取り出す
	LL ans = 0;
	for(int i=0; i<X+Y; i++){
		ans += T[i];
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 9788
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();
    let c: i64 = iter.next().unwrap().parse().unwrap();
    let d: i64 = iter.next().unwrap().parse().unwrap();
    let e: i64 = iter.next().unwrap().parse().unwrap();
    let k: i64 = iter.next().unwrap().parse().unwrap();

    println!("{}", if e - a <= k { "Yay!" } else { ":(" });
}


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

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

	vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (s[i] == s[j])
			{
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
				dp[i + 1][j + 1] = min(dp[i + 1][j + 1], abs(i - j));
			}
		}
	}

	int ans = 0;
	for (auto &&xs : dp)
	{
		for (auto &&x : xs)
		{
			ans = max(ans, x);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 98176
#include <stdio.h>
int main(){
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if(x >= r && x+r <= W && y >= r && y+r <= H){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1820
#include<iostream>
using namespace std;
int main(){
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        else{
            int total = m+f;
            if(total < 30 || m == -1 || f == -1){
                cout << "F" <<endl;
            }
            else if(total >= 30 && total < 50){
                if( r >= 50 ){
                    cout << "C" <<endl;
                }
                else{
                    cout << "D" << endl;
                }
            }
            else if(total >= 50 && total < 65){
                cout << "C" << endl;
            }
            else if(total >= 65 && total < 80){
                cout << "B" <<endl;
            }
            else if (total >= 80){
                cout << "A" << endl;
            }
            
        }  
        
    }
    return 0;
}


Measured memory_bytes: 3072
parseInt(x) = parse(Int, x)

function main()
	n = readline() |> parseInt
	x = Dict{Int,Int}()
	for i in 1:n
		a = readline() |> parseInt
		if haskey(x,a)
			x[a] += 1
		else
			x[a] = 1
		end
	end
	disc = 0
	for key in keys(x)
		if x[key]%2 == 1
			disc += 1
		end
	end
	print(disc)
end

main()

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

class Main
{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char C = sc.next().charAt(0);
    if (C == 'A') System.out.println("T");
    else if (C == 'T') System.out.println("A");
    else if (C == 'C') System.out.println("G");
    else System.out.println("C");
  }
}


Measured memory_bytes: 26828
#include "stdio.h"

static int IsRightTriangle( int a, int b,int c);

int main( void )
{
    int i,cnt,a,b,c;
    
    scanf("%d",&cnt);
    
    for(i=0;i<cnt;i++){
        scanf("%d %d %d",&a,&b,&c);  
        if( 1 == IsRightTriangle(a,b,c) ){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
}

static int IsRightTriangle( int a, int b,int c)
{
    int max;
    int ot1,ot2;
    max = a;
    ot1 = b;
    ot2 = c;
    if( max < b ){
        max = b;
        ot1 = a;
        ot2 = c;
    }
    if( max < c ){
        max = c;
        ot1 = a;
        ot2 = b;
    }
    
    if( max*max == ot1*ot1 + ot2*ot2 ){
        return 1;
    }else{
        return 0;
    }
}

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

tmp=0
cnt=0
m=[]
for i in range(n+1):
    m.append(tmp)
    if i<n:
        tmp+=l[i]
for i in range(n+1):
    if m[i]<=x:
        cnt+=1
print(cnt)


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map(String::toLong)
    val a = if (A.and(1) == 0L) 0L else A
    val b = if (B.and(1) == 0L) B else 0L
    val n = (B - A + 1) / 2 - if (((B - A + 1).and(1) == 0L) && (a != 0L || b != 0L)) 1 else 0
    println(a.xor(b).xor(n.and(1)))
}

Measured memory_bytes: 35980
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int arr[MAXN];
int b[MAXN];
#define self nodes[p]
#define ls nodes[p << 1]
#define rs nodes[p << 1 | 1]
struct SegmentTree {
    struct Node {
        int cov, tag;
    };
    Node nodes[MAXN << 2];
    int tot;

    inline void modify(int l, int r, int p, int f) {
        self.tag += nodes[f].tag;
        self.cov += (r - l + 1) * nodes[f].tag;
    }

    inline void push_down(int l, int r, int p) {
        if (self.tag != 0) {
            int mid = (l + r) / 2;
            modify(l, mid, p << 1, p);
            modify(mid + 1, r, p << 1 | 1, p);
            self.tag = 0;
        }
    }
    void push_up(int p) { self.cov = ls.cov + rs.cov; }
    void update(int x, int y, int l, int r, int p, int v) {
        if (x <= l && y >= r) {
            self.cov += (r - l + 1) * v;
            self.tag += v;
            return;
        }
        push_down(l, r, p);
        int mid = (l + r) / 2;
        if (x <= mid) update(x, y, l, mid, p << 1, v);
        if (y > mid) update(x, y, mid + 1, r, p << 1 | 1, v);
        push_up(p);
    }
    int query(int x, int l, int r, int p) {
        if (l == r) return self.cov;
        int mid = (l + r) / 2;
        push_down(l, r, p);
        if (x <= mid)
            return query(x, l, mid, p << 1);
        else
            return query(x, mid + 1, r, p << 1 | 1);
    }
};

SegmentTree tree;
char text[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &arr[i]);
        tree.update(max(1, i - arr[i]), min(n, i + arr[i]), 1, n, 1, 1);
    }
    for (int i = 0; i < min(m, 50); i++) {
        for (int j = 1; j <= n; j++) {
            b[j] = tree.query(j, 1, n, 1);
        }
        for (int j = 1; j <= n; j++) {
            tree.update(max(1, j - arr[j]), min(n, j + arr[j]), 1, n, 1, -1);
            arr[j] = b[j];
        }
        for (int j = 1; j <= n; j++) {
            tree.update(max(1, j - b[j]), min(n, j + b[j]), 1, n, 1, 1);
        }
    }
    for (int j = 1; j <= n; j++) {
        printf("%d ", b[j]);
    }
    return 0;
}

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

int main()
{
	int i;
	cin >> i;
	int h, m, s;
	h = i / 3600;
	int tmp = i % 3600;
	m = tmp / 60;
	s = tmp - m * 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3108
#!ruby -E Windows-31J:utf-8

def cal nums
    r_pat=0
    r_sum=0
    (1..nums.length).each{|l|
        t_pat,t_sum = cal nums[l...nums.length]
        r_pat += t_pat
        r_sum += (nums[0...l]).to_i*t_pat + t_sum
    }
    return 1,0 if r_pat==0
    return r_pat,r_sum
end


nums = $stdin.gets.chomp
pat,sum = cal nums
pat*=1

puts sum

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  ll ans = 0, sum = 0, mod = 1e9 + 7;
  for (int i = 0; i < n; i++) {
    ll x; cin >> x;
    ans += sum * x % mod;
    sum = (sum + x) % mod;
  }
  cout << (ans % mod) << endl;

  return 0;
}


Measured memory_bytes: 3652