akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
//change null_type here for map/set
typedef tree<int,null_type,less<int>,rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;
typedef long long int  ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define F first
#define S second

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    x*=sgn; return ~c;
}
///START HERE
///indexed_set pbd;
//pbd.insert()
//auto x = pbd.find_by_order(2);
//int od=pbd.order_of_key(7)
///rope<int> rp;
//rp.push_back()
//RandomAccess like vector
//mutable_begin, mutable_end()

int main(){
    ///read()+printf
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //fast;
    string s,t;
    cin>>s>>t;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            c++;
        }
    }
    cout<<c<<endl;


    return 0;
}


Measured memory_bytes: 3920
import sys
input = sys.stdin.readline


def main():
    n, k = input_list()
    a = set()
    c = k*2
    for i in range(c):
        num = input()
        d = input_list()
        for v in d:
            a.add(v)
    print(n-len(a))


def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


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

const int K = 20;
struct Edge {
    int u, v,w;
};
vector<Edge> edges;

void solve(int n, int id) {
    if (id == K) {
        assert(n==1);
        return;
    }
    if (n%2)   edges.push_back({id, K, --n});
    if (n==0)   return;
    edges.push_back({id, id+1, n/2});
    edges.push_back({id, id+1, 0});
    solve(n/2, id+1);
}

int main()
{
    int n;
    cin>>n;
    solve(n, 1);
    cout<<K<<" "<<edges.size()<<endl;
    for (Edge e: edges)
        cout<<e.u<<" "<<e.v<<" "<<e.w<<endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;
int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>cnt(1e6+10,0);

    for(auto x:a){
               if(cnt[x]!=0){
            cnt[x]=2;
            continue;
               }
        
            for(ll i=x;i<1e6+10;i+=x){
                cnt[i]++;

        }
    }
    ll ans=0;
    for(auto x:a){
        if(cnt[x]==1){
            //cout<<x<<" ";
            ans++;
    }
    }
    //cout<<endl;
    cout<<ans<<endl;
}














































































Measured memory_bytes: 12764
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

int u[400],v[400];
string w[400];

int main(){
    ios::sync_with_stdio(0);
    
    int n,m,s,e;
    char str[7];
    string dist[40];
    bool visited[40],change,inf;
    
    while(true){
        cin >> n >> m >> s >> e;
        
        if(n == 0) break;
        
        for(int i = 0;i < m;++i)
            cin >> u[i] >> v[i] >> w[i];
        
        memset(visited,0,sizeof visited);
        
        dist[e] = "";
        visited[e] = true;
        change = true;
        inf = false;
        
        for(int it = 0;it <= 6*n && change;++it){
            change = false;
            
            for(int i = 0;i < m;++i){
                if(visited[ v[i] ]){
                    string aux = w[i] + dist[ v[i] ];
                    
                    if(!visited[ u[i] ] || aux < dist[ u[i] ]){
                        dist[ u[i] ] = aux;
                        change = true;
                        if(it >= n - 1 && u[i] == s) inf = true;
                    }
                    
                    visited[ u[i] ] = true;
                }
            }
        }
        
        if(inf || !visited[s]) cout << "NO\n";
        else cout << dist[s].c_str() << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 1392
#include <cstdio>
#include <algorithm>

const int MN = 10005;

int N, K;
char S[MN], U;
int A[MN], V, W;
char Ans[MN];

inline void check(int p) {
	int ok = 1;
	for (int i = 1; i <= W; ++i) {
		if (Ans[i] > S[p - i + 1]) break;
		if (Ans[i] < S[p - i + 1]) { ok = 0; break; }
	}
	if (!ok) return ;
	for (int i = 1; i <= W; ++i)
		Ans[i] = S[p - i + 1];
}

int main() {
	scanf("%d%d", &N, &K);
	scanf("%s", S + 1);
	for (int i = 1; i <= N; ++i) S[N + N - i + 1] = S[i];
	S[N + N + 1] = '\0';
	U = *std::min_element(S + 1, S + N + N + 1);
	for (int i = 1; i <= N + N; ++i)
		if (S[i] == U) A[i] = A[i - 1] + 1;
		else A[i] = 0;
	V = *std::max_element(A + 1, A + N + N + 1);
	if (K >= 14 || ((N - 1) >> (K - 1)) + 1 <= V) {
		for (int i = 1; i <= N; ++i) printf("%c", U);
		return 0;
	}
	Ans[1] = 'z' + 1;
	W = N - (V << (K - 1));
	for (int i = 1; i <= N; ++i)
		if (A[N + i] == V) check(N + i - V);
	for (int i = 1; i <= (V << (K - 1)); ++i) printf("%c", U);
	printf("%s\n", Ans + 1);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = str, input()
out = "No"
N_list = list(N[1])

if N_list[0]==N_list[1] and N_list[0]==N_list[2]:
    out = "Yes"
elif N_list[1]==N_list[2] and N_list[1]==N_list[3]:
    out = "Yes"

print(out)


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

using ll = long long int;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n, k; cin >> n >> k;
	vector<int> v(n);
	for (auto &i : v)
		cin >> i;
	for (int i = k; i < n; ++i)
		if (v[i] > v[i-k]) cout << "Yes\n";
		else cout << "No\n";
}

Measured memory_bytes: 4012
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define pi 3.14159265358979323846

int main(void){
  int A,B,H,M;
  scanf("%d%d%d%d",&A,&B,&H,&M);
  double degH=(2*pi*(60*(double)H+(double)M))/720,degM=2*pi*(double)M/60;
  
  double C = sqrt((double)(A*A)+(double)(B*B)-(2*(double)A*(double)B*cos((double)degH-degM)));
  
  printf("%.20f",C);
  return 0;
}

Measured memory_bytes: 2600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define le <=
#define ge <=
int mx=9999999;
/**  '' "\n" - ^ **/
bool test(int x,int y)
{
    return (x>y?true:false);
}
class Template{
    public:
    void yes()
    {
        cout<<"Yes\n";
    }

    void no()
    {
        cout<<"No\n";
    }
    void YES()
    {
        cout<<"YES\n";
    }

    void NO()
    {
        cout<<"NO\n";
    }

    void Case(int i,int n)
    {
        cout<<"Case:"<<i<<" "<<n<<endl;
    }
    /**  '' "\n" x ^ **/
    /** printf("\n") */
};

Template root;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    string str;
    cin>>str;
    for(int i=0;i<str.length();i++)
    {
        if(i==k)
        {
            cout<<"...";
            break;
        }
        cout<<str[i];
    }
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vec<ll> a(n);
  scan(a);

  multiset<ll> s;
  for (ll num : a) {
    auto it = s.lower_bound(num);
    if (it == begin(s)) {
      s.insert(num);
      continue;
    }

    it--;
    s.erase(it);
    s.insert(num);
  }

  cout << sz(s) << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 111;

int n;

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int a,b;
	
	cin>>n>>a>>b;
	
	cout<<(abs(a-b)%2==0 ? "Alice" : "Borys")<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b[10];
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	int c=0;
	for(int i=0;i<a;i++){
		if(b[i]>c){
			c=b[i];
		}
	}
	int d=0;
	bool e=1;
	for(int i=0;i<a;i++){
		if(b[i]==c&&e==1){
			d+=b[i]/2;
			e=0;
		}
		else{
			d+=b[i];
		}
	}
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> edge;
map<pair<int, int>, int> colors;
void dfs(int v, int c, int prev, int m) {
    for (auto e: edge[v]) {
        if (e == prev) continue;
        c = (c + 1) % m;
        dfs(e, c, v, m);
        if (e < v) colors[{e, v}] = c + 1;
        else colors[{v, e}] = c + 1;
    }
}

int main() {
    int n;
    cin >> n;
    edge.assign(n, vector<int>());
    vector<pair<int, int>> ps(n-1);
    for (int i = 0; i < n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
        ps[i] = make_pair(a, b);
    }
    int k = 0;
    for (auto x: edge) k = max(k, (int)x.size());
    dfs(0, 0, -1, k);
    cout << k << endl;
    for (auto p: ps) cout << colors[p] << endl;
    return 0;
}

Measured memory_bytes: 16844
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int A, B; cin >> A >> B;
  int x = 0;
  while (true){
    if ((A-1)*x + 1 >= B) break;
    x++;
  }

  cout << x << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;

		ArrayList<Integer> list = new ArrayList<Integer>();
		
		try {
			while (null != (s = br.readLine())) {
				if (isNumber(s))
					list.add(Integer.valueOf(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		Integer[] array = list.toArray(new Integer[0]);
		Arrays.sort(array);

		System.out.println(array[9]);
		System.out.println(array[8]);
		System.out.println(array[7]);

	}

	private static boolean isNumber(String s) {

		try {
			int n = Integer.parseInt(s);
			return true;
		} catch (NumberFormatException e) {
			return false;
		}
	}
}

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

int main(){
    vector<string> inputs = {
        "Sunny", "Cloudy", "Rainy"
    };
    string s;
    cin >> s;
    rep(i,3){
        if(inputs[i] == s){
            cout << inputs[(i+1)%3] << endl;
        }
    }
    return 0;
}

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

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
const int mod = 1000000007;

ll N, A, B;

int main(){
    ios_base::sync_with_stdio(false);
	cin >> N >> A >> B;
    if(A > B) swap(A, B);
    if((B - A) % 2 == 0){
        cout << (B - A) / 2 << endl;
    }
    else{
        ll ans = A - 1 + ((B - A) + 1) / 2;
        ans = min(ans, N - B + ((B - A) + 1) / 2);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pq 	priority_queue<int, vector<int>, greater<int> >
ll e=  1000000007;
using namespace std;


int main()
{
ll n,wt,p=0;
cin>>n>>wt;
ll w[n],v[n];
for(ll i=0;i<n;i++)
{
	cin>>w[i]>>v[i];p=p+v[i];
}
ll val[p+1]={0};
for(ll i=0;i<n;i++)
{
	for(ll j=p;j>0;j--)
	{
		if(val[j]>0){
			if(val[j+v[i]]==0)val[j+v[i]]=val[j]+w[i];
	     else if((val[j]+w[i]<val[j+v[i]]))	val[j+v[i]]=val[j]+w[i];
	}}
	if(val[v[i]]==0){
	val[v[i]]=w[i];
	}
	else if(w[i]<val[v[i]]) val[v[i]]=w[i];
}
ll k;
for(ll i=p;i>=0;i--)
{
	if(val[i]>0&&val[i]<=wt){k=i;break;
	}
}
cout<<k;

	
 return 0;
}

Measured memory_bytes: 1024
(* O(2^n) *)
Scanf.scanf " %d %d" @@ fun n m ->
  let sss = Array.init m @@ fun _ ->
    let k = Scanf.scanf " %d" @@ (+) 0 in
    Array.init k @@ fun _ -> Scanf.scanf " %d" @@ fun s -> s - 1 in
  let ps = Array.init m @@ fun _ -> Scanf.scanf " %d" @@ (+) 0 in
  let array_count f = Array.fold_left (fun n x -> if f x then n + 1 else n) 0 in
  let array_for_all f xs = Array.length xs = array_count f xs in
  let is_on bits i =
    let ss = sss.(i) in
    let c = ref 0 in
    for j = 0 to Array.length ss - 1 do
      if (bits lsr ss.(j)) land 1 = 1 then incr c
    done;
    !c mod 2 = ps.(i) in
  let judge bits = array_for_all (is_on bits) @@ Array.init m @@ (+) 0 in
  let ans = ref 0 in
  for i = 0 to 1 lsl n - 1 do
    if judge i then incr ans
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/


int main(){
    _cin;
    // cout << setprecision(15);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n >> k;
    vll a(n), dp(n+1);
    fo(i,n) cin >> a[i];
    dp[0] = 0;
    // dp[1] = abs(a[1]-a[0]);
    repa(i,1,n){
        // dp[i] = min(dp[i-2] + abs(a[i]-a[i-2]), dp[i-1] + abs(a[i]-a[i-1]));
        dp[i] = MAX;
        repa(j,1,k+1){
            if(i-j>=0) dp[i] = min(dp[i], dp[i-j] + abs(a[i]-a[i-j]));
        }
    }
    // fo(i,n) cout << dp[i] << ' ';
    cout << dp[n-1];
}
 return 0;      
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))

const int maxn = 2e5 + 10;
const int inf = 0x7ffffff;
vector<int> G[maxn], rd;
int N, a[maxn];
int ans[maxn];

void dfs(int u,int p)
{
    int now = lower_bound(rd.begin(), rd.end(), a[u]) - rd.begin();
    int pop = 0, lst;
    if(now==rd.size())
    {
        pop = 1;
        rd.push_back(a[u]);
    }
    else
    {
        lst = rd[now];
        rd[now] = a[u];
    }
    ans[u] = rd.size();
    for(int v:G[u])
    {
        if(v!=p)
            dfs(v, u);
    }
    if(pop)
        rd.pop_back();
    else
        rd[now] = lst;

}
void solve()
{
    int u, v;
    cin >> N;
    for (int i = 1; i <= N;i++)
        cin >> a[i];
    for (int i = 1; i < N;i++)
    {
        cin >> u >> v;
        G[u].push_back(v), G[v].push_back(u);
    }
    dfs(1, 0);
    for (int i = 1; i <= N;i++)
        cout << ans[i] << "\n";
}

int main()
{
    //freopen("out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T-- > 0)
        solve();

}

Measured memory_bytes: 30428
#include <bits/stdc++.h>
const int maxn = int(1e5) + 7, mod = int(1e9) + 7;
int next[maxn][3], f[maxn] = {1}, sum[maxn], ans;
char str[maxn];
int main() {
    scanf("%s", str);
    int n = int(strlen(str));
    bool flag = true;
    for (int i = 1; str[i]; i++) flag &= str[i] != str[i - 1];
    if (flag) return 0 * puts("1");
    for (int i = 0; i < n; i++) sum[i + 1] = (sum[i] + 1 + (str[i] == 'b')) % 3;
    for (int i = 0; i < 3; i++) next[n][i] = n + 1;
    for (int i = n - 1; ~i; i--) for (int j = 0; j < 3; j++) next[i][j] = j == sum[i + 1] ? i + 1 : next[i + 1][j];
    for (int i = 0; i <= n; i++) {
        for (int j = 1; j <= 2; j++) if (next[i][(sum[i] + j) % 3] <= n) f[next[i][(sum[i] + j) % 3]] = (f[i] + f[next[i][(sum[i] + j) % 3]]) % mod;
        if (i > 0 && sum[i] == sum[n]) ans = (ans + f[i]) % mod;
    }
    printf("%d\n", ans);
    return 0;
}



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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] arr = new long[n];
        long ans = 0;
        for (int i = 0; i < n; ++i) {
            arr[i] = in.nextInt();
            while (arr[i] % 2 == 0) {
                arr[i] /= 2;
                ++ans;
            }
        }

        System.out.println(ans);
    }
}

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

using namespace std;

int main(){
	
	char numero[5];
	
	cin >> numero;
	
	if((numero[0] == numero[1])&&(numero[0] == numero[2])){
		cout << "Yes" << '\n';
	}
	else if((numero[1] == numero[2])&&(numero[1] == numero[3])){
		cout << "Yes" << '\n';
	}
	else{
		cout << "No" << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

data = [i for i in range(2, n+1)]

ans = 0
for a in itertools.permutations(data, n-1):
    a = [1] + list(a)
    flag = True
    for i in range(1, len(a)):
        if not ([a[i-1], a[i]] in ab or [a[i], a[i-1]] in ab):
            flag = False
            break
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC123C
{
    class Program
    {
        static void Main(string[] args)
        {
            // 人数
            long N = long.Parse(Console.ReadLine());
            long[] capacity = new long[5];
            for (int i = 0; i < 5; i++)
            {
                capacity[i]=long.Parse(Console.ReadLine());
            }
            long min = capacity.Min();
            //Console.WriteLine(min);
            long ans = (N+min-1)/min + 4L;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
 
#define TRUE 1
#define FALSE 0
 
int solve(int,int);
 
int n , A[20];
 
int solve(int i,int m){
  int res;
 
  if( m == 0 ){
    return TRUE;
  }
 
  if( i >= n ){
    return FALSE;
  }
 
  res = solve(i+1, m) || solve(i+1, m-A[i]);
 
  return res;
}
 
 
int main(){
  int q,j,m;
 
  scanf("%d",&n);
 
  for( j = 0 ; j < n ; j++ ) {
    scanf("%d",&A[j]);
  }
 
  scanf("%d",&q);
 
  for( j = 0 ; j < q ; j++) {
    scanf("%d",&m);
    if( solve( 0 , m ) == 1 ){
      printf("yes\n");
    }else printf("no\n");
  }
 
  return 0;
}

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

#define ff                   first
#define ss                   second
#define ll                   long long int
#define pii                  pair<int,int>
#define pb                   push_back
#define rep(i,a,b)           for(int i=a;i<b;i++)
#define t(x)                 int t; cin>>t; while(t--)
#define vi                   vector<int>
#define mii                  map<int,int>
#define min3(a, b, c)        min(min(a, b), c)
#define min4(a, b, c, d)     min(min(a, b), min(c, d))
#define max3(a, b, c)        max(max(a, b), c)
#define max4(a, b, c, d)     max(max(a, b), max(c, d))
#define ps(x,y)              fixed<<setprecision(y)<<x
#define setbits(x)           __builtin_popcountll(x)
#define zrobits(x)           __builtin_ctzll(x)
#define mod                  1000000007
#define all(x)               x.begin(),x.end()
#define FIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                      rng(chrono::steady_clock::now().time_since_epoch().count());

ll w, h, n;

bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 || n % 3 == 0) return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

int main()
{
    FIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0))
        cout << max((ll)0, max4(a * c, a * d, b * c, b * d));
    else
        cout << max4(a * c, a * d, b * c, b * d);

}

Measured memory_bytes: 3656
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;

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

  vint r(3);
  scan(r[0]); scan(r[1]); scan(r[2]);
  scan(n);
  sort(ALL(r));

  int cnt =0;
  int s[3];

  int m = n;
  int l;
  s[2] = n/r[2]+1;
  for(int i=0; i<s[2]; i++){
    s[1] = m/r[1]+1;
    l = m;
    for(int j=0; j<s[1]; j++){
      if(l%r[0]==0){
          cnt++;
      }
      l -= r[1];
    }
    m -= r[2];
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int a,b;
	cin>>a>>b;
	a-=2*b;
	if(a<0)
	a=0;
	cout<<a;
}
void q2(){
	int n;	cin>>n;
	int arr[n];	int s=0;
	for(int i=0;i<n;++i){
		cin>>arr[i];	s+=arr[i];
	}
	int ans=0;
	for(int i=0;i<n;++i)
		ans+=((s-arr[i])*arr[i]);
	cout<<ans/2;
}
void q3(){
	int n;	cin>>n;
	string s;	cin>>s;
	int a=0;
	for(int i=1;i<n;++i)
	if(s[i]==s[i-1])
	a++;
	cout<<n-a;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q3();
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	int s=0;
	if(a+b<2*c)
		s+=x*a+b*y;
	else
	{
		if(x>y)
		{
			if(a<2*c)
				s+=y*2*c+(x-y)*a;
			else
				s+=x*2*c;	
		}
		else
		{
			if(b<2*c)
				s+=x*2*c+(y-x)*b;
			else
				s+=y*2*c;							
		}
	}
	printf("%d\n",s);
	return 0;
}

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

vector<pair<double, string>>x;

int n; double P, A, B, C, D, E, F, S, M; string L;
int main() {
	while (true) {
		x.clear();
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			x.push_back(make_pair(100000000.00 - ((F*S*M - P) / (A + B + C + (D + E)*M)), L));
		}
		sort(x.begin(), x.end());
		for (int i = 0; i < n; i++) { cout << x[i].second << endl; }
		cout << "#" << endl;
	}
}

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

int main() {
  long N;
  cin >> N;
  long long answer=0;
  for(int i=1;i<sqrt(N);i++){
      if(N%i==0 && N/i -1 > i){
          answer += (N/i -1);
      }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
package main

import (
	"bytes"
	"fmt"
	"strings"
)

func main() {
	var n, k int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&k)
	fmt.Scan(&s)

	buf := bytes.NewBufferString("")
	for i := 0; i < len(s); i++ {
		if i == k-1 {
			buf.WriteByte([]byte(strings.ToLower(string([]byte{s[i]})))[0])
		} else {
			buf.WriteByte(s[i])
		}
	}

	fmt.Println(buf)
}


Measured memory_bytes: 640
n = int(input())
x = list(map(int,input().split()))
sm = sum(x)
p = sm//n
p1 = p+1

b = []
for i in range(n):
    b.append((x[i]-p)**2)
#print(sum(b))

c = []
for i in range(n):
    c.append((x[i]-p1)**2)
print(min(sum(c),sum(b)))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b){
        System.out.println("a < b");
        }
        else if (a > b){
        System.out.println("a > b");
        }
        else{
        System.out.println("a == b");
        }
	}

}


Measured memory_bytes: 26072
#include<cstdio>
#include<iostream>
int n,n1[10000],q,t[500],cnt=0;
void test(int a){
	for(int i=0;i<n;i++){
		if(n1[i]==a){
			cnt++;
			break;
		}
	}
}

int main(void)
{
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&n1[i]);	// 333333333 345
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d",&t[i]);
	}
	for(int i=0;i<q;i++){
		test(t[i]);
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 3216
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
    
    ll n,i,ans=1;
    cin>>n;
    ll cnt[3] = {0};
    for(i=1;i<=n;i++)
    {
    	ll x;
    	cin>>x;
    	ll cn=0,ind = -1;
    	if(x==cnt[0]) cn++,ind = 0;
    	if(x==cnt[1]) cn++,ind = 1;
    	if(x==cnt[2]) cn++,ind = 2;
    	if(ind==-1)
    	{
    		cout<<"0";
    		return 0;
    	}
    	ans = (ans%mod * cn%mod)%mod;
    	cnt[ind]++;
    }
    cout<<ans;
}

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

using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const int M = 10100001;
int mod = 1e9 + 7;
#define INF 0x3f3f3f3f
	
int main()
{

   // ios::sync_with_stdio(0);
    int n, a, b;
    while (~scanf("%d%d%d", &n, &a, &b))
    {
    	int f = n*a;
    	printf("%d\n", min(f, b));
    }
    return 0;
} 

Measured memory_bytes: 256
N, K = map(int, input().split())

B = [False for _ in range(N + 1)]
for _ in range(K):
    _ = input()
    for i in map(int, input().split()):
        B[i] = True

ans = 0
for i in range(1, N + 1):
    if not B[i]:
        ans += 1
print(ans)


Measured memory_bytes: 9184
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9+7
#main code here!
    n,q=MI()
    ans=(n-2)**2
    
    x=n
    y=n
    xlist=[n for i in range(n-2)]
    ylist=[n for i in range(n-2)]
    for i in range(q):
        a,b=MI()
        if a==1:
            if b<x:
                ans-=y-2
                for i in range(b,x):
                    ylist[i-2]=y
                x=b
            else:
                ans-=ylist[b-2]-2
        else:
            if b<y:
                ans-=x-2
                for i in range(b,y):
                    xlist[i-2]=x
                y=b
            else:
                ans-=xlist[b-2]-2
        #print(ans)
        #print(xlist)
        #print(ylist)
        #print(x,y)
        #print()
    print(ans)
    
            

            
            
            

    
        
        
        
        
    
        
                    
            
        



        
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 100304
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  ll  n ;
  cin >> n ;
  ll m = sqrt(n) ;
  ll tmp = 1 ;
  
  FOR(i,1,m+1){
    if(n%i==0){
      tmp = i ;
    }
  }
  
  n = n/tmp ;
  
  cout << (tmp-1)+(n-1) <<endl ;

  return 0 ;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	if ( S.length() <= 3 ) {
	    System.out.println("No");
	    return;
	}
	if ( S.charAt(0) == 'Y' &&
	     S.charAt(1) == 'A' &&
	     S.charAt(2) == 'K' &&
	     S.charAt(3) == 'I' ) System.out.println("Yes");
	else System.out.println("No");
    }
}


Measured memory_bytes: 22612
#include<stdio.h>

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

Measured memory_bytes: 128
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const calc = (n, k) =>{
    let cnt = 0
    while(n<k){
        n *= 2
        cnt++
    }
    return cnt
}
const Main = () => {
    const [N, K] = nextIntArray()
    let ans = 0
    for(let i = 1; i<=N; i++){
        const cnt = calc(i, K)
        ans += 1/N*(0.5**cnt)
    }
    console.log(ans)
}
Main()


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

int main(void){
	char S[110]; scanf("%s",S);
	long int K; scanf("%d",&K);
	int len = strlen(S);
	int flag = 0; if(S[0] == S[len-1]) flag = 1;
	long int i;
	long int cnt[len],cnt_num = 0;
	for(i=0;i<len;i++) cnt[i] = 0;
	i = 1;
	int ini = 0,end = 0;
	if(flag == 1){
		while(S[0] == S[i]){
			i++;
		}
		ini = i;
		i = 1;
		while(S[len-1] == S[len-1-i]){
			i++;
		}
		end = i;
	}
	int samenum = ini + end;
	int ko = 1;
	long long int ans = 0;
	while(S[0] == S[ko]){
		ko++;
	}
	if(ko == len){
		ans = len*K/2;
		printf("%lld\n",ans);
		return 0;
	}
		
	for(i=ini;i<len-end-1;i++){
		while(S[i] == S[i+1]){
			cnt[cnt_num]++;
			i++;
			if(S[i] != S[i+1]) cnt_num++;
		}
	}

	for(i=0;i<len;i++){
		//printf("cnt[%d] = %d\n",i,cnt[i]);
		cnt[i] = (cnt[i]+1) / 2;
		ans += cnt[i] * K;
	}
	ans = ans + (samenum/2)*(K-1);
	ans = ans + (ini/2) + (end/2);
	//printf("samenum = %d\n",samenum);
	printf("%lld\n",ans);
	//printf("ini = %d, end = %d\n",ini,end);
	return 0;
}



Measured memory_bytes: 128
x = int(input())

if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600: 
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)
    

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

int main() {
	string s,t,as,at;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    if(s[0] < t[t.size()-1]){
        cout << "Yes" << endl;
    }else if(s[0] == t[t.size() -1] && s.size()<t.size()){
        for(int i=0; i<s.size(); i++){
            if(s[i] != t[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  long a[3];
  long n=0;
  int i,j,h;
    for(i=0;i<3;i++){
    scanf("%ld",a+i);
  }
if(a[0]<a[1]){
  h=a[0];
}else{
  h=a[1];
}

for(i=h;i>0;i--){
  if(a[0]%i==0){
    if(a[1]%i==0){
      n++;
      if(n==a[2]){
        break;
      }
    }
  }
}

  printf("%d",i);



//   long b[a[1]];
//   long c[a[1]];
//   long d[a[1]];//番目
//   long *e;
//   e = (long *)malloc(sizeof(long) * a[0]*a[1]);
//   long *f;
//   f = (long *)malloc(sizeof(long) * a[0]*a[1]);
//   for(i=0;i<a[0]*a[1];i++){
//     e[i]=0;
//     f[i]=0;
//   }
//   long g[a[0]];
//     for(i=0;i<a[0];i++){
//     g[i]=0;
//   }
//   for(j=0;j<a[1];j++){
//     scanf("%ld",b+j);
//     scanf("%ld",c+j);
//     e[(b[j]-1)*a[1]+g[b[j]-1]]=c[j];
//     f[(b[j]-1)*a[1]+g[b[j]-1]]=j;
//     d[j]=1;
//     g[b[j]-1]++;
//     for(h=0;h<g[b[j]-1];h++){
//       if(e[(b[j]-1)*a[1]+h]==0){}
//       else if(e[(b[j]-1)*a[1]+h]<c[j]){
//         d[j]++;
//       }
//       else if(e[(b[j]-1)*a[1]+h]>c[j]){
//         d[f[(b[j]-1)*a[1]+h]]++;
//       }
//     }
//   }
// for(i=0;i<a[1];i++){
//   printf("%06d",b[i]);
//   printf("%06d\n",d[i]);
// }
// for(i=0;i<a[1]*a[0];i++){
//   printf("%d,",e[i]);
// }
}



Measured memory_bytes: 128
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
bool b[110];
signed main() {
	loop(i, 1, 10) {
		loop(j, 1, 10) {
			b[i * j] = true;
		}
	}
	int n;
	cin >> n;
	if (b[n])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
X = gets.chomp.to_i

answer = 0

can_be_divided_by_500 = X - (X%500)
can_be_divided_by_5 = (X - can_be_divided_by_500)

answer += (can_be_divided_by_500/500)*1000
answer += (can_be_divided_by_5/5)*5

puts answer


Measured memory_bytes: 1788
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  if((b - a) % 2 == 1) cout << "Borys" << endl;
  if((b - a) % 2 == 0) cout << "Alice" << endl;
}

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

int main(){
   int H , W;
   cin >> H >> W;
   vector <vector<char>> hyo(H,vector<char>(W));
   for (int i = 0; i < H; i++){
     for (int j = 0; j < W; j++){
      cin >> hyo.at(i).at(j);
     }
   }
   int count = 0;
   for(int i = 0; i < W; i++){
     bool tate_check = true;
     for (int j = 0; j < H; j++){
       if (hyo.at(j).at(i - count) != '.'){
         tate_check = false;
         break;
       }
     }
     if (tate_check == true){
       for (int k = 0; k < H; k++){
         for (int l = i - count; l < W  -1; l++){
           hyo.at(k).at(l) = hyo.at(k).at(l + 1);
         }
       }
       count++;
     }
   }
  for (int i = 0; i < H; i++){
    bool yoko_check = true;
    for (int j = 0; j < W ;j++){
      if (hyo.at(i).at(j) != '.'){
        yoko_check = false;
        break;
      }
    }
    if (yoko_check == false){
      for (int j = 0; j < W - count; j++){
        cout << hyo.at(i).at(j);
      }
      cout << endl;
    }
  }
} 

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
#include<queue>
using namespace std;
map<string, int> m;
int direction[] = { 1,-1,4,-4 };
void bfs() {
	queue<string> que;
	string s = "01234567";
	m[s] = 0;
	que.push(s);
	while (que.size()) {
		string curs = que.front();
		que.pop();
		int k = 0;
		for (; k < 8; k++) {
			if (curs[k] == '0')
				break;
		}
		for (int i = 0; i < 4; i++) {
			int nk = k + direction[i];
			if ((k == 3 && nk == 4) || (k == 4 && nk == 3))
				continue;
			if (nk >= 0 && nk <= 7) {
				string ss = curs;
				swap(ss[k], ss[nk]);
				if (m.find(ss) == m.end()) {
					que.push(ss);
					m[ss] = m[curs] + 1;
				}
			}
		}
	}
}
void solve(string s) {
	printf("%d\n", m[s]);
}
int main() {
	bfs();
	int cur[8];
	while (scanf("%d", &cur[0]) != EOF) {
		string s = "";
		s += (cur[0] + '0');
		for (int i = 1; i < 8; i++) {
			scanf("%d", &cur[i]);
			s += (cur[i] + '0');
		}
		solve(s);
	}
	return 0;
}

Measured memory_bytes: 5008
n = int(input())
s = []
for i in range(n):
    s.append(input())
print('AC x ' + str(s.count('AC')))
print('WA x ' + str(s.count('WA')))
print('TLE x ' + str(s.count('TLE')))
print('RE x ' + str(s.count('RE')))

Measured memory_bytes: 16180
#include <iostream>
#include <algorithm>
using namespace std;
long long k,n,ans;

int main(){
	cin>>n>>k;
	if(k%2==0){
		ans+=((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
	}
	ans+=(n/k)*(n/k)*(n/k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

int main()
{
  int N = 0;//カードの枚数
  int M = 0;//操作の回数
  int A = 0;
  int B = 0;
  int C = 0;
  long long int ans = 0;
  std::cin >> N >> M;//値を入力

  std::priority_queue< std::pair<int, int> > q;//値の高いもの順

  for(int i = 0; i < N; i++)
  {
    std::cin >> A;
    q.push( std::make_pair(A, 1) );

  }

  for(int i = 0; i < M; i++)
  {
    std::cin >> B >> C;
    q.push( std::make_pair(C, B) );

  }

  for(int i = 0; i < N; i++)
  {
    auto p = q.top();
    q.pop();
    ans += p.first;
    if(p.second > 1)
    {
      p.second--;
      q.push(p);
    }
  }

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





  return 0;
}


Measured memory_bytes: 2420
import sys
 
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  if a[i] == 1:
    break
  else:
    pass
else:
  print("-1")
  sys.exit()
j = 1
for i in range(n):
  if a[i] == j:
    j += 1
  else:
    pass
print(str(n-j+1))

Measured memory_bytes: 26012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
vector<int> par(1000000);//それぞれの頂点の親,最大値をsizeにする
vector<int> dis(1000000);//ランク
int n;
class union_find{
  public:
  void init(){
    for(int i = 0;i < n;i++){
      par[i] = i;//最初、親は自分自身とする
      dis[i] = 0;
    }
  }
  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = root(par[x]);
    }
  }
  //xとyが同じ集合に属すか否か
  bool same(int x,int y){
    //cout << x << " " << y << endl;
    return (root(x) == root(y));
  }
  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y)return;
    if(dis[x] < dis[y]){
      par[x] = y;
    }
    else{
      par[y] = x;
      if(dis[x] == dis[y])dis[x]++;
    }
  }
};

//union_find tree;
//tree.init() //これで初期化
//tree.unite(a,b) //aとbのグループを併合
//tree.same(a,b) //aとbが同じグループか(trueかfalse)

int main(){
  ll w,h;
  cin >> w >> h;
  n = w + h + 2;
  vector<pair<ll,ll>> edge(w + h);
  for(int i = 0;i < w;i++)cin >> edge[i].first,edge[i].second = i;
  for(int i = 0;i < h;i++)cin >> edge[w + i].first,edge[w + i].second = i + w;
  sort(edge.begin(),edge.end());
  union_find tree;
  tree.init();
  ll a = h + 1;
  ll b = w + 1;
  ll res = 0;
  for(int i = 0;i < w + h;i++){
    if(tree.same(edge[i].second,edge[i].second + 1))continue;
    else if(edge[i].second >= w){//h方向
      res += b * edge[i].first;
      a--;
      tree.unite(edge[i].second,edge[i].second + 1);
    }
    else{//w方向
      res += a * edge[i].first;
      b--;
      tree.unite(edge[i].second,edge[i].second + 1);
    }
    //cout << i << " " << edge[i].first << " " << res << endl;
  }
  cout << res << endl;
}

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

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

int main () {
    float n ;
    cin >> n;
    float count = 0.0;
    rep(i, n){
        if ((i+1) % 2 == 1) count+=1.0;
    }
    cout << (float)(count / n) << endl;
    return 0;
}

Measured memory_bytes: 888