akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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

int main() {
    string s; cin >> s;
    ll l = 0, r = sz(s)-1;
    ll cnt = 0;
    while(l < r){
        if(s[l] == s[r]){
            l++;
            r--;
        }else if(s[l] == 'x' && s[r] != 'x'){
            l++;
            cnt++;
        }else if(s[l] != 'x' && s[r] == 'x'){
            r--;
            cnt++;
        }else {
            co(-1);
            return 0;
        }
    }
    co(cnt);

    return 0;
}




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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    int n;
    cin>>n;
    map<long long,long long>mp;
    long long ans=0;
    rep(i,n){
        long long a;
        cin>>a;
        ans+=a;
        mp[a]++;
    }
    int q;
    cin>>q;
    rep(i,q){
        long long  b,c;
        cin>>b>>c;
        auto it=mp.find(b);
        if(it==mp.end()){
            cout<<ans<<endl;
            continue;
        }
        long long num=it->second;
        ans-=b*num;
        ans+=c*num;
        mp.erase(b);
        if(mp.find(c)==mp.end()){
            mp.insert(make_pair(c,num));
        }
        else{
            mp[c]+=num;
        }
        cout<<ans<<endl;
    }
    return 0;

}
/*


*/


Measured memory_bytes: 7444
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    while(true) {
      int n = scan.nextInt();
      int q = scan.nextInt();
      if((n|q) == 0) return;
      Node[] nodes = new Node[n];
      nodes[0] = new Node();
      nodes[0].mark = true;
      nodes[0].num = 0;
      for(int i = 1; i < n; i++) {
        nodes[i] = new Node();
        nodes[i].num = i;
      }
      for(int i = 1; i < n; i++) {
        nodes[scan.nextInt()-1].setChild(nodes[i]);
      }
      long result = 0;
      for(int i = 0; i < q; i++) {
        switch(scan.next()) {
          case "Q":
            result += (long)(nodes[scan.nextInt()-1].saiki()+1);
            break;
          case "M":
            nodes[scan.nextInt()-1].mark = true;
            break;
        }
      }
      System.out.println(result);
    }
  }
}

class Node{
  Node parent;
  boolean mark;
  int num;
  Node() {
  }
  void setChild(Node _node) {
    _node.parent = this;
  }
  int saiki() {
    return (mark)?num:parent.saiki();
  }
}

Measured memory_bytes: 294596
n=int(input())
S=input()

ans=0
for i in range(1,n+1):
  X=S[:i]
  Y=S[i:]
  tmp=[]
  for x in X:
    if x in Y:
      tmp.append(x)
  ans=max(ans,len(list(set(tmp))))
print(ans)

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

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

  cin >> n >> k;
  for (int i = 0; i < k; i++){
    int a, b;
    cin >> a >> b;

    int res = min(min(a, n - a + 1), min(b, n - b + 1));
    if (res % 3 == 0) res = 3;
    else res %= 3;

    cout << res << endl;
  }
}

Measured memory_bytes: 3136
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var c = cin.next();

            var cc = (int)c.ToCharArray()[0] + 1;
            Console.WriteLine((char)cc);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

template< typename T,char start='a',int csize=26 >
struct Trie{
    const int NONE = -1;
    struct Node{
        vector<int> nxt;
        vector<int> acs;
        T prefsum;
        const int NONE = -1;
        Node(){
            prefsum=0;
            nxt.resize(csize,NONE);
        }
    };

    vector<Node> nodes;

    Trie(){
        nodes.push_back(Node());
    }

    void accept(int noid,int id,T v){
        nodes[noid].acs.push_back(id);
        nodes[noid].prefsum+=v;
    }

    void update(int noid,T v){
        nodes[noid].prefsum+=v;
    }

    void add(const string &S,int stid,int noid,int id,T v){
        if(stid==S.size()){
            accept(noid,id,v);
        }else{
            int c=S[stid]-start;
            if(nodes[noid].nxt[c]==NONE){
                nodes[noid].nxt[c]=(int)nodes.size();
                nodes.push_back(Node());
            }
            update(noid,v);
            add(S,stid+1,nodes[noid].nxt[c],id,v);
        }
    }

    void add(const string &S,int id,T v=1){
        add(S,0,0,id,v);
    }

    int find(const string &S){
        int noid=0;
        for(int i=0;i<S.size();++i){
            int c=S[i]-start;
            if(nodes[noid].nxt[c]==NONE) return NONE;
            noid=nodes[noid].nxt[c];
        }
        return noid;
    }

    void solve(ll L){
        ll ans=0;
        int n=nodes.size();
        vector<int> depth(n,0);
        for(int i=0;i<nodes.size();i++){
            int res=0;
            rep(j,csize){
                if(nodes[i].nxt[j]==NONE) res++;
                else depth[nodes[i].nxt[j]]=depth[i]+1;
            }

            if(res==1){
                int num=0;
                ll now=(L-depth[i]);
                while(now%2==0){
                    now/=2;
                    num++;
                }
                ans^=(1ll<<num);
            }
        }

        if(ans==0) cout<<"Bob"<<endl;
        else cout<<"Alice"<<endl;
    }
};

int main(){
  int N;
  ll L;
  cin>>N>>L;
  vector<string> S(N);
  rep(i,N) cin>>S[i];

  Trie<int,'0',2> trie;
  rep(i,N) trie.add(S[i],i);

  trie.solve(L);
  /*int xo[100]={};
  for(int i=1;i<=100;i++){
      if(i%2) xo[i]=1;
      else{
          int res=0;
          int val[100]={};
          for(int j=i;j>=1;j--){
              res^=xo[j];
              val[res]=1;
          }
          for(int j=0;j<=100;j++){
              if(val[j]==0){
                  xo[i]=j;
                  break;
              }
          }
      }
      cout<<i<<" "<<xo[i]<<endl;
  }*/

  return 0;
}


Measured memory_bytes: 14284
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii> 
using vec = vector<T>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

using bst = bitset<10>;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    vec<bst> v(m, bst(0));
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int s;
            cin >> s;
            v[i].set(s - 1);
        }
    }
    vii p(m);
    for (auto &e : p) {
        cin >> e;
    }
    int res = 0;
    for (int i = 0; i < (1 << n); i++) {
        int cnt = 0;
        for (int j = 0; j < m; j++) {
            bst b(i);
            b &= v[j];
            cnt += ((b.count() ^ p[j]) & 1) == 0;
        }
        if (cnt == m) res++;
    }
    cout << res << '\n';
}

Measured memory_bytes: 256
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

int bubbleSort(int a[], int n) 
{
	int cnt = 0;
	bool flag = 1;
	for (int i = 0; flag; i++)
	{
		flag = 0;
		for (int j = n - 1; j > i; j--)
		{
			if (a[j] < a[j - 1])
			{
				swap(a[j], a[j - 1]);
				flag = 1;
				cnt++;
			}
		}
	}
	return cnt;
}

int main()
{
	int cnt = 0;
	int a[100], n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cnt=bubbleSort(a, n);
	for (int i = 0; i < n; i++)
	{
		if (i)
		{
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl << cnt << endl;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    string s1 = s.substr(0,2), s2 = s.substr(2);
    int a = stoi(s1), b = stoi(s2);
    if(a > 0 && a < 13 && b > 0 && b < 13){
        cout << "AMBIGUOUS" << endl;
    }else if(a > 0 && a < 13){
        cout << "MMYY" << endl;
    }else if(b > 0 && b < 13){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())
v = list(map(int, input().split()))

odd = [v[2 * i] for i in range(N // 2)]
even = [v[2 * i + 1] for i in range(N // 2)]

# print(odd, even)

odd_dict = sorted(collections.Counter(odd).items(), key=lambda x: x[1])[::-1]
even_dict = sorted(collections.Counter(even).items(), key=lambda x: x[1])[::-1]

# print(odd_dict)
# print(even_dict)

if odd_dict[0][0] != even_dict[0][0]:
    odd_sum = N // 2 - odd_dict[0][1]
    even_sum = N//2 - even_dict[0][1]
    # print(odd_sum)
    # print(even_sum)
    print(odd_sum + even_sum)

else:
    odd_len = len(odd_dict)
    even_len = len(even_dict)

    if (odd_len == 1) and (even_len == 1):
        print(N//2)
    elif (odd_len == 1) and (even_len != 1):
        even_val, even_sec_val = even_dict[0][1], even_dict[1][1]
        print(N//2 - even_sec_val)

    elif (odd_len != 1) and (even_len == 1):
        odd_val, odd_sec_val = odd_dict[0][1], odd_dict[1][1]
        print(N // 2 - odd_sec_val)

    else:
        odd_val, odd_sec_val = odd_dict[0][1], odd_dict[1][1]
        even_val, even_sec_val = even_dict[0][1], even_dict[1][1]
        print(min(N - odd_val - even_sec_val, N - odd_sec_val - even_val))


Measured memory_bytes: 21204
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);
    if b % a == 0 {
        p(a + b);
    } else {
        p(b - a);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  repp(i, A, B) {
    string S = to_string(i);
    int N = S.size();

    bool ok = true;
    rep(i, N) {
      if (S[i] != S[N - 1 - i]) ok = false;
    }

    if (ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

ll C[51][51];
void comb_table(int N){
	rep(i,0,N+1){
		rep(j,0,i+1){
			if(j==0||j==i)C[i][j]=1LL;
			else C[i][j]=(C[i-1][j-1]+C[i-1][j]);
		}
	}
}

int main(){
	int n,a,b;
	double ave=0.0;
	vector<ll> v(55);
	cin>>n>>a>>b;
	rep(i,0,n)cin>>v[i];
	comb_table(n);
	sort(ALL(v),greater<ll>());
	rep(i,0,a)ave+=v[i];
	ave/=a;
	//v[a-1]と同じ値を持つ数の個数をl,
	//大きい方から,v[a-1]を使った個数をcur_lとする.
	int l=0,cur_l=0;
	rep(i,0,n){
		if(v[i]==v[a-1]){
			l++;
			if(i<a)
				cur_l++;
		}
	}
	ll cnt=0;
	//大きい方から並べてa個までの数が全て同じ時.
	if(cur_l==a)
		rep(i,a,b+1)cnt+=C[l][i];
	//そうでないとき(最後に使った文字の総数)C(最後に使った文字の使った文字数);
	else cnt+=C[l][cur_l];
	cout.precision(20);
	cout<<fixed<<ave<<endl;
	cout<<cnt<<endl;;
}

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

int count(int n,int x){
	int cnt = 0;
	for( int i = 1; i <= n-2 ;i++){
		for( int j = 1+i; j <= n-1 ; j++){
			for( int k = j+1 ; k <= n ; k++){
				if ( i + j + k == x) cnt++;
			}
		}
	}
	return cnt;
}

int main(){
	int n, x;

	while(1){
		cin >> n >> x;
		if( n == 0 && x == 0) break;
		cout << count(n, x) << endl;
	}

	return 0;
}

Measured memory_bytes: 3064
while True:
	try:
		line=list(map(str,input()))
		string=""
		for i in range(len(line)):
			if (line[i]!='@' and line[i-1]!='@' and line[i-2]!='@'):
				string+=line[i]
			elif line[i]=='@':
				string+=line[i+2]*int(line[i+1])
			else:
				pass
		print(string)
	except EOFError:
		break
		
				

Measured memory_bytes: 7592
#include<iostream>
	using namespace std;
	#define fo(i,n) for(int i=0;i<n;i++)
	#define pb push_back
	#define mp map<int,int>
	#define ump unordered_map<int,int>
	#define vi vector<int>
	#define M INT_MAX
	#define MI INT_MIN
	#define ll long long int
	#define pii pair<int,int>
	#define F first
	#define S second
	#define fall(i,a,b) for(int i=a;i<b;i++)
	#define pi 3.1415926535
	#include<map>
	void solve()
	{
			int n;
			cin>>n;
			map<int,int> m1;
			for(int i=1;i<=n;i++)m1[i]=0;
			fo(i,n-1)
			{
				int x;
				cin>>x;
				m1[x]++;
			}
			for(int i=1;i<=n;i++)
			cout<<m1[i]<<endl;
	}
	int main()
	{
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
		solve();
	}

Measured memory_bytes: 13024
using System;

class Program
{
    static void Main(string[] args)
    {
        string Sa = Console.ReadLine();
        string Sb = Console.ReadLine();
        string Sc = Console.ReadLine();

        string Next = "a";
        string Winner = "";

        for (; Winner == "";)
        {
            switch (Next)
            {
                case "a":
                    if (Sa.Length == 1)
                    {
                        Winner = "A";
                        break;
                    }
                    Next = Sa.Substring(0, 1);
                    Sa = Sa.Substring(1);
                    break;
                case "b":
                    if (Sb.Length == 1)
                    {
                        Winner = "B";
                        break;
                    }
                    Next = Sb.Substring(0, 1);
                    Sb = Sb.Substring(1);
                    break;
                case "c":
                    if (Sc.Length == 1)
                    {
                        Winner = "C";
                        break;
                    }
                    Next = Sc.Substring(0, 1);
                    Sc = Sc.Substring(1);
                    break;
            }
        }
        Console.WriteLine(Winner);
    }
}

Measured memory_bytes: 2648
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;


int main(void) {
    int h, n;
    cin >> h >> n;
    int a[n], sum = 0;
    rep (i, n) {
        cin >> a[i];
        sum += a[i];
    }
    
    cout << (sum >= h ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

string fie[200]={};


int main(){
    int h,w;
    while(cin>>h>>w){
        if(w==0 && h==0)break;

        rep(i,h){
            cin>>fie[i];
        }

        int y=0,x=0;

        int c=0;
        while(c<1000000){
            c++;
            char ch = fie[y][x];
            if(ch=='>'){
                x++;
            }else if(ch=='<'){
                x--;
            }else if(ch=='^'){
                y--;
            }else if(ch=='v'){
                y++;
            }else break;
        }
        if(c==1000000)cout<<"LOOP"<<endl;
        else cout<<x<<" "<<y<<endl;
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i=0; i<N; i++){
    cin >> num.at(i);
  } 
  sort(num.begin(),num.end());
  cout << num.at(N-1) - num.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> intint;

int f(int n){
    if(n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}

int main(void)
{
    int s;
    cin >> s;
    vector<int> v;  
    v.push_back(s);
    REP(i, 1000000){
        int fi = f(v[i]);
        if(find(ALL(v), fi) != v.end()){
            cout << i + 2 << endl;
            return 0;
        }
        v.push_back(fi);
    }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
p = list(map(lambda x: x-1, map(int, input().split())))

follow = [i for i in range(n)]
num = [1]*n
def root_index_of(x):
    r = x
    while follow[r] != r:
        r = follow[r]
    return r

def connected(x, y):
    return root_index_of(x) == root_index_of(y)

def connect(x, y):
    rx = root_index_of(x)
    ry = root_index_of(y)

    if rx == ry:
        return

    if num[rx] < num[ry]:
        follow[rx] = ry
        follow[x] = ry
        num[ry] += num[rx]
    else:
        follow[ry] = rx
        follow[y] = rx
        num[rx] += num[ry]

for i in range(m):
    x, y = map(lambda x: x-1, map(int, input().split()))
    connect(p[x], p[y])

ans = 0
for i in range(n):
    if connected(i, p[i]):
        ans += 1
print(ans)


Measured memory_bytes: 13812
package main

import (
	"fmt"
)

// バブルソート
func main() {

	var num int
	// fmt.Scanは自動で空白区切で読み込む
	fmt.Scan(&num)
	nums := make([]int, num)
	for i := range nums {
		fmt.Scan(&nums[i])
	}

	insertSort(nums)
}

func insertSort(nums []int) {
	var count int
	for i := 0; i < len(nums)-1; i++ {
		for j := len(nums) - 1; j > i; j-- {
			if nums[j] < nums[j-1] {
				tmp := nums[j]
				nums[j] = nums[j-1]
				nums[j-1] = tmp
				count++
			}
		}
	}
	output(nums, count)
}

func output(nums []int, count int) {
	for k := 0; k < len(nums); k++ {
		if k != len(nums)-1 {
			fmt.Print(nums[k], " ")
		} else {
			fmt.Println(nums[k])
		}
	}
	fmt.Println(count)
}



Measured memory_bytes: 1132
#include<iostream>
#include<string>
using namespace std;
 
 
int main()
{
  string N;
  cin >> N;
 
  for(int i=0;i<3;i++)
  {    
    if(N[i]=='7')
    {
      cout << "Yes";
      return 0;
    }
  }
 
  cout << "No";
 return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskA {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		string s;
		cin >> s;
		if(s == "RRR") {
			cout << 3 << endl;
			return;
		}
		if(s == "RRS" || s == "SRR") {
			cout << 2 << endl;
			return;
		}
		if(s == "SSS") {
			cout << 0 << endl;
			return;
		}
		cout << 1 << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {
	int i, j, n[5], tmp;
	for (i=0; i<5; i++) scanf ("%d", &n[i]);
	for (i=4; i>=0; i--){
		for (j=0; j<i; j++){
			if (n[j] < n[j+1]){
				tmp = n[j];
				n[j] = n[j+1];
				n[j+1] = tmp;
			}
		}
	}
	for (i=0; i<4; i++) printf ("%d ", n[i]);
	printf ("%d\n", n[4]);
	return 0;
}

Measured memory_bytes: 0
n=int(input())
num=[]
ans=""
for i in range(1000):
    if n%26!=0:
        num.append(n%26)
        n=n//26
    else:
        num.append(26)
        n=n//26-1
    if n==0:
        break
for i in range(len(num)):
    num1=96+num[-1-i]
    ans+=chr(num1)
print(ans)


Measured memory_bytes: 9180
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template<class S,class T>
string to_string(pair<S,T> p){
	return "{"+to_string(p.first)+","+to_string(p.second)+"}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
	ll N,W;
	cin>>N>>W;
	vector<ll> w(N),v(N);
	FOR(i,N)cin>>w[i]>>v[i];
	const int MX=500000;
	vector<vector<ll>> dp(N+1,vector<ll>(MX+1,1LL<<50));
	dp[0][0]=0;
	FOR(i,N){
		FOR(j,MX){
			dp[i+1][j]=min(dp[i][j],j>=v[i]?dp[i][j-v[i]]+w[i]:dp[i][j]);
		}
	}
	int ans=0;
	FOR(i,MX){
		if(dp[N][i]<=W)ans=i;
	}
	print(ans);
  return 0;
}


Measured memory_bytes: 398976
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var dice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var tmp = 0;

            var ops = Console.ReadLine();
            foreach(var c in ops)
            {
                switch(c)
                {
                    case 'N':
                        tmp = dice[0];
                        dice[0] = dice[1];
                        dice[1] = dice[5];
                        dice[5] = dice[4];
                        dice[4] = tmp;
                        break;
                    case 'E':
                        tmp = dice[0];
                        dice[0] = dice[3];
                        dice[3] = dice[5];
                        dice[5] = dice[2];
                        dice[2] = tmp;
                        break;
                    case 'S':
                        tmp = dice[0];
                        dice[0] = dice[4];
                        dice[4] = dice[5];
                        dice[5] = dice[1];
                        dice[1] = tmp;
                        break;
                    case 'W':
                        tmp = dice[0];
                        dice[0] = dice[2];
                        dice[2] = dice[5];
                        dice[5] = dice[3];
                        dice[3] = tmp;
                        break;
                }
            }
            Console.WriteLine(dice[0]);
        }
    }
}


Measured memory_bytes: 18464
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define inf 1000000007
using namespace std;
signed main(){
	string s;
	cin>>s;
	set<char> moji;
	vector<int> cut;
	cut.pb(s.size());
	for(int i=s.size()-1;i>=0;i--){
		moji.insert( s[i] );
		if(moji.size() == 26){
			moji.clear();
			cut.pb(i);
		}
	}
	moji.clear();
	reverse(cut.begin(),cut.end());
	string str = "";
	int cur = 0;
	for(int i=0;i<cut.size();i++){
		moji.clear();
		char ta;
		for(int j=cur;j<cut[i];j++){
			moji.insert(s[j]);
		}
		for(int j=0;j<26;j++){
			if( moji.find( 'a' + j) == moji.end()){
				str.pb('a'+j);
				ta = 'a' + j;
				j = 26;
			}
		}
		cur = cut[i]+1;
		while( s[cur-1] != ta && cur<s.size()-1){ cur++; }
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> connect(n,vector<int>(n));
    rep(i,0,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        connect[a][b] = 1;
        connect[b][a] = 1;
    }

    int array[n];
    rep(i,0,n){
        array[i]=i;
    }
    int cnt=0;

    do {
        if(array[0]!=0){
            break;
        }
        int check=0;
        rep(i,0,n-1){
            int a = array[i];
            int b = array[i+1];
            if(connect[a][b]!=1){
                check=1;
            }
        }
        if(check==0){
            cnt++;
        }
    }while (next_permutation(array, array+n));

    cout<<cnt<<endl;

    return 0;
}

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

using namespace std;
using ll =long long;

static const int inf = (1<<21);
static const int white = 0;
static const int gray =  1;
static const int black = 2;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int n, M[110][110];

void dijkstra(){ 
	int minv;
	int d[110], color[110];

	for (int i = 0; i < n; i++) {
		d[i] = inf;
		color[i] = white;
	}

	d[0] = 0;
	color[0] = gray;
	while(1) {
		minv = inf;
		int u = -1;
		for (int i = 0; i < n; i++){
			if (minv > d[i] && color[i] != black){
				u = i;
				minv = d[i];
			}
		}
		if (u == -1) break;
		color[u] = black;
		for (int v = 0; v < n; v++){
			if (color[v] != black && M[u][v] != inf){
				chmin(d[v],d[u]+M[u][v]);
				color[v] = gray;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] ==inf ? -1 : d[i]) << endl;
	}
}

int main()
{
	cin >> n;
	rep(i,110){
		rep(j,110){
			M[i][j] = inf;
		}
	}
	rep(i,n){
		int u, k;
		cin >> u >> k;
		rep(j,k){
			int a, b;
			cin >> a >> b;
			M[u][a] = b;
		}
	}
	dijkstra();
	return 0;
}



Measured memory_bytes: 3144
t = input()
l = len(t)
a = []
b = ""
for i in range(l):
    a.append(t[i])
if a[-1] == "?":
    a[-1] = "D"
for i in range(1, l):
    if a[-i-1] == "?":
        a[-i-1] = "D"
for i in range(l):
    b += a[i]
print(b)

Measured memory_bytes: 10964
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long LL;
const int Inf = 1 << 30;

int main()
{
	int num[5];
	for(int i = 1;i <= 3;i++)
		scanf("%d", num+i);
	int ans = Inf;
	do
	{
		ans = min(ans, abs(num[2]-num[1])+abs(num[3]-num[2]));
	}while(next_permutation(num+1,num+4));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int N = 300 + 10;

char s[N][N];
int label[N][N];

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') label[i][j] = k--;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      if (!label[i][j] && label[i][j - 1]) label[i][j] = label[i][j - 1];
    }
    for (int j = m - 2; j >= 0; --j) {
      if (!label[i][j] && label[i][j + 1]) label[i][j] = label[i][j + 1];
    }
  }
  for (int j = 0; j < m; ++j) {
    for (int i = 1; i < n; ++i) {
      if (!label[i][j] && label[i - 1][j]) label[i][j] = label[i - 1][j];
    }
    for (int i = n - 2; i >= 0; --i) {
      if (!label[i][j] && label[i + 1][j]) label[i][j] = label[i + 1][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (j) putchar(' ');
      printf("%d", label[i][j]);
    }
    puts("");
  }
  return 0;
}


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

int c[10][10];

int main(void){
	int N;
	cin >> N;
	string s, s_f, s_e;
	int f,e;
	for(int i = 1;i <= N; ++i){
		s = to_string(i);
		s_f = s[0];
		s_e = s.back();
		f = stoi(s_f);
		e = stoi(s_e);
		++c[f][e];
	}
	int ans = 0;
	for(int i = 0; i < 10; ++i){
		for(int j = 0; j < 10; ++j){
			//cout << "plus " << (c[i][j] * c[j][i]) << endl;
			ans += c[i][j] * c[j][i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int nakazimamegumi(int asumikana, int mizuhasikaori) {
	return asumikana < mizuhasikaori ? asumikana : mizuhasikaori;
}

int main(void) {
	int A, B, C, D;
	if (scanf("%d", &A) != 1) return 1;
	if (scanf("%d", &B) != 1) return 1;
	if (scanf("%d", &C) != 1) return 1;
	if (scanf("%d", &D) != 1) return 1;
	printf("%d\n", nakazimamegumi(A, B) + nakazimamegumi(C, D));
	return 0;
}


Measured memory_bytes: 256
N  =int(input())
la = list(map(int,input().split()))
ans = 1
if N == 0:
    print(0)
    exit()
if 0 in la:
    print(0)
    exit()
for i in la:
    if ans > 10**18:
        print("-1")
        exit()
    else:
        ans = ans*i
 
if ans > 10**18:
    print("-1")
else:
    print(ans)

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

int main()
{
    string s, t;
    cin >> s >> t;
    int z = 0;
    int ans = 2000;
    for(int i = 0; i < s.size() - t.size() + 1; i++)
    {
        int ss = t.size();
        z = 0;
        for(int k = i; k < t.size() + i; k++)
        {
            if(s[k] == t[z])
                ss--;
            z++;
        }
        ans = min(ss, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

// Please name your class Main
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
	    		Scanner in = new Scanner(System.in);

	   int n = in.nextInt();
	   
	   List<Integer> l = new ArrayList<>();
	   
	   for(int i=0; i<n; i++) {
		   l.add(in.nextInt());
	   }
	    
	   
	   Collections.sort(l);
	   
	   long cur = 0;
	   int left = 0;
	   
	   for(int i=0; i<n-1; i++) {
		   
		   cur += l.get(i);
		   
		   if(cur * 2 < l.get(i+1)) {
			   left = i+1;
		   }
	   }
	   
	   System.out.println(n - left);
	}
}

Measured memory_bytes: 61124
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"No"<<endl;return 0;}
//template
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(1e6),Finverse(1e6);
void Cinit(){
  Factorial[0]=1;
  for(int i=1;i<1e6;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<1e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 1;if(k<0)return 0;
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}
//main
signed main(){
  int N,K;cin>>N>>K;Cinit();
  for(int i=1;i<=K;i++){
    int ans=nCk(K-1,i-1)*nCk(N-K+1,i);
    ans%=MOD;
    if(N-K-(i-1)<0)cout<<0<<endl;
    else cout<<ans<<endl;
  }
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main(){
  int N; cin >> N;
  vector<double> p(N);
  rep(i, N) cin >> p[i];
  vector<vector<double>> dp(N + 1, vector<double>(N + 1,0));
  dp[0][0] = 1;
  rep(i, N) {
    rep(j, i + 1) {
      dp[i + 1][j] += dp[i][j] * (1 - p[i]);
      dp[i + 1][j + 1] += dp[i][j] * p[i];
    }
  }
  double ans = 0;
  for (int i = (N / 2) + 1; i <= N; i++) {
    ans += dp[N][i];
  }
  cout << fixed << setprecision(10) << ans << endl; 
}

Measured memory_bytes: 73812
n,k,q = map(int,input().split())
l= [int(input()) for i in range(q)]
x=[k-q]*n
for i in range(q):
  x[l[i]-1]+=1
for i in range(n):
  if x[i]>0: 
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 10472
/*      ###########################
            #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007  
#define endl '\n'
#define INF 1e18L+1
#define mp make_pair
#define pb push_back
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
using namespace std;
template<class T> T max(T a, T b, T c) {
    return max(a, max(b, c));
}
template<class T> T min(T a, T b, T c) {
    return min(a, min(b, c));
}
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
            freopen("error.txt","w",stderr);
    #endif
}
bool prime[100005];
void SieveOfEratosthenes(ll n)//O(nloglogn) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
bool isPrime(ll n)//O(sqrt(n))
{
    if(n<2)
        return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
std::vector<ll> factors(ll n)//O(sqrt(n))
{
    std::vector<ll> f;
    for(ll i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            f.push_back(i);
            n = n/i;
        }
    }
    if(n>1) f.push_back(n);
    return f;
}
ll gcd(ll a,ll b)//O(logn)
{
    return b==0?a:gcd(b,a%b);
}
ll modpow(ll x,ll n,ll m)//O(logn)// used for calculating (x^n)%m
{
    if(n==0) return 1%m;
    ll u = modpow(x,n/2,m);
    u = (u%m * u%m)%m;
    if(n%2==1)
        u = (u%m * x%m)%m;
    return u%m;
}
ll eulerstotientfunction(ll n)//O(sqrt(n))
{
    ll ans = n;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                n = n/i;
            ans -= ans/i;
        }
    }
    if(n>1)
        ans -= ans/n;
    return ans;
}
ll modinverse(ll x,ll m)//O(logn)
{
    // ll temp = eulerstotientfunction(m);
    return modpow(x,m-2,m);
}
ll ncr(ll n,ll k)
{
    ll res = 1;
    k = min(k,n-k);
    for(ll i=0;i<k;i++)
    {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
} 
int main()
{
    //fastio();
    ll n;
    cin >> n;
    ll a[n+1],b[n];
    for(ll i=0;i<=n;i++)
        cin >> a[i];
    for(ll i=0;i<n;i++)
        cin >> b[i];
    ll ans = 0;
    for(ll i=n-1;i>=0;i--)
    {
        ans += min(a[i+1],b[i]);
        ll a1 = b[i];
        b[i] -= min(b[i],a[i+1]);
        a[i+1] -= min(a1,a[i+1]);
        ans+=min(a[i],b[i]);
        a1 = b[i];
        b[i] -= min(a[i],b[i]);
        a[i] -= min(a1,a[i]);
    }
    // for(ll i=0;i<=n;i++)
    //     cout << a[i] << " ";
    // cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,m;
 	cin >> n>>m;
 	priority_queue<ll> x;
 	for (int i = 0; i < n; i++){
 		ll y;
 		cin >> y;
 		x.push(y);
 	}
 	for (int i = 0; i < m; i++){
 		ll y=x.top()/2;
 		x.pop();
 		x.push(y);
 	}
 	ll ans=0;
 	for (int i = 0; i < n; i++){
 		ans+=x.top();
 		x.pop();
 	}
 	cout << ans << endl;
 }

Measured memory_bytes: 1400
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)
#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c))
#define     M             32000

ll ans[200010];
ll a[200010];
int main()
{

int n;

cin>>n;
for(int i=2;i<=n;i++) cin>>a[i];
for(int i=2;i<=n;++i) ans[a[i]]++;
for(int i=1;i<=n;i++) cout<<ans[i]<<endl;

return 0;

}


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

int main() {
    int N, R;
    cin >> N >> R;
    if(N >= 10){
        cout << R;
        return 0;
    }
    else{
        cout << R + 100 * (10 - N);
    }
}


Measured memory_bytes: 256
#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 MOD 1000000007
#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())

signed main(){

	lli n;
	cin>>n;
	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	lli now = 1;
	lli cnt=0;
	REP(i,0,n){
		if(now!=a[i])cnt++;
		else{
			now++;
		}
	}
	if(cnt==n){
		cout<<-1<<endl;
	}
	else cout<<cnt<<endl;



	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long i64;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const i64 INF_LONG = 1LL << 62;
const i64 INF_LONG_NEG = INF_LONG * -1;

int main()
{
    string S; cin >> S;
    int N = S.length();
    int num0 = 0, num1 = 0;
    for (int i = 0; i < N; ++i){
        if (S[i] == '0') ++num0;
        else ++num1;
    }

    cout << min(num0, num1) * 2 << endl;
    return 0;
}


Measured memory_bytes: 512
open System.Collections.Generic

let sortString (str:string) = new string (Array.sort (str.ToCharArray()))
let sumTotal N = N*(N-1L)/2L
let cnt = int(stdin.ReadLine())
let xs = Dictionary<string, int64>()
for _ in 0..cnt-1 do
    let s = sortString (stdin.ReadLine ())
    if (xs.ContainsKey s) then
        xs.[s] <- xs.[s] + 1L
    else
        xs.Add (s, 1L)

let mutable sum = 0L
for x in xs do
    let N = x.Value
    sum <- sum + sumTotal N

printfn "%d" sum

Measured memory_bytes: 33864
n=int(input())
word_list = ['AC','WA','TLE','RE']
A = 0
W = 0
T = 0
R = 0

for i in range(n):
    s = input()
    if s == 'AC':
        A = A + 1
    elif s == 'WA':
        W = W + 1
    elif s == 'TLE':
        T = T + 1
    else:
        R = R + 1
Ans_list = [A,W,T,R]
for i in range(4):
    print(str(word_list[i])+ ' x '+ str(Ans_list[i]))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

long double P[200010];
long double sum[200010];

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	for (ll i = 0; i < N; ++i)
	{
		long double p; cin >> p;
		P[i] =( p*(1+p)/2)/p;
	}

	sum[0] = 0.0;
	for (ll i = 0; i < N; ++i) sum[i+1] = sum[i] + P[i];

	long double res{0.0};
	for (ll i = 0; i < N-K+1; ++i)
	{
		res = max(res, sum[i+K]-sum[i]);
	}
		
	std::cout << fixed << setprecision(10) << res << std::endl;
}
 


Measured memory_bytes: 6528