akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

void rsorta_u32(void *base, const int count, const int size, const int index){
	typedef uint32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(0<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(1<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(2<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(3<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(3<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	free(b);
}

int a[100000][2];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i][0]=i;
		a[i][1]=nextint();
	}
	rsorta_u32(a, n, 2, 1);
	long sum=0;
	int ans=0;
	for(int i=0; i<n; i++){
		if(a[i][1]<=sum*2){
			ans++;
		}else{
			ans=1;
		}
		sum+=a[i][1];
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 2920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> connect(10, vector<bool>(10, false));
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            connect.at(i).at(s-1) = true;
        }
    }
    vector<int> p(M,0);
    for (int i = 0; i < M; i++) {
        cin >> p.at(i);
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        vector<int> count(M,0);
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                for (int j = 0; j < M; j++) {
                    if (connect.at(j).at(i) == true) {
                        count.at(j)++;
                    }
                }
            }
        }
        bool mcheck = true;
        for (int j = 0; j < M; j++) {
            // cout << count.at(j);
            if ((count.at(j))%2 != p.at(j)) {
                mcheck = false;
            }
        }
        if (mcheck) ans++;
        // cout << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def search(l, n):
    l = l.copy()
    l.append(n)
    i = 0
    while l[i] != n:
        i += 1

    if i == len(l) - 1:
        print("NOT FOUND")
    else:
        print("FOUND")


n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

s = set(s)
ans = 0
for ti in t:
    if ti in s:
        ans += 1

print(ans)


Measured memory_bytes: 16892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <string>
using namespace std;

int main(void)
{
    stack<int> S;
    
    int a, b;
    string c;

    while((cin>>c))
    {
        if(c == " ") continue;

        if(c == "+")
        {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a + b);
        }
        else if(c == "-")
        {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(b - a);
        }
        else if(c == "*")
        {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a * b);
        }
        else
        {
            S.push(atoi(c.c_str()));
        }
        
    }

    cout << S.top() << endl;

    

    return 0;
}


Measured memory_bytes: 3184
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int [] acc = new int[m];
			for(int i = 0; i < n; i++){
				int count = sc.nextInt();
				for(int j = 0; j < count; j++){
					acc[sc.nextInt()-1]++;
				}
				
			}
			
			int ans = 0;
			for(int i = 0; i < m; i++){
				if(acc[i] == n)ans++;
			}
			System.out.println(ans);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define int long
main(){
  int n,r=0;
  cin>>n;
  vector<int> a(n),b(n),c,d(n);
  for(auto& i:a)cin>>i;
  for(auto& i:b)cin>>i;
  c=b;
  for(int i=0;i<n;++i)d[i]=i;
  bool modi=true;
  while(modi){
    modi=false;
    sort(d.begin(),d.end(),[&](int p,int q){return b[p]>b[q];});
    for(auto i:d){
      int k=c[0<i?i-1:n-1]+c[i<n-1?i+1:0];
      if(c[i]<k)continue;
      int dif=(c[i]-a[i])/k*k;
      if(dif==0&&c[i]<a[i])cout<<-1,exit(0);
      if(dif)modi=true;
      r+=(c[i]-a[i])/k;
      c[i]-=dif;
      //cerr<<"["<<r<<":"<<i<<"]";
      //for(int i=0;i<n;++i)cerr<<(i?" ":"")<<c[i];
      //cerr<<"\n";
    }
    //cerr<<"modi:"<<modi<<"\n";
    if(!modi&&a!=c)cout<<-1,exit(0);
  }
  //cerr<<"[res]";
  //for(int i=0;i<n;++i)cerr<<(i?" ":"")<<c[i];
  //cerr<<"\n";
  //cerr<<"r=";
  cout<<(a==c?r:-1);
}

Measured memory_bytes: 6656
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(n**0.5)+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
      
  if temp!=1:
    arr.append([temp, 1])
    
  if arr==[]:
    arr.append([n, 1])
    
  return arr

import math

n=int(input())
if(1==n):
    print(0)
    exit()
a=factorization(n)
ans=0
for i,j in a:
    c=1
    while True:
        j-=c
        c+=1
        ans+=1
        if(j<c):break

print(ans)

Measured memory_bytes: 9404
#include<stdio.h>
#define MAX 1000000;
#define MIN -1000000;

int main (void){
    int n,min,max,inp;
    long sum=0;
    min=MAX;
    max=MIN;
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
            scanf("%d",&inp);
            sum+=inp;
            if (min>=inp)min=inp;
            if (max<=inp)max=inp;
        }
    printf("%d %d %ld\n",min,max,sum);


    return 0;
}


Measured memory_bytes: 2124
n = input()
int_n = int(n)
n_len = len(n)

ans = 0
tmp = 0

if n_len == 1:
    ans = int_n
else:
    for i in range(1,n_len):
        if i % 2 == 1:
            ans += (10 ** i) - (10 ** (i-1))
    if (n_len % 2) == 1:
        tmp = int_n - (10**(n_len-1)) + 1
        ans += tmp
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] cnt = new int[N];
		int min = N + 1;
		int max = 0;
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			cnt[a[i]] += 1;
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i]);
		}
		sc.close();

		String POSSIBLE = "Possible";
		String IMPOSSIBLE = "Impossible";
		String ans = POSSIBLE;
		if (cnt[min] == 1) {
			if (max == min * 2) {
				ans = POSSIBLE;
				for (int i = min + 1; i <= max; i++) {
					if (cnt[i] < 2) {
						ans = IMPOSSIBLE;
						break;
					}
				}
			} else {
				ans = IMPOSSIBLE;
			}
		} else if (cnt[min] == 2) {
			if (max == min * 2 - 1) {
				ans = POSSIBLE;
				for (int i = min + 1; i <= max; i++) {
					if (cnt[i] < 2) {
						ans = IMPOSSIBLE;
						break;
					}
				}
			} else {
				ans = IMPOSSIBLE;
			}
		} else {
			ans = IMPOSSIBLE;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 10324
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N=I()
    
    L=[0]*(N+1)
    L[0]=2
    L[1]=1
    for i in range(1,N):
        L[i+1]=L[i]+L[i-1]
    print(L[N])

main()


Measured memory_bytes: 38704
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int f(int X){
    int res = 0;
    while(X){
        res += X%10;
        X /= 10;
    }
    return res;
}
int main(void){
    int N; cin >> N;
    cout << (N%f(N) ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
    #include <bitset>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <deque>
    #include <fstream>
    #include <functional>
    #include <iostream>
    #include <limits>
    #include <map>
    #include <numeric>
    #include <queue>
    #include <set>
    #include <vector>
    using namespace std;
    using ll = long long;
    #define fst first
    #define snd second
     
    /* clang-format off */
    template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
    template <class T> struct _vec<T, 0> { using type = T; };
    template <class T, size_t D> using vec = typename _vec<T, D>::type;
    template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
    template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
    /* clang-format on */
     
    int N;
    vector<ll> A;
     
    ll dp[200010][20];
     
    int lg(ll A, int x, ll B) {
      for (int i = 0; i < x; i++) A *= 4;
      double dB = B;
      // A*4^x <= B*4^y
      for (int y = 0;; y++) {
        if (dB > A + 100 || A <= B) {
          return y;
        }
        dB *= 4;
        B *= 4;
      }
    }
     
    ll solve(int i, int x) {
      if (i == N - 1) return 0;
      if (x > 15) {
        return solve(i, 15) + (ll)(N - i - 1) * (x - 15);
      }
      ll& res = dp[i][x];
      if (res != -1) return res;
      int y = lg(A[i], x, A[i + 1]);
      return res = y + solve(i + 1, y);
    }
     
    int main() {
      while (cin >> N) {
        A.resize(N);
        for (int i = 0; i < N; i++) cin >> A[i];
        vector<ll> costA(N + 1, 0);
        {
          memset(dp, -1, sizeof(dp));
          for (int i = 0; i < N; i++) costA[i] = solve(i, 0) * 2;
        }
        vector<ll> costB(N + 1, 0);
        {
          reverse(A.begin(), A.end());
          memset(dp, -1, sizeof(dp));
          for (int i = 0; i < N; i++) costB[i] = solve(i, 0) * 2;
        }
        reverse(costB.begin(), costB.end());
        ll res = 1ll << 60;
        for (int i = 0; i <= N; i++) {
          ll cost = i + costA[i] + costB[i];
          res = min(res, cost);
        }
        cout << res << endl;
      }
      return 0;
    }

Measured memory_bytes: 54912
from sys import stdin
from itertools import accumulate
from pprint import pprint
input = stdin.readline

N, M, Q = map(int, input().split())

count = [[0]*(N+1) for _ in range(N+1)]
for i in range(M):
    l, r = map(int, input().split())
    count[l][r] += 1
# pprint(count)

#accum = [[0]*(N+1) for _ in range(N+1)]
#for i in range(N+1):
#    accum[i][0] = count[i][0]
#    for j in range(1, N+1):
#        accum[i][j] = accum[i][j-1] + count[i][j]
#pprint(accum)
#for i in range(1, N+1):
#    for j in range(N+1):
#        accum[i][j] = accum[i-1][j] + accum[i][j]
#pprint(accum)
accum = list(zip(*[list(accumulate(d)) for d in zip(*(accumulate(c) for c in count))]))
#pprint(accum)

#test = [[0]*(N+1) for _ in range(N+1)]
#for i in range(1, N+1):
#    for j in range(1, N+1):
#        test[i][j] = accum[j][j] - accum[i-1][j] - \
#            accum[j][i-1] + accum[i-1][i-1]
# pprint(test)


for _ in range(Q):
    p, q = map(int, input().split())
    ans = accum[q][q] - accum[p-1][q] - accum[q][p-1] + accum[p-1][p-1]
    print(ans)


Measured memory_bytes: 18292
d=[0,0,0,0,0,0]
n=input()
for i in range(n):
    a=input()
    if 165.0>a:d[0]+=1
    elif 165.0<=a<170:d[1]+=1
    elif 170.0<=a<175.0:d[2]+=1
    elif 175.0<=a<180.0:d[3]+=1
    elif 180.0<=a<185.0:d[4]+=1
    else:d[5]+=1
a=["*"*i for i in d]
print "1:{}\n2:{}\n3:{}\n4:{}\n5:{}\n6:{}".format(a[0],a[1],a[2],a[3],a[4],a[5])

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

#define xx first
#define yy second

const int N = 1e7 + 1;

ll sv[N];
void solve() {
    ll ans = 0;

    int n; cin >> n;
    fill(sv, sv + n + 1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j += i)
            sv[j]++;
        ans += i * sv[i];
    }

    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 81768
S = input()
if int(S[0: 2]) >= 13 or int(S[0: 2]) == 0:
    if int(S[2: 4]) == 0 or int(S[2: 4]) >= 13:
        print('NA')
    else:
        print('YYMM')
else:
    if int(S[2: 4]) == 0 or int(S[2: 4]) >= 13:
        print('MMYY')
    else:
        print('AMBIGUOUS')

Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){


*/
signed main(){
  char c;
  cin>>c;
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout<<"vowel"<<endl;

  }
  else
    cout<<"consonant"<<endl;
}


  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int N;
ll T,A;
ll ans1=-1,ans2=-1;
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%lld%lld",&T,&A);
		if(ans1==-1){
			ans1=T;
			ans2=A;
		}
		else{
			ll a1=(ans1-1)/T;
			ll a2=(ans2-1)/A;
			ans1=T*max(a1+1,a2+1);
			ans2=A*max(a1+1,a2+1);
		}
	}
	printf("%lld\n",ans1+ans2);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var alist = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x=>x);
            var good = 0;
            var now = 0;
            var nowcount = 0;
            foreach(var a in alist)
            {
                if (a != now)
                {
                    now = a;
                    nowcount = 0;
                }
                nowcount += 1;
                if(nowcount == a)
                {
                    good += a;
                }
            }
            Console.WriteLine(N - good);
        }
    }
}

Measured memory_bytes: 30812
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "Draw";
	}
	else if (a==1){
		cout << "Alice";
	}
	else if (b == 1)cout << "Bob";
	else if (a>b)
	{
		cout << "Alice";
	}
	else if (a<b)
	{
		cout << "Bob";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 764
n,m,x,y = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))
x_list.append(x)
y_list.append(y)
if max(x_list) < min(y_list):
  print('No War')
else:
  print('War')

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}


Measured memory_bytes: 3624
import sun.reflect.generics.tree.Tree;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;


public class Main {
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		s.nextLine();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
		}
		int cur = n;
		int doi=0;
		for(int i:arr)
		{
			if(i%4!=0)
				if(i%2==0)
				{
					doi++;
				}
		}
		if(doi!=0)
		{
			cur-=doi;
		cur++;
		}
		int patru=0;
		for(int i:arr)
		{
			if(i%4==0)
				patru++;
		}
		//System.out.println(cur+" "+patru);
				
		if(patru>=cur/2) System.out.println("Yes");
		else System.out.println("No");
		
		
	}
	
	
}

Measured memory_bytes: 50344
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
H = list(map(int, input().split()))
ans = 1
maxH = H[0]
for h in H[1:]:
    if h >= maxH:
        ans += 1
        maxH = h
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
  long long N, K;
  cin >> N >> K;
  priority_queue<long long, vector<long long>, greater<long long> > A;
  int flg=0;

  for (int i = 0; i < N; i++){
    long long tmp;
    cin >> tmp;
    A.push(tmp);
    if (tmp == K){
      printf("POSSIBLE\n");
      return 0;
    }
    if(tmp > K) flg = 1;
  }

  if (flg==0){
    printf("IMPOSSIBLE\n");
  }else{
    
    long long t;
    while (!A.empty() && A.top() != 1){
      t = A.top();
      A.pop();
      while (!A.empty() && A.top() % t == 0) A.pop();
      if (!A.empty()){
        A.push(A.top() % t);
      }
    }
    

    if (A.empty() && K%t!=0){
      printf("IMPOSSIBLE\n");
    }else{
      printf("POSSIBLE\n");
    }
    
  }
  
  
}


Measured memory_bytes: 4320
#include <iostream>
#include <queue>
#define MAX 101
#define NIL -1

using namespace std;


int matrix[MAX][MAX] = {0};
int dis[MAX];
//提交时须对time改名 
int n;


void bfs_visit(int u);
int next(int u);

int main()
{
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		int u, k, v;
		cin >> u >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> v;
			matrix[u][v] = 1;			
		}
	}
	
//显示邻接矩阵 
//	for (int i = 0; i < n; i++)
//	{
//		for (int j = 0; j < n; j++)
//		{
//			if(j) cout << ' ';
//			cout << matrix[i+1][j+1];		
//		}
//		cout << endl;
//	}

	bfs_visit(1);

	for (int i = 1; i <= n; i++)
	{
		cout << i << ' ';
		cout << dis[i] << endl;
	}
}



void bfs_visit(int u)
{
	
	//dis[]初始化，取值NIL时表示未访问 
	for (int i = 1; i <= n; i++)
		dis[i] = NIL;	
	dis[u] = 0;	
	
	queue<int> Q;
	Q.push(u);
	
//	int d = 1;
//	while (!Q.empty())
//	{
//		u = next(Q.front());
//
//		if (u)
//		{
//			dis[u] = d; 
//			Q.push(u);
//		}
//		else
//		{
//			Q.pop();			
//		}
//		
//		//判断是否进入下一层 
//		if (dis[Q.front()] == d) d++;
//
//	}

//另一种实现 
	while (!Q.empty())
	{
		u = Q.front();
		Q.pop();
		for (int v = 1; v <= n; v++)
		{
			if (matrix[u][v] != 0 && dis[v] == NIL)
			{
				dis[v] = dis[u] + 1;
				Q.push(v);
			}
		}
	} 
}


int next(int u)
{
	for (int i = 1; i <= n; i++)
	{
		if (matrix[u][i] != 0 && dis[i] == NIL)
			return i;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N, i; cin >> N >> i;
    cout << N - i + 1;
    
    return 0;
}


Measured memory_bytes: 256
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define fore(i, m, n) for (int i = m; i <= n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
const int N=1e6+5;
lli fac[N];
int main()
{
    kira;
    lli x,y;
    fac[0]=1;
    for(int i=1;i<N;i++)
    {
      fac[i]=(fac[i-1]*i)%mod;
    }
    cin>>x>>y;
    lli s=x+y;
    lli a,b;
    if(s%3)cout<<0;
    else 
    {
      lli c=s/3;
      b=x-c;
      if(b<0||b>c)cout<<0;
      else 
      {
        lli ans=fac[c];
        ans*=modi(fac[b],mod);
        ans%=mod;
        ans*=modi(fac[c-b],mod);
        ans%=mod;
        cout<<ans;
      }
    }
    return 0;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
    	int n, m;
	    cin >> n >> m;
	 
	    int a[n] = {}, f[n] = {};
	    for(int i=0;i<m;i++) 
	    {
	        int p; 
	        string s;
	        cin >> p >> s;
	        p--;
	 
	        if(!f[p]) 
	        {
	            if(s == "WA") 
	            	a[p]++;
	            else 
	            	f[p] = true;
	        }
	 
	 
	 
	    }
	 
	    int ac = 0, wa = 0;
	    for(int i=0;i<n;i++) 
	    {
	        if(f[i]) 
	        {
	            ac++;
	            wa += a[i];
	        }
	    }
 
    	cout << ac << ' ' << wa << '\n';

    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 1792
import functools
import math
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)

  divisors.sort()
  divisors.pop(0)
  return divisors

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

N = input()
A = list(map(int, input().split()))
A = sorted(A)
gcd = functools.reduce(math.gcd, A)

dp = []
if 2 <= gcd:
  print("not coprime")
else:
  isPC = True
  for a in A:
    if is_prime(a):
      dp.append(a)
    else:
      divs = make_divisors(a)
      for d in divs:
        if d in dp:
          isPC = False
          break
        dp.append(d)

    if not isPC:
      break
  if isPC:
    print("pairwise coprime")
  else:
    print("setwise coprime")

Measured memory_bytes: 191388
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 10;
   const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
    const int p = 179;
   const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")`

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int r;
    cin >> r;
    cout << fixed << setprecision(10) << PI * (ld)r * 2.0;
}
/*

*/


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n,m; cin >> n >> m;
    int student[n][2];
    int points[m][2];
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 2;j++){
            cin >> student[i][j];
        }
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j < 2;j++){
            cin >> points[i][j];
        }
    }
    
    for(int i = 0;i < n;i++){
        ll ans = LLONG_MAX;
        int point = 0;
        for(int j = 0;j < m;j++){
            ll c = (ll)abs(student[i][0]-points[j][0])+(ll)abs(student[i][1]-points[j][1]);
            if(c < ans){
              ans = c;
              point = j+1;
            }
        }
        cout << point << endl;
    }
    
}



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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);
#define int long long


signed main(){
	int n;
	cin>>n;
	vector<pair<int,int> > v[200];
	lp(i,n){
		int u,k;
		cin>>u>>k;
		lp(j,k){
			int a,b;
			cin>>a>>b;
			v[u].push_back(make_pair(a,b));
		}
	}
	queue<pair<int,int> > q;
	q.push(make_pair(0,0));
	int memo[200];
	lp(i,200) memo[i]=INF;
	memo[0]=0;
	while(!q.empty()){
		pair<int,int> hoge=q.front();
		q.pop();
		int now=hoge.first;
		int cos=hoge.second;
		lp(i,v[now].size()){
			int next=v[now][i].first;
			int cost=v[now][i].second;
			if(memo[next]>cos+cost){
				 q.push(make_pair(next,cos+cost));
				 memo[next]=cos+cost;
			}
		}
	}
	lp(i,n){
		cout<<i<<" "<<memo[i]<<endl;
	}
    return 0;
}



Measured memory_bytes: 3132
N=gets.to_i
ABS=N.times.map {gets.split.map(&:to_i)}

ABS = ABS.sort
ABS = ABS.sort {|a,b| a[1] <=> b[1]}

time=0
flag=0
ABS.each do |ab|
  time+=ab[0]
  flag = 1 if time > ab[1]
end

if flag == 1
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 20956
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

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

void solve(int N, int M, long X, vector<long> C, vector<vector<long>> A) {
  long min_cost = 13 * 1E5;
  for (int bit = 0; bit < (1<<N); ++ bit) {
    vector<long> skill(M);
    long cost(0);
    REP(i, N) {
      if (bit & (1<<i)) {
	cost += C[i];
	REP(j, M)
	  skill[j] += A[i][j];
      }
    }
    bool achieve = true;
    REP(j, M) {
      if (skill[j] < X)
	achieve = false;
    }
    // cout << (achieve ? "Achieve" : "Not") << cost << endl;
    if (achieve)
      min_cost = min(min_cost, cost);
  }
  cout << (min_cost != 13 * 1E5 ? min_cost : -1) << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  long X;
  cin >> N >> M >> X;

  vector<long> C(N);
  vector<vector<long>> A(N, vector<long>(M));
  REP(i, N) {
    cin >> C[i];
    REP(j, M)
      cin >> A[i][j];
  }

  solve(N, M, X, move(C), move(A));
  
  return 0;
}


Measured memory_bytes: 3624
//https://blog.csdn.net/hesorchen
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <set>
#include <queue>
#include <string>
#include <cstring>
using namespace std;
#define ll long long
#define lowbit(a) (a & (-a))
#define endl "\n"
#define PI acos(-1.0)
#define mod 1000000009
#define INF 0x3f3f3f3f
#define MAX 200010
string a;
int main()
{

    ll n;
    while (cin >> n)
        cout << ((n - 1) * n) / 2 << endl;
    return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool win[100100];

void func(long long N, long long K, long long R, long long S, long long P, std::string T){

    map<char,lli>score;
    score['r']=P;
    score['s']=R;
    score['p']=S;

    lli ans = 0;
    REP(i,0,N){
        if(i<K){
            win[i]=true;
            ans+=score[T[i]];
        }
        else{
            if(T[i-K]==T[i] && win[i-K])continue;
            win[i]=true;
            ans += score[T[i]];
        }
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long R;
    scanf("%lld",&R);
    long long S;
    scanf("%lld",&S);
    long long P;
    scanf("%lld",&P);
    std::string T;
    std::cin >> T;
    func(N, K, R, S, P, T);
    return 0;
}


Measured memory_bytes: 3976
a,b,c,x,y=map(int,input().split())
ans=float("inf")
for i in range(2*(max(x,y)+1)):
  p=i*c
  p+=max(x-i//2,0)*a
  p+=max(y-i//2,0)*b
  ans=min(p,ans)
print(ans)

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    vector<bool> b(1000001, true);
    for (Int i = 0; i < (Int)n; i++) {
        if (0 < i and a[i - 1] == a[i]) continue;
        if (b[a[i]]) {
            for (Int j = 2; a[i] * j < (Int)1000001; j++) {
                b[a[i] * j] = false;
            }
        }
    }
    Int res = 0;
    for (Int i = 0; i < (Int)n; i++) {
        if (0 < i and a[i - 1] == a[i]) continue;
        if (i < n - 1 and a[i] == a[i + 1]) continue;
        if (b[a[i]]) {
            res++;
        }
    }
    print(res);
    return 0;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    int n;cin>>n;
    vi v(n);cin>>v;
    sort(all(v));
    reverse(all(v));
    
    vi nw;
    nw.push_back(v[0]);
    for(int i=1;i<n;i++){
        nw.push_back(v[i]);
        nw.push_back(v[i]);
    }
    
    int cnt=0;
    for(int i=0;i<n-1;i++){
        cnt+=nw[i];
    }
    cout<<cnt;
}

Measured memory_bytes: 8992
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var b = 0
    var w = s.filter { it == '.' }.count()

    var ans = w

    for (i in (0 until n)) {
        if (s[i] == '#') {
            b++
        } else {
            w--
        }
        ans = Math.min(ans, b + w)
    }

    println(ans)
}

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

using namespace std;
using ll = long long;

int main() {
    int a,b,c = 0;
    cin >> a >> b >> c;

    if((a == b && b == c) || (a != b && b != c && a != c)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}

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

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

constexpr ll inf = 1e18;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    for(auto& aa : a) cin >> aa;

    vector<map<ll, int>> dp(n + 1);
    vector<map<ll, pair<ll, int>>> pre(n + 1);
    dp[0][-inf] = 0;
    for(int i = 0; i < n; ++i) {
        ll sum = 0;
        for(int j = i + 1; j <= n; ++j) {
            sum += a[j - 1];
            auto it = dp[i].lower_bound(sum);
            if(it == dp[i].begin()) continue;
            it = prev(it);
            { // update
                auto nit = dp[j].lower_bound(sum);
                while(nit != end(dp[j]) && nit->second <= it->second + 1) {
                    pre[j].erase(nit->first);
                    nit = dp[j].erase(nit);
                }
                if(nit == begin(dp[j]) || prev(nit)->second < it->second + 1) {
                    dp[j][sum] = it->second + 1;
                    pre[j][sum] = {it->first, i};
                }
            }
        }
    }

    int max_len = 0;
    ll cur_sum = 0, cur_idx = n;
    for(auto const& p : dp[n]) {
        if(max_len < p.second) {
            max_len = p.second;
            cur_sum = p.first;
        }
    }
    vector<int> ans;
    while(pre[cur_idx].count(cur_sum)) {
        const auto p = pre[cur_idx][cur_sum];
        ans.push_back(p.second);
        cur_sum = p.first, cur_idx = p.second;
    }
    ans.pop_back();
    reverse(begin(ans), end(ans));

    cout << ans.size() + 1 << endl;
    for(int i = 0; i < (int)ans.size(); ++i) {
        cout << ans[i] << " \n"[i + 1 == (int)ans.size()];
    }
}



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

int main(void) {
  int n;
  cin >> n;
  vector<int> as(n);
  for (int &a : as) cin >> a;

  int xsum = as[0];
  for (int i = 1; i < n; i++) {
    xsum ^= as[i];
  }

  cout << (xsum ^ as[0]);
  for (int i = 1; i < n; i++) {
    cout << " " << (xsum ^ as[i]);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4052
# vim: fileencoding=utf-8


def main():
    n = int(input())
    li = list(map(int, input().split()))
    res = 0
    li = li + li
    li.sort()
    tmp = int(len(li) / 2)
    print(sum(li[-tmp:-1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 104920
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Array.Sort(ai);
            Console.WriteLine(ai[2] - ai[0]);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

vector<pil> G[100010];
int flag;
lint x;
pil p[100010];
lint num[100010];

void dfs(int v, int prev, int sig, lint val){
    if(p[v].fi){
        if(sig == p[v].fi){
            if(p[v].se != val) flag = 2;
            return;
        }
        lint tmp = 0;
        if(sig < 0) tmp = val - p[v].se;
        else tmp = p[v].se - val;
        if(tmp <= 0 || tmp % 2){
            flag = 2;
            return;
        }
        flag = 1;
        x = tmp / 2;
        return;
    }
    p[v] = make_pair(sig, val);
    for(pil e: G[v])if(e.fi != prev){
        dfs(e.fi, v, -sig, e.se - val);
        if(flag > 0) return;
    }
}

bool check_dfs(int v, int prev, lint y){
    if(num[v]) return num[v] == y;
    num[v] = y;
    if(y <= 0) return false;
    bool ret = true;
    for(pil e: G[v])if(e.fi != prev){
        ret &= check_dfs(e.fi, v, e.se - y);
    }
    return ret;
}

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    rep(i, m){
        int u, v;
        lint s;
        scanf("%d%d%lld", &u, &v, &s);
        G[--u].emplace_back(--v, s);
        G[v].emplace_back(u, s);
    }
    flag = 0;
    x = 0;
    rep(i, n) p[i] = make_pair(0, 0);
    dfs(0, -1, 1, 0);
    if(flag == 2){
        printf("0\n");
        return 0;
    }
    if(flag == 1){
        rep(i, n) num[i] = 0;
        printf("%d\n", check_dfs(0, -1, x) ? 1 : 0);
        return 0;
    }
    lint l = -1e18;
    lint r = 1e18;
    rep(i, n){
        if(p[i].fi > 0) l = max(l, 1 - p[i].se);
        else r = min(r, p[i].se);
    }
    printf("%lld\n", max(0ll, r - l));
}

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

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

bool cmp1(PII p1, PII p2) {
	if (p1.first < p2.first) return true;
	if (p1.first > p2.first) return false;
	return p1.second < p2.second;
}

bool cmp2(PII p1, PII p2) {
	if (p1.first > p2.first) return true;
	if (p1.first < p2.first) return false;
	return p1.second > p2.second;
}

ll mul(PII p1, PII p2, PII o) {
	return 1LL * (p1.first - o.first) * (p2.second - o.second) - 1LL * (p2.first - o.first) * (p1.second - o.second);
}

vector<PII> getHalf(vector<PII> &p) {
	vector<PII> res;
	res.push_back(p.front());
	for (int i = 1; i < p.size(); i++) {
		while (res.size() > 1 && mul(res[res.size() - 1], p[i], res[res.size() - 2]) <= 0) res.pop_back();
		res.push_back(p[i]);
	}
	return res;
}

vector<PII> getConvex(vector<PII> &p) {
	sort(p.begin(), p.end(), cmp1);
	vector<PII> res = getHalf(p);
	res.pop_back();
	sort(p.begin(), p.end(), cmp2);
	vector<PII> h = getHalf(p);
	h.pop_back();
	for (int i = 0; i < h.size(); i++) {
		res.push_back(h[i]);
	}
	return res;
}

int main() {
	vector<PII> p;
	p.push_back(make_pair(0, 0));
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		vector<PII> np;
		for (auto e: p) {
			np.push_back(e);
			np.push_back(make_pair(e.first + x, e.second + y));
		}
		p = getConvex(np);
		// for (auto e: p) {
		// 	cout << e.first << " " << e.second << endl;
		// }
		// cout << endl;
	}
	ll ans = 0;
	for (auto e: p) {
		ans = max(1LL * e.first * e.first + 1LL * e.second * e.second, ans);
	}
	cout << setprecision(15) << sqrt(ans) << endl;
	return 0;
}

Measured memory_bytes: 256