akhauriyash/Code-Regression huggingface dataset:
def ReadMap(n, m):
  Map = [0] * m
  for i in range(m):
    a = raw_input()
    b = map(int,list(a.replace('.','0').replace('#','1').replace('&','2')))
    if a.count('&')>0:
      j = a.index('&')
      PosCas = [j, i]
      b[j] = 0
    Map[i] = b
  return Map, PosCas

def fill(SP, c1, c2):
  for x, y in SP:
    try:
      if Map[y][x]!=c1:continue
    except: continue
    if x in [0, n-1] or y in [0, m-1]: return 1
    Map[y][x] = c2
    SP += ([[x+1, y] , [x-1, y], [x, y+1], [x, y-1]])
  return 0

while 1:
  n, m = map(int, raw_input().split())
  if n == m == 0: break
  Map, PosCas = ReadMap(n, m)
  c = 0
  while 1:
    SP = [PosCas]
    if fill(SP, 0, 1): break
    c += 1
    if fill(SP, 1, 0): break
  print c

Measured memory_bytes: 12560
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  const pn = input[1].split(' ').map((n) => {
    return parseFloat(n);
  });
 console.log(dp(N,pn));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function dp(N,pn) {
  const dp = Array(N).fill(0).map( n =>Array(N+1).fill(0));
  dp[0][0] = pn[0];
  dp[0][1] = (1 - pn[0]);
  for (var i = 0; i < (N - 1); i++) {
    for (var j = 0; j < N; j++) {
      dp[i+1][j] += dp[i][j] * pn[i + 1];
      dp[i+1][j + 1] += dp[i][j] * (1 - pn[i + 1]);
    }
  }
  let key = Math.floor(N/2);
  let ans = 0;
  for (var k = 0; k <= key; k++) {
    ans += dp[N - 1][k];
  }
  return ans;
}


Measured memory_bytes: 197496
import java.util.*;
import java.io.*;
 
public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.input();
    }
 
    public void input(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int half = n / 2;
        ArrayList<Integer> numList = new ArrayList<Integer>();
        for(int i = 0; i < n; i++){
            int x = sc.nextInt();
            numList.add(x);
        }
        sc.close();
        ArrayList<Integer> nowList = (ArrayList<Integer>) numList.clone();
        Collections.sort(nowList);
        int minhalf = nowList.get((n / 2) - 1);
        int maxhalf = nowList.get(n / 2);
        for(int i = 0; i < numList.size(); i++){
            int now = numList.get(i);
            if(now < maxhalf){
                System.out.println(maxhalf);
            }else{
                System.out.println(minhalf);
            }
            
        }
        
    }

}

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

int main() {
    int N;
    cin >> N;
    int A1[N], A2[N];
    for (int i=0; i<N; ++i) cin >> A1[i];
    for (int i=0; i<N; ++i) cin >> A2[i];

    int s1[N+1], s2[N+1];
    s1[0] = 0;
    s2[0] = 0;
    for (int i=1; i<=N; ++i) {
        s1[i] = s1[i-1] + A1[i-1];
        s2[i] = s2[i-1] + A2[i-1];
    }
    int ans = 0;
    for (int i=1; i<=N; ++i) {
        int cand = s1[i] + (s2[N] - s2[i-1]);
        if (cand > ans) ans = cand;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int n,sum = 0;
  cin>>n;
  int v[n],c[n];
  for(int i = 0; i < n; i++) cin>>v[i];
  for(int i = 0; i < n; i++) cin>>c[i];
  
  for(int i = 0; i < n; i++) {
    if(v[i] > c[i]) sum += v[i] - c[i];
  }
  
  cout<<sum<<"\n";
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;

vector<ll> dp(1000,0);

vary(int,v,0,0);
int solve(int n){
  rep(i,1000){
    dp[i] = 0;
  }
  dp[1] = 1;
  REP(i,1,18){
    REP(j,1,400){
      if(j - v[i]>= 0)
        dp[j] += dp[j-v[i]];
    }
  }
  return dp[n+1];
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  v.clear();
  REP(i,0,18){
    v.pb(i*i);
  }
  int n;
  while(cin >> n&&n){
    cout << solve(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
n = int(input())
lst_n = list(map(int,input().split()))
x = lst_n[n-1]
left  = []
right = []
i = -1
for j in range(0,n-1):
    if lst_n[j] <= x:
        i += 1
        lst_n[i],lst_n[j] = lst_n[j],lst_n[i]
i += 1
lst_n[i],lst_n[n-1] = lst_n[n-1],lst_n[i]

ans = ['['+str(lst_n[k])+']' if k == i else str(lst_n[k])
        for k in range(len(lst_n))]
print(' '.join(ans))


Measured memory_bytes: 16592
def btc_to_jpy btc
  return btc * 380000
end
n = gets.chomp.to_i
sum = 0
n.times do
  val = gets.chomp.split(' ')
  if val[1] == 'JPY'
    sum += val[0].to_f
  else
    sum += btc_to_jpy(val[0].to_f)
  end
end

puts sum

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,k[10],s[10][10],p[10],A[10],ans=0;
  cin>>n>>m;
  rep(i,m){
    cin>>k[i];
    rep(j,k[i]) cin>>s[i][j];
  }
  rep(i,m) cin>>p[i];
  rep(i,pow(2,n)){
    int x=i,y=0;
    rep(j,n) A[j+1]=x%2,x=x/2;
    rep(j,m){
      int z=0;
      rep(K,n){
        rep(l,k[j]) if(A[K+1]&&s[j][l]==K+1) z++;
      }
      if(z%2==p[j]) y++;
    }
    if(y==m) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 512
///Comentary AC

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

using namespace std;
int main(){
    int N; cin >> N;
    string S; cin >> S;
    int ans=0;

    for (int i=1;i<N;i++){
        int cnt=0;

        for (char c='a';c<='z';c++){
            bool left=false,right=false;

            for (int j=0;j<i;j++){
                if (S[j]==c) left=true;
            }

            for (int j=i;j<N;j++){
                if (S[j]==c) right=true;
            }
            
            if (left&&right) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

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

signed main(void){
  int N; cin >> N;
  vector<int> A(N); set<int> se;
  for(int i = 0; i < N; i++){ cin >> A[i];}
  for(int bit = 0; bit < (1<<N); bit++){
    int sum = 0;
    for(int i = 0; i < N; i++){ 
      if( bit >> i & 1 ){ sum += A[i];}
    }
    se.insert(sum);
  }
  int q; cin >> q;
  while(q--){
    int m; cin >> m;
    if( se.find(m) != se.end() ){ cout << "yes" << endl;}
    else{ cout << "no" << endl;}
  }
  
  return 0;
}


Measured memory_bytes: 3136
require "set"

N = gets.chomp.to_i

a = [[]]
N.times { a << gets.chomp.split(" ").map(&:to_i) }

search_list = Set.new([*(1..N)])


days = 0
until search_list.empty?
  next_search_list = Set.new

  search_list.each do |n|
    next if a[n].empty?
    pair = a[n][0]
    next if a[pair].empty? || a[pair][0] != n
    next_search_list << n
    next_search_list << pair
  end
  next_search_list.each do |i|
    a[i].shift
  end

  days += 1
  search_list = next_search_list
end

if a.all?(&:empty?)
  puts days - 1
else
  puts "-1"
end

Measured memory_bytes: 65276
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n,m;cin >> n >>m;
    ll dp[m+1][(1<<n)];
    rep(i,m+1)rep(j,1<<n)dp[i][j]=INF;
    rep(i,m+1)dp[i][0]=0;
    vl v(m);vl key(m);
    rep(i,m){
        ll a,bit=0;
        cin >> v[i] >> a;
        rep(j,a){
            ll b;cin >> b;b--;
            bit+=(1<<b);
        }
        key[i]=bit;
    }
    rep(i,m){
        rep(bit,1<<n){
            chmin(dp[i+1][bit],dp[i][bit]);
            chmin(dp[i+1][bit|key[i]],dp[i][bit]+v[i]);
        }
    }
    if(dp[m][(1<<n)-1]==INF)cout << -1 <<endl;
    else cout <<dp[m][(1<<n)-1] <<endl;
}

Measured memory_bytes: 32256
#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++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    string ans="No";
    if(a+b==c||a+c==b||c+b==a){
        ans="Yes";
    }
    cout << ans<< endl;
    return 0;
}

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

int main()
{
    ll x,y;
    while(cin>>x>>y)
    {
        map<ll,ll>mp;
        mp[1]=300000;
        mp[2]=200000;
        mp[3]=100000;
        if(x==1 and y==1)
        {
            cout<<1000000<<endl;
        }
        else
        {
            ll ans=0;
           if(x<4)
           {
               ans+=mp[x];
           }
           if(y<4)
           {
               ans+=mp[y];
           }
           cout<<ans<<endl;
        }
        mp.clear();
    }

    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
@b = gets.split(' ').map(&:to_i)
@removed_values = []

def remove_max
	s = @b.size
	@b.each_with_index do |_, idx|
		t = s - idx
		if @b[t - 1] == t
			@removed_values << @b.delete_at(t - 1)
			return true
		end
	end
	return false
end

def check
	while @b.size > 0	
		return false unless remove_max
	end
	return true
end


if check
	@removed_values.reverse.each do |i|
		print i
		print "\n" if i != @b.size
	end
else
	print -1
end


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

int H, W;

int main() {
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 0; i < H; i++){
      for (int j = 0; j < W; j++) {
        if((i%2 == 0 && j%2 == 0) ||(i%2 == 1 && j%2 == 1)){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

// int main(){
//
//   int n;
//   cin >> n;
//
//   vector<int> t;
//   vector<int> x;
//   vector<int> y;
//
//   bool flag = true;
//
//   REP(i,n){
//     int t1,x1,y1;
//     cin >> t1 >> x1 >> y1;
//     t.push_back(t1);
//     x.push_back(x1);
//     y.push_back(y1);
//   }
//
//   int t_t,t_x,t_y;
//
//   REP(i,n){
//     if(t[i] >= x[i]+y[i]){
//       if(i==0){
//         if((x[i]+y[i])%2 == t[i]%2){
//           if(i<n-1){
//             t_t = t[i+1]-t[i];
//             t_x = abs(x[i+1]-x[i]);
//             t_y = abs(y[i+1]-y[i]);
//           }
//           continue;
//         } else {
//           flag = false;
//           break;
//         }
//       } else {
//         if((t_x+t_y)%2 == t_t%2){
//           if(i<n-1){
//             t_t = t[i+1]-t[i];
//             t_x = abs(x[i+1]-x[i]);
//             t_y = abs(y[i+1]-y[i]);
//           }
//           continue;
//         } else {
//           flag = false;
//           break;
//         }
//       }
//     } else {
//       flag = false;
//       break;
//     }
//   }
//
//   if(flag) cout << "Yes" << endl;
//   else cout << "No" << endl;
//
//   return 0;
// }

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main ()
{
    int n;
    cin>>n;
    vector<int> per(n);
    for(int i=0;i<n;i++)
    {
        cin>> per.at(i);
    }
    int ans=0;
    set<int> num;
    for(int i=0;i<n;i++)
    {
        num.insert(per.at(i));
        if(*begin(num)==per.at(i))
        ans+=1;
    }
    cout<<ans;
}

Measured memory_bytes: 10368
// Your code here!
    #include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
  ll n,ans=0;
  cin>>n;
  vll a(3*n);
  rep(i,3*n)cin>>a.at(i);
  sort(ALL(a));
  ll k=0;
  for(ll i=3*n-2;k<n;i-=2){
      ans+=a.at(i);
      k++;
  }
  cout<<ans<<endl;
}

   
    

   



Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){
 	int b[101]={},a,n,v=0;
 	std::cin>>n;
	while(n-->0){std::cin>>a;v+=std::max(1-b[a]++, 0);}
	std::cout <<v<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    int N; cin >> N;
    string S; cin >> S;
    const int mod = 1e9 + 7;

    int l = 0;

    ll ans = 1;

    rep(i, N*2) {
        if (S[i] == 'B') {
            if (l % 2 == 0) {
                l++;
            } else {
                ans *= l;
                ans %= mod;
                l--;
            }
        } else {
            if (l % 2 == 0) {
                ans *= l;
                ans %= mod;
                l--;
            } else {
                l++;
            }
        }
    }

    if (l > 0) {
        puts("0");
        return 0;
    }

    rep(i, N) {
        ans *= i + 1;
        ans %= mod;
    }

    cout << ans << endl;
}


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

int main() {
  priority_queue<uint64_t> q;
  uint64_t N, M;
  cin >> N >> M;
  for (uint64_t i = 0LL; i < N; i++) {
    uint64_t a;
    cin >> a;
    q.push(a);
  }
  for (uint64_t i = 0LL; i < M; i++) {
    uint64_t x = q.top() / 2LL;
    q.pop();
    q.push(x);
  }
  uint64_t cnt = 0LL;
  for (uint64_t i = 0LL; i < N; i++) {
    uint64_t x = q.top();
    cnt += x;
    q.pop();
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1400
#B
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
r = []
for i in range(N):
    r.append(V[i] - C[i])
r.sort()
ans = 0
for i in r:
    if i > 0:
        ans += i
print(ans)


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

int main() {
    long long N,sum,a=0,b=0,c=0,d=0;
    cin >> N;
    string S;
    for(long long i=0;i<N;i++){
        cin >> S;
        if(S=="AC"){
            a++;
        }else if(S=="WA"){
            b++;
        }else if(S=="TLE"){
            c++;
        }else if(S=="RE"){
            d++;
        }
    }
    
    printf("AC x %ld\nWA x %ld\nTLE x %ld\nRE x %ld",a,b,c,d);
    
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
#define REP(i,a,b) \
for(int i=int(a);i<=int(b);i++)
#define DEP(i,a,b) \
for(int i=int(a);i>=int(b);i--)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int T,n,m,i,j;
	cin>>n>>m;
	int a[n],sum=0;
	REP(i,0,n-1){
		cin>>a[i];
		sum+=a[i];
	}
	int ans=0;
	T=4*m;
	j=sum/T;
	if(sum%T!=0){
		j++;
	}
	REP(i,0,n-1){
        if(a[i]>=j){
      	ans++;
      }
	}
	if(ans>=m){
		cout<<"Yes";
	}
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

long long a[100];
int N = 0;

bool result=false;

int main() {
	cin >> N;
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i < 87; i++) {
		a[i] = a[i - 1] + a[i - 2];
	}
	cout << a[N] << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1<<30)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool b=1;for(auto s:t)os<<(exchange(b,0)||strlen(abi::__cxa_demangle(typeid(S).name(),0,0,0))>20?"":" ")<<s;return os<<endl;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	using val=bitset<256>;
	
	int n;
	cin>>n;
	map<string,val> num;
	rep(_,n){
	    val v(0);
	    string s; cin>>s; 
	    int l,r; cin>>l>>r;
	    range(i,l,r+1)v[i]=true;
	    num[s]=v;
	}
	rep(i,256){
	    val v(0); v[i]=1;
	    num[to_string(i)]=v;
	}
	int m; cin>>m;
	bool ok=true;
	stack<val> vs;
	rep(_,m){
	    string s; cin>>s;
	    val v(0);
	    if(s=="+"){
	        auto b=vs.top(); vs.pop();
	        auto a=vs.top(); vs.pop();
	        rep(i,256)rep(j,256){
	            if(a[i] and b[j]) v[(i+j)%256]=1;
	        }
	        vs.push(v);
	    }else if(s=="-"){
	        auto b=vs.top(); vs.pop();
	        auto a=vs.top(); vs.pop();
	        rep(i,256)rep(j,256){
	            if(a[i] and b[j]) v[(i-j+256)%256]=1;
	        }
	        vs.push(v);
	    }else if(s=="*"){
	        auto b=vs.top(); vs.pop();
	        auto a=vs.top(); vs.pop();
	        rep(i,256)rep(j,256){
	            if(a[i] and b[j]) v[(i*j)%256]=1;
	        }
	        vs.push(v);
	    }else if(s=="/"){
	        auto b=vs.top(); vs.pop();
	        auto a=vs.top(); vs.pop();
	        if(b[0]==1) {
	            ok=false;
	            break;
	        }
	        rep(i,256)rep(j,256){
	            if(a[i] and b[j]) v[(i/j)]=1;
	        }
	        vs.push(v);
	    }else{
	        vs.push(num[s]);
	    }
	}
	cout<<(ok?"correct":"error")<<endl;
	
	return 0;
}



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

int main(){
	int n; cin >> n;
	ll A[n];
	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
		if(A[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if(ans > 1000000000000000000/A[i]){
			cout << -1 << endl;
			return 0;
		}
		ans *= A[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 4416
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm>
#include <vector>
#include <queue> 
using namespace std; 
inline int gi() { 
    register int data = 0, w = 1; 
    register char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int MAX_N = 2e3 + 5; 
int N, a[MAX_N], deg[MAX_N]; 
bool vis[MAX_N], Link[MAX_N][MAX_N]; 
vector<int> G[MAX_N]; 
void dfs(int x) { 
	vis[x] = 1; 
	for (int i = 1; i <= N; i++) if (!vis[i] && Link[x][i]) ++deg[i], G[x].push_back(i), dfs(i); 
} 
void TopSort() { 
	priority_queue<int> que; 
	for (int i = 1; i <= N; i++) if (!deg[i]) que.push(i); 
	while (!que.empty()) { 
		int x = que.top(); que.pop();
		printf("%d ", a[x]); 
		for (auto v : G[x]) que.push(v); 
	}
	putchar('\n'); 
} 

int main () {
	N = gi(); for (int i = 1; i <= N; i++) a[i] = gi(); 
	sort(&a[1], &a[N + 1]); 
	for (int i = 1; i <= N; i++)
		for (int j = i + 1; j <= N; j++) 
			if (__gcd(a[i], a[j]) != 1) Link[i][j] = Link[j][i] = 1; 
	for (int i = 1; i <= N; i++) if (!vis[i]) dfs(i); 
	TopSort(); 
	return 0; 
} 


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

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int>D( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> D[i];
	}
	double maxans = 1, minans = 0;
	for( size_t idx = 0; idx < 100; idx++ ) {
		double midans = ( maxans + minans ) / 2;
		set<int>prev;
		prev.insert( 1 );
		for( size_t i = 0; i < N; i++ ) {
			double minvalue = D[i] * ( 1. - midans );
			double maxvalue = D[i] * ( 1. + midans );
			set<int>next;
			for( auto one : prev ) {
				for( int j = minvalue / one + 1; j <= maxvalue / one; j++ ) {
					next.insert( j*one );
				}
			}
			prev = next;
		}
		if( prev.size() ) {
			maxans = midans;
		} else {
			minans = midans;
		}

	}
	cout << fixed << setprecision( 20 ) << minans << endl;
}

Measured memory_bytes: 10824
import heapq
n,m,s,t = map(int,input().split())
en = []
su = []
for i in range(m):
    x1,y1,z1,a1=[int(i) for i in input().split()]
    en.append([x1-1,y1-1,z1])
    su.append([x1-1,y1-1,a1])
def shortest_path(edge,num_v,start):
    inf = float("inf")
    cost = [[] for i in range(n+1)]
    for path in edge:
      cost[path[0]].append((path[1],path[2]))
      cost[path[1]].append((path[0],path[2]))
    d = [inf for j in range(num_v)]
    q = []
    heapq.heappush(q, (0, start))
    d[start] = 0
    while len(q) != 0:
      prov_cost, src = heapq.heappop(q)
      if d[src] < prov_cost:
                continue
      for dest,weight in cost[src]:
        if weight != float('inf') and d[dest] > d[src] + weight:
          d[dest] = d[src] + weight
          heapq.heappush(q, (d[dest], dest))
    return d
 
 
from collections import deque
ans = deque([])
tori = shortest_path(en,n,s-1)
kae = shortest_path(su,n,t-1)
sai = float("inf")
for i in range(n-1,-1,-1):
  kon = kae[i]+tori[i]
  if sai > kon:
     ans.appendleft(kon)
     sai = kon
  else:
    ans.appendleft(sai)
    
moti = 10**15
for i in range(n):
  print(moti-ans[i])

Measured memory_bytes: 77620
#include<cstdio>
 
int main(){
    int i,j,t,data[10];
     
    for(i=0;i<10;i++)
    {
        scanf("%d",&data[i]);
    }
     
    for(i=0;i<9;i++)
    {
        for(j=0;j<9-i;j++)
        {
            if(data[j]<data[j+1])
            {
                t=data[j];
                data[j]=data[j+1];
                data[j+1]=t;
            }
        }
    }
    for(i=0;i<3;i++)
    {
        printf("%d\n",data[i]);
    }
 
    return 0;
}
 

Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int n,a[1000],cnt[1001];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	    a[i]=i+1;
	long long ans=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<n;j++)
		{
			while(a[j]%i==0&&a[j]!=1)
			    cnt[i]++,a[j]/=i;
		}
		ans=ans*(cnt[i]+1)%1000000007;
	}
	cout<<ans;
	return 0;
}

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<ll,ll>
#define vi vector<int>
#define vpi vector< pi > 
#define IOS ios_base::sync_with_stdio(false),cin.tie(NULL)
const int N=100002;

int main()
{
	int n;
	cin>>n;
	int f=0;
	while(n) {if(n%10==7) f=1;n/=10;}
	if(f) cout<<"Yes";
	else cout<<"No";

	return 0;
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
int power(long long x, long long y, long long p) {
    long long res = 1;  // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1) res = (res * x) % p;

        // y must be even now
        y = y >> 1;  // y = y/2
        x = (x * x) % p;
    }
    return res;
}

long long modInverse(long long n, long long p) { return power(n, p - 2, p); }

long long nCrModPFermat(long long n, long long r, long long p) {
    if (r == 0) return 1;
    long long fac[n + 1];
    fac[0] = 1;
    for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long n, k;
    cin >> n >> k;
    long long ans = 0;
    for (long long i = k; i <= n + 1; i++) {
        ans += (n * (n + 1) / 2) - ((n - i) * (n - i + 1) / 2) - (i * (i - 1)) / 2 + 1;
        // cout << ans << endl;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

int N;
int X[1000];
int Y[1000];
std::vector<int> graph[1000];
std::bitset<5001> make[1000];

void impossible() {
    puts("IMPOSSIBLE");
    exit(0);
}

void dfs(const int& v) {
    int sum = 0;
    make[v][0] = 1;
    for (const int& u : graph[v]) {
        dfs(u);
        sum += X[u] + Y[u];
        make[v] = (make[v] << X[u]) | (make[v] << Y[u]);
    }
    for (int i = X[v]; i >= 0; --i) {
        if (make[v][i]) {
            Y[v] = sum - i;
            return;
        }
    }
    impossible();
}

int main() {

    std::cin >> N;
    rep (i, N - 1) {
        int p;
        std::cin >> p;
        graph[p - 1].emplace_back(i + 1);
    }
    rep (i, N) std::cin >> X[i];

    dfs(0);
    puts("POSSIBLE");
    return 0;

}


Measured memory_bytes: 2048
n=int(input())
a=list()
for i in range(n):
	x,y=map(str,input().split())
	y=int(y)
	if x=="S":
		a.append(y+0)
	elif x=="H":
		a.append(y+13)
	elif x=="C":
		a.append(y+26)
	elif x=="D":
		a.append(y+39)
for i in range(1,53):
	if not (i in a):
		if i<=13:
			print("S {}".format(i-0))
		elif i<=26:
			print("H {}".format(i-13))
		elif i<=39:
			print("C {}".format(i-26))
		else:
			print("D {}".format(i-39))



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    ll N,M,K;
    cin >> N >> M >> K;
    vector<ll> AList(N);
    vector<ll> BList(M);
    for (int i=0; i<N; i++) cin >> AList[i];
    for (int i=0; i<M; i++) cin >> BList[i];

    // resolve
    vector<ll> AList_sum(N);
    AList_sum[0] = AList[0];
    for (int i=1; i<N; i++) AList_sum[i] = AList_sum[i-1] + AList[i];
    vector<ll> BList_sum(M);
    BList_sum[0] = BList[0];
    for (int i=1; i<M; i++) BList_sum[i] = BList_sum[i-1] + BList[i];

    auto iter = upper_bound(AList_sum.begin(), AList_sum.end(), K);
    int ans_a=iter - AList_sum.begin();
    int ans = 0;
    int a_ind = iter - AList_sum.begin() -1;
    for (int i = 0; i<=a_ind; i++) {
        ll last_time = K-AList_sum[a_ind-i];
        auto iter_b = upper_bound(BList_sum.begin(), BList_sum.end(), last_time);
        int b_ans = iter_b - BList_sum.begin();
        ans = max(ans_a-i+b_ans, ans);
    }

    auto iter_b = upper_bound(BList_sum.begin(), BList_sum.end(), K);
    int ans_b=iter_b - BList_sum.begin();
    ans = max(ans_b,ans);

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int p[100020];
    for(int i = 0;i < n;i++)cin >> p[i],p[i]--;
    bool b[100020]{};
    for(int i = 0;i < n;i++){
        b[i] = (p[i] == i);
    }
    int ans = 0;

    if(b[n-1] | b[n-2])b[n-1] = b[n-2] = false,ans++;
    for(int i = 0;i < n-1;i++){
        if(b[i])b[i] = b[i+1] = false,ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
N,M=map(int,input().split())

lists = [[] for _ in range(N)]
items = [list(map(int, input().split())) for _ in range(M)]
for p, y in items:
  lists[p-1].append(y)

dic = {}

for n in range(N):
  lists[n].sort()  

for n in range(N):
  l = lists[n]
  count = 1
  for i in l:
    dic[i] = count
    count+=1

for p, y in items:
  print("{:06g}{:06g}".format(p,dic[y]))


Measured memory_bytes: 47436
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
i = 0
ans = [[0 for _ in range(w)] for _ in range(h)]
for j in range(n):
  for _ in range(a[j]):
    hi = i//w
    if hi%2 == 0:
      ans[hi][i%w] = j+1
    else:
      ans[hi][w-1-i%w] = j+1
    i += 1
for ansi in ans:
  for j in range(w-1):
    print(ansi[j],end=" ")
  print(ansi[w-1])

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
Node treeSearch(Node, int);

#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
    while (u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

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] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      }
      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: 25120
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//int R = in.nextInt();
		char[] S = in.nextLine().toCharArray();
		
		if(S[0] != 'A') {
			System.out.print("WA");
			System.exit(0);
		}
		
		if((int)S[1] < (int)'a') {
			System.out.print("WA");
			System.exit(0);
		}
		int count = 0;
		for(int i=2; i<S.length-1; i++) {
			if(S[i] == 'C') {
				count++;
				if(count == 2) {
					System.out.print("WA");
					System.exit(0);
				}
			}
		}
		if(count != 1) {
			System.out.print("WA");
			System.exit(0);
		}
		if((int)S[S.length-1] < (int)'a') {
			System.out.print("WA");
			System.exit(0);
		}
		System.out.print("AC");
		in.close();
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;
const int logN = 16;

map<string,int> mp;
void solve() {
	int n;
	string p;
	cin>>n;
	int ans = 0;
	REP(i,1,n) {
        cin>>p;
        mp[p]++;
        ans = max(ans, mp[p]);
	}
	for (auto it:mp) {
        if (it.second==ans) {
            cout<<it.first<<"\n";
        }
	}
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


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

using ll = long long int;
using P = std::pair<int, int>;

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

int main()
{
    int n, p;

    std::cin >> n >> p;

    std::string s;

    std::cin >> s;

    auto g = [](char ch) { return atoi(&ch); };

    if (p == 2 || p == 5)
    {
        ll ans = 0;
        for (int i = 0; i < s.size(); ++i)
        {
            if (g(s[i]) % p == 0)
                ans += i + 1;
        }
        std::cout << ans << std::endl;
    }
    else
    {
        std::vector<int> p10(p - 1);

        int x = 1;

        rep(i, p - 1)
        {
            p10[i] = x;
            x = x * 10 % p;
            //std::cerr << p10[i] << ' ';
        }
        //std::cerr << std::endl;

        int mod = 0;
        std::map<int, ll> mp;

        for (int i = n - 1; i >= 0; --i)
        {
            mod += g(s[i]) * p10[(n - 1 - i) % (p - 1)];
            mod %= p;
            ++mp[mod];
            //std::cerr << i << ' ' << mod << std::endl;
        }
        ll ans = 0;
        for (auto p : mp)
        {
            if (p.first == 0)
                ans += p.second;
            ans += p.second * (p.second - 1) / 2;
        }

        std::cout << ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 4248
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-20;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i+1);
	int pr=0;
	int ret=0;
	for(int i=1;i<=a+1;i++){
		if(p[i]==0){
			ret=max(ret,i-pr);
			pr=i;
		}
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 2740
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

#define int long long

signed main(){
  string s;
  cin >> s;
  int n = s.length();
  int chan0 = 0;
  int chan1 = 0;
  LOOP(i,n){
    if(i%2){
      if(s[i]=='0'){
        chan1++;
      }else{//s[i]: '1'
        chan0++;
      }
    }else{
      if(s[i]=='1'){
        chan1++;
      }else{
        chan0++;
      }
    }
  }
  cout << min(chan0, chan1) << endl;
}


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

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int N,M,X;
  cin>>N>>M>>X;
  int Left=0,Right=0;
  while (M--) {
    int A;
    cin>>A;
    Left+=(A<X?1:0); Right+=(A>X?1:0);
  }
  cout<<min(Left,Right)<<endl;
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a,ans;
map<int,int> m;

main() {
    cin >> n;
    rep(i,n) cin >> a,m[a]++;
    for(auto i = m.begin();i != m.end();++i) if (i->se%2) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 6528
n = int(input())
sum = 0
skip = -1
for i in range(1,n+1):
    sum += i
    if sum >= n:
        skip = sum - n # 超過分 skip <= n
        last = i
        break
for i in range(1,last+1):
    if i == skip:
        continue
    else:
        print(i)


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

using namespace std;

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


Measured memory_bytes: 3620
import collections

def main():
    n = int(input())
    s_list = [input() for _ in range(n)]
    c = collections.Counter(s_list)
    mc = c.most_common()

    ans_list = []
    max_v = mc[0][1]
    for k, v in mc:
        if v == max_v:
            ans_list.append(k)
    ans_list.sort()
    ans = '\n'.join(ans_list)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 120144
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	char c;
	cin>>c;
	
	bool jud=true;
	if('a'<=c and c<='z') jud=false;
	
	cout<<(jud?'A':'a')<<endl;
}

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

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(1<=a && a<10 && 1<=b && b<10){
        printf("%d\n",a*b);
    }
    else puts("-1");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++ ) {
			a[i] = sc.nextInt();
		}
		sc.close();
		int q =partition1(a, 0, n-1);
		for(int i = 0 ;i < a.length ; i++) {
			if(i>0) System.out.print(" ");
			if(i==q) {
				System.out.print("[");
			}
			System.out.print(a[i]);
			if(i==q) {
				System.out.print("]");
			}
		}
		System.out.println();
	}
	public static int partition(int[] arr,int p,int r ) {
		int x = arr[r];
		int i = p-1;
		for(int j = p;j < r;j++) {
			if(arr[j] <= x) {
				i++;
				arr[i] = arr[i] ^ arr[j];
				arr[j] = arr[i] ^ arr[j];
				arr[i] = arr[i] ^ arr[j];
			}	
		}
		arr[i+1] = arr[i+1] ^ arr[r];
		arr[r] = arr[i+1] ^ arr[r];
		arr[i+1] = arr[i+1] ^ arr[r];
		return i+1;
	}
	public static int partition1(int[] arr,int p,int r ) {
		int x = arr[r];
		int i = p-1;
		int t;
		for(int j = p;j < r;j++) {
			if(arr[j] <= x) {
				i++;
				t = arr[i];
				arr[i] = arr[j];
				arr[j] = t;
			}	
		}
		t = arr[i+1];
		arr[i+1] = arr[r];
		arr[r] = t;
		return i+1;
	}
	
}



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

class dice{

public:
  int _1,_2,_3,_4,_5,_6,temp;

  void moveN(){
    temp=_1;
    _1=_2;
    _2=_6;
    _6=_5;
    _5=temp;
  }

  void moveE(){
    temp=_1;
    _1=_4;
    _4=_6;
    _6=_3;
    _3=temp;
  }

  void moveW(){
    temp=_1;
    _1=_3;
    _3=_6;
    _6=_4;
    _4=temp;
  }

  void moveS(){
    temp=_1;
    _1=_5;
    _5=_6;
    _6=_2;
    _2=temp;
  }

  void spin(){
    temp=_2;
    _2=_3;
    _3=_5;
    _5=_4;
    _4=temp;
  }

};
int main(){
  dice d[100];
  int i,j,k,l,n;
  cin>>n;
  for(i=0; i<n; i++)cin>>d[i]._1>>d[i]._2>>d[i]._3>>d[i]._4>>d[i]._5>>d[i]._6;
  for(i=0; i<n; i++)for(j=0; j<n; j++){
    if(i==j)continue;
      for(k=0; k<6; k++){
        if(k==4)d[i].moveE();
        if(k==5){
          d[i].moveE();
          d[i].moveE();
        }
          for(l=0; l<4; l++){
            d[i].spin();
            if(d[i]._1==d[j]._1 &&
               d[i]._2==d[j]._2 &&
               d[i]._3==d[j]._3 &&
               d[i]._4==d[j]._4 &&
               d[i]._5==d[j]._5 &&
               d[i]._6==d[j]._6){
              cout<<"No"<<endl;
              return 0;
              }
        }
      }
    }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1160