akhauriyash/Code-Regression huggingface dataset:
import sys
a,b = map(int,input().split())
if (a+b)%3 == 0:
  print("Possible")
  sys.exit()
elif a%3 == 0:
  print("Possible")
  sys.exit()
elif b%3 == 0:
  print("Possible")
  sys.exit()
else:
  print("Impossible")

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

int main() {
   int n;
   cin >> n;
   int lmax=-1,sum=0;
   rep(i,n){
      int l;  cin >> l;
      lmax=max(lmax,l), sum+=l;
   }
   cout << (lmax<sum-lmax ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
cnt=[0] * 11000
n = int(input())

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            value = (x+y+z)**2 -(x*y+y*z+z*x)
            if value <= n:
                cnt[value] += 1

for i in range(1,n+1):
    print(cnt[i])
                



Measured memory_bytes: 69272
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int N;
   cin >> N;
   vector<string> s(N);
   for(int i = 0; i < N; i++){
      cin >> s[i];
   }
   int M;
   cin >> M;
   vector<string> t(M);
   for(int i = 0; i < M; i++){
      cin >> t[i];
   }

   int ans = -INF;
   for(int i = 0; i < N; i++){
      int blue = 0, red = 0;
      for(int j = 0; j < N; j++){
         if(s[i] == s[j]){
            blue++;
         }
      }
      for(int j = 0; j < M; j++){
         if(s[i] == t[j]){
            red++;
         }
      }
      ans = max(ans, blue-red);
   }
   cout << max(ans, 0) << endl;

   return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::str::FromStr;

fn read_vec<T: FromStr>(s: String) -> Result<Vec<T>, T::Err> {
    s.split(' ').map(|x| x.parse()).collect()
}

fn main() {
    const M: i64 = 1000_000_000 + 7;
    let mut lines = BufReader::new(io::stdin()).lines().map(|l| l.unwrap());
    let nk: Vec<usize> = read_vec(lines.next().unwrap()).unwrap();
    let k = nk[1];
    let mut v: Vec<i64> = read_vec(lines.next().unwrap()).unwrap();
    let mut P: Vec<_> = v.iter().filter(|&&x| x > 0).collect();
    let mut N: Vec<_> = v.iter().filter(|&&x| x < 0).collect();
    P.sort_unstable();
    N.sort_unstable();
    // 正の数にできるか否か
    let can_positive = if P.len() >= k {
        true // Pが十分あればok
    } else if P.len() == 0 {
        k & 1 == 0 && k <= N.len() // Pがゼロ個なら、kが偶数で、Nはkより多い必要がある
    } else {
        // Pが1つ以上あって、kより少ない時
        (k - P.len() + 1) & !1 <= N.len() // Pが一つ以上あれば、k-Pを2の倍数に切り上げた数より、Nが多い必要がある
    };
    if !can_positive {
        if v.contains(&0) {
            // ゼロにできる時
            println!("0");
        } else {
            // 負の数になる時
            v.sort_unstable_by_key(|x| {
                let y = x >> 31;
                (x ^ y) - y
            });
            let ans = v
                .iter()
                .take(k) // 小さい方から集めて
                .fold(1, |acc, x| acc * (x % M) % M);
            println!("{}", (ans + M) % M);
        }
        return;
    }
    let mut ans = 1;
    let mut k = k;
    if k & 1 == 1 {
        ans *= P.pop().unwrap();
        k -= 1;
    }
    let mut P = P.rchunks_exact(2).map(|x| x[0] * x[1]).peekable();
    let mut N = N.chunks_exact(2).map(|x| x[0] * x[1]).peekable();
    while k > 0 {
        // pnどっちからとるか。 両方空っぽはありえない
        ans *= if P.peek().unwrap_or(&0) > N.peek().unwrap_or(&0) {
            P.next()
        } else {
            N.next()
        }
        .unwrap()
            % M;
        ans %= M;
        k -= 2;
    }
    println!("{}", (ans + M) % M);
}

Measured memory_bytes: 6128
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int ac = 0;
        int bc = 0;
        int cc = 0;
        char turn = 'a';

        while(true){
            if (turn == 'a') {
                turn = a.charAt(ac);
                ac++;
            }else if(turn == 'b'){
                turn = b.charAt(bc);
                bc++;
            }else{
                turn = c.charAt(cc);
                cc++;
            }
            if (ac == a.length() && turn == 'a') {
                System.out.println("A");
                break;
            }
            if (bc == b.length() && turn == 'b') {
                System.out.println("B");
                break;
            }
            if (cc == c.length() && turn == 'c') {
                System.out.println("C");
                break;
            }
        }

        sc.close();
    }

}





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

int main()
{
  int h;
  int i;
  int n;
  cin>>h>>n;
  int a[n];
  int sum=0;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
    sum=sum+a[i];
  }
  if(sum>=h)
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int[] arr=new int[n];
    for(int i=0;i<n;i++){
      arr[i]=s.nextInt();
    }
    int[] dp=new int[n];
    dp[0]=0;
    dp[1]=Math.abs(arr[1]-arr[0])+dp[0];
    for(int i=2;i<n;i++){
      dp[i]=Math.min(Math.abs(arr[i]-arr[i-1])+dp[i-1],Math.abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    System.out.println(dp[n-1]);
  }
    
}

Measured memory_bytes: 50876
#include<stdio.h>
#include<string.h>

int max(int a,int b){
  if(a > b)return a;
  else return b;
}

int lcs(char s1[],char s2[],int m,int n){
  int c[1001][1001];
  int i,j;
  int maxl = 0;

  for(i=1;i<=m;i++){
    if(i<=m)break;
  }

  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }
  for(j=1;j<=n;j++){
    c[0][j] = 0;
  }

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(s1[i-1] == s2[j-1]){
        c[i][j] = c[i-1][j-1] + 1;
      }else{
        c[i][j] = max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }

  return maxl;
}


int main(){
  int n;
  int i;
  char s1[1001],s2[1001];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",lcs(s1,s2,strlen(s1),strlen(s2)));
  }
  return 0;
}



Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <iterator>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int N,M,B;
int A[1000];
int C[1000];
int main(){
  cin>>N>>M;
  FOR(i,0,N){
    cin>>A[i];
  }
  FOR(i,0,M){
    cin>>B;
    int j=0;
    while(B<A[j]){
      j++;
    }
    C[j]++;
  }
  int M=0,ans;
  FOR(i,0,N){
    if(M<C[i]){
      M=C[i];
      ans=i+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int cnt=0;

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;
    }
    if(i!=minj){
      swap(A[i], A[minj]);
      cnt++;
    }
  }
}

int main(){

  int n, a[110];

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

  selectionSort(a, n);

  for(int i=0;i<n;i++){
    cout<<(i?" ":"");
    cout<<a[i];
  }
  cout<<endl<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define bs ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define pb push_back

#define rep(var,start,end)       for(int var=start;var<end;var++)
#define erep(var,start,end)      for(int var=start;var<=end;var++)
#define rrep(var,start,end)      for(int var=start;var>=end;var--)

#define pa(x)                    cout<<x<<endl

#define pii                      pair<int,int>
#define pci                      pair<char,int>
#define pll                      pair<ll,ll>
#define test                     int t;cin>>t;while(t--)

ll modularExponentiation(ll x,ll n,ll M){
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;
}
template<class T> 
T power(T n, T p){ if(p==0) return 1; else return power(n,p-1)*n;} 

void solve(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<' '<<x<<' '<<y;    
}

int main()
{
    bs;
    solve();
    
}

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

int main(){
  int N, K; cin >> N >> K;

  vector<int64_t> x(100010);
  for(int i=0; i<N; i++) cin >> x[i];
  sort(x.begin(), x.begin()+N);

  int64_t ans = 1e18;
  for(int l=0; l<N-K+1; l++){
    int r = l + K-1;
    if(x[r] <= 0){
      ans = min(ans, abs(x[l]));
    } else if (x[l] >= 0){
      ans = min(ans, abs(x[r]));
    } else {
      ans = min(ans, 2*min(abs(x[l]), abs(x[r])) + max(abs(x[l]), abs(x[r])));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(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;
}


int main() {

	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if (s < t) { cout << "Yes"; }
	else { cout << "No"; }

	system("PAUSE");

	

}


Measured memory_bytes: 504
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[100005], b[100005];
    for (i = 0; i < n; i++)
        scanf("%d %d", &a[i], &b[i]);
    int min = 0;
    for (i = 1; i < n; i++)
        if (b[i] < b[min])
            min = i;
    printf("%d\n", a[min] + b[min]);
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt(), x = sc.nextInt();
		
		for(int i = Math.max(-(int)1e6, x - k + 1), j = Math.min((int)1e6, x + k - 1); i <= j; i++)
			System.out.print(i + ( i == j ? "\n" : " "));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    string s;
    cin>>s;

    string ss = "CODEFESTIVAL2016";
    
    int cnt=0;
    for (int i = 0; i < ss.size(); i++){
        if(s[i]!=ss[i]) cnt++;
    }

    cout << cnt << endl;

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool check(int n,int wei,vector<int> book)
{
  int tmp=wei;
  n--;
  for(int i=0;i<book.size();i++)
    {
      if(tmp<book[i])
	{
	  if(n>0)
	    {
	      n--;
	      tmp=wei;
	      if(tmp<book[i])
		return false;
	    }
	  else
	    return false;
	}
      //  cout<<n<<" "<<tmp<<" "<<book[i]<<endl; 
      tmp-=book[i];
    }
  return true;
}
int main()
{
  int m,n;
  for(;cin>>m>>n,m;)
    {
      vector<int> book;
      for(int i=0;i<n;i++)
	{
	  int tmp;
	  cin>>tmp;
	  book.push_back(tmp);
	}
      /*
      while(true)
	{
	  int tmp;
	  cin>>tmp;
	  if(check(m,tmp,book))
	      cout<<"YES"<<endl;
	  else
	      cout<<"NO"<<endl;
	}
      */

      int l=0;
      int r=1500000;
      int ans;
      while(l<r)
	{
	  //	  cout<<l<<" "<<r<<endl;
	  // cout<<(l+r)/2<<endl;
	  if(check(m,(l+r)/2,book))
	    {
	      ans=(l+r)/2;
	      if(r==(l+r)/2)
		break;
	      r=(l+r)/2;

	    }
	  else
	    {
	      if(l==(l+r)/2)
		break;
	      l=(l+r)/2;
	    }
	}
      cout<<ans<<endl;

    }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
   
   string s,t;
   cin>>s>>t;
   int m=INT32_MAX;
   for (int i = 0; i < s.size()-t.size()+1; i++)
   {
       int count=0,c=i;
       for (int j = 0; j < t.size(); j++,i++)
       {
           if(s[i]!=t[j])
            count++;
            if(count>m)
             {  count=INT32_MAX;
                    break;
             }

       }
       
       m=min(m,count);
       i=c;

   }
   
cout<<m;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X,count500,count5,happiness;
  cin >> X;
  count500 = X / 500;
  X -= (X / 500) * 500;
  count5 = X / 5;
  happiness = count500 * 1000 + count5 * 5;
  cout << happiness << endl;
  return 0;
}

Measured memory_bytes: 256
N = list(map(int, input().split()))
H = list(map(int, input().split()))
B = [list(map(int, input().split())) for i in range(N[1])]

# N = [6, 5]
# H = [8, 6, 9, 1, 2, 1]
# B = [[1, 3], [4, 2], [4, 3], [4, 6], [4, 6]]

# N = [4, 3]
# H = [1, 2, 3, 4]
# B = [[1, 3],[2, 3],[2, 4]]

counter = [1 for i in range(N[0])]

for b in B:
    if H[b[1]-1] > H[b[0]-1]:
        counter[b[0]-1] = 0
    elif H[b[0]-1] > H[b[1]-1]:
        counter[b[1]-1] = 0
    elif H[b[0]-1] == H[b[1]-1]:
        counter[b[0]-1] = 0
        counter[b[1]-1] = 0

print(sum(counter))

Measured memory_bytes: 32056
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <cmath>
#include <array>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int n=sz(s);
	ll ans =0;
	rep(i,(1<<n-1)){
		VI v(n-1);
		rep(j,n-1) if((i >> j) & 1) v[j]=1;
		v.push_back(1);
		int st=0;
		rep(j,n) if(v[j]==1){
			string a=s.substr(st,j+1-st);
			//printf("%s:%d:%d  ", a.c_str(),st,j+1-st);
			st = j+1;
			ans +=stoll(a);
		}
	}

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}



ll const mod=1e9+7;
int main() {
  int N,K,tt; ll x=0,d,res=0,tmp=0;
  cin >> N >> K;
  vector<ll> val(N,-1);
  vector<vector<ll>> td(N);
  rep(i,N) {
    cin >> tt >> d;
    tt--;
    td[i] = {d,tt};
  }
  sort(td.rbegin(),td.rend());
  priority_queue<ll,vector<ll>,greater<>> pq;
  
  rep(i,N) {
    auto t = td[i];
    if (i<K){
      if (val[t[1]]==-1) {
        x++;val[t[1]]++;tmp+=t[0];
      }
      else {
        tmp+=t[0];
        pq.push({t[0]});
      }
    }
    else{
      if (val[t[1]]==-1) {
        if (pq.empty()) break;
        x++;val[t[1]]++;tmp+=t[0]-pq.top();
        pq.pop();
      }
      else continue;
    }
    chmax(res,tmp+x*x);
  }
  cout << res << endl;
}

Measured memory_bytes: 7164
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	ll r, b, g;
	cin >> r >> g >> b;
	ll k;
	cin >> k;
	int c = 0;
	while (g <= r)
	{
		g *= 2;
		c++;
	}
	while (b <= g)
	{
		b *= 2;
		c++;
	}

	if (c > k or (b < g and g < r))
	{
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int fibonacci(int);

int n;

int main(){
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}

int fibonacci(int n){
  if(n==44){
    return 1134903170;
  }
  if(n==0 || n==1){
    return 1;
  }
  return fibonacci(n-2)+fibonacci(n-1);
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

string S,T;
int H,W;
int N;

bool f(const vector<int> &tak, const vector<int> &aok, int s, int mx, bool gr){
  int x = s;
  if(gr){
    REP(i,N){
      if(tak[i]){
	++x;
	if(x > mx) return true;
      }

      if(aok[i] and x > 1){
	--x;
      }
    }
  }else{
    REP(i,N){
      if(tak[i]){
	--x;
	if(x < 1) return true;
      }

      if(aok[i] and x < mx){
	++x;
      }
    }    
  }

  return false;
}


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

  while(cin >> H >> W >> N){
    int sr,sc; cin >> sr >> sc;
    cin >> S >> T;

    vector<int> vert_tak_u(N), vert_tak_d(N), vert_aok_u(N), vert_aok_d(N);
    vector<int> hor_tak_l(N), hor_tak_r(N), hor_aok_l(N), hor_aok_r(N);

    int l=0,r=0,u=0,d=0;

    REP(i,N){
      switch(S[i]){
      case 'L':{hor_tak_l[i] = 1; break;}
      case 'R':{hor_tak_r[i] = 1; break;}
      case 'U':{vert_tak_u[i] = 1; break;}
      case 'D':{vert_tak_d[i] = 1; break;}
      }
      switch(T[i]){
      case 'L':{hor_aok_l[i] = 1; chmax(l,i); break;}
      case 'R':{hor_aok_r[i] = 1; chmax(r,i); break;}
      case 'U':{vert_aok_u[i] = 1; chmax(u,i); break;}
      case 'D':{vert_aok_d[i] = 1; chmax(d,i); break;}     
      }
    }

    bool ans =
      f(hor_tak_l, hor_aok_r, sc, W, false) || f(hor_tak_r, hor_aok_l, sc, W, true) ||
      f(vert_tak_u, vert_aok_d, sr, H, false) || f(vert_tak_d, vert_aok_u, sr, H, true);
        
    
    cout << (ans ? "NO" : "YES") << endl;

  }
  
  return 0;
}


Measured memory_bytes: 7192
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
int main() {
   long long a;
   cin>>a;
   long long tes=a;
   bool flag=true;
   int i=1;
   int j=1;
   long long min = 1000000000000;
   //vector<long long> xvec(1000000);
   //vector<long long> yvec(1000000);
   //vector<vector<long long>> data(1000000, vector<long long>(10000000));
   for(long long i=1;i<=1000000;i++){
      if(a%i==0){
         flag=false;
         if(min>(a/i+i-2)){
            min=(a/i+i-2);
         }
      }
   }
   if(flag){
      cout<<a-1<<endl;
   }
   else{
      cout<<min<<endl;
   }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
typedef long long ll;
const int INF = 1e9;


int main(void){
    string s,t;
    cin>>s>>t;
    int n = s.size();
    bool ans = false;
    rep(i,n){
        if(s.substr(i,n-i)+s.substr(0,i) == t){
            ans = true;
        }
    }
    cout<<((ans) ? "Yes" : "No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int a[200004],n;
vector <int> b;
int main()
{
	cin>>n;
	bool ok=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>a[i-1]+1) ok=0;
		if(a[i]==0)
			b.push_back(i);
	}
	if(a[1]!=0||ok==0)
	{
		printf("-1");
		return 0;
	}
	int len=b.size();
	b.push_back(n+1);
	unsigned long long ans=0;
	for(int i=0;i<len;i++)
	{
		int q=0;
		for(int j=b[i];j<b[i+1]-1;j++)
		{
			if(a[j]+1==a[j+1]) q++;
			else
			{
				ans+=q;
				q=a[j+1];
			}
		}
		ans+=q;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

#define NIL -1
#define MAX 10000

struct Node { int parent, left, right; };
struct Node Nodes[MAX];
int n;

void preParse(int id) {
  if (id == NIL) return;
  printf(" %d", id);
  preParse(Nodes[id].left);
  preParse(Nodes[id].right);
}

void inParse(int id) {
  if (id == NIL) return;
  inParse(Nodes[id].left);
  printf(" %d", id);
  inParse(Nodes[id].right);
}

void postParse(int id) {
  if (id == NIL) return;
  postParse(Nodes[id].left);
  postParse(Nodes[id].right);
  printf(" %d", id);
}

int getRoot() {
  for (int i = 0; i < n; i++) {
    if (Nodes[i].parent == NIL) return i;
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    Nodes[i].parent = -1;
  }
  for (int i = 0; i < n; i++) {
    int id, left, right;
    cin >> id >> left >> right;
    Nodes[id].left = left;
    Nodes[id].right = right;
    Nodes[left].parent = id;
    Nodes[right].parent = id;
  }

  int root = getRoot();

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 3208
#include <iostream>

using namespace std;

int main(){
    int a,b,c,k;
    int ans=0;
    cin >> a >> b >>c;
    cin >> k;
    ans=a+b+c-max(a,max(b,c));
    int mm=max(a,max(b,c));
    for(int i=0;i<k;i++){
        mm*=2;
    }
    ans+=mm;
    cout << ans << endl;
    return 0;
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003&lang=jp

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		if (b < a) {
			int t = b;
			b = a;
			a = t;
		}
		if (c < b) {
			int t = c;
			c = b;
			b = t;
		}
		cout << (a * a + b * b == c * c ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  ll l=0, r=s.size()-1;
  bool is_ac = true;
  ll ans = 0;
  while (l<r) {
    if (s[l]=='x') {
      if (s[r]=='x') {
        l++; r--;
      } else {
        l++; ans++;
      }
    } else {
      if (s[r]=='x') {
        r--; ans++;
      } else {
        if (s[l]==s[r]) {
          l++; r--;
        } else {
          is_ac = false; break;
        }
      }
    }
  }
  if (!is_ac) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


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

int main() {
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  int x, y; cin >> x >> y;
  cout << (a[x] == a[y] ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,c,k,ans=0;
  scanf("%d %d %d %d",&a,&b,&c,&k);
  if(a>=k){
    ans=k;
  }else{
    k-=a;
    ans+=a;
    if(b>=k){
      k-=b;
    }else{
      k-=b;
      ans-=k;
    }
  }
  printf("%d",ans);
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    deque<int> d;
    rep(i,n){
        int a;
        cin >> a;
        if(i%2 == 0) d.push_front(a);
        else d.push_back(a);
    }
    if(n%2 != 0){
        rep(i,n) cout << d[i] << " ";
    }
    else{
        for(int i = n-1;i >= 0;i--){
            cout << d[i] << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 2944
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>

using namespace std;

long long gcd(long long a, long long b)
{
	long long Min = min(a, b);
	long long Max = max(a, b);
	long long remainder;
	while (1)
	{
		remainder = Max%Min;
		if (remainder == 0)
		{
			break;
		}
		Max = Min;
		Min = remainder;
	}

	return Min;
}
int main(void)
{
	
	int n;
	long long temp, res;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		if (i == 0)
		{
			res = temp;
		}
		else
		{
			long long g = gcd(res, temp);
			res /= g;
			res *= temp;
		}
	}

	cout << res << endl;	

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n-1);
    vector<int> b(n);
    for(int i = 0; i< n-1;i++){
        cin >> v[i];
    }

    int ans = 0 ;
    int tmp = 0;
    if(n == 2){
        cout << v[0]+v[0] << endl;
        return 0;
    }
    else {
        //ans += (v[0]*2);
        b[0] = v[0];
        b[1] = v[0];
        for(int i = 1; i < n-1; i++){
            b[i] = min(v[i-1], v[i]);
        }
        b[n-1] = v[v.size()-1];
        
    }
    for(int i = 0; i < b.size(); i++){
        ans += b[i];
        //cout << ans << endl;
        //cout << b[i] << " ";
    }
    //cout << endl;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define rev(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;
using ull = unsigned long long;

int main() {
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,x,y;
int a[110],b[110];
int main(){
	cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<m;i++) cin>>b[i];
	int maxx=a[0];
	for(int i=0;i<n;i++){
		maxx=max(maxx,a[i]);
	}
	int minx=b[0];
	for(int i=0;i<m;i++){
		minx=min(minx,b[i]);
	}
	if(maxx<minx && x<minx && minx<=y) cout<<"No War"<<endl;
	else cout<<"War"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin>>n>>q;
    ll m,maki=n+1,niko=1,a[n];

    while(1){
        m=(maki+niko)/2;
        if(m==niko){
            break;
        }
        if(m*m==n){
            break;
        }
        else if(m*m>n){
            maki=m;
        }
        else{
            niko=m;
        }
    }
    niko=n/m;
    if(n%m)niko++;


////////////!!!!!!!!!
    ll makichankawaiikakikukeko[niko];
////////////!!!!!!!!!
    vector<ll> ans;
    memset(a,0,sizeof(a));
    memset(makichankawaiikakikukeko,0,sizeof(makichankawaiikakikukeko));
    ll com,x,y,sum;
    for(int i=0;i<q;i++){
        cin>>com>>x>>y;
        x--;
        if(com&&(x/m)!=((y-1)/m)){

            y--;
            sum=0;
            //cout <<"s"<< x/m+1<<" "<<y/m-1<<endl;
            for(int i=x/m+1;i<y/m;i++){
                sum+=makichankawaiikakikukeko[i];
            }
            //cout << "x"<<x<<" "<<m*(x/m+1)-1<<endl;
            for(int i=x;i<m*(x/m+1);i++){
                sum+=a[i];
            }
            //cout << "y"<<m*(y/m)<<" "<<y<<endl;
            for(int i=m*(y/m);i<=y;i++){
                sum+=a[i];
            }
            ans.pb(sum);
        }
        else if(com){
            sum=0;
            for(int i=x;i<y;i++){
                sum+=a[i];
            }
            ans.pb(sum);
        }
        else{
            a[x]+=y;
            makichankawaiikakikukeko[x/m]+=y;
        }
    }
    for(int i=0;i<ans.size();i++){
        cout << ans[i]<<endl;
    }
    return 0;
}




Measured memory_bytes: 4276
#include<stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  for(int i=0;i<200;i++){
    if(i%2==0){
      c-=b;
      if(c<=0){
        printf("Yes\n");
        break;
      }
    }else{
      a-=d;
      if(a<=0){
        printf("No\n");
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1628
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 3e18;
long long int mod = 4294967296;
double Pi = 3.1415926535897932384626;

//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}

ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,e,g,h,w,ok,ng;
ll x[100005],y[100005];
bool flag,dame;
char s[1000005];


int main(){
    cin >> a;
	while(1){
		if(x[a]){
			p(num + 1);
			return 0;
		}else{
			x[a] = 1;
			if(a % 2 == 0){
				a /= 2;
			}else{
				a = a * 3 + 1;
			}
		}
		num ++;
	}
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(' ').map(Number);

function gcd(x, y) {
  if (y === 0) {
    console.log(x);
  } else {
    gcd(y, x % y);
  }
}

gcd(input[0], input[1]);

Measured memory_bytes: 15532
import heapq

N, M = map(int, input().split())
case = sorted([[int(j) for j in input().split()] for i in range(N)], key=lambda x: -x[0])

candidate_queue = []
ans = 0

for i in range(1, M + 1):
    while case:
        if case[-1][0] <= i:
            heapq.heappush(candidate_queue, case.pop(-1)[1] * (-1))
        else:
            break

    if candidate_queue:
        ans += heapq.heappop(candidate_queue) * (-1)

print(ans)


Measured memory_bytes: 26856
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define PB(e) push_back(e)
//#define MP(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

int main(){
    string s;
    cin >> s;
    int ans=0;
    char before=s[0];
    for(int i=1;i<s.size();i++){
        if(s[i]!=before){
            ans++;
            before=s[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
object Main {
  def main(args: Array[String]): Unit = {
    val buy_num    = scala.io.StdIn.readInt
    var max_price  = 0
    var sum        = 0

    for(i <- 0 until buy_num) {
      val price = scala.io.StdIn.readInt
      sum += price
      if(max_price < price) max_price = price
    }

    println(sum - max_price/2)
  }
}

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

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i=0;i< int (n);i++)

int main(void)
{
    int  A, B;
    vector<int> vec(9);
    vector<int>::iterator itr;
  
    for(itr = vec.begin();itr != vec.end(); itr++)
    {
        cin >> *itr;
    }

    cin >> A;
    for (int i = 0; i < A; i++)
    {
        cin >> B;
        for (itr = vec.begin(); itr != vec.end(); itr++)
        {
            if (B == *itr)
            {
                *itr = 1;
                break;
            }
        }
    }
    if (vec[0] == vec[1] && vec[2] == vec[1])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (vec[3] == vec[4] && vec[4] == vec[5])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (vec[7] == vec[6] && vec[7] == vec[8])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (vec[0] == vec[3] && vec[3] == vec[6])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (vec[1] == vec[4] && vec[4] == vec[7])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (vec[2] == vec[5] && vec[5] == vec[8])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (vec[0] == vec[4] && vec[4] == vec[8])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else if (vec[2] == vec[4] && vec[4] == vec[6])
    {
        cout << "Yes" << endl;
        return 0;
    }
    else 
    {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import numpy as np
ls = []
n = int(input())
for i in range(n):
    ls.append(int(input()))
ls = np.array(ls)
maxindex1 = np.argmax(ls)
for j in range(n):
    if j != maxindex1:
        print(ls[maxindex1])
    else:
        tmp = ls[maxindex1]
        ls[maxindex1] = 0 
        maxindex2 = np.argmax(ls)
        print(ls[maxindex2])
        ls[maxindex1] = tmp

Measured memory_bytes: 21752
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int64_t n,a,b,c;
    cin>>n>>a>>b;
    c=a+b;
    cout<<n/c*a+min(n%c,a)<<endl;
}

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

using namespace std;
int X;
bool point[301][301],link[301][301];
int abs(int x){
	if(x<0){
		return -x;
	}
	return x;
}

int min(int x,int y){
	if(x<y)return x;
	return y;
}
int max(int x,int y){
	if(x>y)return x;
	return y;
}
 
int main(){
	cin >> X;
	int a=1;
	int ans=0;
	while(ans<X){
		
		ans+=a;
		a++;
		
	}


	cout <<a-1<<endl;

	return 0;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
a,f=[gets,gets].map{|x|x.split.map(&:to_i).sort}
p (0..(a.max*f.max)).bsearch{|x|
  t=0
  n.times{|i|a[-i-1]>x/f[i] && t+=a[-i-1]-x/f[i]}
  t <= k
}


Measured memory_bytes: 34272
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX 1000000000

using namespace std;

int Search(int n, vector<int> &p, int l, int r) {
	if (l == r) {
		if (p[l] == MAX)
			r++;
		p[l] = min(p[l], n);
		return r;
	}
	int pos = (l + r) >> 1;
	if (p[pos] <= n)
		return Search(n, p, pos + 1, r);
	else
		return Search(n, p, l, pos);
}

int main(void) {
	int num, i, size = 0;
	cin >> num;
	vector<int> d(num), t(num, true), p(num, MAX);
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	for (i = num - 1; i >= 0; i--) {
		size = max(size, Search(d[i], p, 0, size));
	}
	printf("%d\n", size);
	return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;

int main(void)
{
    IOS
    const int M=5;
    vector<int> v(M);
    REP(M) cin >> v[i];

    int m = 10;
    int last = -1;
    REP(M) {
        if (m > (v[i]-1) % 10) {
            m = v[i] % 10;
            last = i;
        }
    }

    int ans = 0;
    REP(M) {
        if (i == last) continue;
        ans += (v[i] + 9) / 10 * 10;
    }
    ans += v[last];
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import random
import numpy as np
random.seed(42)
TYPE_NUM = 26

def resolve():

    inp = sys.stdin.readlines()
    D = int(inp[0])
    c = np.array(list(map(int, inp[1].split(' '))))
    s = []
    last = np.zeros(TYPE_NUM, dtype=int)
    types = []

    for i in range(2, len(inp)):
        s.append(list(map(int, inp[i].split(' '))))
    s = np.array(s, dtype=int)

    for d in range(D):
        temp_delta_satis = np.zeros([TYPE_NUM, TYPE_NUM, TYPE_NUM], dtype=int)
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis[:, :, idx] = np.sum(-c*(d+1-last)) + val
            if D > d+1:
                for idx2 in range(TYPE_NUM):
                    rand = random.random()
                    if rand > 0.7:
                        val2 = s[d+1, idx2]
                        org2 = last[idx2]
                        last[idx2] = d+2
                        temp_delta_satis[idx2, idx] += np.sum(-c*(d+2-last)) + val2
                        last[idx2] = org2
                    else:
                        temp_delta_satis[idx2, idx] = -10 ** 16
                        continue
                if D > d+2:
                    for idx3 in range(TYPE_NUM):
                        rand = random.random()
                        if rand > 0.7:
                            val3 = s[d+2, idx3]
                            org3 = last[idx3]
                            last[idx3] = d+3
                            temp_delta_satis[idx3, idx2, idx] += np.sum(-c*(d+3-last)) + val3
                            last[idx3] = org3
                        else:
                            temp_delta_satis[idx3, idx2, idx] = -10 ** 16
            last[idx] = org
        opt_idx = np.unravel_index(np.argmax(temp_delta_satis), temp_delta_satis.shape)[2]
        types.append(opt_idx+1)
    print(*types, sep='\n')

resolve()

Measured memory_bytes: 27192
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int MAXN=505;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int mods,n;
PR a[MAXN];
int f[MAXN][MAXN];
int upd(int x,int y) { return x+y>=mods?x+y-mods:x+y; }
int main()
{
	n=read(),mods=read();
	for (int i=0;i<n<<1;i++)
	{
		int y=floor(sqrt(n*n*4-i*i))+1;
		upmin(y,n<<1);
		if (i<n) 
		{
			int x=floor(sqrt(n*n-i*i));
			if (x*x+i*i!=n*n) x++;
			a[i]=MP(x,y);
		}
		else a[i]=MP(y,0);
//		cout<<a[i].fi<<" "<<a[i].se<<endl;
	}
	
	sort(a,a+n*2);
	int ans=0;
	for (int k=0;k<=n;k++)
	{
		memset(f,0,sizeof f); f[0][0]=1;
		int cnt1=0,cnt2=0;
		for (int i=0;i<n<<1;i++)
		{
			for (int j=0;j<=k;j++)
				if (!a[i].se) f[i+1][j]=upd(f[i+1][j],1ll*f[i][j]*(a[i].fi-cnt1-j)%mods);
				else
				{
					if (j<k) f[i+1][j+1]=upd(f[i+1][j+1],1ll*f[i][j]*(a[i].fi-cnt1-j)%mods);
					f[i+1][j]=upd(f[i+1][j],1ll*f[i][j]*(a[i].se-n-k-cnt2+j)%mods);
				}
			if (!a[i].se) cnt1++;
			else cnt2++;
		}
//		cout<<ans<<endl;
		if (k&1) ans=upd(ans,mods-f[n<<1][k]);
		else ans=upd(ans,f[n<<1][k]);
	}
	printf("%d\n",ans);
	return 0;
}

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

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


int arr[405];
ll int dp[405][405];
ll int psum[405];

ll int kil(int s, int l)
{
  if(s == l)
  {
    return 0;
  }

  if(dp[s][l] != -1)
    return dp[s][l];

  dp[s][l] = 1e15;
  for(int i=s;i<l;i++)
  {
    dp[s][l] = min(dp[s][l], kil(s, i) + kil(i+1, l));
  }
  dp[s][l] += psum[l] - psum[s-1];

  return dp[s][l];
}

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

  memset(dp, -1, sizeof dp);
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];
    psum[i] = psum[i-1] + arr[i];
  }
  cout<<kil(1, n)<<endl;

  return 0;
}


Measured memory_bytes: 1536