akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

class xorShift{
    uint32_t x, y, z, w;
    static const double TO_DOUBLE;
public:
    xorShift(){
        x = 123456789;
        y = 362436069;
        z = 521288629;
        w = 88675123; 
    }
    xorShift(uint32_t seed){
        x = seed = 1812433253u * (seed ^ (seed >> 30));
        y = seed = 1812433253u * (seed ^ (seed >> 30)) + 1;
        z = seed = 1812433253u * (seed ^ (seed >> 30)) + 2;
        w = seed = 1812433253u * (seed ^ (seed >> 30)) + 3;
    }
    uint32_t nextInt(uint32_t n){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w % n;
    }
    uint32_t nextInt(){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }
    double nextDouble(){
        return nextInt() * TO_DOUBLE;
    }
};
const double xorShift::TO_DOUBLE = 1.0 / (1LL << 32);

class Timer{
    chrono::time_point<chrono::system_clock>start;
public:
    Timer(){
        start = chrono::system_clock::now();
    }
    double duration(){
        return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()- start).count();
        //return chrono::duration<chrono::milliseconds>(chrono::system_clock::now()- start).count();
    }
};

Timer T;
xorShift rnd;
constexpr double TIME_LIMIT = 1900;

int D = 365;
vector<int> c(26);
vector<vector<int>> s(D, vector<int>(26));

int main(){
  cin >> D;
  REP(i, 26){
      cin >> c[i];
  }
  REP(i, D){
      REP(j, 26){
          cin >> s[i][j];
      }
  }
  REP(i, D){
      int maxt = 0, maxscore = -1;
      REP(j, 26){
          if(maxscore < s[i][j]){
              maxt = j;
              maxscore = s[i][j];
          }
      }
      cout << maxt+1 << endl;
  }
  return 0;
}


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

ll gcd(ll m, ll n) {//最大公約数
    if (n == 0)return m;
    return gcd(n, m % n);
}//gcd

ll lcm(ll m, ll n) {//最小公倍数
    return m / gcd(m, n) * n;
}

int main() {
  ll a,b;
  cin>>a>>b;
  cout<<lcm(a,b)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define pll pair <ll, ll>
#define MOMI using namespace std;
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#pragma optimize("TKACHENKO-GORYACHENKO")
#pragma GCC optimize("O3")
 
//#pragma GCC optimize("unroll-loops")
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 4e5;
const ll inf = 1e14;

struct edge{
    ll to;
    ll c;
};

ll n, m, k;

ll A[maxn];

ll C[maxn];

ll MC[maxn];

ll S[maxn];

bool can(ll ans, ll k) {
    if (ans == 0) {
        return 1;
    }
    ll i = lower_bound(&MC[0], &MC[n], -ans) - &MC[0];
    i--;
    // cout << "I " << i + 1 << " " << S[i + 1] << endl;
    ll newn = n - S[i + 1] + ans * (i + 1);
    // cout << k << " " << ans << " " << newn << " DEBUG" << endl << endl;
    return newn >= ans * k;
}

int main() {
    ll q, w, e, a, b;
    cin >> n;
    for (q = 0; q < n; q++) {
        cin >> A[q];
        C[A[q] - 1]++;
    }
    sort(&C[0], &C[n]);
    reverse(&C[0], &C[n]);
    S[0] = 0;
    for (q = 0; q < n; q++) {
        S[q + 1] = S[q] + C[q];
    }
    for (q = 0; q < n; q++) {
        MC[q] = -C[q];
    }
    ll i = 0;
    ll lastans = n;
    for (q = 1; q <= n; q++) {
        while (!can(lastans, q)) {
            lastans--;
        }
        cout << lastans << endl;
    }
    return 0;
}

Measured memory_bytes: 13184
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

fn main() {
    input! {
    n: usize,
    m: usize,
    x: i64,
    y: i64,
    mut xs: [i64; n],
    mut ys: [i64; m]
    }
    xs.sort();
    ys.sort();
    for z in x + 1..=y {
        if xs[n - 1] < z && z <= ys[0] {
            println!("No War");
            return
        }
    }
    println!("War");
}


Measured memory_bytes: 2180
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))

h = []
for a in A:
    heapq.heappush(h, -a)

for i in range(M):
    new = heapq.heappop(h)
    new = -((-new)//2)
    heapq.heappush(h, new)

print(-sum(h))

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

public class Main {

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
//        while (n > 0) {
//            int k = n % 10;
//            if (k == 7) {
//                out.println("YES");
//                out.flush();
//                out.close();
//                return;
//            }
//            n /= 10;
//        }

        long sum = 0;
        for (int i = 1; i<= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }
        out.println(sum);
//        out.println("NO");
        out.flush();
        out.close();
    }

    private static void solve(double x, ArrayList<Long> arr, int n) {
        long sum = 0;
        for (int i = 0; i < n; i++) {
            sum += arr.get(i);
        }
        if (1.0 * sum / n >= x) System.out.println(n);
        else {
            Collections.sort(arr);
            long cur = 0;
            long people = 0;
            for (int i = n - 1; i >= 0; i--) {
                cur += arr.get(i);
                people++;
                if (1.0 * cur / people < x) {
                    System.out.println(people - 1);
                    return;
                }
            }
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }
}

/**
 *x=3
 * 1 1 2 5
 */

/**
 *
 *  1+1
 **/

Measured memory_bytes: 32880
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  char c;
  s="AGTCAG";
  cin>>c;
  for(int i=0;;++i){
    if(c==s[i]){
      cout<<s[i+2]<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int n_ac = 0;
    int wa_sum[N];
    for(int i=0; i<N; i++){
        wa_sum[i] = 0;
    }
    int n_wa = 0;
    int p;
    string s;
    bool done[N]; 
    for(int i=0; i<N; i++){
        done[i] = false;
    }
    for(int i=0; i<M; i++){
        cin >> p >> s;
        p--;
        if(done[p]){
            ;
        }
        else{
            if(s == "AC"){
                done[p] = true;
                n_ac++;
                n_wa += wa_sum[p];
            }
            else{
                wa_sum[p]++;
            }
        }
    }   
    cout << n_ac << " " << n_wa << endl;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
using namespace std;
int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int x = 0;
    int sum = 0;

    for(int i = 1; i <= N; i++){
        //iの各桁をたす
        int t = i, x = 0;
        for(int j = 0; j < 5; j++){
            //一の位を足す
            x += t % 10; 
            //1つ位をずらす
            t /= 10;
        }
        if(A<=x && x <= B) {
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3648
// AtCoder Educational DP Contest E - Knapsack 2
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define PB push_back
#define NMAX 105
#define VMAX (int)(1e5+5)
#define INF 0x7f7f7f7f
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

int N, W, weight[NMAX], value[NMAX], dp[NMAX][VMAX];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);

    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> weight[i] >> value[i];
    }

    memset(dp, 0x3f3f3f, sizeof(dp));
    dp[0][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= (int)(1e5); j++) {
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if (j-value[i-1] >= 0) dp[i][j] = min(dp[i][j], dp[i-1][j-value[i-1]] + weight[i-1]);
        }
    }

    for (int i = (int)(1e5); i >= 0; i--) {
        if (dp[N][i] <= W) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

using namespace std;

int main()
{
    int a, b;
    while (cin >> a >> b, a || b)
    {
        int n, dp[20][20] = {0};
        dp[1][1] = 1;
        cin >> n;

        for (int i = 0; i < n; i++)
        {
            int x, y;
            cin >> x >> y;
            dp[y][x] = -1;
        }

        for (int y = 1; y <= b; y++)
        {
            for (int x = 1; x <= a; x++)
            {
                if (dp[y][x] != -1)
                {
                    if (y != 1 && dp[y - 1][x] != -1)
                    {
                        dp[y][x] += dp[y - 1][x];
                    }

                    if(x != 1 && dp[y][x - 1] != -1)
                    {
                        dp[y][x] += dp[y][x - 1];
                    }
                }
            }
        }

        cout << dp[b][a] << endl;
    }
}


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

class team{
public:
  team(int a, int b, int c, int d){
    id = a;
    aff = b;
    ac = c;
    pen = d;
  }
  int id;
  int aff;
  int ac;
  int pen;

  bool operator <(const team arg) const{
    if(ac != arg.ac){
      return ac > arg.ac;
    }else{
      if(pen != arg.pen){
	return pen < arg.pen;
      }else{
	return id < arg.id;
      }
    }
  }
};

int main(void){
  int n;
  while(cin >> n && n){
    vector<team> v;
    map<int,int> m;
    int a,b,c,d;
    int selected = 0;
    for(int i=0;i<n;i++){
      cin >> a >> b >> c >> d;
      v.push_back(team(a,b,c,d));
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
      if(selected < 10 && m[v[i].aff] < 3){
	cout << v[i].id <<endl;
	m[v[i].aff]++;
	selected++;
	continue;
      }
      if(selected < 20 && m[v[i].aff] < 2){
	cout << v[i].id <<endl;
	m[v[i].aff]++;
	selected++;
	continue;
      }
      if(selected < 26 && m[v[i].aff] == 0){
	cout << v[i].id <<endl;
	m[v[i].aff]++;
	selected++;
	continue;
      }
    }
  }
}

Measured memory_bytes: 0
#include <cstdio>
#include <cctype>
#include <utility>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	int m {in()}, f {in()}, b{in()};
	if (m + f < b)
		outl("NA");
	else
		outl(m >= b ? 0 : b - m);
}


Measured memory_bytes: 2624
#include <iostream>
#include<vector>
using namespace std;
typedef long long ll;
int main() {
	int n;cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int flag=0;
	long long num=0;
	long long ans=0;
	while(1){
		flag=1;
		for(int i=0;i<n;i++){
			a[i]+=num;

		}
		num=0;
		for(int i=0;i<n;i++){
			long long add=a[i]/n;
			num+=add;
			a[i]-=add*(n+1);
//			cout<<a[i]<<' ';
		}
//		cout<<endl;
		if(num==0){
			break;
		}else{
			ans+=num;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int N;
vector<int> g[100001];
int dist[2][100001],id;
void dfs(int idx,int par=-1)
{
	if(~par) dist[id][idx]=dist[id][par]+1;
	for(auto &to  :  g[idx]) if(to!=par) dfs(to,idx);
} 
int main()
{
	cin>>N;
	for(int i=0;i<N-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(N-1);
	int ret=0;
	for(int i=0;i<N;i++)
	{
		if(dist[0][i]<=dist[1][i])
			ret++;
	}
	if(ret>=(N+2)/2)
	    printf("Fennec\n");
    else
        printf("Snuke\n");
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,t;
char s[500010];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	FOR(i,1,n) if (s[i]=='o') ++t;
	t+=15-n;
	if (t>=8) puts("YES"); else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

#define int long long

signed main() { 
        int n;
        cin >> n;
        vector<int> a(n);
        int sum = 0;
        int ss = 0;
        rep(i, n) { 
                cin >> a[i];
                sum += a[i];
                ss += i + 1;
        }
        if (sum % ss != 0) {
                cout << "NO" << endl;
                return 0;
        }
        int k = sum / ss;
        vector<int> diff(n);
        diff[0] = a[0] - a[n - 1];
        rep(i, n - 1) diff[i + 1] = a[i + 1] - a[i];
        rep(i, n) diff[i] -= k;
        bool f = true;
        rep(i, n) if (diff[i] % n || diff[i] > 0) f = false;
        cout << (f ? "YES" : "NO") << endl;
        return 0;
}               


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct SmallestIndex {
  vector<vector<int> > index;
  SmallestIndex(const string &s) {
    index.assign(s.length(),vector<int>('z'-'a'+1,-1));
    string words = s; //sの文字
    sort(all(words));
    words.erase(unique(all(words)),words.end());
    for (int i = (int)s.size()-1; i >= 0; --i) {
      for (auto x : words) {
        int ind = x - 'a';
        if (s[i] == x) index[i][ind] = i; //update
        else if (i < (int)s.size()-1) {
          index[i][ind] = index[i+1][ind];
        }
      }
    }
  }
  int operator()(int i, char c) {
    assert(i < (int)index.size());
    return index[i][c - 'a'];
  }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  SmallestIndex SI(s);
  ll n = s.length();
  ll ans = 1 + (n-1)*n/2;
  rep(i,'z'-'a'+1) {
    char c = 'a'+i;
    int ind = SI(0,c);
    if (ind == -1) continue;
    ll cnt = 1;
    while(ind+1 < n) {
      if (SI(ind+1, c) != -1) {
        ind = SI(ind+1, c);
        cnt++;
      }
      else break;
    }
    ans -= cnt*(cnt-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 27156
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    k = kwargs["k"]
    res = 0
    p = 7
    rs = 0

    while True:
        res += 1
        r = p % k
        rs += r
        if rs % k == 0:
            break
        if r == 0 or res > 1000000:
            res = -1
            break
        p = r * 10


    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["k"] = [int(i) for i in cin][0]

    cout = main(kwargs)
    print(cout)


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

int main() {
  string S; cin >> S;
  bool check = true;
  for (int i = 0; i < 3; i++)
  {
    if (S[i] == S[i + 1]) check = false;
  }
  if (check) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d %d %d",&a,&s,&d);
	f=(a+s)*d/2;
	printf("%d\n",f);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cmath>

#define ll long long

using namespace std;

int num[300000];

int main()
{
	int N;
	scanf("%d", &N);

	printf("%d", (1000 - N % 1000)%1000);


	return 0;
}


Measured memory_bytes: 3792
#include <cstring>
#include <iostream>

using namespace std;
int n;
string s;
int r,g,b;
unsigned long long ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }
    ans=r*g;
    ans*=b;
    if(!ans){cout<<0;return 0;}
    for(int a=0;a<n-2;a++)
        for(int b=a;b<n-1;b++){
            int c=b+(b-a);
            if(c>=n) continue;
            if(s[a]!=s[b]&&s[a]!=s[c]&&s[b]!=s[c]) ans--;
        }
    cout<<ans;
    return 0;
}

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


int main(void){
    // Your code here!
    ll N,c=0;
    cin>>N;
    string S;
    rep(0,i,N){
        if(to_string(i+1).length()%2==1)++c;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<iomanip>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<double> a(n);
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a.begin(), a.end());
	for(int i = 0; i < n-1; ++i) {
		a[i+1]=(a[i] + a[i + 1]) / 2.0;
	}
	cout <<fixed<<setprecision(15)<< a[n - 1] << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;
 
int main() {
    int N; cin >> N;
    vector<string> s(N); for (int i = 0; i < N; i++) cin >> s.at(i);
    int M; cin >> M;
    vector<string> t(M); for (int i = 0; i < M; i++) cin >> t.at(i);

    map<string, int> que;
    for (int i = 0; i < N; i++) {
        que[s.at(i)]++;
    }
    for (int i = 0; i < M; i++) {
        que[t.at(i)]--;
    }
    
    int ans = 0;
    for (auto ite = que.begin(); ite != que.end(); ite++) {
        if (ans < ite -> second) ans = ite -> second;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3608
import java.util.*;

public class Main{
	void run(){
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			if(n == 0) break;
			int a[] = new int[n];
			int abs;
			int ans = 1000000;
			for(int i = 0; i < n;i++){
				a[i] = scan.nextInt();
			}
			for(int i = 0; i < n;i++){
				for(int j = 0; j < n; j++){
					if(i != j){
						abs = Math.abs(a[i]-a[j]);
						if(ans > abs) ans = abs;
					}
				}
			}
			System.out.println(ans);
		}
		
	}
	public static void main(String[] args){
		new Main().run();
		
	}
}

Measured memory_bytes: 47784
#include <stdio.h>
#include <math.h>

int main(){
    int a, b, c, k;
    scanf("%d%d%d", &a, &b, &c);
    scanf("%d", &k);
    int max, sum;
    sum = a + b + c;
    max = a;
    max = b>max ? b:max;
    max = c>max ? c:max;
    sum -= max;

    for (int i = 0; i < k; ++i){
        max *= 2;
    }

    printf("%d", max+sum);

    return 0;
}

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

signed main() {
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m), a(m);
	int ans = 0;

	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}

	for (int i = 0; i < n; ++i) {
		int cnt = c;
		for (int j = 0; j < m; ++j) {
			cin >> a[j];
			cnt += a[j] * b[j];
		}
		if (cnt > 0) ans++;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::input;
 
fn main() {
  input! {
    n: usize,
    vals: [isize;n]
  }
  
  let mut minus_count = 0;
  let mut total = 0;
  let mut min = isize::max_value();
  for v in vals.iter() {
    if v < &0 {
      minus_count += 1;
    }
    let abs_v = v.abs();
    min = std::cmp::min(min, abs_v);
    total += abs_v;
  }
  
  if minus_count % 2 == 0 {
    println!("{}", total);
  } else {
    println!("{}", total - 2 * min);
  } 
}

Measured memory_bytes: 3880
//Begin Template
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
// define
const int INF = 1<<24;
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET cin.tie(0);ios::sync_with_stdio(false);
// Inspired by: https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a) - 1, n, d, >=)

#define repc(...) GET_MACRO(__VA_ARGS__, repc4, repc3, repc2, repc1) (__VA_ARGS__)
#define repc1(n) repc2(_, n)
#define repc2(i, n) repc3(i, 0, n)
#define repc3(i, a, n) repc4(i, a, n, 1)
#define repc4(i, a, n, d) rep5(i, a, n, d, <=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int,int> pii;
typedef pair<lint,lint> pll;
// func
template <class C> inline void vcin(C &c);
template <class C,class D> inline void vcin(C &c,D &d);
template <class C> inline void vcout(const C &c,const string separate="\n");
template <class T=int> inline T in();
template <class T> inline bool chmin(T &a, T b);
template <class T> inline bool chmax(T &a, T b);
//http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T> vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}

void solve()
{
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<lint> a(x), b(y), c(z);
  vcin(a);
  vcin(b);
  vcin(c);

  vector<lint> ab;
  rep(i, x) rep(j, y)
  {
    ab.push_back(a[i] + b[j]);
  }

  sort(ab.rbegin(), ab.rend());
  ab.resize(k);

  vector<lint> abc;

  rep(i, ab.size()) rep(j, z)
  {
    abc.push_back(ab[i] + c[j]);
  }

  sort(abc.rbegin(), abc.rend());

  rep(l, k)
  {
    cout << abc[l] << endl;
  }
}

signed main(){
  AMULET
  solve();
  return 0;
}

template <class C>inline void vcin(C &c){for(auto &a:c){cin>>a;}}
template <class C,class D> inline void vcin(C &c,D &d){for(auto it1=c.begin(),it2=d.begin();it1!=c.end()&&it2!=d.end();it1++,it2++){cin>>*it1>>*it2;}}
template <class C> inline void vcout(const C &c,const string separate){for(auto it=c.begin();it!=c.end();it++){if(it!=c.begin())cout<<separate;cout<<*it;}}
template <class T=int> inline T in(){T x;cin>>x;return (x);}
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;}
//End Template


Measured memory_bytes: 42984
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const int inf = 1012345678;
struct flow_edge {
	int to, cap, rev;
	flow_edge() : to(-1), cap(0), rev(-1) {};
	flow_edge(int to_, int cap_, int rev_) : to(to_), cap(cap_), rev(rev_) {};
};
int max_flow(vector<vector<flow_edge> > G, int src, int dst) {
	vector<bool> vis;
	function<int(int, int)> find_augment = [&](int pos, int curcap) {
		if (pos == dst) return curcap;
		vis[pos] = true;
		for (flow_edge &e : G[pos]) {
			if (e.cap == 0 || vis[e.to]) continue;
			int res = find_augment(e.to, min(curcap, e.cap));
			if (res > 0) {
				e.cap -= res;
				G[e.to][e.rev].cap += res;
				return res;
			}
		}
		return 0;
	};
	int ret = 0;
	while (true) {
		vis = vector<bool>(G.size(), false);
		int res = find_augment(src, inf);
		ret += res;
		if (res == 0) break;
		if (ret >= inf) return inf;
	}
	return ret;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	for (int i = 0; i < H; i++) cin >> s[i];
	vector<vector<flow_edge> > G(2 * H * W + 2);
	function<void(int, int, int)> add_edge = [&](int va, int vb, int cap) {
		G[va].push_back(flow_edge(vb, cap, G[vb].size()));
		G[vb].push_back(flow_edge(va, 0, G[va].size() - 1));
	};
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			add_edge(i * W + j, H * W + i * W + j, (s[i][j] == 'X' ? inf : 1));
			if (i >= 1) {
				add_edge(H * W + i * W + j, i * W + j - W, inf);
				add_edge(H * W + i * W + j - W, i * W + j, inf);
			}
			if (j >= 1) {
				add_edge(H * W + i * W + j, i * W + j - 1, inf);
				add_edge(H * W + i * W + j - 1, i * W + j, inf);
			}
			if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
				add_edge(H * W + i * W + j, 2 * H * W + 1, inf);
			}
			if (s[i][j] == 'X') {
				add_edge(2 * H * W, i * W + j, inf);
			}
		}
	}
	int ret = max_flow(G, 2 * H * W, 2 * H * W + 1);
	cout << (ret != inf ? ret : -1) << "\n";
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int w;
    cin>>s>>w;
    for(int i=0;i<s.size();i+=w){
        cout<<s[i];
    }
}

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

using namespace std;

#define int long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}

#define forinc(a,b,c) for(int a=b, __c=c; a<=__c; ++a)
#define fordec(a,b,c) for(int a=b, __c=c; a>=__c; --a)
#define forv(a,b) for(auto &a:b)

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

const int N=2e5+5;
const int inf=1e9;
int n,m;
struct trees{
   int it[N<<2], lz[N<<2];
   trees(){
      reset(it,0); reset(lz,0);
   }
   void push(int i){
      if(lz[i]){
         it[i<<1]=it[i<<1|1]=lz[i];
         lz[i<<1]=lz[i<<1|1]=lz[i];
         lz[i]=0;
      }
   }
   void build(int i,int l,int r){
      if(l==r){
         it[i]=-l;
         return;
      }
      int m=l+(r-l)/2;
      build(i<<1,l,m); build(i<<1|1,m+1,r);
      it[i]=min(it[i<<1], it[i<<1|1]);
   }
   void upd(int i,int l,int r,int u,int v,int val){
      if(v<l || u>r || u>v) return;
      if(u<=l && r<=v){
         it[i]=val;
         lz[i]=val;
         return;
      }
      push(i);
      int m=l+(r-l)/2;
      upd(i<<1,l,m,u,v,val); upd(i<<1|1,m+1,r,u,v,val);
      it[i]=min(it[i<<1], it[i<<1|1]);
   }
   int get(int i,int l,int r,int u,int v){
      if(v<l || u>r || u>v) return inf;
      if(u<=l && r<=v) return it[i];
      push(i);
      int m=l+(r-l)/2;
      return min(get(i<<1,l,m,u,v),get(i<<1|1,m+1,r,u,v));
   }
} p1,p2;

int32_t main(){
   fasty;

   cin>>n>>m;
   p2.build(1,1,m);
   forinc(i,1,n+1){
      if(i>1){
         int ans=p1.get(1,1,m,1,m);
         if(ans==inf) ans=-1;
         else ans+=i-1;
         cout<<ans<<'\n';
      }
      if(i==n+1) break;
      int u,v; cin>>u>>v;
      if(v<m){
         int tmp=p2.get(1,1,m,u,v);
         int val=p1.get(1,1,m,v+1,v+1);
         if(val>tmp+v+1){
            p1.upd(1,1,m,v+1,v+1,tmp+v+1);
            p2.upd(1,1,m,v+1,v+1,tmp);
         }
      }
      p1.upd(1,1,m,u,v,inf);
      p2.upd(1,1,m,u,v,inf);
   }
}



Measured memory_bytes: 28684
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if ( Math.abs(x-a) > Math.abs(x-b) )
			System.out.println("B");
		else if ( Math.abs(x-a) < Math.abs(x-b) )
			System.out.println("A");
	}
}


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

#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define snd sd.ft
#define td sd.sd
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()

#define ninf -1000000000
#define pinf 1000000000

typedef long long int ll;
const ll MOD= 1e9+7;
typedef vector<pair<ll,ll> > vecpair;
typedef vector<pair<ll, pair<ll,ll> > > vecpair3;
typedef pair<ll, ll> pi;

//double mei ye line cout << fixed << setprecision(10); kam mei le

ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}

struct subset // disjoint set use subsets.claer and subsets.resize............
{
	int parent,sz;
};
vector< subset> subsets;
int find( int i)
{
    if (subsets[i].parent != i)
        subsets[i].parent = find(subsets[i].parent);

    return subsets[i].parent;
}
void uniona(int x, int y){
	if( x == y)
	return ;
    int xroot = find( x);
    int yroot = find( y);
    if (subsets[xroot].sz < subsets[yroot].sz){
        subsets[xroot].parent = yroot;
        subsets[yroot].sz += subsets[xroot].sz;
    }
    else{
        subsets[yroot].parent = xroot;
        subsets[xroot].sz += subsets[yroot].sz;
    }
}
//........................................................
int n,a[305];
double dp[305][305][305];
double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += rec(i-1, j, k) * i;
    if (j > 0) res += rec(i+1, j-1, k) * j;
    if (k > 0) res += rec(i, j+1, k-1) * k;
    res += n;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}



int main()
{
	std:ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

		cin >> n;
		int c[4];
		for(int i=0;i<4;i++)
			c[i]=0;
		for(int i=1;i<=n;i++)
		{
			cin >> a[i];
			c[a[i]]++;
		}
		for(int i=0;i<305;i++)
		{
			for(int j=0;j<305;j++)
			{
				for(int k=0;k<305;k++)
				{
					dp[i][j][k]=-1;
				}
			}
		}
		cout << fixed << setprecision(10);

		cout << rec(c[1],c[2],c[3]);

	return 0;
}


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

int main() {
    int N, A[200002];
    int num_sup[200002] = {0};
    cin >> N;
    for (int i = 2; i <= N; i++){
        cin >> A[i];
        num_sup[A[i]]++;
    }
    for(int i = 1; i <= N; i++) {
        cout << num_sup[i] << endl;
        // printf("%d\n",num_sup[i]);
    }
}

Measured memory_bytes: 5140
#include <iostream>

using namespace std;

int main() {
	int a, b, c,i,n;
	i = 0;
	cin >> a >> b >> c;
	if (a == 5) {
		i=i+1;
	}
	if (b == 5) {
		i=i+1;
	}
	if (c == 5) {
		i=1+1;
	}
	if (i == 2) {
		n = a + b + c;
		if (n == 17) {
			cout << "YES";
		}
		else {
			cout << "NO";
		}
	}
	if (i != 2) {
		cout << "NO";
	}
	cout << endl;
	return 0;
}


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

int main(int argc, char const *argv[]) {
    using pii = pair<int, int>;
    int N;
    cin >> N;
    // vector<vector<int>> students(N, vector<int> (2));
    vector<pii> students(N);
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        students.at(i).first = num;
        students.at(i).second = i+1;
    }

    sort(students.begin(), students.end());

    for (int i = 0; i < N; i++) {
        cout << students.at(i).second << " ";
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	char z[200], x[200], y[200];
	memset(x, '\0', sizeof(x));
	memset(y, '\0', sizeof(y));
	scanf("%d", &a);
	scanf("%s", z);
	if (a % 2)printf("No\n");
	else
	{
		for (int i = 0; i < a / 2; i++)
			x[i] = z[i];
		for (int i = a/2; i < a ; i++)
			y[i-a/2] = z[i];
		if (strcmp(x, y) == 0)printf("Yes\n");
		else printf("No\n");
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N;
  cin >> N;
  string S;
  cin >> S;
  int Q;
  cin >> Q;
  REP(q, Q) {
    lint k;
    cin >> k;
    lint l = 0;
    lint cnt = 0;
    lint dcnt = 0;
    lint mcnt = 0;
    lint ans = 0;
    REP(r, N) {
      if(r-l == k) {
        if(S[l] == 'D') {
          cnt -= mcnt;
          dcnt--;
        } else if(S[l] == 'M') {
          mcnt--;
        }
        l++;
      }
      if(S[r] == 'M') {
        cnt += dcnt;
        mcnt++;
      } else if(S[r] == 'C') {
        ans += cnt;
      } else if(S[r] == 'D') {
        dcnt++;
      }
    }
    cout << ans << "\n";
  }
}

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


using namespace std;

typedef long long ll;

#define pi 2*acos(0.0)
#define eps 1e-9
const int N = 10000000;
bool isprime[N+1];

void sieve()
{
    memset(isprime,true,sizeof(isprime));
    isprime[0]=isprime[1]=false;

    for(ll i=2; i*i<=N; i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i; j<=N; j+=i)
            {
                isprime[j]=false;
            }
        }
    }
}


int main(void)
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);


    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }



}



Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    if(A>=1&&A<=13&&B>=1&&B<=13)
    {
    if(A==1||B==1)
    {
        if(A==1&&B>1) cout << "Alice";
        else if(A>1&&B==1) cout << "Bob";
        else cout << "Draw";
    }
    else if(A>B) cout << "Alice";
    else if (A<B) cout << "Bob";
    else cout << "Draw";
    return 0;
    }
    else return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>

int main()
{
  char s[100001];
  scanf("%s", s);
  long long len = strlen(s);
  long long ans = 0;
  for (char *p = s, *q = s + len - 1; p < q;)
  {
    long long lx = 0;
    long long rx = 0;
    while (*p == 'x' && *p)
    {
      ++p;
      ++lx;
    }
    while (*q == 'x' && q >= s)
    {
      --q;
      ++rx;
    }
    if (p > q) break;
    if (*p != *q)
    {
      puts("-1");
      return 0;
    }
    ans += std::abs(lx - rx);
    ++p;
    --q;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long s[128], p[128];
long long solve(int n, long long x){
	if(n == 0)
		return 1;
	else if(x == 1)
		return 0;
	if(x > 1 && x <= 1 + s[n - 1])
		return solve(n - 1, x - 1);
	else if(x == s[n - 1] + 2)
		return p[n - 1] + 1;
	else if(x > s[n - 1] + 2 && s[n] > x)
		return p[n - 1] + 1 + solve(n - 1, x - s[n - 1] - 2);
	else if(x == s[n])
		return p[n];
	
}
int main(){
	int n;
	long long x;
	cin >> n >> x;
	s[0] = 1, p[0] = 1;
	for(int i = 1; i <= n; i++){
		s[i] = 2 * s[i - 1] + 3;
		p[i] = 2 * p[i - 1] + 1;
	}
	cout << solve(n, x);
}

Measured memory_bytes: 256
from functools import reduce
from itertools import product

N = int(input())
*A, = map(int, input().split())
ans = 0
for t in product([-1, 0, 1], repeat=N):
    prod = reduce(lambda x, y: x*y, [a + t[i] for i, a in enumerate(A)])
    if prod % 2 == 0: ans += 1
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << (N+1)/2 << "\n";
}

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

int main()
{
    int k;
    string s;

    cin >> k >> s;

    if(k >= s.size())
    {
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }

    return 0;
}

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

//75 = 3 5 5 >> 18

//1 1 75
//1 3 25
//1 5 15
//3 5 5

int main()
{
    int N;
    cin >> N;
    
    vector<int> data(100,1);
    
    for(int i = 2;i<=N;i++)
    {
        int temp = i;
        for(int j = 2; j<=sqrt(temp);j++)
        {
            if(temp % j == 0)
            {
                temp /= j;
                data[j] ++;
                j = 1;
            }
        }
        
        data[temp]++;
    }
    
    vector<int> data3(100,0);
    vector<int> data5(100,0);
    vector<int> data15(100,0);
    vector<int> data25(100,0);
    vector<int> data75(100,0);
    
    for(int i = 2;i<=N;i++)
    {
        if(data[i] >= 3)
        {
            data3[i] = 1;
            if(data[i] >= 5)
            {
                data5[i] = 1;
                if(data[i] >= 15)
                {
                    data15[i] = 1;
                    if(data[i] >= 25)
                    {
                        data25[i] = 1;
                        if(data[i] >= 75)
                        {
                            data75[i] = 1;
                        }
                    }
                }
            }
        }
    }
    
    int ans = 0;
    for(int i = 2;i<=N;i++)
    {
        if(data75[i] == 1)
        {
            ans ++;
        }
        if(data25[i] == 1)
        {
            for(int j = 2;j<=N;j++)
            {
                if(data3[j] == 1 && j != i)
                {
                    ans ++;
                }
            }
        }
        if(data15[i] == 1)
        {
            for(int j = 2;j<=N;j++)
            {
                if(data5[j] == 1 && j != i)
                {
                    ans ++;
                }
            }
        }
        if(data5[i] == 1)
        {
            for(int j = i+1;j<=N;j++)
            {
                if(data5[j] == 1 && j != i)
                {
                    for(int k = 2;k<=N;k++)
                    {
                        if(data3[k] == 1 && k != i && k!= j)
                        {
                            ans ++;
                        }
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 256
n, k, *a = map(int, open(0).read().split())
a.sort()
for i in range(n-1): a[n-i-1] = abs(a[n-i-1]-a[n-i-2])
a[0] = 0
for i in range(n-1): a[i+1] += a[i]

mn = 1e18
for i in range(n-k+1): mn = min(mn, a[i+k-1]-a[i])
print(mn)

Measured memory_bytes: 14092
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;


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

class DMazeMaster {
public:

    vector<vector<char>> G;
    int H, W;
    set<pair<P, P>> found;

    int calc(int sx, int sy) {
        if (G[sx][sy] == '#') return 0;

        queue<pair<P, int>> q;
        set<P> used;
        q.push({{sx, sy}, 0});
        int res = 0;
        while (!q.empty()) {
            auto kv = q.front();
            q.pop();
            P pos = kv.first;
            int d = kv.second;
            res = max(res, d);
            if (used.count(pos)) continue;
            used.insert(pos);
            REP(i, 4) {
                int nx = pos.first + dx[i];
                int ny = pos.second + dy[i];
                if (nx < 0 || ny < 0 || nx >= H || ny >= W) continue;
                if (G[nx][ny] == '#') continue;
                if (used.count({nx, ny})) continue;
                q.push({{nx, ny}, d + 1});
            }
        }
        return res;
    }

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> H >> W;
        G = vector<vector<char>>(H, vector<char>(W));
        REP(i, H) REP(j, W) cin >> G[i][j];

        int res = 0;
        REP(si, H) {
            REP(sj, W) {
                res = max(res, calc(si, sj));
            }
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DMazeMaster solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
struct state{
  int bill,floor,jump;
  state(int b,int f,int j) : bill(b),floor(f),jump(j) {}
};
bool operator < (state s, state m){
  return s.jump > m.jump;
}
int main(void){
  int n;
  while(cin>>n,n){
    priority_queue<state> que;
    que.push(state(0,0,0));
    que.push(state(1,0,0));
    bool memo[2][101]={};
    int kabe[2][101];
    REP(i,n)cin>>kabe[0][i];
    REP(i,n)cin>>kabe[1][i];
    int ans = -1;
    while(!que.empty()){
      state s = que.top(); que.pop();
      if(memo[s.bill][s.floor]) continue;
      memo[s.bill][s.floor] = true;
      int k = kabe[s.bill][s.floor];
      if(k!=2&&s.floor == n-1){
        ans = s.jump;
        break;
      }
      if(k==1&&kabe[s.bill][s.floor+1]!=1) k=0;//ツづ債つオツつイツづ個暗ェツ氾板湘」
      if(k==1){
        que.push(state(s.bill,s.floor+1,s.jump));
      }else if(k==2){
        que.push(state(s.bill,s.floor-1,s.jump));
      }else{
        REP(dif,3){
          if(s.floor+dif<n){
            que.push(state((s.bill+1)%2, s.floor+dif, s.jump+1));
          }
        }
      }
    }
    if(ans==-1)cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
	//input
	int N;
	cin >> N;
	float money[N];
	char m_type[N][3];
	for(int i = 0; i < N; i++){
		cin >> money[i];
		for(int j = 0; j < 3; j++){
			cin >> m_type[i][j];
		}
	}
	//check
	float T_money = 0.0; //Otoshidama of Takahashi
	for(int i = 0; i < N; i++){
		if(m_type[i][0] == 'J'){
			T_money += money[i];
		}else if(m_type[i][0] == 'B'){
			T_money += 380000 * money[i];
		}
	}	
	cout << T_money << endl;
	return 0;
}


Measured memory_bytes: 256