akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
vector<ll> fact;
vector<ll> ifact;
ll add(ll a,ll b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
ll mult(ll a,ll b)
{
	return (a*1LL*b)%MOD;
}
ll binpow(ll a, ll b)
{
	ll r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
ll choose(ll a, ll b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	ll r = mult(ifact[b],ifact[a-b]);
	r = mult(r,fact[a]);
	return r;
}
ll inv(ll a){return binpow(a,MOD-2);}
void init(ll n)
{
	fact.clear(); ifact.clear();
	fact.resize(n+1);
	ifact.resize(n+1);
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=n;i++){fact[i]=mult(fact[i-1],i);}
	ifact[n] = inv(fact[n]);
	for(int i=n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
}
ll rchoose(ll n,ll r){
	ll res = 1;
	for(int i=0;i<r;i++)res = mult(res,n-i);
	return res;
}
int main()
{
  ll k;
  string s;
  cin>>k>>s;
  ll n = s.length();
  init(n+1+k);
  ll ans = 0;
  for(ll i=0;i<=k;i++)
  {
	  ll r = choose(n+k,i+n);
	  r = mult(r,binpow(25,k-i));
	  ans = add(ans,r);
  }
  cout<<ans;

}

Measured memory_bytes: 35648
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		while(true){

			//1??????????????????
			String s = sc.nextLine();

			if(s.equals("0")){
				break;
			}


			char [] cha = s.toCharArray();
			int sum = 0;

			for(int i = 0; i < cha.length; i++){
				//System.out.println(cha[i]);
				sum += Character.getNumericValue(cha[i]);
			}

			System.out.println(sum);
		}
		sc.close();
	}
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y==NIL)root=z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;
  
}

void inorder(Node u){
if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
 if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25152
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
ll n;
ll T[N], A[N];
ll lot[N], hit[N], loa[N], hia[N];
ll overlap(ll l1, ll h1, ll l2, ll h2){
	if (l1 > h2 || l2 > h1)return 0;
	return min(h1, h2) + 1 - max(l1, l2);
}
int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> T[i];
		if (i == 0 || T[i] > T[i - 1]){
			lot[i] = hit[i] = T[i];
		}
		else {
			lot[i] = 1;
			hit[i] = T[i];
		}
	}
	for (int i = 0; i < n; i++){
		cin >> A[i];
	}
	for (int i = n - 1; i >= 0; i--){
		if (i == n - 1 || A[i] > A[i + 1]){
			loa[i] = hia[i] = A[i];
		}
		else {
			loa[i] = 1;
			hia[i] = A[i];
		}
	}
	int ret=1;
	for (int i = 0; i < n; i++){
		ret = (ret*overlap(lot[i], hit[i], loa[i], hia[i]))%MOD;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4992
def main():
  def update(k,x):
    k+=N0-1
    data_min[k]=data_max[k]=x
    while k>=0:
      k=(k-1)//2
      a,b=data_min[2*k+1],data_min[2*k+2]
      data_min[k]=a if a<b else b
      a,b=data_max[2*k+1],data_max[2*k+2]
      data_max[k]=a if a>b else b
  def query_min(l,r):
    L,R=l+N0,r+N0
    s=INF
    while L<R:
      if R&1:
        R-=1
        t=data_min[R-1]
        if t<s:s=t
      if L&1:
        t=data_min[L-1]
        if t<s:s=t
        L+=1
      L//=2
      R//=2
    return s
  def query_max(l,r):
    L,R=l+N0,r+N0
    s=0
    while L<R:
      if R&1:
        R-=1
        t=data_max[R-1]
        if t>s:s=t
      if L&1:
        t=data_max[L-1]
        if t>s:s=t
        L+=1
      L//=2
      R//=2
    return s
  n,k,*p=map(int,open(0).read().split())
  N0=2**(n-1).bit_length()
  INF=10**18
  data_min=[INF]*2*N0
  data_max=[0]*2*N0
  c=[0]
  for a,b in zip(p,p[1:]):c+=c[-1]+(a<b),
  *c,f=[b-a==k-1for a,b in zip(c,c[k-1:])]
  x=not f
  for i,q in enumerate(p):update(i,q)
  for i,(a,b,c)in enumerate(zip(p,p[k:],c)):
    f|=c
    if not c and(a!=query_min(i,i+k)or b!=query_max(i+1,i+k+1)):x+=1
  print(x+f)
main()

Measured memory_bytes: 101692
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#define mp make_pair
#define lli long long int
#define modi 1000000007
#define pb push_back
using namespace std;
int main(){
int a,b;
cin>>a;
cin>>b;
lli total=0;
if(a>b){
    total=total+a;
    if(a-1>b){
        total=total+a-1;
    }
    else total=total+b;
}
else{
    total=total+b;
    if(b-1>a){
        total=total+b-1;
    }
    else total=total+a;
}
cout<<total<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (k, n) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val distances = readLine()?.split(" ")?.map(String::toInt) ?: return
    // 各家の距離で一番離れている場所からスタートする
    val max = distances.mapIndexed { i, distance ->
        if (i == 0) {
            distance + (k - distances.last())
        } else {
            distance -  distances[i-1]
        }
    }.max()!!
    println(k - max)
}

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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [[usize1]; k]
    }
    let mut cs = vec![0; n];
    for l in &v {
        for &x in l {
            cs[x] += 1;
        }
    }
    println!("{}", cs.iter().filter(|&&x| x == 0).count());
}


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

using namespace std;

int solve(int n, int m, int d[], int c[]) {
    int prev[m + 1], cur[m + 1];
    for (int mi = 0; mi <= m; ++mi) {
        cur[mi] = 0;
    }
    for (int ni = 0; ni < n; ++ni) {
        for (int mi = 0; mi <= m; ++mi) {
            prev[mi] = cur[mi];
            cur[mi] = -1;
        }
        for (int mi = 1; mi <= m; ++mi) {
            cur[mi] = cur[mi - 1];
            if (prev[mi - 1] >= 0) {
                int t = prev[mi - 1] + d[ni] * c[mi - 1];
                if (cur[mi] < 0) {
                    cur[mi] = t;
                } else {
                    cur[mi] = min(cur[mi], t);
                }
            }
        }
    }
    return cur[m];
}

int main() {
    int n, m;
    int d[1000], c[1000];
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> c[i];
    }
    cout << solve(n, m, d, c) << endl;
    return 0;
}

Measured memory_bytes: 1172
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
  int N;
  cin >> N;
  vector<ll> A(N+1);
  rep(i,N+1) cin >> A[i];
  vector<ll> B(N);
  rep(i,N) cin >> B[i];
  
  ll ans = 0;
  rep(i,N){
    int left = min(B[i],A[i]);
    ans += left;
    B[i] -= left;
    A[i] -= left;
    int right = min(B[i],A[i+1]);
    ans += right;
    B[i] -= right;
    A[i+1] -= right;
  }
  cout << ans << endl;
  return;     
}

int main()
{
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
}


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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //





// --------- library end - //


int main(){

  string s = is();
  ll len = SZ(s);

  rep(i, len-1){
    if (s[i] == s[i+1]){
      cout << i + 1 << " " << i + 2 << endk;
      return 0;
    }
  }

  rep(i, len-2){
    if (s[i] == s[i+2]){
      cout << i + 1 << " " << i + 3 << endk;
      return 0;
    }
  }

  cout << "-1 -1" << endk;


}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],arr1[1000000];
pair <long long, long long > p[1000000],p1[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k,x,y,z;
    cin>>n;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i]>>arr1[i];
    	p[i].first=arr[i];
    	p[i].second=arr1[i];
     	p1[i].first=arr1[i];
    	p1[i].second=arr[i];  	
	}
	sort(arr,arr+n);
	sort(arr1,arr1+n);
	sort(p,p+n);
	sort (p1,p1+n);
	if (n%2==1)
	{
		cout<<arr1[n/2]-arr[n/2]+1<<endl;;
	}
	else
	{
		cout<<arr1[n/2]+arr1[n/2-1]-arr[n/2]-arr[n/2-1]+1<<endl;
	}
}

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

using namespace std;
long long a[3005],ans;
int main()
{
	long long n;
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>a[i];
		ans+=a[i]-1;
	}
	cout<<ans;
	return 0;
}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
void solve(void)
{

  int n; cin>>n;
  string str;cin>>str;
  int cnt = 0;
  int flg = 0;
  for (int i = n-1; i >= 0; i--) 
  {
    if(str[i] =='R') cnt++;
  }
  int res = 0;
  for (int i = 0; i < cnt; i++)
  {
    if(str[i] =='W')res++;
  }
  cout<<res<<endl;
  
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            final int n = Integer.parseInt(br.readLine());
            if (n == 0) { break; }
            
            Map<String, Long> data = new LinkedHashMap<>();
            for (int i=1; i <= n; i++) {
                String[] e = br.readLine().split(" ");
                data.merge(e[0], Long.parseLong(e[1]) * Long.parseLong(e[2]), Long::sum);
            }
            
            long count = data.entrySet().stream()
                .filter(e -> e.getValue() >= 1_000_000L)
                .peek(e -> System.out.println(e.getKey()))
                .count();
            if (count == 0L) { System.out.println("NA"); }
        }
    }
}

Measured memory_bytes: 31776
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,D;
int X[10][10];

int main(){
    cin>>N>>D;
    rep(i,N) rep(j,D) cin>>X[i][j];

    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int sum=0;
            rep(k,D){
                sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            int d1=sqrt(sum);
            double d2=sqrt(sum);

            if(d1==d2) ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	int n ; 
	cin>>n ;
	vector<int>v(n) ; 
	rep( i , n) cin>>v[i] ;
	sort(v.begin() , v.end()) ;
	bool ok  = true ;
	repu(i , 1 , n-1){
		ok &= (v[i]!=v[i-1]) ;
	}
	if(ok){
		cout<<"YES\n" ;
	}
	else{
		cout<<"NO\n" ;
	}
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 1024
#include<stdio.h>
#define N 10000



int main(){
  int S[N];
  int n,T,i,q,result;
  int sum = 0;

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

  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T);
    result = search(S, n, T);
    if(result != -1){
      sum++;
    }
  }

  printf("%d\n",sum);

  return 0;
  
}

  int search(int S[], int n, int key){
  int i = 0;
  S[n] = key;
  while(S[i] != key){
  i++;
}
  if(i >= n){
  return -1;
}
  return i;
}



Measured memory_bytes: 2048
t[7][7]={
{0,0,0,0,0,0,0},
{0,0,3,5,2,4,0},
{0,4,0,1,6,0,3},
{0,2,6,0,0,1,5},
{0,5,1,0,0,6,2},
{0,3,0,6,1,0,4},
{0,0,4,2,5,3,0}
},i,N[7],n,a,b;
h(p){
int i;
for(i=0;p!=N[++i];);
    return i;
}
main(){
    for(i=1;i<7;scanf("%d",&N[i++]));
    for(scanf("%d",&n);scanf("%d%d",&a,&b),n--;)
        printf("%d\n",N[t[h(a)][h(b)]]);
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

#define MAX_V 1000

long long int INF = 10000000000000000LL;

using namespace std;

struct edge{
	long long int to, cap, rev; // 行き先、容量、逆辺
};

vector<edge> G[MAX_V] = {};
bool used[MAX_V];

// from から to へ向かう容量 cap の辺を張る
void add_edge(long long int from, long long int to, long long int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size() - 1}); // 有向辺
	// G[to].push_back((edge){from, cap, G[from].size() - 1}); // 無向辺
}

// 増加パスを dfs で探す
long long int dfs(int v, int t, long long int f){
	if(v == t){
		return f;
	}
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			long long int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// s から t への最大流を求める
long long int max_flow(int s, int t){
	long long int flow = 0;
	while(true){
		fill(used, used + MAX_V, 0);
		long long int f = dfs(s, t, INF);
		if(f == 0){
			return flow;
		}
		flow += f;
	}
}

int main(){
	
	int N;
	cin >> N;
	
	long long int sum = 0;
	
	for(int i = 1; i <= N; i++){
		long long int a;
		cin >> a;
		if(a > 0){
			add_edge(i, N + 1, a);
			sum += a;
		}else{
			add_edge(0, i, -a);
		}
	}
	
	for(int i = 1; i <= N; i++){
		for(int j = 2; j <= N; j++){
			if(i * j > N){
				break;
			}
			add_edge(i, i * j, INF);
		}
	}
	
	cout << sum - max_flow(0, N + 1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dijkstra(s):
        d = [float("inf")]*n
        p = [s]*n
        d[s] = 0
        q = [(0,s)]
        while q:
            dx,x = heappop(q)
            nd = dx+1
            for y in v[x]:
                if nd < d[y]:
                    d[y] = nd
                    p[y] = x
                    heappush(q,(nd,y))
        path = [[i] for i in range(n)]
        for i in range(1,n):
            pre = path[i][-1]
            while pre != s:
                path[i].append(p[pre])
                pre = path[i][-1]
            path[i] = path[i][::-1]
        return d,path

    n = I()
    v = [[] for i in range(n)]
    e = defaultdict(lambda : 0)
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
        e[(a,b)] = i
        e[(b,a)] = i
    d = [[0]*n for i in range(n)]
    path = [[None]*n for i in range(n)]
    for i in range(n):
        D,p = dijkstra(i)
        d[i] = [j for j in D]
        path[i] = [j for j in p]
    m = I()
    l = LIR(m)
    for i in range(m):
        l[i][0] -= 1
        l[i][1] -= 1
    ans = 0
    B = [0]*m
    for j in range(m):
        x,y = l[j]
        for k in range(len(path[x][y])-1):
            a,b = path[x][y][k],path[x][y][k+1]
            B[j] |= 1<<e[(a,b)]
    for b in range(1,1<<m):
        f = bin(b).count("1")
        p = 0
        for j in range(m):
            if b&(1<<j):
                p |= B[j]
        s = bin(p).count("1")
        f &= 1
        k = 1<<(n-s-1)
        if f:
            ans += k
        else:
            ans -= k
    print((1<<(n-1))-ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

long long n;
vector<long long> a;

int main() {
  cin >> n;
  a.resize(n);
  for (auto &p : a) cin >> p;
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    if (i != 0 && a[i] && a[i - 1]) {
      --a[i - 1];
      --a[i];
      ++res;
    }
    res += a[i] / 2;
    a[i] %= 2;
  }
  cout << res << endl;
  return 0;
}


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

typedef pair<vector<int>, bool> PVIB;

int main() {
	int N;
	while( cin >> N, N ) {
		vector<int>T( 3 );
		priority_queue<PVIB, vector<PVIB>, greater<PVIB>>que;
		for( size_t i = 0; i < N; i++ ) {
			for( int j = 1; j >= 0; j-- ) {
				char c;
				cin >> T[0] >> c >> T[1] >> c >> T[2];
				que.push( make_pair( T, j ) );
			}
		}
		int now = 0, ans = 0;
		while( que.size() ) {
			auto X = que.top(); que.pop();
			if( X.second ) {
				now++;
				ans = max( now, ans );
			} else {
				now--;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4480
N = gets.to_i
Ts = Array.new(N)
As = Array.new(N)
N.times do |i|
  Ts[i], As[i] = gets.split.map(&:to_i)
end

tz = az = 1
N.times do |i|
  tk = (tz + Ts[i] - 1) / Ts[i]
  ak = (az + As[i] - 1) / As[i]
  k = [tk, ak].max
  tz = Ts[i] * k
  az = As[i] * k
end

puts tz + az


Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

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

	vector<vector<int>> k(m);

	rep(i, m)
	{
		int num;
		cin >> num;

		k[i].resize(num);

		rep(j, num)
		{
			cin >> k[i][j];
			k[i][j]--;
		}
	}

	vector<int> p(m);
	rep(i, m) cin >> p[i];

	int ans = 0;

	rep(i, (1 << n))
	{
		bool ok = true;

		rep(j, m)
		{
			int on = 0;

			for (int id : k[j])
			{
				if ((i >> id) & 1) on++;
			}
			on %= 2;
			if (on != p[j]) ok = false;
		}
		if (ok) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created on 2020/07/05.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n;
    cin>>n;
    map<string, int>mp;
    for (int i = 0; i < n; ++i) {
        string status;
        cin>>status;
        mp[status] ++;
    }
    printf("%s %s %d\n","AC","x",mp["AC"]);
    printf("%s %s %d\n","WA","x",mp["WA"]);
    printf("%s %s %d\n","TLE","x",mp["TLE"]);
    printf("%s %s %d\n","RE","x",mp["RE"]);
    return 0;
}


Measured memory_bytes: 3732
#include <stdio.h>

void youbi(int x)
{
	if(x%7==0) printf("Thursday\n");
	else if(x%7==1) printf("Friday\n");
	else if(x%7==2) printf("Saturday\n");
	else if(x%7==3) printf("Sunday\n");
	else if(x%7==4) printf("Monday\n");
	else if(x%7==5) printf("Tuesday\n");
	else printf("Wednesday\n");
	
}

int main(void)
{
	int d[366];
	int i;
	
	for(i=0; i<366; i++)
		d[i]=i%7;
	
	for(; ; ) {
		int month, day;
		
		scanf("%d %d", &month, &day);
		if(month==0) break;
		switch(month) {
			case 1: youbi(d[day-1]); break;
			case 2: youbi(d[day+30]); break;
			case 3: youbi(d[day+59]); break;
			case 4: youbi(d[day+90]); break;
			case 5: youbi(d[day+120]); break;
			case 6: youbi(d[day+151]); break;
			case 7: youbi(d[day+181]); break;
			case 8: youbi(d[day+212]); break;
			case 9: youbi(d[day+243]); break;
			case 10: youbi(d[day+273]); break;
			case 11: youbi(d[day+304]); break;
			case 12: youbi(d[day+334]); break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 580
#include<iostream>
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl prinf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)

#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair

// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }

#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

ll gcd(ll a,ll b){ return ((b==0)? a:gcd(b,a%b) ); }

int main()
{
    SYNC
    string s;
    cin>>s;
    s[3] = '8';
    cout<<s<<endl;
}


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

for i,csf in enumerate(CSF):
    c,s,f=csf[0],csf[1],csf[2]
    ans=c+s
    for j in range(i+1,N-1):
        csf_=CSF[j]
        c_,s_,f_=csf_[0],csf_[1],csf_[2]
        if ans<s_:
            ans=s_
        elif ans%f_!=0:
            ans=ans+f_-ans%f_
        ans+=c_
    print(ans)
print(0)

Measured memory_bytes: 3188
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();

    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 5028
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

struct grid{
    
    struct data{
        lli x,y,p;
    };
    
    vector<string> maze;
    
    grid(lli h,lli w){
        lli i;
        string s;
        maze.push_back(string(w+2,'#'));
        rep(i,0,h){
            cin>>s;
            maze.push_back('#'+s+'#');
        }
        maze.push_back(string(w+2,'#'));
    }
    
    void print(){
        lli i;
        rep(i,0,maze.size()){
            cout<<maze[i]<<endl;
        }
    }
    
    lli clear(lli h,lli w){
        lli i,j,point=0;
        data dat;
        queue<data> que;
        vector<string> check;
        check=maze;
        que.push({1,1,0});
        while(que.size()!=0){
            dat=que.front();
            if(dat.y==h&&dat.x==w){
                point=dat.p;
                break;
            }
            else{
                rep(i,-1,2){
                    rep(j,-1,2){
                        if(abs(i+j)==1){
                            if(check[dat.y+i][dat.x+j]=='.'){
                                que.push({dat.x+j,dat.y+i,dat.p+1});
                                check[dat.y+i][dat.x+j]='#';
//                                cout<<"・"<<dat.p+1<<"回目の移動で座標"<<dat.x+j<<","<<dat.y+i<<"に行ける"<<endl;
                            }
                        }
                    }
                }
                check[dat.y][dat.x]='#';
                que.pop();
            }
        }
        return point;
    }
    
    void count(lli h,lli w){
        lli i,j,cnt=0,ans;
        ans=clear(h,w);
//        cout<<"よってゴールには最短"<<ans<<"回でたどり着ける"<<endl;
        if(ans!=0){
            rep(i,1,h+1){
                rep(j,1,w+1){
                    if(maze[i][j]=='.'){
                        cnt++;
                    }
                }
            }
            cout<<cnt-1-ans<<endl;
        }
        else{
            cout<<"-1"<<endl;
        }
    }
    
};

int main() {
    lli h,w;
    lli i,j,k;
    cin>>h>>w;
    grid mazer(h,w);
//    mazer.print();
    mazer.count(h,w);
}


Measured memory_bytes: 256
ls = list(map(int,input().split()))
if ls[1] != ls[2] and ls[2] == ls[0]:
  print(ls[1])
if ls[0] != ls[1] and ls[1] == ls[2]:
  print(ls[0])
if ls[2] != ls[1] and ls[1] == ls[0]:
  print(ls[2])

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
import copy

def pl2(L):
    for l in L:
        print(l)

def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
    c2 = []
    while True:
        is_updated = False 
        c2 =  copy.deepcopy(c)
        for i in range(10):
            for j in range(10):
                if i != j:
                    for k in range(10):
                        if c2[i][j] > c[i][k]+c[k][j]:
                            c2[i][j] = c[i][k]+c[k][j]
                            is_updated = True
        if not is_updated:
            break
        else:
            c = copy.deepcopy(c2)

    res = 0
    for a in A:
        for c in a:
            if abs(c) != 1:
                res += c2[c][1]

    print(res)







# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [ [ int(next(tokens)) for _ in range(9-0+1) ] for _ in range(9-0+1) ]  # type: "List[List[int]]"
    A = [ [ int(next(tokens)) for _ in range(W) ] for _ in range(H) ]  # type: "List[List[int]]"
    solve(H, W, c, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3784
nm = list(map(int, input().split()))
mod = 10 ** 9 + 7
def fact(a):
  ret = 1
  while a > 0:
    ret = ret * a % mod
    a -= 1
  return ret

nm.sort()
if nm[1] - nm[0] > 1:
  print(0)
elif nm[1] - nm[0] == 1:
  print(fact(nm[1]) * fact(nm[0]) % mod)
else:
  print(2* fact(nm[1]) * fact(nm[0]) % mod)

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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

using namespace std;

void solve(ll N, ll K, vector<ll> h) {
    sort(h.begin(), h.end());
    ll ans = 1e18;
    for (int i = 0; i + K <= N; i++) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll N;
    ll K;
    cin >> N;
    vector<ll> h(N - 1 + 1);
    cin >> K;
    for (int i = 0; i <= N - 1; i++) {
        cin >> h[i];
    }
    solve(N, K, h);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 1792
# Problem A - Can you get AC?

# input process
S = input()

# initialization
is_ok = False

# count process
for i in range(len(S)-1):
    if S[i]=='A' and S[i+1]=='C':
        is_ok = True
        break

if is_ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
import java.lang.reflect.Array;
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.println(a*b);
    }
}


Measured memory_bytes: 35552
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int _gcd(int m, int n){
    int a = max(m, n);
    int b = min(m, n);

    while(b != 1 && b != 0){
        a %= b;
        swap(a, b);
    }
    return b == 1 ? 1 : a;
}

int main(void){
    ll A, B, C, D;
    ll answer;

    cin >> A >> B >> C >> D;
    answer = B - A + 1;
    ll k = _gcd(C, D);
    ll c, d;
    c = C / k;
    d = D / k;

    ll cnt_A;
    ll cnt_B;

    cnt_A = (A - 1) / (c * d * k) * (d + c - 1);
    cnt_B = B / (c * d * k) * (d + c - 1);

    ll res_A = (A - 1) % (c * d * k);
    ll res_B = B % (c * d * k);

    res_A = res_A / (c * k) + res_A / (d * k);
    res_B = res_B / (c * k) + res_B / (d * k);
    
    ll div = (cnt_B + res_B) - (cnt_A + res_A);
    answer -= div;

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ll arr[n];
  ll acc[n];
  fi(0, n) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  acc[0] = arr[0];
  fi(1, n) {
    acc[i] = acc[i - 1] + arr[i];
  }
  // fi(0, n)
  //   cout << arr[i] << " ";
  // cout << endl;
  // fi(0, n)
  //   cout << acc[i] << " ";
  // cout << endl;

  for(int i = n - 2; i >= 0; i--) {
    if(acc[i] * 2 < arr[i + 1]) {
      cout << n - i - 1 << endl;
      return 0;
    }
  }
  cout << n << endl;
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

int main(){
	int tt, tk, at, ak, f;
	f=0;
	
	scanf("%d %d %d %d", &tt, &tk, &at, &ak);
	
	while(1){
		at=at-tk;
		if(at<=0){
			f=1;
			break;
		}
		tt=tt-ak;
		if(tt<=0){
			break;
		}
	}
	
	if(f==0){
		printf("No");
	}else{
		printf("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 1732
n   = gets.to_i
sum = 0
ary = []

n.times do
  ary << gets.to_i
  sum += ary[-1]
end

ary.sort!

if sum % 10 == 0
  i = 0
  while ary[i] % 10 == 0
    if i >= n - 1
      puts 0
      exit
    else
      i += 1
    end
  end
  puts sum - ary[i]
else
  puts sum
end


Measured memory_bytes: 1788
<?php

$n = trim(fgets(STDIN));
$MOD = 1000000000+7;

$acgt = ["A", "C", "G", "T"];
foreach($acgt as $c1){
    foreach($acgt as $c2){
        foreach($acgt as $c3){
            $map[3][$c1. $c2. $c3] = in_array($c1. $c2. $c3, ['AGC','ACG','GAC']) ? 0 : 1;
        }
    }
}
for($i = 4; $i <= $n; $i++){
    foreach($acgt as $c1){
        foreach($acgt as $c2){
            foreach($acgt as $c3){
                $map[$i][$c1. $c2. $c3] = 0;
                foreach($acgt as $c){
                    if(in_array($c1. $c2. $c3, ['AGC','ACG','GAC'])){
                    }elseif($c == "A" && $c1 == "G" && $c3 == "C"){
                    }elseif($c == "A" && $c2 == "G" && $c3 == "C"){
                    }else{
                        $map[$i][$c1. $c2. $c3] += $map[$i - 1][$c.$c1. $c2];
                        $map[$i][$c1. $c2. $c3] = $map[$i][$c1. $c2. $c3] % $MOD;
                    }
                }
            }
        }
    }
}
echo array_sum($map[$n]) % $MOD;

Measured memory_bytes: 4604
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: u8 = sc.input();
    let ans: String = sc.input::<String>().chars()
        .map(|ch: char| ((ch as u8 - 'A' as u8 + n) % 26 + 'A' as u8) as char).collect();
    println!("{}", ans)
}


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

#define mod 1000000007
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N = 3e6 + 5;
using namespace std;

long long dp[N][24];


long long dp_func(vector<vector<int>>&v, int i, int m, int &n)
{
	if(i==n)
	return 1;
	
	if(dp[m][i]!=-1)
	return dp[m][i];
	
	long long ans=0;
	for(int j=0;j<n;j++)
	{
		
		if(v[i][j]==1 && (m&(1<<j))==0 )
			ans = (ans + dp_func(v, i+1, m|(1<<j), n) ) % mod;
			
	}
	return dp[m][i] = ans;
}

int main()
{
	
	fast_io;
	int n;
  	//bool x;
	cin>>n;
	vector<vector<int>>v(n,vector<int>(n,0));
	memset(dp, -1, sizeof dp);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>v[i][j];
		}
	}
	
	cout<<dp_func(v,0,0,n);
	
}



Measured memory_bytes: 566148
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        
        if(a == b && c == d || a == c && b == d || a == d && b == c){
        System.out.println("yes");
        }else{
    System.out.println("no");

    }

}
}



Measured memory_bytes: 26328
#include <cstdio>

int a[10];


int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    bool ans = true;
    for (int i = 0; i < 10; ++i) {
      scanf("%d", &a[i]);
    }
    int l, r;
    l = r = 0;
    for (int i = 0; i < 10; ++i) {
      if (a[i] > l) {
        l = a[i];
      } else if (a[i] > r) {
        r = a[i];
      } else {
        ans = false;
        break;
      }
    }
    printf("%s\n", ans ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(false);
    ll a,b;
	cin>>a>>b;
	if (a%b==0)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	else if (b%a==0)
	{
		cout<<a<<endl;
	}
	else
	{
		cout<<a*(b-1)<<endl;
	}
    return 0;
}

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

int main(){
    // 変数を準備
    int n;
    cin >> n;     
    int R[n];
    for(int i = 0; i < n; i++){
        cin >> R[i];
    }
    
    int minv = R[0];
    int maxv = R[1] - minv;
    for(int i = 1; i < n; i++){
        if(R[i] - minv > maxv){
            maxv = R[i] - minv;
        }
        if(R[i] < minv){
            minv = R[i];
        }
    }
    
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>

using namespace std;

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("input.in", "r", stdin);
	int n; cin >> n;
	cout << n/3 << "\n";
}






Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        //購入商品N個
		int N = sc.nextInt();
		int maxP =0;
		int sum = 0;
		for(int i=0; i<N; i++) {
			int P = sc.nextInt();
			//Pを合計する
			sum +=P;;
			//Pの最大値を出す
			maxP = Math.max(maxP, P);
		}
           //最大値を半額にする
		  int halfMaxP=maxP/2;
      	  //合計値から最大値を引いて、最大の半額分を足す
		  System.out.println((sum-maxP)+halfMaxP);
	}
}

Measured memory_bytes: 21844