akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int n = in.nextInt();
            final int k = in.nextInt();
            int[][] field = new int[k * 4 + 1][k * 4 + 1];
            for (int i = 0; i < n; i++) {
                int cx = in.nextInt();
                int cy = in.nextInt();
                char cc = in.next().charAt(0);
                if (cc == 'B') {
                    cy += k;
                }
                cx %= (k * 2);
                cy %= (k * 2);

                field[cx][cy]++;
                field[cx + k][cy]--;
                field[cx][cy + k]--;
                field[cx + k][cy + k]++;

                cx += k;
                cy += k;
                field[cx][cy]++;
                field[cx + k][cy]--;
                field[cx][cy + k]--;
                field[cx + k][cy + k]++;
            }
            for (int i = 0; i < 4 * k; i++) {
                for (int j = 0; j < 4 * k - 1; j++) {
                    field[i][j + 1] += field[i][j];
                }
            }
            for (int i = 0; i < 4 * k - 1; i++) {
                for (int j = 0; j < 4 * k; j++) {
                    field[i + 1][j] += field[i][j];
                }
            }

            int[][] sum = new int[2 * k][2 * k];
            for (int i = 0; i < 2 * k; i++) {
                for (int j = 0; j < 2 * k; j++) {
                    sum[i][j] += field[i][j] + field[i + (2 * k)][j] + field[i][j + (2 * k)] + field[i + (2 * k)][j + (2 * k)];
                }
            }

            int max = 0;
            for (int x = 0; x < k * 2; x++) for (int y = 0; y < k * 2; y++) if (sum[x][y] > max) max = sum[x][y];
            out.println(max);
        }

    }
}



Measured memory_bytes: 165092
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}



ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(ll n)
{
    if(n==1)
        return false;
    for(ll i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+=  n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
int a=RD(),b=RD();
if((a+b)%2==0)
cout<<(a+b)/2<<"\n";
else
cout<<"IMPOSSIBLE\n";
}


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

struct Ps{
  int r,c;
  Ps():r(0),c(0){}
  Ps(int r,int c):r(r),c(c){}
  Ps operator+(const Ps&p)const
  { return Ps(r+p.r,c+p.c);  }
  friend istream& operator>>(istream&is,Ps&p)
  {is >> p.r >> p.c; return is;  }
};

int main(){
  int h,w; cin >> h >> w;
  Ps s,g; cin >> s >> g;
  s = s+Ps(-1,-1);
  g = g+Ps(-1,-1);
  bitset<1000> mz[1000];
  for(int i = 0; i < h; ++i)for(int j = 0; j < w; ++j)
      mz[i][j] = []{char c; cin >> c; return c;}() == '.';
  optional<int> distance[1000][1000];
  deque<pair<Ps,int>> dq;
  dq.emplace_front(s,0);
  while(!dq.empty()){
    auto [ps,di] = dq.front();
    dq.pop_front();
    if(distance[ps.r][ps.c])continue;
    distance[ps.r][ps.c] = di;
    if(ps.r==g.r && ps.c==g.c)break;
    static int mr[] = {0,0,1,-1};
    static int mc[] = {1,-1,0,0};
    for(int i = 0; i < 4; ++i){
      Ps nps = ps + Ps(mr[i],mc[i]);
      if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
      if(!mz[nps.r][nps.c])continue;
      if(distance[nps.r][nps.c])continue;
      dq.emplace_front(nps,di);
      mz[nps.r][nps.c] = 0;
    }
    static int nr[] = {-2,-2,-2,-2,-2,-1,-1,-1,-1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};
    static int nc[] = {-2,-1, 0, 1, 2,-2,-1, 1, 2,-2, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2};
    for(int i = 0; i < 20; ++i){
      Ps nps = ps + Ps(nr[i],nc[i]);
      if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
      if(!mz[nps.r][nps.c])continue;
      if(distance[nps.r][nps.c])continue;
      dq.emplace_back(nps,di+1);
    }
  }
  cout << (distance[g.r][g.c] ? distance[g.r][g.c].value() : -1) << endl;
}


Measured memory_bytes: 12000
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int a;
    int b;
    int c;
    int ans;

    cin >> a >> b >> c;
    ans = b/a;
    if(ans>c){
        ans = c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
import itertools

N = int(input())

renban = list(range(N))
michi = list(itertools.combinations(renban, 2))
arr = [list(map(int, input().split())) for _ in range(N)]
kyori_list =[]

for i in range(len(michi)):
    kyori = math.sqrt((arr[michi[i][0]][0]-arr[michi[i][1]][0])**2+(arr[michi[i][0]][1]-arr[michi[i][1]][1])**2)
    kyori_list.append(kyori)

print(sum(kyori_list)*(N-1)/len(michi))

Measured memory_bytes: 38768
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0549
#include<vector>
#include<iostream>
#include<cmath>
using namespace std;
//宿場町はn個　m日間
int n, m, pos = 0, a;
long long ans = 0;
long long t[100000];

int main()
{
	
	cin >> n >> m;
	t[0] = 0;
	for (int i = 1; i < n; i++)
	{
		cin >> t[i];
		t[i] += t[i - 1];
	}
	pos = 0;
	for (int i = 0; i < m; i++)
	{
		cin >> a;
		ans += abs(t[pos]-t[pos+a]);
		ans %= 100000;
		pos += a;

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


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

int main(){
  int n,t;
  cin>>n>>t;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
  }
  int m[n+1];
  m[0]=0;
  rep(i,0,n){
    m[i+1]=max(m[i],a[n-1-i]);
  }
  int cur=0;
  int ans=0;
  rep(i,0,n-1){
    if(cur<-a[n-2-i]+m[i+1]){
      cur=-a[n-2-i]+m[i+1];
      ans=1;
    }
    else if(cur==-a[n-2-i]+m[i+1]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int N, A, B;
  string s;
  cin >> N >> A >> B >> s;
  
  int a = 0, b = 0;
  for (char c : s) {
    cerr << a << " " << b << endl;
    if (c == 'a') {
      cout << (a + b < A + B ? "Yes" : "No") << endl;
      a += (a + b < A + B);
    }
    else if (c == 'b') {
      cout << (a + b < A + B && b < B ? "Yes" : "No") << endl;
      b += (a + b < A + B && b < B);
    }
    else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true){
        	String[] line = br.readLine().split(" ");
        	int h = Integer.parseInt(line[0]);
        	int w = Integer.parseInt(line[1]);
        	if(h==0 && w== 0) break;
        	
        	for(int j=0;j<h;j++){
        	for(int i=0;i<w;i++){
        	if(j== 0||j==h-1 ||i ==0||i==w-1){
        		sb.append("#");
        	}else{
        		sb.append(".");
        	}
        	}
        	sb.append("\n");
        	}
        	sb.append("\n");	
        }
        System.out.print(sb);
    }
}

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

int main() {
	int n;
	cin>>n;
	int ans=0;
	int a[2][n];
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<n;i++){
		int m=0;
		for(int j=0;j<=i;j++){
			m+=a[0][j];
		}
		for(int j=i;j<n;j++){
			m+=a[1][j];
		}
		if(m>ans){
			ans=m;
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

const int INF = 1 << 29;

int clamp(int n, int mi, int ma) {
    return max(mi, min(ma, n));
}

int dp[20010][256];
int solve_testcase() {
    int N, M; cin >> N >> M;
    if(N == 0 and M == 0) return 1;

    vector<int> C(M);
    for(int i=0; i<M; i++) cin >> C[i];

    vector<int> x(N);
    for(int i=0; i<N; i++) cin >> x[i];

    const int mi = 0, ma = 255;
    fill(dp[0], dp[N+1], INF);
    dp[0][128] = 0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<256; j++) {
            for(int k=0; k<M; k++) {
                int nj = clamp(j + C[k], mi, ma);
                int er = (nj - x[i]) * (nj - x[i]);
                dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + er);
            }
        }
    }

    cout << *min_element(dp[N], dp[N] + 256) << endl;
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



Measured memory_bytes: 23148
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split('/');
            var y = int.Parse(_[0]);
            var m = int.Parse(_[1]);
            var d = int.Parse(_[2]);
            var s = new DateTime(y,m,d);

            var t = new DateTime(2019,4,30);
            Console.WriteLine(t.Date >= s.Date ? "Heisei" : "TBD");
        }
    }
}


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

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

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

const long long INF = 1LL << 60;

long long h[100010];
long long dp[100010];

int main() {
  int N; cin >> N;
  for (int i = 1; i <= N; i++) cin >> h[i];
  for (int i = 0; i < 100010; i++) dp[i] = INF;

  dp[1] = 0;

  for (int i = 2; i <= N; i++) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if (3 <= i) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){

int m[10];
for(int i=0;i<10;i++)cin>>m[i];
sort(m,m+10,greater<int>());
cout<<m[0]<<endl<<m[1]<<endl<<m[2]<<endl;

return 0;

}

Measured memory_bytes: 1176
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string().chars().collect::<Vec<char>>();
    let mm = 2019;
    let mut v: Vec<u64> = vec![0;s.len()];
    v[s.len()-1] = s[s.len()-1].to_digit(10).unwrap() as u64;
    let mut base = 10;
    for i in (0..s.len()-1).rev(){
        v[i] = (v[i+1] + s[i].to_digit(10).unwrap() as u64*base) % mm;
        base = (base*10)%mm;
    }

    let mut counters: Vec<u64> = vec![0;mm as usize];
    for elem in v{
        counters[elem as usize] += 1;
    }

    let mut ans = 0;
    for i in 0..mm as usize{
        if counters[i] > 0{
            ans += counters[i]*(counters[i]-1)/2;
        }
    }
    println!("{}", ans + counters[0]);
}


Measured memory_bytes: 4344
/* Author rumoisen */
/* created 2018/10/13 */

#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include<iostream>
#include <algorithm>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main()
{
    int w,a,b;
    cin>>w>>a>>b;
    if(a+w<b) cout<<b-a-w;
    else{
        if(b+w<a) cout<<a-b-w;
        else cout<<0;
    }
    return 0;
}

Measured memory_bytes: 256
// #define H

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>


using namespace std;
const int maxN = 2e5 + 5;

int main() {
#ifdef H
    freopen("in.in", "r", stdin);
#endif
    /*
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    int sum = a + b + c;
    vector<pair<int, char>> myPairs;
    for (int i = 0; i < a; i++){
        int p;
        cin >> p;
        myPairs.push_back(make_pair(p, 'r'));
    }
    for (int i = 0; i < b; i++){
        int p;
        cin >> p;
        myPairs.push_back(make_pair(p, 'g'));
    }
    for (int i = 0; i < c; i++){
        int p;
        cin >> p;
        myPairs.push_back(make_pair(p, 'c'));
    }
    sort(myPairs.begin(), myPairs.end(), greater<int>());
    */


    int K, N;
    cin >> K >> N;
    int dist[maxN], res[maxN];
    int sum = 0;
    for (int i = 0; i < N; i++)
        cin >> dist[i];

    for (int i = 0; i < N - 1; i++) {
        res[i] = dist[i + 1] - dist[i];
        sum += res[i];
    }

    res[N - 1] = K - sum;
    sort(res, res + N);
    cout << K - res[N - 1];
}


Measured memory_bytes: 1792
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int k,x;
    cin>>k>>x;
    int lft=x-k+1;
    int rgt=x+k-1;
    f(i,lft,rgt)
    {
        cout<<i<<" ";
    }
    cout<<endl;



















    return 0;

}













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

int main() {
  int x, N;
  cin >> N >> x;
  int a = 1;
  for (int i = 0; i < N; i++) {
    if (a * 2 < a + x) {
      a *= 2;
    }
    else {
      a += x;
    }
  }
  cout << a << endl;
}
      

Measured memory_bytes: 256
import java.math.BigDecimal
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()

    val counts = IntArray(5)
    while (sc.hasNext()) {
        val line = sc.nextLine().trim()
        if (line.isNotEmpty()) {
            when (line[0]) {
                'M' -> ++counts[0]
                'A' -> ++counts[1]
                'R' -> ++counts[2]
                'C' -> ++counts[3]
                'H' -> ++counts[4]
            }
        }
    }

    var ret = BigDecimal(0)

    for (i in 0 until 5 - 2) {
        for (j in i + 1 until 5 - 1) {
            for (k in j + 1 until 5 - 0) {
                val bi = BigDecimal(counts[i])
                val bj = BigDecimal(counts[j])
                val bk = BigDecimal(counts[k])
                ret = ret.add(bi.multiply(bj).multiply(bk))
            }
        }
    }

    println(ret)
}


Measured memory_bytes: 111564
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int f(int n) {
  if (n % 2 == 1) return 3 * n + 1;
  else return n / 2;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int s; cin >> s;
  map<int, bool> mp;
  int tmp = s;
  mp[tmp] = true;
  REP(i, 1000000) {
    if (mp[f(tmp)]) {
      cout << i + 2 << '\n';
      return 0;
    } else {
      tmp = f(tmp);
      mp[tmp] = true;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

constexpr ll MOD = 1000000007;

int n, m;
ll dp[1005][1005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	dp[1][1] = 1;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < m; ++j) {
			if (i == 0 && j == 0) continue;
			if (s[j] == '.') {
				dp[i+1][j+1] = dp[i][j+1]+dp[i+1][j];
				dp[i+1][j+1] %= MOD;
			}
		}
	}
	cout << dp[n][m] << "\n";
	return 0;
}

Measured memory_bytes: 8192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            long N = Long.parseLong(br.readLine());
            long ans = 0;
            long base = 100;
            while (base < N) {
                base += base/100;
                ans++;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 25332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(n, m, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

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

Measured memory_bytes: 256
n,m = map(int,input().split())
mod = 10**9+7
dp = [1]*(n+1)
for i in range(m):
    dp[int(input())] =0

for i in range(2,n+1):
    if dp[i]!=0:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[n]%mod)


Measured memory_bytes: 460020
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC165D
//ABC165C
//ABC165B

//ABC165A
int main(void) {
  int n, k, a, b, i, cou=0, tmp;
  scanf("%d %d %d", &k, &a, &b);
  for(i=a; i<=b; i++){
    if(i%k==0){
      printf("OK");
      return 0;
    }

  }
  printf("NG");
}

Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x,int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
		return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {	
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	if(x>=y)cout << min({ c*max(x,y) * 2,a*x + b * y,c*min(x,y) * 2 + (x-y)*a }) << endl;
	else cout << min({ c*max(x,y) * 2,a*x + b * y,c*min(x,y) * 2 + (y-x)*b }) << endl;
	ll
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int W = 6, H = 12;

typedef vector<vector<char>> Field;

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

int dfs_count(Field& f, int x, int y, char color) {
    int blocks = 1;
    f[y][x] = '.';
    REP(i, 4) {
        int sx = x + dx[i], sy = y + dy[i];
        if (0 <= sx && sx < W && 0 <= sy && sy < H) {
            if (f[sy][sx] == color) {
                blocks += dfs_count(f, sx, sy, color);
            }
        }
    }
    f[y][x] = color;
    return blocks;
}

void dfs_disappear(Field& f, int x, int y, char color) {
    f[y][x] = '.';
    REP(i, 4) {
        int sx = x + dx[i], sy = y + dy[i];
        if (0 <= sx && sx < W && 0 <= sy && sy < H) {
            if (f[sy][sx] == 'O') {
                f[sy][sx] = '.';
            }
            if (f[sy][sx] == color) {
                dfs_disappear(f, sx, sy, color);
            }
        }
    }
}

bool disappear(Field& f) {
    bool update = false;
    REP(y, 12) {
        REP(x, 6) {
            if (f[y][x] == '.') continue;
            if (f[y][x] == 'O') continue;
            int blocks = dfs_count(f, x, y, f[y][x]);
            if (blocks >= 4) {
                dfs_disappear(f, x, y, f[y][x]);
                update = true;
            }
        }
    }
//    LOG("======\n");
//    REP(y, H) {
//        REP(x, W) {
//            LOG("%c", f[y][x]);
//        }
//        LOG("\n");
//    }
    // fall down
    REP(x, 6) {
        REDO:
        int bottom = -1;
        for (int y = 11; y >= 0; y--) {
            if (bottom == -1 && f[y][x] == '.') {
                bottom = y;
            } else if (bottom != -1 && f[y][x] != '.') {
                swap(f[bottom][x], f[y][x]);
                goto REDO;
            }
        }
    }
    return update;
}

int main() {
    int n;
    cin >> n;
    REP(i, n) {
        Field f(H, vector<char>(W));
        REP(y, H) REP(x, W) cin >> f[y][x];
        int chain = 0;
        while (disappear(f)) {
            chain++;
//            LOG("------\n");
//            REP(y, H) {
//                REP(x, W) {
//                    LOG("%c", f[y][x]);
//                }
//                LOG("\n");
//            }
        }
        cout << chain << endl;
    }
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    ll A,B,C;
    cin >> A >> B >> C;
    if(!(A <= B))swap(A,B);
    Yes(A <= C && C <= B);
}

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

import functools
import itertools
import math

from collections import defaultdict

k = int(input())

@functools.lru_cache(maxsize=40000)
def gcd(a, b):
    return math.gcd(a, b)

last_result = defaultdict(int)
for a, b in itertools.product(range(1, k+1), repeat=2):
    tmp = gcd(a, b)
    last_result[tmp] += 1

s = 0
for ab, count in last_result.items():
    for c in range(1, k+1):
        s += gcd(ab, c) * count

print("{}".format(s))


Measured memory_bytes: 15564
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;

const int MOD = 1e9 + 7;

int n;
long long k;


vector<vector<int>> mul(vector<vector<int>> A, vector<vector<int>> B) {
    vector<vector<int>> C(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < n; ++k) {
                C[i][j] += ((long long) A[i][k] * B[k][j]) % MOD;
                C[i][j] %= MOD;
            }
        }
    }
    return C;
}

/*
vector<vector<int>> mod_pow(vector<vector<int>> A, long long k) {
    if(k % 2 == 1) {
        if (k == 1) return A;
        return mul(mod_pow(A, k - 1), A);
    } else {
        vector<vector<int>> half = mod_pow(A, k / 2);
        return mul(half, half);
    }
}
*/


/*
vector<vector<int>> mod_pow(vector<vector<int>> A, long long k) {
    if (k == 0) {
        vector<vector<int>> ans(n, vector<int>(n, 0));
        for(int i = 0; i < n; ++i) ans[i][i] = 1;
        return ans;
    }
    vector<vector<int>> half = mod_pow(A, k / 2);
    if (k % 2 == 1) {
        return mul(mul(half, half), A);
    } else {
        return mul(half, half);
    }
}
*/

vector<vector<int>> mod_pow(vector<vector<int>> A, long long k) {
    vector<vector<int>> ans(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i) ans[i][i] = 1;
    vector<vector<int>> v = A;
    if(k == 0) return ans;
    while(k) {
        if(k % 2 == 1) ans = mul(ans, v);
        k /= 2;
        v = mul(v, v);
    }
    return ans;
}

void add_self(int & x, int y) {
    x += y;
    if(x >= MOD) x -= MOD;
}

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    vector<vector<int>> A(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            cin >> A[i][j];
        }
    }
    vector<vector<int>> ans = mod_pow(A, k);
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            add_self(cnt, ans[i][j]);
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <cstring>
#include <map>
#include <queue>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
int const maxn = 1e5+5;
int a[maxn], b[maxn], m[maxn][3], s[maxn];
int main(){
	int A, B, M;
	scanf("%d %d %d", &A, &B, &M);
	int min1 = INF, min2 = INF;
	for(int i = 1; i <= A; i++){
		scanf("%d", &a[i]);
		min1 = min(min1, a[i]);
	}
	for(int i = 1; i <= B; i++){
		scanf("%d", &b[i]);
		min2 = min(b[i], min2);
	}
	for(int i = 0; i < M; i++)
		for(int j = 0; j < 3; j++)
			scanf("%d", &m[i][j]);
	int Min = INF;
	for(int i = 0; i < M; i++)
		for(int j = 0; j < 3; j++){
			s[i] = a[m[i][0]] + b[m[i][1]] - m[i][2];
			Min = min(s[i], Min);
		}
	Min = min(min1+min2, Min); 
	printf("%d\n", Min);
}

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

using namespace std;

int main(){
    int n, k, num = 1;
    int a[200000], b[200000] = {};

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

    sort(a, a+n);
    int j = 0;
    b[j]++;
    for(int i = 1; i < n; i++){
        if(a[i] != a[i-1]){
          num++;
          j++;
        }
        b[j]++;
    }
    sort(b,b+j+1);
    int ans = 0;
    int mem_ans = 0;
    if(num > k){
        mem_ans = num-k;
        for(int i = 0; i < mem_ans; i++){
            ans += b[i];
        }
    }
    cout << ans << '\n';
}

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

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

    for(int x = 0; x <= n; ++x){
        for(int y = 0; y <= n - x; ++y){
            int z = n - x - y;
            if(10000 * x + 5000 * y + 1000 * z == s){
                cout << x << " "<< y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    char ch;

	cin >> ch;

	if (ch == 'A') Out('T');
	else if (ch == 'C') Out('G');
	else if (ch == 'G') Out('C');
	else Out('A');
	
	return 0;
}


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

item_prices = []

for i in range(num):
    price = int(input())
    item_prices.append(price)
    
highest_price = max(item_prices)

item_prices[item_prices.index(highest_price)] = highest_price // 2

total_price = sum(item_prices)
print(total_price)

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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;


int main(){
	setIO();
	int x; cin >> x;
	if (x >= 1800) cout << "1\n";
	else if (x >= 1600) cout << "2\n";
	else if (x >= 1400) cout << "3\n";
	else if (x >= 1200) cout << "4\n";
	else if (x >= 1000) cout << "5\n";
	else if (x >= 800) cout << "6\n";
	else if (x >= 600) cout << "7\n";
	else cout << "8\n";
}

Measured memory_bytes: 3556
package main

import (
	"fmt"
	"math"
)

func countPrime(nums []int) int {
	counter := 0
	for i := range nums {
		if true == isPrime(nums[i]) {
			counter++
		}
	}
	return counter
}

func isPrime(num int) bool {

	if num == 2 {
		return true
	} else if num < 2 {
		return false
	} else if (num % 2) == 0 {
		return false
	} else {
		for i := 3; i <= int(math.Sqrt(float64(num))); i += 2 {
			if (num % i) == 0 {
				return false
			}
		}
	}
	return true
}

func main() {
	var num int
	fmt.Scanln(&num)
	nums := make([]int, num)
	for i := range nums {
		fmt.Scanln(&nums[i])
	}
	fmt.Println(countPrime(nums))
}




Measured memory_bytes: 1760
#include <iostream>
using namespace std;
int main(){
  //入力用
  char S[100];
  cin >> S;
  //奇数番目にLなし
  //偶数番目にRなし
  for(int i=0;i<sizeof(S);i++){
    if(i%2==0 && S[i]=='L'){
      cout << "No" <<endl;
      return 0;
    }else if(i%2==1 && S[i]=='R'){
      cout << "No" <<endl;
      return 0;
    }
  }
  cout << "Yes" <<endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    if n <= 1:
        return 0
    return P(n, r)//math.factorial(r)
N = int(input())
d = defaultdict(int)
for i in range(N):
    d[','.join(sorted(input()))] += 1
ans = 0
for value in d.values():
    ans += C(value,2)
print(ans)

Measured memory_bytes: 18908
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long Res=0, n,i,j,k;
    cin >> n;
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
            for (k=1;k<=n;k++) Res=Res+__gcd(__gcd(i,j),k);
    cout<<Res;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007

int D;
vector<int> c(26);
vector<vector<int>> s;

void score(vector<int> t){
  vector<int> last(26,0);
  int ans=0;
  for(int i=0;i<D;i++){
    ans+=s.at(i).at(t.at(i));
    last.at(t.at(i))=i+1;
    for(int j=0;j<26;j++){
      ans-=c.at(j)*((i+1)-last.at(j));
    }
    cout<<ans<<endl;
  }
}


int main(){
  cin>>D;
  for(int i=0;i<26;i++){
    cin>>c.at(i);
  }
  s.resize(D);
  for(int i=0;i<D;i++){
    s.at(i).resize(26);
    for(int j=0;j<26;j++){
      cin>>s.at(i).at(j);
    }
  }
  vector<int> t(D);
  for(int i=0;i<D;i++){
    cin>>t.at(i);
    t.at(i)--;
  }

  score(t);
}


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;

int main(){
    int N,K;
    double ans = 0.0;
    cin >> N >> K;

    rep1(i,N){
        double tmp = 1.0/N;
        int now = i;
        while(now < K){
            now *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }
    //cout << ans << endl;
    printf("%.15lf",ans);
    //cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c-(a-b)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( ) {
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if (W >= (x + r) && 0 <= (x - r)) {
    if (H >= (y + r) && 0 <= (y - r)) {
      printf("Yes\n");
    }
    else {
      printf("No\n");
    }
  }
  else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<string>
using namespace std;
string s;
int len,l,r;
int main()
{
    cin>>s;
    len=s.length();
    for(int i=0;i<len;i++)
    {
        if(s[i]=='A')
        {
            l=i;
            break;
        }
    }
    for(int i=len-1;i>=0;i--)
    {
        if(s[i]=='Z')
        {
            r=i;
            break;
        }
    }
    cout<<r-l+1;
    return 0;
}

Measured memory_bytes: 640
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Tue May 22 01:17:44 2018
//
#include <bits/stdc++.h>
using namespace std;

#define rep(_n, _init, _N) for (int32_t _n = _init; _n < (int32_t)(_N); _n++)
#define rrep(_n, _N, _end) for (int32_t _n = (int32_t)(_N); _n >= _end; _n--)
#define iceil(_x, _y) (((_x) + (_y)-1) / (_y))
#define ifloor(_x, _y) ((_x) / (_y))

static const double pi = 2 * asin(1);
static const double precision = 10e-9;

struct node_t {
  int32_t to;
  int32_t weight;
};

static int32_t N, M;
static vector<vector<node_t>> graph;
static vector<int32_t> vals;

static bool dfs(int root, int val)
{
  if (vals[root] == -(1 << 30)) {
    vals[root] = val;
  } else {
    return vals[root] == val;
  }

  for (auto node : graph[root]) {
    int32_t to = node.to;
    int32_t weight = node.weight;
    if (!dfs(to, val + weight)) {
      return false;
    }
  }
  return true;
}

int32_t main()
{
  cin >> N >> M;

  graph.resize(N + 1, vector<node_t>());
  for (int32_t i = 0; i < M; i++) {
    int32_t L, R, D;
    cin >> L >> R >> D;
    graph[L].push_back(node_t{R, D});
    graph[R].push_back(node_t{L, -D});
  }

  vals.resize(N + 1, -(1 << 30));
  for (int32_t i = 1; i < graph.size(); i++) {
    if (vals[i] == -(1 << 30) && !dfs(i, 0)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 11008
#include<iostream>
#include<vector>
#include <cmath>
#include <map>

#define rep(i,n) for(int (i) = 0;(i)<(n);(i)++)


using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[109];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  int sum=0;
  for(int i=1;i<n;i++)sum+=a[i];
  if(a[0]<sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}


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

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define len(a) ((int) (a).size())
#define all(a) (a).begin(), (a).end()

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    if (n & 1) cout << b[n / 2] - a[n / 2] + 1; else cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1;
    return 0;
}


Measured memory_bytes: 6352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int A, B, C, X, Y;
    int i;
    int Z;
    cin >> A >> B >> C >> X >> Y;
    int result = 0;
    if(A + B > 2 * C)
        result += min(X, Y) * 2 * C;
    else
        result += min(X, Y) * (A + B);
    if(X > Y){
        if(A > 2 * C)
            result += (X - Y) * 2 * C;
        else
            result += (X - Y) * A;
    }
    else{
        if(B > 2 * C)
            result += (Y - X) * 2 * C;
        else   
            result += (Y - X) * B;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db(x)					  cout << "!!!!!! " << #x << " => " << x << "\n"
#define ll							long long int
using namespace std;

// DP
///////////////////////////////////////////////////////////////////////////
// KP
ll vs[105], wes[105];
ll memokp[105][(int)1e5+5];
ll kp(int n, int w){
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=w;j++){
			if(wes[i-1] > j) memokp[i][j] = memokp[i-1][j];
			else memokp[i][j] = max(memokp[i-1][j], 
					memokp[i-1][j-wes[i-1]]+vs[i-1]);
		}
	}	
	return memokp[n][w];
}

int test(){
	int n,w;
	cin>>n>>w;
	for(int i = 0;i<n;i++){
		cin>>wes[i]>>vs[i];
	}
	cout<<kp(n,w)<<"\n";
}

//////////////////////////////////////////////////////////////////////////

int main(){
	test();
	return 0;
}

Measured memory_bytes: 79360
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		Vector2 beginPoint = new Vector2(decimal.Parse(input[0]), decimal.Parse(input[1]));
    Vector2 endPoint = new Vector2(decimal.Parse(input[2]), decimal.Parse(input[3]));
		long q = long.Parse(Console.ReadLine());

    for(long i = 0; i < q; i++)
    {
      string[] inputSub = Console.ReadLine().Split(' ');
      Vector2 answer = Vector2.Projection(beginPoint, endPoint,
        new Vector2(decimal.Parse(inputSub[0]), decimal.Parse(inputSub[1])));
      Console.WriteLine(answer.x + " " + answer.y);
    }
	}
}

class Vector2//2次元ベクトル
{
  public Vector2 (decimal X, decimal Y)
  {
    this.x = X;
    this.y = Y;
  }

  public decimal x {private set; get;}
  public decimal y {private set; get;}

  public static Vector2 operator + (Vector2 ob1, Vector2 ob2)//ベクトルの基本演算
  {
    return new Vector2 (ob1.x + ob2.x, ob1.y + ob2.y);
  }
  public static Vector2 operator - (Vector2 ob1, Vector2 ob2)
  {
    return new Vector2 (ob1.x - ob2.x, ob1.y - ob2.y);
  }
  public static Vector2 operator * (Vector2 ob, decimal scalar)
  {
    return new Vector2 (ob.x * scalar, ob.y * scalar);
  }

  public decimal Length()//ベクトルの長さ
  {
    return x * x + y * y;
  }
  public static decimal DotProduct(Vector2 ob1, Vector2 ob2)//内積
  {
    return ob1.x * ob2.x + ob1.y * ob2.y;
  }

  public static Vector2 Projection(Vector2 beginPoint, Vector2 endPoint, Vector2 point)//点の射影
  {
    Vector2 segment = endPoint - beginPoint;
    decimal ratio = Vector2.DotProduct(point - beginPoint, segment) / segment.Length();
    return beginPoint + segment * ratio;//始点にたす
  }
}



Measured memory_bytes: 17988
#include<stdio.h>
int main(){
int a[6],i,b=100,c=0;
for(i=0;i<4;i++){
scanf("%d\n",&a[i]);
if(a[i]<b){
b=a[i];
}
c=c+a[i];
}
c=c-b;
b=100;
for(i=0;i<2;i++){
scanf("%d\n",&a[i]);
if(a[i]<b){
b=a[i];
}
c=c+a[i];
}
c=c-b;
printf("%d\n",c);
return 0;
}




Measured memory_bytes: 2072
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll t,ans[200001],a[200001];
int i,j,k,n,b[200001];
bool cmp(ll x,ll y){
	return a[x]>a[y]||a[x]==a[y]&&x<y;
}
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]),b[i]=i;
	sort(b+1,b+1+n,cmp);
	for (i=1,t=0;i<=n;i=j){
		for (j=i;j<=n&&b[j]>=b[i];j++) t+=a[b[j]];
		if (j>n){
			ans[b[i]]+=t;
			break;
		}
		ans[b[i]]+=t-(ll)(j-1)*a[b[j]];
		t=(ll)(j-1)*a[b[j]];
	}
	for (i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long[] arr = Console.ReadLine().Trim().Split(' ').Select(tmp => long.Parse(tmp)).ToArray<long>();

			for (int i = n - 1; i > 0; i--)
			{
				if (arr[i] == arr[i - 1] - 1)
				{
					arr[i - 1] = arr[i - 1] - 1;
				}
				else if (arr[i] >= arr[i - 1])
				{

				}
				else
				{
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}
}


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    double n, k; cin >> n >> k;
    double ans = 0;
    for (int i = 1; i <= min(n, k); ++i) {
        ans += (1.0 / n) * pow(0.5, ceil(log2(k / (double)i)));
    }
    if (n >= k) ans += (n - k) / n;
    cout << setprecision(20) << ans << "\n";
                
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std; 
#define MODULO 1000000007
#define ull long long int
int f;
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
int main(){
    int n,x,d=0;
    cin>>n>>x;
    int arr[n];
    forn(i,n)cin>>arr[i];
    ull count=1;

    for(int i=0;i<n;i++)
    {d+=arr[i];

            if(d>x)break;
            count++;
            
    }
    cout<<count<<endl;
    
}

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

int main(){
    int n;
    cin >> n;
    string ans = "Three";
    char color;
    for (int i = 0; i < n; i++){
        cin >> color;
        if (color == 'Y'){
            ans = "Four";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3)){
    cout << "Bad" << endl;
  } else{
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf\n", &x1, &y1, &x2, &y2);
    printf("%.8lf\n", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));
    return 0;
}



Measured memory_bytes: 2064