akhauriyash/Code-Regression huggingface dataset:
a,b,m = map(int, input().split())
f = list(map(int, input().split()))
g = list(map(int, input().split()))
ans = min(f) + min(g)
for _ in range(m):
  x,y,c = map(int, input().split())
  t = f[x-1] + g[y-1] - c
  if ans > t: ans = t
print(ans)

Measured memory_bytes: 18616
n,m=map(int,input().split())
lrd=[list(map(int,input().split())) for _ in range(m)]
g=[[] for _ in range(n)]
for l,r,d in lrd:
  g[l-1].append([d,r-1])
  g[r-1].append([-d,l-1])

no_seen=set(range(n))
inf=float('inf')
dst=[inf]*n
while no_seen:
  todo=[[0,no_seen.pop()]]
  #print(todo)
  while todo:
    d,t=todo.pop()
    no_seen.discard(t)
    l=g[t]
    for di,ti in l:
      if dst[ti]!=inf and dst[ti]!=d+di:
        print('No')
        exit()
      elif dst[ti]!=inf and dst[ti]==d+di:
        pass
      else:
        todo.append([d+di,ti])
        dst[ti]=d+di

print('Yes')

Measured memory_bytes: 171192
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  h,w=LI()

  a=[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]

  l=[]
  for i in range(h):
    l.append(list(S()))

  for i in range(h):
    for j in range(w):
      if l[i][j]=='#':
        continue
      c=0
      for x in a:
        p=i+x[0]
        q=j+x[1]
        if 0<=p and p<h and 0<=q and q<w:
          if l[p][q]=='#':
            c+=1
      l[i][j]=str(c)

  for x in l:
    print(''.join(x))

main()


Measured memory_bytes: 5544
#include <stdio.h>

int main(void){
	unsigned int X;
	unsigned int t;
	int i;
	if(scanf("%u %u", &X, &t)<0)
		return -1;
	if (X > 0 && t > 0){
		i = X - t;
		if (i < 0)
			i = 0;
		printf("%u\n", i);
	}
	
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
    string s;
    cin >> s;
    rep(i, 3) {
        if(s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

using namespace std;

int main(){
    int n,k;cin>>n>>k;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans += min(abs(k-x[i]), x[i]);
    }
    cout<<ans*2<<endl;
}

Measured memory_bytes: 256
x_base = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]


def solve(k):
    return x_base[k - 1]


def main():
    k = int(input())
    res = solve(k)
    print(res)


def test():
    assert solve(6) == 2
    assert solve(27) == 5


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


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

int main(){
  int h,w;
  char ch;
  cin>>w>>h>>ch;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int f=0;
      if(i==0||i==h-1)f++;
      if(j==0||j==w-1)f+=2;
      if(i==h/2&&j==w/2){
        cout<<ch;
      }else if(f==3){
        cout<<'+';
      }else if(f==2){
        cout<<'|';
      }else if(f==1){
        cout<<'-';
      }else{
        cout<<'.';
      }
    }
    cout<<endl;
  }
  return 0;
}



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

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int number = 0;
        int count = 0;

        for(int i = 0; i < n; i++){
            if(checkPrimeNumber(Integer.parseInt(br.readLine()))){
                count++;
            }
        }
        System.out.println(count);
    }

    private static boolean checkPrimeNumber(int number) {
        if(number < 2){
            return false;
        }
        if(number == 2){
            return true;
        }
        if(number % 2 == 0){
            return false;
        }
        for(int i = 3; i <= Math.sqrt(number); i += 2){
            if(number % i == 0){
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 30660
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn calc(v: [i32; 4], opi: u8) -> (i32, String) {
    let mut n = v[0];
    let mut exp = v[0].to_string();
    for i in 0..3 {
        if ((opi >> i) & 1) == 1 {
            exp = format!("{}+{}", exp, v[i + 1]);
            n = n + v[i + 1]
        } else {
            exp = format!("{}-{}", exp, v[i + 1]);
            n = n - v[i + 1]
        }
    }
    return (n, exp);
}


fn main() {
    input! {
    n: u32,
        p: [u32;n]
    }
    if p.len() == 0 {
        println!("0");
    }else{
        let sum:u32 = p.iter().sum();
        let max = p.iter().max().unwrap();
        println!("{}",sum - max / 2);
    }
}

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

N2 = N // 2

def sum_all_digits(n):
    return sum([int(x) for x in str(n)])

rtn = N
for A in range(2, N2+1):
    B = N - A
    c = sum_all_digits(A) + sum_all_digits(B)
    if c < rtn:
        rtn = c

print(rtn)

Measured memory_bytes: 3060
x, y = map(int,input().split())

for i in range(x+1):
    for j in range(x+1):
        z = 10000*i + 5000*j
        if y-z == 1000*(x-i-j) and x-i-j >= 0:
            print(i, j, x-i-j)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 42108
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

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

    int n; cin>>n;
    vi d = readVector<int>(n);
    ll sum=0;

    FOR(i,n)
    RNG(j,i+1,n-1)
    sum += d[i]*d[j];

    cout<<sum<<endl;

    return 0;
}



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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll N , A ,B ,C , D;
    string S;
    cin >> N >> A >> B >> C >> D >> S;

    A--;
    B--;
    C--;
    D--;

    ll streak_p = 1;

    bool flag_swap = false;
    bool flag_A = true;
    bool flag_B = true;

    for(int i = B - 1; i <= D; i++){
        if(S[i] == S[i + 1] && S[i] == '.'){
            streak_p++;
            if(streak_p >= 3) flag_swap = true;
        }else{
            streak_p = 1;
        }
    }

    for(int i = A ; i < C; i++){
        if(S[i] == S[i + 1] && S[i] == '#'){
            flag_A = false;
        }
    }

    for(int i = B ; i < D; i++){
        if(S[i] == S[i + 1] && S[i] == '#'){
            flag_B = false;
        }
    }

    if(flag_A == false || flag_B == false){
        cout << "No" << endl;
        return 0;
    }



    if(D < C && flag_swap){
        cout << "Yes" << endl;
        return 0;
    }else if(C < D){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }


}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      ans=1;
      rrep(i,1,n+1){
        ans*=i;
        ans%=MOD;
      }
      Cout(ans);
     

       
return 0;
}


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

#define N 1000000

int L[N],R[N],cnt=0;
void merge(int[],int,int,int);
void mergeSort(int[],int,int);



int main(void)
{
	int A[N],i,n;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}

		mergeSort(A,0,n);
	
	for(i = 0; i < n;i++){
		printf("%d",A[i]);
		if(i!=n-1){
			printf(" ");
		}
	}


	printf("\n%d\n",cnt);
	return 0;
}

/*
	マージソート (昇順)
*/
void mergeSort(int A[], int left,int right)
{
    int mid;
	if(left+1 < right){
        mid = (left + right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }

}


/*
	マージ
*/
void merge(int A[N], int left, int mid, int right)
{
	int n1,n2,i,j,k;
    n1 = mid -left;
    n2 = right - mid;
	/* 前半の要素を作業用配列へ */
	for( i = 0; i < n1; ++i){
		L[i] = A[left + i];
	}

	/* 後半の要素を逆順に作業用配列へ */
	for( i = 0; i < n2 ; ++i){
		R[i] = A[mid + i];
	}

    L[n1] = 1e9+1;
    R[n2] = 1e9+1;

	/* 作業用配列の両端から取り出した要素をマージ */
	i = 0;
	j = 0;
	for( k = left; k < right ; ++k) {
				cnt++;
		/* 昇順にソートするので、小さい方の要素を結果の配列へ移す。 */
		if( L[i] <= R[j] ){ /* == の場合は先頭を優先すると安定なソートになる */
			A[k] = L[i];
			++i;
		}
		else{
			A[k] = R[j];
			++j;
		}
	}
}




Measured memory_bytes: 5656
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
cin>>a[i];
  }
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++){
    sum=sum+a[n-1-i];
  }
  cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long FINF=-1000000000000000000ll;
struct Pair{
	long long x,v;
}s[100010];
long long n,c/*,dp[100010][2],f[100010][2]*/,ans,a,b,sum[100010],rsum[100010],k,sz,tot,ms[100010],rms[100010];
int main(){
	scanf("%lld%lld",&n,&c);
	s[0].x=0;
	s[n+1].x=c;
	ms[0]=FINF;
	ms[n+1]=FINF;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&s[i].x,&s[i].v);
		sum[i]=sum[i-1]+s[i].v-s[i].x+s[i-1].x;
		ms[i]=max(sum[i],ms[i-1]);
	}
	for(int i=n;i>=1;i--){
		rsum[i]=rsum[i+1]+s[i].v-s[i+1].x+s[i].x;
		rms[i]=max(rms[i+1],rsum[i]);
	}
	ans=max(0ll,max(ms[n],rms[1]));
	for(int i=1;i<=n;i++){
		ans=max(ans,ms[i]-s[i].x+rms[i+1]);
		ans=max(ans,rms[i]-c+s[i].x+ms[i-1]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    string s;
    string t;
    cin >> s >> t;
    vector<vector<ll>> dp(s.size() + 1, vector<ll>(t.size() + 1));
    for(int i = 0; i <= s.size(); i++) dp[i][0] = i;
    for(int i = 0; i <= t.size(); i++) dp[0][i] = i;
    for(int i = 1; i <= s.size(); i++){
        for(int j = 1; j <= t.size(); j++){
            if(s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1];
            else{
                dp[i][j] = dp[i - 1][j - 1] + 1;
                dp[i][j] = min(dp[i][j], min(dp[i - 1][j], dp[i][j - 1]) + 1);
            }
        }
    }
    /*for(int i = 0; i <= s.size(); i++){
        cout << "\n";
        for(int j = 0; j <= t.size(); j++){
            cout << dp[i][j] << " ";
        }
    }*/
    cout << dp[s.size()][t.size()] << "\n";
}


Measured memory_bytes: 10796
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;


int main() {
	ll N, K; cin >> N >> K;
	vector<ll> p, n;
	for (int i = 0; i < N; i++) {
		ll a; cin >> a;
		if (a >= 0)p.push_back(a);
		else n.push_back(a);
	}
	
	int lp = p.size(), ln = n.size(), cnt = 0;
	if (K == N) {
		ll b = 1;
		for (int i = 0; i < lp; i++) {
			b *= p[i];
			b %= DIV;
		}
		for (int i = 0; i < ln; i++) {
			b *= n[i] + DIV;
			b %= DIV;
		}
		cout << b << endl;
	}
	else if (K % 2 == 1 && ln == N) {		
		sort(n.begin(), n.end(), greater<ll>());
		ll b = 1;
		for (int i = 0; i < K; i++) {
			b *= (n[i] + DIV);
			b %= DIV;
		}
		cout << b << endl;
	}

	else {
		if (lp != 0)sort(p.begin(), p.end(), greater<ll>());
		if (ln != 0)sort(n.begin(), n.end());
		int px = 0, nx = 0;
		if (lp == 0)nx = K;
		else if (ln == 0)px = K;
		else {
			while (cnt < K) {
				if ((px < lp && nx >= ln) || abs(p[px]) >= abs(n[nx]))
					px++;
				else if ((px >= lp && nx < ln) || abs(p[px]) <= abs(n[nx]))
					nx++;
				cnt++;
			}
		}

		if (nx % 2 == 1) {
			if (px == 0)px++, nx--;
			else {
				ll s = p[px] * p[px - 1], t = n[nx] * n[nx - 1];
				if (s >= t)px++, nx--;
				else px--, nx++;
			}
		}

		ll b = 1;
		for (int i = 0; i < px; i++) {
			b *= p[i];
			b %= DIV;
		}
		for (int i = 0; i < nx; i++) {
			b *= n[i] + DIV;
			b %= DIV;
		}
		cout << b << endl;
	}
}


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

int main(void) {
  int N, X;
  cin >> N >> X;

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

  sort(x.begin(), x.end());

  int D = x[1] - x[0];
  for (int i = 2; i < N + 1; i++) {
    D = __gcd(D, x[i] - x[i-1]);
  }
  
  cout << D << endl;
  return 0;
}

Measured memory_bytes: 640
a,b=map(int,input().split())
ans=0
for nums in range(a,b+1):
    temp=str(nums)
    for j in range(len(temp)//2):
        if temp[j]!=temp[len(temp)-1-j]:
            break
        elif j==len(temp)//2-1:
            ans+=1

print(ans)

Measured memory_bytes: 9184
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
    priority_queue<int> p;

    int a,b,c;
    cin >> a>>b >>c;

    p.push(a);
    p.push(b);
    p.push(c);

    a = p.top();
    p.pop();
    b = p.top();
    p.pop();
    c = p.top();
    p.pop();

    if (a == b + c){
      cout <<"Yes";
    }else{
      cout <<"No";
    }

    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const lines = input.split('\n');
  const [a, b, c] = lines[0].split('').map(s => parseInt(s));
  const total = lines[0].split('').map(s => parseInt(s)).filter(i => !!i).length;
  console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30564
import math
import itertools
import collections
import bisect
import heapq

def IN(): return int(input())
def sIN(): return input()
def MAP(): return map(int,input().split())
def LMAP(): return list(map(int,input().split()))
def TATE(n): return [input() for i in range(n)]
MOD = 10**9 + 7

n = IN()
dic = {'AC':0,'WA':0,'TLE':0,'RE':0}

for i in range(n):
  s = sIN()
  dic[s] += 1
  
for key,value in dic.items():
  print(key,'x',value)

Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
bool rMin(int &a, int b) {
    return b < a ? a = b, true : false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    cin>>n;
    vector<int> dp(n);
    int h[100000];
    for(int i = 0; i< n; i++) cin>>h[i];
    dp[0] = 0;
    for(int i = 1; i< n; i++){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i-2 >= 0) rMin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<dp[n-1]<<"\n";
        
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using vl = vector<ll>;

vl b(const vl &v)
{
    int n = v.size();

    vl r(v);
    sort(all(r));
    r[0]+=n;
    for(int i=1; i<n; ++i) --r[i];
    sort(all(r));
    return r;
}

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

    int n = 50;

    ll num = k/n;
    vl a(n,num+49);
    k -= num*n;

    while(k--) a = b(a);

    printf("%d\n", n);
    rep(i,n) printf("%lld%c", a[i], " \n"[i==n-1]);
    return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    weather = ['Sunny', 'Cloudy', 'Rainy']
    idx = 0
    for i,s in enumerate(weather):
        if s == S:
            idx = i+1
    print(weather[idx]) if idx != 3 else print(weather[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    scanf("%d", &n);
    int k;
    scanf("%d", &k);
    vector<int> h(n);
    forn(i, n) scanf("%d", &h[i]);
    vector<int> dp(n, INF);
    dp[0] = 0;
    forn(i, n){
        for(int j = i + 1; j <= i + k; ++j) dp[j] = min(dp[j], dp[i] + abs(h[j]- h[i]));
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define tam 5120
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000009 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<string,int> ii;
typedef pair<int,int> II;
ii v[tam];
bool cmp(II num1,II num2)
{
    if (num1.fi==num2.fi)
    {
        return num1.se>num2.se;
    }
    else
        return num1.fi<num2.fi;
}
int pos[tam];
int main()
{
    int n;
    cin>>n;
    string txt;
    int num;
    forr(i,0,n)
    {
        cin>>txt>>num;
        pos[num]=i+1;
        v[i]=ii(txt,num);
    }
    sort(v,v+n);
    vector<II> vect;
    int c=1;
    map<string,int> mapa;
    forr(i,0,n)
    {
        txt=v[i].fi;
        num=v[i].se;
        if (mapa[txt]==0)
            mapa[txt]=c++;
        //<<txt<<" "<<num<<endl;
        vect.pb(II(mapa[txt],num));
    }
    //<<endl;
    sort(vect.begin(),vect.end(),cmp);
    forr(i,0,n)
    {
        cout<<pos[vect[i].se]<<endl;
    }
}

Measured memory_bytes: 512
import qualified Data.Vector as V
main=print.solve.map read.words=<<getLine
solve[n,m]=max(2-abs(n-m))0*fact V.! n*fact V.! m`mod`mo
  where fact=V.generate(max n m+1)$ \i->if i<3 then i else fact V.!(i-1)*i`mod`mo
mo=10^9+7

Measured memory_bytes: 15668
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin>>D;
  if(D==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  else if(D==23){
    cout<<"Christmas Eve Eve"<<endl;
  }
  else if(D==24){
    cout<<"Christmas Eve"<<endl;
  }
  else if(D==25){
    cout<<"Christmas"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define target g[x][i].first
using namespace std;

vector< pair<int,int> > g[100001];
int gae[100001];
int parent[100001];
long long dist[100001];
int n;
void tree(int x){
	gae[x] = 1;
	for(int i=0;i<g[x].size();i++){
		if(target == parent[x]) continue;
		parent[target] = x;
		tree(target);
		gae[x] += gae[target];
	}
}

pair<int,int> centroid(int x){
	for(int i=0;i<g[x].size();i++){
		if(target == parent[x]) continue;
		if(gae[target] * 2 == n){
			return make_pair(x, i);
		}else if(gae[target] * 2 > n){
			return centroid(target);
		}
	}
	return make_pair(x, -1);
}

void gett(int x){
	gae[x] = 1;
	for(int i=0;i<g[x].size();i++){
		if(target == parent[x]) continue;
		parent[target] = x;
		gett(target);
		gae[x] += gae[target];
		dist[x] += dist[target];
		long long cal = gae[target];
		cal *= g[x][i].second;
		dist[x] += cal;
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int aa,bb,cc;
		scanf("%d%d%d",&aa,&bb,&cc);
		g[aa].push_back({bb,cc});
		g[bb].push_back({aa,cc});
	}
	parent[1] = 1;
	tree(1);
	pair<int,int> v = centroid(1);
	parent[v.first] = v.first;
	gett(v.first);
	/*
	for(int i=1;i<=n;i++){
		printf("%d %d %lld\n", i, gae[i], dist[i]);
	}
	*/
	long long ans = dist[v.first]; ans *= 2;
	if(v.second != -1) ans -= g[v.first][v.second].second;
	else{
		int mn = g[v.first][0].second;
		for(int i=1;i<g[v.first].size();i++) mn = min(mn, g[v.first][i].second);
		ans -= mn;
	}
	printf("%lld\n", ans);
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 1e5 + 10;
int n, k, a[MAXN], b[MAXN];
int f[MAXN];

LL Solve(int k) {
    if (k == 0) {
        LL ans = 0;
        for (int i = 1; i <= n; ++i)
            if (f[i] == 1 && a[i] == 0) ans += b[i];
        return ans;
    }
    int h = 29; while ((k >> h & 1) == 0) h--;
    for (int i = 1; i <= n; ++i) if (a[i] >= (1 << (h + 1))) f[i] = 0;
    LL ans = 0;
    for (int i = 1; i <= n; ++i) if (f[i]) {
        if (a[i] >> h & 1) {
            a[i] -= 1 << h;
            continue;
        }
        ans += b[i];
    }
    return max(ans, Solve(k - (1 << h)));
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i], &b[i]);

    for (int i = 1; i <= n; ++i) f[i] = 1;
    printf("%lld\n", Solve(k));
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, K;
	long long ans = 0;
	cin >> N >> K;
	if (K == 0) {
		cout << 1LL * N*N << '\n';
		return 0;
	}
	for (int i = K + 1; i <= N; i++) {
		ans += 1LL * (N / i)*(i - K) + max(N%i - K + 1, 0);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        long t[] = new long[n];
        long a[] = new long[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }

        long mod = 1_000_000_007;
        long p[] = new long[n];
        p[0] = 1;
        p[n - 1] = 1;
        for (int i = 1; i < n - 1; i++) {
            if (t[i - 1] != t[i] || a[i] != a[i + 1]) {
                if (t[i - 1] == t[i]) {
                    p[i] = (t[i] >= a[i] ? 1 : 0);
                } else if (a[i] == a[i + 1]) {
                    p[i] = (t[i] <= a[i] ? 1 : 0);
                } else {
                    p[i] = (t[i] == a[i] ? 1 : 0);
                }
            } else {
                p[i] = Math.min(t[i], a[i]);
            }
        }

        long ans = (t[n - 1] == a[0] ? 1 : 0);
        for (int i = 0; i < n; i++) {
            ans *= p[i];
            ans %= mod;
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

int main(){
int a,b;
cin >>a>>b;
if((a<=0)&&(b>=0)){
  cout<<"Zero"<<endl;
  return 0;
}
if((a<0)&&(b<0)&&(abs((a-b)%2)==1)){
  cout<<"Positive"<<endl;
  return 0;
}
if((a>0)&&(b>0)){
  cout<<"Positive"<<endl;
  return 0;
}

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5,M=10e9+7,OO=0x3f3f3f3f;
string s;
int main ()
{
    cin>>s;
    for(int i=0;i<s.size();i++){
        s[i]==','?cout<<" ":cout<<s[i];
    }

    return 0;
}

Measured memory_bytes: 256
s = input()
if s[0] != 'A':
	print("WA")
	exit()
else:
	s = s[1:]
if 'C' not in s[1:-1]:
	print("WA")
	exit()
else:
	i = s.index('C')
	s = s[:i] + s[i+1:]
print("AC" if s.islower() else "WA")

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
  string s;
  int n,k;
  cin >> n >> k >> s;
  k=k-1;
  if(s.at(k)=='A'){
    s.at(k)='a';
  }
  else if(s.at(k)=='B'){
    s.at(k)='b';
  }
  else{
    s.at(k)='c';
}
  cout << s << endl;
}

Measured memory_bytes: 3556
!true:honest
!false:unkind
      module piyoMod
      implicit none
      
      type persons
        integer :: a=0,x(14)
        logical :: y(14)
      end type
      end module
      
      PROGRAM HonestOrUnkind2
      use piyoMod
      IMPLICIT NONE
      integer :: n,ans=0
      type(persons),allocatable :: person(:)
      logical,allocatable :: tempP(:)
      integer :: i,j,k,buffer(2)
      logical :: expect
      
      read*,n
      allocate( person(n),tempP(n) )
      do i = 1,n
        read*,person(i)%a
        do k = 1,person(i)%a
          read*,buffer(1:2)
          person(i)%x(k) = buffer(1)
          if( buffer(2)==1 )then
            person(i)%y(k) = .true.
          else
            person(i)%y(k) = .false.
          end if
        end do
      end do
 !   print*,n
 !   do i = 1,n
 !     print*,person(i)%a
 !     do k = 1,person(i)%a
 !       print*,person(i)%x(k),person(i)%y(k)
 !     end do
 !   end do
      
      
      outer:do i = 0,2**n-1
        do k = 1,n
          tempP(k) = btest( i,k-1 )
        end do
!print*,tempP
        
        do j = 1,n
          if( tempP(j) )then
            
            do k = 1,person(j)%a
              expect = person(j)%y(k)
              if( tempP(person(j)%x(k)).neqv.expect )then
                cycle outer
              end if
            end do
          end if
        end do
        
        ans = max( ans,count(tempP(1:n)) )
        
        
      end do outer
      
      print*,ans
      
      
      END PROGRAM

Measured memory_bytes: 896
def swap(arr, idx0, idx1)
  arr[idx0], arr[idx1] = arr[idx1], arr[idx0]
end

def answer(arr)
  count = 0
  arr.size.times do |idx|
    next if arr[idx] != idx + 1

    swap(
      arr,
      idx,
      (idx - 1 < 0 || arr[idx + 1] == idx + 2) ? idx + 1 : idx - 1
    )
    count += 1
  end

  count
end

gets
puts answer(gets.split.map(&:to_i))

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vst s(n);
  vin(s);
  ll m;
  cin >> m;
  vst t(m);
  vin(t);

  map<st, ll> money;
  vrep(i, s){
    if(money.count(i)) money[i]++;
    else money[i] = 1;
  }
  vrep(i, t) if(money.count(i)) money[i]--;
  ll ans = 0;
  vrep(i, money) if(i.second > ans) ans = i.second;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()

{

  char c;

  scanf ("%c", &c);

    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' ||
       c=='A' || c=='E' || c=='I' || c=='O' || c=='U')
    {
        printf("vowel", c);
    }
    else {
        printf("consonant", c);
    }


  return 0;
}

Measured memory_bytes: 1644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
    A: usize,
    B: usize
    }
    println!("{}", calc(A, B));
}

fn calc(a: usize, b: usize) -> usize {
    let af = a as f32;
    let bf = b as f32;
    f32::ceil((bf-1.0)/(af-1.0)) as usize
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#define INF 1000000000
#define MOD 1000000007

using namespace std;

int main()
{
    int n;
    int a[105];

    int cost;
    int minv = INF;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    for (int i = -100; i < 105; i++) {
        cost = 0;
        for (int j = 0; j < n; j++) {
            cost += (a[j] - i) * (a[j] - i);
        }

        minv = min(cost, minv);
    }

    cout << minv << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)


#define mod 1000000007
#define maxn 100009
#define maxr 100009

const ll inf = 1e18+5;
ll wt[110],val[110];
void solve()
{
	ll n,w;
	rl2(n,w);
	fr(i,0,n)
	{
		rl2(wt[i],val[i]);
	}
	ll sum=0;
	for(ll i:val)
	{
		sum+=i;
	}
	VL dp(sum+1,inf);
	dp[0]=0;
	fr(i,0,n)
	{
		frr(j,sum+1,0)
		{
			if(j+val[i]<=sum)
			{
				dp[j+val[i]]=min(dp[j+val[i]],dp[j]+wt[i]);
			}
		}
	}
	ll ans=0;
	fr(i,0,sum+1)
	{
		if(dp[i]<=w)
		{
			ans=max(ans,(ll)i);
		}
	}
	wl(ans);
	NL;
	//ll k[n+1][w+1];
	// fr(i,0,n+1)
	// {
	// 	fr(j,0,w+1)
	// 	{
	// 		if(i==0||j==0)
	// 			k[i][j]=0;
	// 		else if(wt[i-1]<=j)
	// 		{
	// 			k[i][j]=max(val[i-1]+k[i-1][j-wt[i-1]],k[i-1][j]);
	// 		}
	// 		else
	// 			k[i][j]=k[i-1][j];

	// 	}
	// }
	//wl(k[n][w]);
	NL;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1000000007;

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

    cout << x / 500 * 1000 + (x % 500)/ 5 * 5 << endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <deque>

#include <stdio.h>

#include <cstdio>

#include <algorithm>

#include<bits/stdc++.h>

#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define sp <<" "
#define nw <<"\n"
#define ca "Case "<<tc++<<": "
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define ull unsigned LL
#define check cout<<"* ";
#define show_vector for(int q=0;q<v.size();q++){cout<<v[q]<<" ";}
#define REP(i,n) for (int i=0;i<(n);++i)
#define N_MAX 26


const int inf=1<<30;
const long long int INF=1e10;
const int MOD=1e9+7;
const int maxn = 1e5+10;
int a[200005],b[1000005];

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
/*
int ck_prime(int n)
{
    int coun;
     coun=0;
     if(n>1){
      for(int i=2;i*i<=n;i++){
        if( n%i==0 ){
            coun++;
            break;
          }
        }
      }
     if(n==1){
       coun=coun;
         }
    if(coun==0){
           return 1; // n is prime
        }
    return 0;
}
*/
int main()
{
    int n;
    cin>>n;
    char s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int x=1,i=0,j;
    st:
        char p=s[i];
        for(j=i+1;j<n;j++){
            if(p==s[j]){
                continue;
            }
            x=x+1;
            i=j;
            goto st;
        }
    cout<<x nw;
}



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

int main(){
  int n; cin >> n;
  int a = 0, b = 0;
  for(int i = 0; i < n; i++){
    int c; cin >> c;
    if(c % 4 == 0){
      a++;
      continue;
    }
    if(c % 2 == 1){
      b++;
      continue;
    }
  }
  bool ok = true;
  if(b > a + 1) ok = false;
  if(b == a + 1 && n - b - a > 0) ok = false;
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1000000
int main(){
  int a[MAX + 1],b[MAX + 1];
  a[0] = b[0] = 0;
  for(int i = 1; i < MAX + 1; i++){
    a[i] = b[i] = i;
    for(int j = 1;  ; j++ ){
      int java = j * (j + 1) * (j + 2) / 6;
      if(i - java < 0) break;
      a[i] = min( a[i], a[i - java] + 1);
      if(java & 1) b[i] = min( b[i], b[i - java] + 1);
    }
  }
  int n;
  while(cin >> n, n){
    cout << a[n] << " " << b[n] << endl;
  }
}

Measured memory_bytes: 8968
import Data.Array.Unboxed
import qualified Data.ByteString.Char8  as C
import Data.Char
import Data.List

main = C.interact $ sol . tail . C.lines

sol ss = C.pack $ g b
  where
  (a:as) = f <$> ss :: [UArray Char Int] 
  b = foldl' ((. assocs) . accum min) a as

f = array ('a','z') . fmap ((,) <$> C.head <*> C.length) . C.group . C.sort . C.filter isLetter

g = concatMap (\(c,n) -> replicate n c) . filter ((>0) . snd) . assocs

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

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#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 srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll max_1 {}, max_2 {};
  rep(i, N) {
    if (max_1 < A[i]) {
      max_2 = max_1;
      max_1 = A[i];
    } else if (max_2 < A[i]) {
      max_2 = A[i];
    }
  }
  rep(i, N) {
    if (max_1 == A[i]) {
      cout << max_2 << '\n';
    } else {
      cout << max_1 << '\n';
    }
  }
}


Measured memory_bytes: 3200
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        String ans = "YES";

        int index = s.length();

        while (index > 0) {
            boolean isOK = false;

            if (index >= 7 && s.substring(index - 7, index).equals("dreamer")) {
                isOK = true;
                index -= 7;
            }
            else if (index >= 5 && s.substring(index - 5, index).equals("dream")) {
                isOK = true;
                index -= 5;
            }
            else if (index >= 6 &&s.substring(index - 6, index).equals("eraser")) {
                isOK = true;
                index -= 6;
            }
            else if (index >= 5 && s.substring(index - 5, index).equals("erase")) {
                isOK = true;
                index -= 5;
            }

            if (!isOK) {
                ans = "NO";
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 28860
# 長方形のど真ん中の点を通る直線で分ければ半分にできます
w,h,x,y = map(float,input().split())
half_w = w / 2
half_h = h / 2
max_area = w * h / 2
if x == half_w and y == half_h:
  print("{:.9f} 1".format(max_area))
  
else:
  print("{:.9f} 0".format(max_area))
  

Measured memory_bytes: 9020
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  int i;
  unsigned long long int K,A,B,Bis=0,Yen=0;

  cin>>K>>A>>B;
  K=K+1;

  if(A+2>=B){
    cout<<K<<endl;
    return 0;
  }

  else{
    for(i=0;i<K;i++){
      if(i==K-1 && Yen == 0){ //最後の一回でBisが多すぎるとき、換金しない
        Bis++;
      }
      else if(Yen == 0){
        if(Bis>=A){
          Yen = 1;
          Bis-= A;
        }
        else{
          Bis++;
        }
      }
      else if(Yen == 1){
        Yen = 0;
        Bis+= B;
      }
    }
    cout<<Bis<<endl;
  }
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


i64 m, d[202020], c[202020], cnt[202020];

int main(){
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> d[i] >> c[i];
	}
	
	i64 ans = 0, cnt = 0;
	for(int i = 0; i < m; i++){
		ans += c[i];
		cnt += d[i] * c[i];
	}
	
	cout << ans-1 + (cnt-1)/9LL << endl;
	
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>

#define MAX 100000

int n, k;
double T[MAX];

int check(double );
int solve();


int main(){
  int i;
  double ans;
  
  scanf("%d%d", &n, &k);
  for( i = 0 ; i < n ; i++){
    scanf("%lf", &T[i]);
  }
  ans = solve();
  printf("%d\n", (int)ans);

  return 0;
}

int check(double p){
  
  int i =0, j;
  double s;
  
  for( j = 0 ; j < k ; j++){
    s = 0.0;
    while( s + T[i] <= p){
      s += T[i];
      i++;
      if( i == n ){
	return n;
      }
    }
  }
  return i;
}

int solve(){
  double left = 0.0;
  double right = 100000*10000;
  double mid;
  int v;

  while( right - left > 1){
    mid = ( left + right ) / 2;
    v = check(mid);
    if( v >= n ) {
      right = mid;
    }
    else{
      left = mid;
    }
  }
  return right;
}



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

int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	double area = (double)w * (double)h / 2.0;

	if (w == x * 2 && h == y * 2) {
		cout << setprecision(10) << area;
		cout << ' ' << 1 << endl;
	}
	else {
		cout << setprecision(10) << area;
		cout << ' ' << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
int main(){
    int t;
    cin >> t;
    for(int tt = 0;tt<t;tt++){
        long n,a,b,c,d;
        cin >> n >> a >> b >> c >> d;
        // long ans = 0;
        long costa = a*15;
        long costb = b*10;
        long costc = c*6;
        long ans = 1LL<<60;
        queue<pair<long,long> >que;
        que.push(mp(n,0));              //mp(Number,cost)
        map<long,long>m;
        while(!que.empty()){
            long number = que.front().first;
            long nowCost = que.front().second;
            que.pop();

            if((number!=n && m[number]==0)||m[number] > nowCost||(number==n && nowCost==0)){
                m[number] = nowCost;
            }else{
                continue;
            }

            if(number==0){
                ans = min(nowCost,ans);
                continue;
            }

            if(number<0){
                continue;
            }

            if(number < ((1LL<<60) - nowCost)/d){
                ans = min(nowCost+number*d,ans);
            }

           




            if(number%2==0){
                que.push(mp(number/2,nowCost+a));
            }else{
                que.push(mp((number+1)/2,nowCost+d+a));
                que.push(mp((number-1)/2,nowCost+d+a));
            }

            if(number %3 == 0){
                que.push(mp(number/3,nowCost+b));
            }else{
                que.push(mp((number+3-number%3)/3,nowCost + d*(3-number%3) + b));
                que.push(mp((number-number%3)/3,nowCost+d*(number%3)+b));
            }

            if(number%5==0){
                que.push(mp(number/5,nowCost+c));
            }else{
                que.push(mp((number+5-number%5)/5,nowCost + d*(5-number%5) + c));
                que.push(mp((number-number%5)/5,nowCost+d*(number%5)+c));
            }

            // cout << number << " "<<nowCost<<endl;
        }
        cout << ans <<endl;
    }
    
}

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

int main(void) {
    string N;
    cin >> N;
    long long sum = 0;
    for (int i = 0; i < N.length(); i++) {
        sum += N[i] - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fr ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include<string>
#include<algorithm>
#include<vector>
const long long int maxn = 1e3+2;
const long long int mod = 1e3+2;

int main()
{
	fr
	ll n;
	cin>>n;
	ll a[n+2], b[n+2], c[n+2];
	ll dp[n+2][3];
	memset(dp, 0, sizeof(dp));	
	for(ll i=0;i<n;i++)	cin>>a[i]>>b[i]>>c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	
	for(ll i=1;i<n;i++)
	{
		dp[i][0] = a[i]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i]+max(dp[i-1][1], dp[i-1][0]);
	}
	ll ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	cout<<ans<<endl;
	return 0;
	
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
map<LL,int> mp;
set<LL> p2,p1;
int n;
LL val[100005];
int pr[N],pcnt,ccnt;
LL cube[N];
bool vis[N];
void pre(){
	for(int i=2;i<N;i++)
		if(vis[i]==false){
			pr[++pcnt]=i;p2.insert(i*1LL*i);p1.insert(i);
			cube[pcnt]=i*1LL*i*i;
			if(i<=2155) ccnt=pcnt;
			for(int j=i+i;j<N;j+=i) vis[j]=true;
		}
}
LL op(LL v){
	LL ret=1;
	for(int i=1;i<=ccnt&&pr[i]<=v;i++){
		if(v%pr[i]==0){
			v/=pr[i];ret*=pr[i];
			if(v%pr[i]==0) v/=pr[i];
			else ret*=pr[i];
			if(ret>1e10) return -1;
		}
	}
	if(v==1) return ret;
	if(p1.find(v)!=p1.end()) return ret*v*v;
	if(p2.find(v)!=p2.end()) return ret*(int)(sqrt((long double)v)+0.5);
	return -1;
}
int main(){
	pre();
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&val[i]);
		for(int j=1;j<=pcnt&&cube[j]<=val[i];j++)
			while(val[i]%cube[j]==0) val[i]/=cube[j];
		mp[val[i]]++;
	}
	sort(val+1,val+n+1);
	n=unique(val+1,val+n+1)-val-1;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(val[i]==1) {ans++;continue;}
		long long opz=op(val[i]);
		if(opz==-1)
			ans+=mp[val[i]];
		else if(mp[val[i]]>mp[opz]||(mp[val[i]]==mp[opz]&&val[i]>=opz))
			ans+=mp[val[i]];
		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12416