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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];
		IntStream.rangeClosed(1, n).forEach(i -> p[i - 1] = sc.nextInt());
		IntStream.rangeClosed(1, n).forEach(i -> q[i - 1] = sc.nextInt());
		int[] convertedP = convert(p);
		int[] convertedQ = convert(q);
		int diff = 0;
		for (int i = 0; i < n; i++) {
			diff = diff + (convertedP[i] - convertedQ[i]) * pow(n - i - 1);
		}
		print(abs(diff));
		sc.close();
	}

	public static int[] convert(int[] n) {
		int[] converted = new int[n.length];
		for (int i = 0; i < n.length; i++) {
			converted[i] = n[i];
			int order = n[i];
			for (int j = 0; j < i; j++) {
				if (n[j] < order) {
					converted[i] = converted[i] - 1;
				}
			}
		}
		return converted;
	}

	public static int abs(int n) {
		return n > 0 ? n : -n;
	}

	public static int pow(int n) {
		int powNum = 1;
		for (int i = 1; i <= n; i++) {
			powNum = powNum * i;
		}
		return powNum;
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}

Measured memory_bytes: 27092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n, x;
llong a[100005];
llong ans;

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

    for (int i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] > x) {
            ans += (a[i] + a[i + 1]) - x;

            if (a[i] > x) {
                a[i] -= llabs(x - a[i + 1]);
                a[i + 1] = 0;
            }
            else {
                a[i + 1] -= llabs(x - (a[i] + a[i + 1]));
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    
    // 各種変数宣言
    
    int n,p,i,j,k,c,a; int count=0;
    
    // 配列宣言
    int cand[100],peb,diag,w1,h,w,min;
    
    // メインループ
    
    while(1){
      int h1=min=2147483647;
        
        // nとpを読み込む
        scanf(" %d", &h);
        scanf(" %d", &w);
        
        
        // 否定条件
        if( (h==0) && (w==0) ) break;
        
        diag=h*h + w*w;
       
        for(i=1;i<151;i++){
            for(j=i+1;j<151;j++){
                a=i*i + j*j;
                
                if(a>diag || (a==diag && i>h)){
                    if(a<min || (a==min && i<h1)){
                        min=a;
                        h1=i;
                        w1=j;
                    }
                    break;
                }
            }
            
        }
       
        printf("%d %1d\n",h1,w1);
    }
    // 終了
    return 0;
    
}



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

int main(){
    int n,tmp,max,min;
    long long sum;
    cin >> n;
    cin >> tmp;
    max = min = sum =tmp;
    for(int i=2; i<=n; i++){
        cin >> tmp;
        if(max<tmp) max=tmp;
        if(min>tmp) min=tmp;
        sum+=tmp;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3124
s = input()

a = int(s[:2])
b = int(s[2:])

if 0 < a <= 12 and 0 < b <= 12:
    print('AMBIGUOUS')
elif 0 < a <= 12:
    print('MMYY')
elif 0 < b <= 12:
    print('YYMM')
else:
    print('NA')


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

int main() {
  int H;
  int W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> data.at(i).at(j);
    }
  } 
  
  int count=0;
  int w=W;
  
  for(int i=0; i<H; i++){
    count = 0;
    for(int j=0; j<W; j++){
      if(data.at(i).at(j)=='.') count++;
      if(count==W){
        for(int k=0; k<W; k++){
          data.at(i).at(k) = 'x';
        }
      }
    }
  }
  
  for(int j=0; j<W; j++){
    count = 0;
    for(int i=0; i<H; i++){
      if(data.at(i).at(j)=='.' || data.at(i).at(j)=='x') count ++;
      if(count==H){
        for(int k=0; k<H; k++){
          data.at(k).at(j) = 'x';
        }
        w--;
      }
    }
  }
  
  for(int i=0; i<H; i++){
    count = 0;
    for(int j=0; j<W; j++){
      if(data.at(i).at(j)!='x'){
        cout << data.at(i).at(j);
        count++;
        if(count==w) cout <<endl;
      }
    }
  }
          
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

typedef long long ll;

const int MAX_N = 30;
double L[MAX_N], a[MAX_N], b[MAX_N];
int N, M;

double max_comb(ll n)
{
    vector<int> s;
    double ret = 0.0;

    for (int i = 0; i < N; i++) {
        if (n & 1 == 1)
            s.push_back(i);
        n >>= 1;
    }

    for (int i = 0; i < s.size(); i++) 
        for (int j = i + 1; j < s.size(); j++)
            ret += (L[s[i]] - L[s[j]]) * (L[s[i]] - L[s[j]]) +
                (a[s[i]] - a[s[j]]) * (a[s[i]] - a[s[j]]) +
                (b[s[i]] - b[s[j]]) * (b[s[i]] - b[s[j]]);
    return ret;
}

int main()
{
    double ans = 0.0;
    
    cout << setprecision(7) << fixed;
    cin >> N >> M;
    if (M == 0 || N == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) 
        cin >> L[i] >> a[i] >> b[i];

    ll comb = (1 << M) - 1;
    while (comb < 1 << N) {
        ans = max(ans, max_comb(comb));
        
        int x = comb & -comb , y = comb + x;
        comb = ((comb & ~y) / x >> 1) | y;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1312
w,a,b = map(int,input().split())
B=[b,b+w]
A=[a,a+w]
ans = 0
if not (A[0] <= B[0] <= A[1] or A[0] <= B[1] <= A[1]):
    ans = max(B[0] - A[1], A[0] - B[1])
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <iostream>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const int MAXN=1100;
const ll MOD=1e9+7;
ll n;
ll ksm(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}
int main()
{
    ios;
    cin>>n;
    cout<<((ksm(10,n)-ksm(9,n)*2+2*MOD)%MOD+ksm(8,n))%MOD<<'\n';
    return 0;
}

Measured memory_bytes: 3648
/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        System.out.println(n/2 + n%2);
	}
}


Measured memory_bytes: 23892
q,h,s,d=map(int,input().split())
n=int(input())
a1=min(8*q,4*h,2*s,d)#2Lあたりの一番安い金額
a2=min(4*q,2*h,s)#1Lあたりの一番安い金額
if n%2==0:
    ans=(n//2)*a1
else:
    ans=(n//2)*a1+a2
print(ans)


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

int main() {
  ll n,x,m;
  cin >> n >> x >> m;
  vector<ll> v(m,-1);
  ll j=0;
  ll f=0;
  ll i=x;
  ll a=0;
  ll b=0;
  while(f==0){
    if (v[i]==-1){
      v[i]=j;
    }else{
      a=v[i];
      b=j;
      f=1;
    }
    i=(i*i)%m;
    j++;
  }
  ll s=0;
  ll p=0;
  ll q=0;
  rep(i,m){
    if (v[i]<a && v[i]!=-1) p+=i;
    if (a<=v[i] && v[i]<b) s+=i;
    if (a<=v[i] && v[i]<(n-a)%(b-a)+a) q+=i;
  }
  ll res=s*((n-a)/(b-a))+p+q;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3996
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String integers = br.readLine();
			System.out.println(sort(toIntArray(integers)));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static int[] toIntArray(String stringArray) {
		String[] integerss = stringArray.split(" ");
		int[] IntArray = new int[3];
		IntArray[0] = Integer.parseInt(integerss[0]);
		IntArray[1] = Integer.parseInt(integerss[1]);
		IntArray[2] = Integer.parseInt(integerss[2]);
		return IntArray;
	}

	private static String sort(int[] integers) {
		for (int i = 0; i < integers.length - 1; i++) {
			int a = integers[i];
			int b = integers[i + 1];
			if (a > b) {
				integers[i] = b;
				integers[i + 1] = a;
				for (int j = i; j > 0; j--) {
					int c = integers[j];
					int d = integers[j - 1];
					if (c < d) {
						integers[j] = d;
						integers[j - 1] = c;
					} else {
						break;
					}
				}
			}
		}
		return String.valueOf(integers[0]) + " " + integers[1] + " " + integers[2];
	}
}


Measured memory_bytes: 24308
#include<bits/stdc++.h>
using namespace std;
string s;
int c[100010], t[100010]={0}, p;
int main() {
    cin >> s;
    int n = s.length();
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') p = i;
        else c[i] = p;
    }
    for(int i = n-1; i > -1; i--) {
        if(s[i] == 'L') p = i;
        else c[i] = p;
    }
    for(int i = 0; i < n; i++) {
        int m = abs(c[i] - i);
        if(m & 1) {
            if(s[i] == 'L') t[c[i]+1]++;
            else if(s[i] == 'R') t[c[i]-1]++;
        }
        else {
            t[c[i]]++;
        }
    }
    for(int i = 0; i < n; i++) cout << t[i] << " ";
}

Measured memory_bytes: 1408
// 4_abc143_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n){
        cin >> l[i];
    }
    sort(l.begin(), l.end());

    ll ans = 0;
    for(int i = 0; i < n - 2; i++){
        for(int j = i + 1; j < n - 1; j++){
            int s = l[i] + l[j];
            auto k = lower_bound(l.begin(), l.end(), s);
            int ind = k - l.begin();

            ans += ind - j - 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+5;
int a[N];
int main(){
	int n,k;scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	for(int i=k;i<n;i++){
		if(a[i]>a[i-k])puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 4516
n = int(input())
l = []
a = 0
b = 0

for _ in range(n):
    li = list(map(int, input().split()))
    l.append(li)
    a += li[0]
    b = max(b,li[1])
    
l = sorted(l, key=lambda x: x[1])
if a > b:
    print('No')
    exit()

count = 0
for i in range(n):
    count += l[i][0]
    if count <= l[i][1]:
        continue
    else:
        print('No')
        exit()
print('Yes')
    

Measured memory_bytes: 48620
#include <bits/stdc++.h>
int main ()
{
    int A,B;
    scanf ("%d %d",&A,&B);
    if ((A==1 && B==2)||(B==1 && A==2))
    {
        printf ("3\n");
    }
    if ((A==2 && B==3)||(B==2 && A==3))
    {
        printf ("1\n");
    }
    if ((A==1 && B==3)||(B==1 && A==3))
    {
        printf ("2\n");
    }
    return 0;
}

Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long A = in.nextLong();
		long B = in.nextLong();
		long C = in.nextLong();
		long D = in.nextLong();
		long cm = (B / C) - ((A - 1) / C);
		long dm = (B / D) - ((A - 1) / D);
		long lcm = C * D / gcd(Math.max(C, D), Math.min(C, D));
		long common = (B / lcm) - ((A - 1) / lcm);
		long ans = (B - (A - 1)) - cm - dm + common;
		System.out.println(ans);
		in.close();
	}

	private static long gcd(long m, long n) {
		long temp;
		while (m % n != 0) {
			temp = n;
			n = m % n;
			m = temp;
		}
		return n;
	}
}

Measured memory_bytes: 23380
def gcd(a,b):   #　ユーグリッドの互除法
    if b == 0:
        return a
    return gcd(b, a % b)


N, X = map(int, input().split())

ans = 0


x = list(map(int, input().split()))
x.append(X)
x.sort()
a = []

for i in range(N):
    a.append(abs(x[i] - x[i+1]))
    ans = gcd(ans, a[i])


print(ans)



Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<double,ll> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
    int n,l;
    scanf("%d%d",&n,&l);
    deque<pi> dq;
    double ans=0;
    for(int i=0;i<n;i++)
    {
        ll t,v;
        scanf("%lld%lld",&t,&v);
        ll tmp=v;
        double tv=t*v;
        ll cur=(i?tmp:0);
        while(cur&&dq.front().second<=cur)
        {
            //dbg(cur,dq.front().second);
            cur-=dq.front().second;
            ans-=dq.front().first;
            dq.pop_front();
        }
        if(dq.size())
        {
            ans-=(long double)1.0*dq.front().first/dq.front().second*cur;
            dq.front().first-=dq.front().first/dq.front().second*cur;
            dq.front().second-=cur;
        }
        if(dq.size())
        //dbg(dq.front().second,ans);
        while(dq.size()&&(__int128)dq.back().first*v>=(__int128)tv*dq.back().second)
        {
            tv+=dq.back().first;
            v+=dq.back().second;
            ans-=dq.back().first;
            dq.pop_back();
        }
        //dbg(tv,v);
        dq.push_back(make_pair(tv,v));
        ans+=tv;
        //dbg(ans);
        printf("%.10f\n",1.0*ans/l);
    }
}

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

using namespace std;

int main()
{
    int n,a,b,pt;
    cin>>n>>a>>b;
    pt=n*a;
    if(pt<b)
    {
        cout<<pt;
    }
    else
    {
        cout<<b;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	while(a>0 && c>0){
		c-=b;
		//printf("aoki %d ", c);
		if(c<=0)break;
		a-=d;
		//printf("takahashi %d\n", a);
	}
	if(c<=0)printf("Yes\n");
	else	printf("No\n");
	return 0;
}

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

import array
import collections


class Solver(object):

    deltas = {"N": (0, 1), "E": (1, 0), "S": (0, -1), "W": (-1, 0)}

    def __init__(self, gems, initial_point=(10, 10)):
        self.gems = gems
        self.current_point = initial_point
        self.visited = collections.defaultdict(bool)

    def move(self, direction, distance):
        (x0, y0) = self.current_point
        (dx, dy) = self.deltas[direction]
        for i in range(1, distance + 1):
            (x, y) = (x0 + i * dx, y0 + i * dy)
            self.current_point = (x, y)
            self.visited[(x, y)] = True

    def moves(self, commands):
        for direction, distance in commands:
            self.move(direction, distance)

    def judge(self):
        for gem in self.gems:
            if not self.visited[gem]:
                return False
        else:
            return True


def main():
    while True:
        n = int(input())
        if n == 0:
            break
        gems = [tuple(map(int, input().split())) for _ in range(n)]
        m = int(input())
        commands = []
        for _ in range(m):
            direction, distance = input().split()
            distance = int(distance)
            commands.append((direction, distance))
        solver = Solver(gems)
        solver.moves(commands)
        if solver.judge():
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()

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

int main() {
  std::string x(4, ' ');
  scanf("%s", &x[0], x.size());
  for (int i = 1; i < 4; i++) {
    if (x[i] == x[i - 1]) {
      printf("Bad");
      return 0;
    }
  }
  printf("Good");
}


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

int main () {

    int M, D;
    cin >> M >> D;

    int ans = 0;
    for (int m = 1; m <= M; m++) {
        for (int d = 1; d <= D; d++) {

            int d1 = d % 10, d10 = d / 10;

            if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int x, y, z, k;
   cin >> x >> y >> z >> k;
   ll a[x], b[y], c[z];
   for (int i = 0; i < x; i++) cin >> a[i];
   for (int i = 0; i < y; i++) cin >> b[i];
   for (int i = 0; i < z; i++) cin >> c[i];

   vector<ll> ab;
   for (int i = 0; i < x; i++) {
      for (int j = 0; j < y; j++) {
         ab.push_back(a[i] + b[j]);
      }
   }
   sort(ab.rbegin(), ab.rend());

   vector<ll> abc;
   for (int i = 0; i < min(k, x * y); i++) {
      for (int j = 0; j < z; j++) {
         abc.push_back(ab[i] + c[j]);
      }
   }
   sort(abc.rbegin(), abc.rend());

   for (int i = 0; i < k; i++) cout << abc[i] << endl;

   return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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 (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> a(n);
  int32 sum = 0;
  REP(i,n){
    cin >> a[i];
    sum ^= a[i];
  }
  REP(i,n){
    cout << (sum ^ a[i]) << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4780
import copy
s=list(input())
a=copy.deepcopy(s)
b=copy.deepcopy(s)
a=a[0::2]
b=b[1::2]
resulta="L" in a
resultb="R" in b
if resulta == False and resultb == False:
  print("Yes")
else:
  print("No")

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

void PRINT(int* A,int Len){
    for(int i = 0;i<Len-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[Len-1]);
    return;
}

void selectionSort(int* A,int N){
    for(int i = 0;i<N;i++){
        int minj = i;
        for(int j=i;j < N;j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        int buff = A[i];
        A[i] = A[minj];
        A[minj] = buff;
    }
    return;
}

void selectionSort(int* A,int N,int* count){
    *count = 0;
    for(int i = 0;i<N;i++){
        int minj = i;
        for(int j=i;j < N;j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(minj != i){
            *count += 1;
        }
        int buff = A[i];
        A[i] = A[minj];
        A[minj] = buff;
    }
    return;
}

int main(){
    
    int Len,count;
    scanf("%d",&Len);
    int Num[Len];

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


    selectionSort(Num,Len,&count);
    PRINT(Num,Len);
    printf("%d\n",count);


    return 0;
}



Measured memory_bytes: 2748
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N;
  cin >> N;
  vector<int> T(N), A(N);
  for (int i = 0; i < (int)N; ++i) cin >> T[i] >> A[i];

  ll t = T[0], a = A[0];
  for (int i = 1; i < N; ++i) {
    ll kt = (t + T[i] - 1) / T[i], ka = (a + A[i] - 1) / A[i];
    if (kt * A[i] < a) {
      t = T[i] * ka;
      a = A[i] * ka;
      continue;
    }
    if (ka * T[i] < t) {
      t = T[i] * kt;
      a = A[i] * kt;
      continue;
    }
    t = T[i] * min(ka, kt);
    a = A[i] * min(ka, kt);
  }

  cout << t + a << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

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

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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

	// long long?
	long long A,B, C;
	cin >> A >> B >> C;

	ll ans = abs(B - A) + abs(C - B);
	ans = min(ans, abs(A - C) + abs(C - B));
	ans = min(ans, abs(A - C) + abs(A - B));

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

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

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  const int inf = 1e9;
  vector<vector<int>> D(H, vector<int>(W, inf));
  queue<pair<int, int>> que;
  D[0][0] = 1;
  que.push({0, 0});
  auto update = [&](int i, int j, int now) {
    if (i < 0 or j < 0 or i >= H or j >= W) return;
    if (S[i][j] == '#' or D[i][j] != inf) return;
    D[i][j] = now + 1;
    que.push({i, j});
  };
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    int i = p.first, j = p.second;
    update(i + 1, j, D[i][j]);
    update(i, j + 1, D[i][j]);
    update(i - 1, j, D[i][j]);
    update(i, j - 1, D[i][j]);
  }
  if (D[H - 1][W - 1] == inf) {
    cout << -1 << endl;
    return 0;
  }

  int cnt_white = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') cnt_white++;
    }
  }
  cout << cnt_white - D[H - 1][W - 1] << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
n ,T = map(int, input().split())

c = [0] * n
t = [0] * n

for i in range(n):
    c[i], t[i] = map(int, input().split())

arr = []
for i in range(n):
    if t[i] <= T:
        arr.append(c[i])

if len(arr) == 0:
    print('TLE')
else:
    print(min(arr))


Measured memory_bytes: 3060
function Main(input) {
  'use strict';

  const s = input.split("");
  if(s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) console.log("Good");
  else console.log("Bad")
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
N = int(input())
S = input().strip()

def check():
	if N % 2 == 1:
		print("No")
	else:
		Nh = N // 2
		for i in range(Nh):
			if S[i] != S[i + Nh]:
				print("No")
				return
		print("Yes")
check()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
	int a,b;
	cin>>a>>b;
	string ans="Odd";
	if(a*b%2==0)ans="Even";
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main()
{
  int n;
  cin >> n;
  unordered_map<string, int> map;
  for (int i = 0;i < n;i++) {
  	string str;
    cin >> str;
    map[str] = i;
  }
  cout << map.size() << endl;
  return 0;
}

Measured memory_bytes: 17788
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

p = int(1e9+7)
res = 0

for i in range(60):
    zc = np.count_nonzero(A & 1)
    oc = N - zc

    res += zc*oc*2**i
    res %= p
    A >>= 1

print(res)

Measured memory_bytes: 48840
import sys

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

a = []
for i in range(0, n):
    a.append(list(input()))

b = []
for i in range(0, m):
    b.append(list(input()))

def diff(x, y):
    r = []
    for i in range(y, y+m):
        r.append(a[i][x:(len(b[0]) + x)])
    return r

if __name__ == '__main__':
    for i in range(0, (n - m)+1):
        for j in range(0, (n - m)+1):
            if(diff(i, j) == b):
                print('Yes')
                sys.exit()
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

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

    int res = 0;

    rep(i, 1000) {
        string num = to_string(i);
        while (num.size() < 3) num = '0' + num;

        bool flag[3] = {};
        for (int c = 0; c < N; c++) {
            if (flag[1] && S[c] == num[2]) flag[2] = true;
            else if (flag[0] && S[c] == num[1]) flag[1] = true;
            else if (S[c] == num[0]) flag[0] = true;
        }

        if (flag[0] && flag[1] && flag[2]) res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b,c,d=I()
if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c) <= d:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10416
n = int(input())
done = set()
start = input()
done.add(start)
status = True
for i in range(n-1):
    x = input()
    if x in done:
        status = False
    if x[0] != start[-1]:
        status = False
    done.add(x)
    start = x
if status:
    print("Yes")
else:
    print("No")    


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

int main(){
  long long n,sum=0;
  cin>>n;
  long long a[n+4]={},k=0;
  if(n==3){
    cout<<"2 5 63"<<endl;
    return 0;
  }else if(n==4){
    cout<<"2 5 20 63"<<endl;
    return 0;
  }else if(n==5){
    cout<<"2 5 20 30 63"<<endl;
    return 0;
  }
  for(long long i=0;i<=n;i+=4){
    a[i]=6*k;
    a[i+1]=6*k+2;
    a[i+2]=6*k+3;
    a[i+3]=6*k+4;
    k++;
    sum+=a[i]+a[i+1]+a[i+2]+a[i+3];
  }
  sum-=a[n+1]+a[n+2]+a[n+3];
  if(sum%6==2){
    a[5]=a[n-n%4]+6;
  }else if(sum%6==3){
    a[6]=a[n-n%4]+6;
  }else if(sum%6==5){
    a[6]=a[n-n%4]+4;
  }
  for(long long j=1;j<n;j++) cout<<a[j]<<" ";
  cout<<a[n]<<endl;
  return 0;
}


Measured memory_bytes: 1020
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,cnt=1;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(cnt==a){
            cnt++;
        }
    }
    if(cnt==1)cout<<-1<<endl;
    else cout<<n-cnt+1<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <map>

using namespace std;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(){
	cin.tie(0);                       
   	ios::sync_with_stdio(false);
   	float R,G;

   	cin >> R;
   	cin >> G;
   	cout << 2.0 * G - R << endl;

   	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <stack>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int N = (1 << 21); // 必要な数よりも大きい2^nよりも大きい数を入れるとよい
long long int BIT[(1 << 21) + 1];

void add(int a, long long int w){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
		BIT[x] %= MOD;
	}
}

long long int sum(int a){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	long long int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
		ret %= MOD;
	}
	return ret;
}

void init(){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

long long int DP[1100000] = {};

int main(){
	
	int n;
	cin >> n;
	
	init();
	
	DP[0] = DP[1] = DP[2] = 1;
	add(1, 1);
	add(2, 1);
	add(3, 1);
	
	
	for(int i = 3; i < n; i++){
		DP[i] = DP[i - 1];
		DP[i] += sum(i - 2);
		DP[i] %= MOD;
		add(i + 1, DP[i]);
	}
	
	long long int ans = 0;
	
	for(int i = 0; i < n - 1; i++){
		long long int p = (DP[i] * (n - 1)) % MOD;
		ans += p * (n - 1);
		ans += DP[i] * min(i + 2, n - 1);
		ans %= MOD;
	}
	
	ans += DP[n - 1] * n;
	ans %= MOD;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 25216
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    s = input()
    ans = 1
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            continue
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        n:usize,d:isize
    }
    let mut ans = 0;
    for _ in 0..n {
        input! {
            x:isize,y:isize
        }
        let d2 = x * x + y * y;
        if d * d >= d2 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

H = list(map(int, input().split()))

if len(H) != 1:
    for i in range(0, N-1, 1):
        if H[i] > H[i+1]:
            H[i+1]=H[i+1]+1

    check_list = sorted(H)

    if check_list==H:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")


Measured memory_bytes: 14252
N, K = list(map(int, input().split()))
RSP = list(map(int, input().split()))
D = {'r': 0, 's': 1, 'p': 2}
T = input()

M = N//K
dp = [[[0]*3 for _ in range(M+(i < (N % K)))] for i in range(K)]
# print(dp)


def wins(i, s):
    j = D[s]
    return i % 3 == (j-1) % 3


ans = 0
for i in range(K):
    L = dp[i]
    for k in range(3):
        L[0][k] = RSP[k]*wins(k, T[i])
    for j in range(1, len(L)):
        for k in range(3):
            L[j][k] = max(L[j-1][l] + RSP[k]*wins(k, T[i+j*K])
                          for l in range(3) if k != l)
    # print(L)
    ans += max(L[-1][k] for k in range(3))
print(ans)


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int l,r,d;
    cin>>l>>r>>d;
    int count = 0;
    for(int i=l;i<=r;++i){
        if(i%d==0)count++;
    }
    cout << count << endl;
    return 0;
    
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int b,i;
  vector <int> v;
  for(i=0;i<5;i++) {
    cin >> b;
    v.push_back(b);
  }
  sort(v.begin(),v.end(),greater<int>());
  cout << v[0];
  for(i=1;i<5;i++) cout << " " << v[i];
  cout << endl;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N;
    cin >> N;
    VI A(N);
    REP(i, N) {
        cin >> A[i];
    }
    LL ans = 0;
    LL n_minus = 0;
    LL min_minus = LLONG_MAX, min_plus = LLONG_MAX;

    EACH(x, A) {
        ans += abs(x);
        if (x < 0) {
            n_minus++;
            if (abs(x) < min_minus) {
                min_minus = abs(x);
            }
        } else {
            if (x < min_plus) {
                min_plus = x;
            }
        }
    }
    if (n_minus % 2 == 0) {
        cout << ans << endl;
    } else {
        cout << ans - 2 * min(min_minus, min_plus) << endl;
    }
	
    return 0;
}


Measured memory_bytes: 1024
s = input()
y = int(s[0:4])
m = int(s[5:7])
d = int(s[8:])

if y < 2019 or (y == 2019 and m < 4 ) or (y == 2019 and m == 4 and d <= 30):
  print("Heisei")
else:
  print("TBD")

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

int bs(Vi& vec, int x) {
	int left = 0, right = static_cast<int>(vec.size());
	while (right - left > 0) {
		int mid = (right + left) / 2;
		if(x < vec[mid]) {
			right = mid;
		}
		else {
			left = mid + 1;
		}

	}
	return right;
}

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

	int ans = 1;
	Vi c_min;
	c_min.push_back(a[N - 1]);
	
	for (int i = N - 2; i >= 0; --i) {
		int pos = bs(c_min, a[i]);
		if (pos == ans) {
			c_min.push_back(a[i]);
			++ans;
		}
		else {
			c_min[pos] = a[i];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1276
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc =new Scanner(System.in);
        
        int r=sc.nextInt();
        int c=sc.nextInt();
        
        int a[][]=new int[r+1][c+1];
      
        for(int i=0;i<r;i++)
         for(int j=0;j<c;j++)
         a[i][j]=sc.nextInt();
        
        for(int i=0;i<r;i++)
         for(int j=0;j<c;j++)
         a[i][c]+=a[i][j];
        
        for(int i=0;i<=c;i++)
            for(int j=0;j<r;j++)
            a[r][i]+=a[j][i];
        
        for(int i=0;i<=r;i++) {
         for(int j=0;j<c;j++) 
         System.out.print(a[i][j]+" ");
         System.out.println(a[i][c]);
         }
    }   
    }
    


Measured memory_bytes: 40692
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
   int n;
   cin >> n;
   int count=0;
   int p[n];

   for(int j=0;j<n;j++){
       cin >> p[j];
   }
   for(int i = 1;i<n-1;i++){
       if(p[i]<p[i-1] && p[i] >p[i+1]){
           count +=1;
       }else if(p[i]>p[i-1] && p[i]<p[i+1]){
           count +=1;
       }
   }
   cout << count;
    return 0;
}


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

const int MAX = 8;
int x[MAX], y[MAX];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int n; std::cin >> n;
	rep(i, n) std::cin >> x[i] >> y[i];
	vi route(n);
	rep(i, n) route[i] = i;
	auto calcCost = [&](){
		double ret = 0;
		rep(i, n - 1) {
			int from = route[i], dest = route[i+1];
			double dx = x[from] - x[dest], dy = y[from] - y[dest];
			ret += pow(dx * dx + dy * dy, 0.5);
		}
		return ret;
	};
	double sum = 0;
	do {
		sum += calcCost();
	} while (next_permutation(rng(route)));
	int fact = 1;
	rrep(i, n) fact *= i;
	std::cout << sum / fact << "\n";
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskA {
public:
    void solve(std::istream &in, std::ostream &out) {
        std::string N;
        in >> N;

        for (auto c: N) {
            if (c == '9') {
                out << "Yes\n";
                return;
            }
        }

        out << "No\n";
    }
};


int main() {
    TaskA solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int index;
    rep(i,n) cin >> a[i];
    int ans = 1;
    int lef = 0, rig = k-1;
    while(rig < n-1) {
        ans++;
        lef = rig;
        rig = lef+k-1;
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 
    ll N;
    cin >> N;

    ll sum = 0;
    ll m = 0;
    for(ll i=0; i<N; i++)
    {
        ll a;
        cin >> a;

        sum+=a;

        m = max(m, a);
    }   

    if(2*m < sum)
    {
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

ll num(ll n){//10^n~10^1
    ll res = 0;
    rep(i,n){
        res += mypow(10,i);
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    vecin(vec);
    sort(all(vec));
    ll ans = 0,cnt = 0;
    rep(i,N){
        if(cnt + vec[i] <= K){
            cnt += vec[i];
            ans++;
        }
        else{
            cnt = INF;
            break;
        }
    }
    if(cnt != INF){
        if(cnt == K)cout << N << "\n";
        else cout << N - 1 << "\n";
    }
    else{
        cout << ans << "\n";
    }
}

Measured memory_bytes: 3576
package main
import (
	"bufio"
	"fmt"
	"os"
)
var r = bufio.NewReader(os.Stdin)
func main() {
	var x int
	fmt.Fscan(r, &x)
         // ↓ここを変える
	 x2 := x * x * x
	fmt.Println(x2)
}


Measured memory_bytes: 1140
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int r;
    cin >> r;

    cout << 3.141592 * 2 * r << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score=0;
  
    rep(i,n-1){
        if(s[i] == s[i+1]) score += 1;
    }
	score = min(score+2*k, n-1);
    cout << score << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) cout << "A" << endl;
	else cout << "B" << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import numpy as np
N = int(input())
alphabets = list('abcdefghijklmnopqrstuvwxyz')
A = np.zeros((N, N), dtype=int)
for i in range(N):
    for j, c in enumerate(input()):
        A[i,j] = alphabets.index(c)

B = np.concatenate([A, A], axis=0)
cnt = 0
for i in range(N):
    C = B[i:i+N, :]
    if (C==C.T).all():
        cnt += 1
print(cnt*N)

Measured memory_bytes: 21540
def seven(s,i):
    if i==l-1:
        if eval(s)==7:
            print(s+"=7")
            exit()
        return
    seven(s+"+"+N[i+1],i+1)
    seven(s+"-"+N[i+1],i+1)
        
N = input()
l=len(N)
seven(N[0],0)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int A,B,C;
    
    scanf("%d %d %d",&A,&B,&C);
    
    if(A>=B&&A>=C)
        printf("%d\n",10*A+B+C);
    else if(B>=A&&B>=C)
        printf("%d\n",10*B+A+C);
    else
        printf("%d\n",10*C+A+B);
        
    return 0;
}


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

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

Measured memory_bytes: 256