akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#define MP make_pair
using namespace std;

void init(int n, vector<int> &par)
{
  for(int i=0; i < n;i++)
    par[i] = i;
}

int find(int x, vector<int> &par)
{
  if(par[x] == x)
    return x;
  else
    return par[x] = find(par[x], par);
}

void uniont(int x, int y, vector<int> &par)
{
  x = find(x, par);
  y = find(y, par);
  if(x == y) return;
  par[x] = y;
}

int main()
{
  int N,K,L;
  cin >> N >> K >> L;
  int x,y;
  vector<int> road(N);
  init(N, road);
  for(int i=0; i < K; i++){
    cin >> x >> y;
    uniont(x-1,y-1,road);
  }
  for(int i=0; i < N; i++){
    road[i] = find(i, road);
  }
  vector<int> rail(N);
  init(N, rail);
  for(int i=0; i < L; i++){
    cin >> x >> y;
    uniont(x-1,y-1, rail);
  }
  for(int i=0; i < N; i++){
    rail[i] = find(i, rail);
  }
  map<pair<int,int>, int>E;
  for(int i=0; i < N; i++){
    E[MP(road[i],rail[i])]++;
  }
  for(int i=0; i < N; i++){
    if(i >= 1) cout << " ";
    cout << E[MP(road[i],rail[i])];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 13568
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

const int N = 1e6 + 11;
int dp[N];
bool isprime[N];
vector<int> primes;

void solve(){
   fill (isprime + 2, isprime + N, true);
   for (int i = 2; i < N; i++){
	    if (isprime[i]){
		  primes.push_back(i);
		  for (int j = 2; j * i < N; j++){
			isprime[i * j] = false;  
		  }	
		} 
	  }	
   dp[0] = 0;
   for (int i = 1; i < N; i++){
	   dp[i] = dp[i - 1] + isprime[i];  
	 }
   int n;
   while (cin >> n && n > 0){
	int l = n;
	int r = 2 * n;
	int ret = dp[r] - dp[l];
	cout << ret << endl;   	   
	}
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}




Measured memory_bytes: 12540
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

typedef std::pair<long, long> P;

long n, m;
std::vector<long> edge[100005];
long dist[100005];

int main(){
    scanf("%ld%ld", &n, &m);
    for(int i = 0; i < m; i++){
        long a, b;
        scanf("%ld%ld", &a, &b);
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(long i = 1; i <= n; i++){
        dist[i] = -1;
    }
    std::queue<long> que;
    que.push(1);
    dist[1] = 0;
    while(!que.empty()){
        long vis = que.front();
        que.pop();
        for(long i = 0; i < edge[vis].size(); i++){
            long nx = edge[vis][i];
            if(dist[nx] == -1){
                dist[nx] = dist[vis]+1;
                que.push(nx);
            }
        }
    }

    printf("Yes\n");
    for(long vis = 2; vis <= n; vis++){
        for(long i = 0; i < edge[vis].size(); i++){
            long nx = edge[vis][i];
            if(dist[nx] < dist[vis]){
                printf("%ld\n", nx);
                break;
            }
        }
    }
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
const int inf = 1<<29;

int main(){
    string s; cin >> s;
    int N = s.size();
    vector<int> A(N+1);
    REP(i,N)A[i] = (int)(s[N-1-i]-'0');
    vector<vector<int>> dp(N+2, vector<int>(2, 1<<29));
    dp[0][0] = 0;
    REP(i,N+1) REP(j,2) {
        int k = A[i];
        if(j) k++;
        REP(a,10) {
            int ni = i+1, nj = 0;
            int b = a - k;
            if(b<0) {
                nj = 1;
                b += 10;
            }
            dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
        }
    }
    cout << dp[N+1][0] << endl;
    return 0;
}

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

int main(){
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A);
  for(int i=0;i<A;i++){
    cin >> a.at(i);
  }
  vector<int> b(B);
  for(int i=0;i<B;i++){
    cin >> b.at(i);
  }
  vector<int> x(M);
  vector<int> y(M);
  vector<int> c(M);
  for(int i=0;i<M;i++){
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  vector<int> s(M);
  for(int i=0;i<M;i++){
    s.at(i)=a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i);
  }
  sort(s.begin(),s.end());
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(a.at(0)+b.at(0)>s.at(0)){
    cout << s.at(0) << endl;
  }
  else{
    cout << a.at(0)+b.at(0) << endl;
  }
}

Measured memory_bytes: 2560
x = int(input())
if x == 2:
    print(1, -1)
    exit(0)
for d in range(1, int(x ** 0.5) + 1):
    for w in [-d, -x // d, d, x // d]:
        for a in range(-1000, 1000):
            if a ** 5 - (a - w) ** 5 == x:
                print(a, a - w)
                exit(0)


Measured memory_bytes: 9380
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
  ll r;
  cin >> r;
  cout << pow(r, 2);
}


Measured memory_bytes: 888
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let [a,b,c,d]=tnn(4)
  to(min(b,d)-max(a,c)>=0?min(b,d)-max(a,c):0)
}
main()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#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, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s; cin >> s;
  REP(i,s.size()){
    s[i] = 'x';
  }
  cout << s << endl;
}

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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 2e5 + 10;
const ll MOD  = 998244353;
const ll INF  = 1e18;

ll n, k, A[N], fen[2][N], dp[N], F[N], ans;

void Add(int z, int i, ll val) {
	for (i += 2; i < N; i += i & (-i))
		fen[z][i] = (fen[z][i] + val) % MOD;
}

ll Get(int z, int r) {
	ll res = 0;
	for (r += 2; r > 0; r -= r & (-r))
		res = (res + fen[z][r]) % MOD;
	return res;
}

ll Get(int z, int l, int r) {
	return (Get(z, r) - Get(z, l - 1) + MOD) % MOD;
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
    	cin >> A[i];
    	F[i] = min(n, max(i - k + 1, 0LL) + k);
    }
    dp[0] = pw(2, MOD - 2, MOD);
    ll kinv = pw(k, MOD - 2, MOD);
    for (int i = 1; i <= n; i++) {
    	dp[i] = kinv * (1 + (k - 2) * dp[i - 1] % MOD) % MOD;
    }
    ll w = (k - 1) * pw(k, MOD - 2, MOD) % MOD;
    ll winv = k * pw(k - 1, MOD - 2, MOD) % MOD;
    for (int i = 0; i < n; i++) {
    	ll gt = i - Get(0, A[i]);
    	Add(0, A[i], +1);
    	ll g = dp[n - F[i]] * pw(w, F[i], MOD) % MOD;
    	ans += Get(1, 0, A[i]) * g % MOD; 
    	ans += (gt + MOD - Get(1, A[i], n) * g % MOD) % MOD;
    	ans %= MOD;
    	Add(1, A[i], pw(winv, F[i], MOD));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11460
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Hi = Sarray();
            var cnt = 0L;
            for (var i = 0; i < N; ++i)
                if (Hi.Take(i + 1).Max() == Hi[i]) ++cnt;
            WriteLine(cnt);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28284
#include <iostream>
using namespace std;
int main ()
{
    int n, a, b;
    cin >> n >> a >> b;
    int r = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        int c = 0, t = i;
        for (int j = 0; j < 5; j++)
        {
            c += t % 10;
            t /= 10;
        }
        if(a <= c && c <= b)
        r += i;
    }
    cout << r;
    return 0;
}

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

const int maxn = 100010;
int n, rt, rtv, cost, sz[maxn];
long long ans;
vector<pair<int, int>> G[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1, u, v, w; i < n; i++) {
        scanf("%d %d %d", &u, &v, &w);
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    function<void(int, int, int)> dfs = [&](int v, int fa, int w) {
        sz[v] = 1;
        int mx = 0;
        for (auto e : G[v]) if (e.first ^ fa) {
            int u = e.first;
            dfs(u, v, e.second), sz[v] += sz[u];
            mx = max(mx, sz[u]);
        }
        if (2 * sz[v] == n) cost = w;
        ans += 1LL * w * min(sz[v], n - sz[v]);
        mx = max(mx, n - sz[v]);
        if (mx < rtv) rt = v, rtv = mx;
    };
    rtv = n, dfs(1, 0, 0);
    if (!cost) {
        cost = INT_MAX;
        for (auto e : G[rt]) cost = min(cost, e.second);
    }
    printf("%lld\n", ans * 2 - cost);
    return 0;
}

Measured memory_bytes: 20284
#include<stdio.h>

int solve(int,int);
int n,A[2000];

int main() {
	int i,q,m[2000];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		scanf("%d",&A[i]);
		}
		scanf("%d",&q);
		
		for(i=0;i<q;i++) {
		scanf("%d",&m[i]);
		}
		for(i=0;i<q;i++) {
			if(solve(0,m[i])==1)
			printf("yes\n");
			else printf("no\n");
		}
			return 0;
			}
			
		int solve(i, m) {
			int res;
   if (m == 0)
     return 1;
   if (i >= n)
   return 0;
   res = solve(i + 1, m) || solve(i + 1, m - A[i]);
   return res;
   }


Measured memory_bytes: 2108
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int64
    let bs = reads int64 |> List.sort
    let cs = List.tail bs
    let ds = List.scan (+) 0L bs |> List.tail

    let es = Seq.zip cs ds |> List.ofSeq

    let mutable ans = 0L
    for x, y in es do
        if x > y * 2L then
            ans <- 0L
        else
            ans <- ans + 1L
    printfn "%i" (ans + 1L)

    0

Measured memory_bytes: 40916
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define int long long
using namespace std;
long long k=1000000007;

int f(int n){
  if(n==0)return 1;
  else return n*f(n-1)%k;
}

signed main(){
  int n,m;
  cin>>n>>m;

  if(n==m){
    cout<<2*f(n)*f(n)%k<<endl;
  }else if(n-1==m){
    cout<<f(n)*f(m)%k<<endl;
  }else if(n==m-1){
    cout<<f(m)*f(n)%k<<endl;
  }else cout<<0<<endl;
}



Measured memory_bytes: 1792
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

class UnionFind {
 public:
  explicit UnionFind(const int32_t n) : parents_(n, -1) {}
  UnionFind() = delete;

  bool IsRoot(const int32_t x) const {
    return (parents_[x] < 0);
  }

  int32_t FindRoot(const int32_t x) {
    if (IsRoot(x)) {
      return x;
    }
    parents_[x] = FindRoot(parents_[x]);
    return parents_[x];
  }

  bool Unite(const int32_t x, const int32_t y) {
    int32_t root_1 = FindRoot(x);
    int32_t root_2 = FindRoot(y);
    if (root_1 == root_2) {
      return false;
    }
    if (parents_[root_1] > parents_[root_2]) {
      std::swap(root_1, root_2);
    }
    parents_[root_1] += parents_[root_2];
    parents_[root_2] = root_1;
    return true;
  }

  bool IsSame(const int32_t x, const int32_t y) {
    return FindRoot(x) == FindRoot(y);
  }

  int32_t Size(const int32_t x) {
    return -1 * parents_[FindRoot(x)];
  }

 private:
  std::vector<int32_t> parents_;
};

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

  int64_t N, M;
  cin >> N >> M;
  // vector<int64_t> A(M);
  // vector<int64_t> B(M);
  UnionFind uf(N);
  for (int64_t i = 0; i < M; ++i) {
    int64_t a, b;
    cin >> a >> b;
    --a;
    --b;
    uf.Unite(a, b);
  }
  map<int64_t, int64_t> groups;
  for (int64_t i = 0; i < N; ++i) {
    const int64_t croot = uf.FindRoot(i);
    const int64_t csize = uf.Size(croot);
    if (groups.find(croot) == groups.end()) {
      groups[croot] = csize;
    }
  }
  vector<int64_t> hist(groups.size());
  int64_t indx = 0;
  for (auto a : groups) {
    hist[indx] = a.second;
    ++indx;
  }
  sort(hist.begin(), hist.end());
  // reverse(hist.begin(), hist.end());
  int64_t result = 0;
  const int64_t L = static_cast<int64_t>(hist.size());
  int64_t tmp = 0;
  for (int64_t i = 0; i < L; ++i) {
    result += hist[i] - tmp;
    tmp = hist[i];
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;
using LL = long long;

const int N = 1e5 + 5;
int link[N];

int find(int a) {
	return a == link[a] ? a : link[a] = find(link[a]);
}

bool unite(int a, int b) {
	a = find(a);
	b = find(b);
	if (a == b) return false;
	link[b] = a;
	return true;
}
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i) link[i] = i;

	int res = n;
	for (int i = 0; i < m; ++i) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (unite(a, b)) res --;
	}
	printf("%d\n", res);
}

Measured memory_bytes: 640
// review
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;

int n;
int a[MAXN];

void solve() {
  ll sum = 0;
  for (int i=0;i<n;i++) {
    sum += a[i] - 1;
  }
  cout << sum << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 256
from collections import Counter as C
N = int(input())
P = []
M = []
d = 32
for i in range(N):
    x, y = map(int, input().split(" "))
    x += 3<<d # 桁揃え
    P.append(x+y)
    M.append(x-y)
  
k = 1 - P[0]%2
if len(C([p%2 for p in P])) > 1:
    print(-1) 
else: 
    print(d+k)
    print(" ".join(["1"][:k]+[str(1<<i) for i in range(d)]))
    for i in range(N):
        a = bin(P[i])[-d-1:]
        b = bin(M[i])[-d-1:]
        print(''.join(['LDUR'[(int(a[i])*2+int(b[i]))] for i in range(d+k)])[::-1])

Measured memory_bytes: 3564
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

double square(pair<int, int> p) {
    return p.first * p.first + p.second * p.second;
}

pair<int, int> add(pair<int, int> p, pair<int, int> q) {
    return make_pair(p.first + q.first, p.second + q.second);
}

double dot(pair<int, int> p, pair<int, int> q) {
    return p.first * q.first + p.second * q.second;
}

int main() {
    int x0, y0, x1, y1, q;
    cin >> x0 >> y0 >> x1 >> y1;
    pair<int, int> a = make_pair(x1 - x0, y1 - y0);

    cin >> q;
    while (q--) {
        int x, y;
        cin >> x >> y;

        pair<int, int> b = make_pair(x - x0, y - y0);
        
        if (x0 == x1) {
            if (x == x0) {
                if ((y - y0) * (y1 - y0) < 0) cout << "ONLINE_BACK" << endl;
                else if (abs(y - y0) > abs(y1 - y0)) cout << "ONLINE_FRONT" << endl;
                else cout << "ON_SEGMENT" << endl;
                continue;
            }
        }
        else if (y0 == y1) {
            if (y == y0) {
                if ((x - x0) * (x1 - x0) < 0) cout << "ONLINE_BACK" << endl;
                else if (abs(x - x0) > abs(x1 - x0)) cout << "ONLINE_FRONT" << endl;
                else cout << "ON_SEGMENT" << endl;
                continue;
            }
        }
        else {
            if ((x - x0) * (y1 - y0) == (x1 - x0) * (y - y0)) {
                if ((x - x0) * (x1 - x0) < 0) cout << "ONLINE_BACK" << endl;
                else if (abs(x - x0) > abs(x1 - x0)) cout << "ONLINE_FRONT" << endl;
                else cout << "ON_SEGMENT" << endl;
                continue;
            }
        }

        if (y1 == y0) {
            if (x0 < x1 && y > y1) cout << "COUNTER_CLOCKWISE" << endl;
            else if (x0 < x1) cout << "CLOCKWISE" << endl;
            else if (y > y1) cout << "CLOCKWISE" << endl;
            else cout << "COUNTER_CLOCKWISE" << endl;
            continue;
        }


        if (x1 - x0 == 0) {
            if (y0 < y1 && x > x1) cout << "CLOCKWISE" << endl;
            else if (y0 < y1) cout << "COUNTER_CLOCKWISE" << endl;
            else if (x > x1) cout << "COUNTER_CLOCKWISE" << endl;
            else cout << "CLOCKWISE" << endl;
        }
        else if (x1 - x0 > 0) {
            if ((x1 - x0) * y > (y1 - y0) * x + (x1 * y0 - x0 * y1))
                cout << "COUNTER_CLOCKWISE" << endl;
            else cout << "CLOCKWISE" << endl;
        }
        else {
            if ((x1 - x0) * y > (y1 - y0) * x + (x1 * y0 - x0 * y1))
                cout << "COUNTER_CLOCKWISE" << endl;
            else cout << "CLOCKWISE" << endl;
        }




    }
}


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

const int INF = 1000000000;

int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		map<string,vector<int> > ttable;
		map<string,int> point;
		for(int i=0;i<n;i++){
			string str;
			int m;
			cin >> str;
			cin >> m;
			int t;
			for(int j=0;j<m;j++){
				cin >> t;
				ttable[str].push_back(t);
			}
			point[str] = INF;
		}
		
		for(int i=0;i<31;i++){
			int p = 1+n;
			for(map<string,vector<int> >::iterator it = ttable.begin();it != ttable.end();it++){
				for(vector<int>::iterator itt = it->second.begin();itt != it->second.end();itt++){
					if(i == *itt)
						p--;
				}
			}	
			for(map<string,vector<int> >::iterator it = ttable.begin();it != ttable.end();it++){
				for(vector<int>::iterator itt = it->second.begin();itt != it->second.end();itt++){
					if(i == *itt){
						if(point[it->first] == INF)
							point[it->first] = p;
						else
							point[it->first] += p;
					}
				}
			}	
		}

		map<string,int>::iterator it = point.begin();
		string nmemo = it->first;
		int pmemo = it->second;
		for(it;it != point.end();it++){
			if(it->second ==  INF)
				it->second = 0;
			if(it->second < pmemo){
				nmemo = it->first;
				pmemo = it->second;
			}
		}
		cout << pmemo << " " << nmemo << endl; 
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long dp[100][100000];
long long fun(int i,int wt,int w[],long long v[])
{
	if(i==0||wt==0)
	return 0;
	if(dp[i-1][wt-1]!=-1)
	return dp[i-1][wt-1];
	else
{
	if(w[i-1]>wt)
	dp[i-1][wt-1]=fun(i-1,wt,w,v);
	else
	dp[i-1][wt-1]=max(fun(i-1,wt,w,v),fun(i-1,wt-w[i-1],w,v)+v[i-1]);
	return dp[i-1][wt-1];
}    

}
int main() 
{
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(NULL);
int n,W;
cin>>n>>W;
int w[n];
long long v[n];
for(int k=0;k<n;k++)
cin>>w[k]>>v[k];
for(int k=0;k<n;k++)
for(int j=0;j<W;j++)
dp[k][j]=-1;
cout<<fun(n,W,w,v);
}

Measured memory_bytes: 78336
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top+1];
}

int main(void) {
	int a, b;
	top = 0;
	char s[100];
	int count = 0;
	
	while (1) {
                scanf("%s", s);
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}else {
			push(atoi(s));
		}
		if (getchar() == '\n') break;
	}
	printf("%d\n", pop());

	return 0;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int a;
    cin >> a;
    string s;
    cin >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


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

int main(void){
   char o[51],e[51];
   int ol,el,i;
   double l;

   scanf("%s%s",o,e);
   ol=strlen(o); el=strlen(e);

   for(l=0;l<el;l+=0){
      i=(int)l;
      if(l-i==0){printf("%c",o[i]);l+=0.5;}
      else {printf("%c",e[i]);l+=0.5;}
   }

   if(ol-l>=0.5) printf("%c",o[(int)l]);
   printf("\n");

   return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
typedef long long ll;
int main(){
	int a[3];
	for(int i=0;i<3;i++)scanf("%d",&a[i]);
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]!=a[2])printf("Yes\n");
	else if(a[0]!=a[1]&&a[1]==a[2])printf("Yes\n");
	else puts("No");
	return 0;
} 

Measured memory_bytes: 256
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); while( _t-- )
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
// head collected

string str;
ll n, m, ans, an, _;
ll ara[200007];
ll b[200007];

start;

    cin1(n);
    rep(i, 0, n){
        cin1(_);
        b[ i ] = _;
        ara[ _ ]++;
    }
    ans = 0;
    rep(j, 1, n+1) ans += (    (  ara[j]  *  (ara[j]-1)  )  /  2    );

    rep(i, 0, n){
        an = (    (  (ara[b[i]] -1) *  (ara[b[i]]-2)  )  /  2    );
        m = (    (  ara[b[i]]  *  (ara[b[i]]-1)  )  /  2    );
        coul(ans-m+an);

    }


finish



Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;
 
int main() {


				 fast
				 int n,m;
				 cin>>n>>m;
				 if(m>n) swap(m,n);
				 if(m==1) cout<<(n*(n-1))/2<<endl;
				 else
				 cout<<(n*(n-1))/2+(m*(m-1)/2)<<endl;
                return 0;
            }

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a[50],b[50],c[50],d[50],A[10],h=0,k=0;

void tryy(int t){
    if(t==0){
        for (int i=1;i<=m;i++){
            A[t]=i;
            tryy(1);
        }
    }
    else if (t==n-1){
        for (int i=A[t-1];i<=m;i++){
            A[t]=i;
            h=0;
            for(int j=0;j<q;j++){
                if(A[b[j]-1]-A[a[j]-1]==c[j]) h+=d[j];
            }
            if(k<h) k=h;
        }
        }
    else{
        for (int i=A[t-1];i<=m;i++){
            A[t]=i;
            tryy(t+1);
    }
    }
}
int main()
{
    cin>>n>>m>>q;
    for (int i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    tryy(0);
    cout<<k;
}


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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    int W=in();
    int a=in();
    int b=in();
    int ans;
    if((a<=b&&b<=a+W)||(a<=b+W&&b+W<=a+W)){
        ans=0;
    }else if(b>a+W){
        ans=b-a-W;
    }else{
        ans=a-(b+W);
    }
    print(ans);
}

Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
const long long int N = 6999999;
#define all(x) begin(x),end(x)
#define ll long long int
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;

int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int r,d,s,t =10;
  cin >> r >> d >> s;
  while(t--)
  {
    s = r*s -d;
    cout << s << endl;
  }
  return 0;
}


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

int main(){
    ll n,k;
    cin >> n >> k;
    if(n-k <= 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    rep(i,n-k){
        ans += h[i];
    }
    cout << ans << endl;
}

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

const string bo = "aiueo";
const string musei = "ksthp";

int main(){
  string s;
  while(cin >> s, s!="#"){
    vector< pair<string,int> > haku;
    rep(i,s.size()){
      int len = 0, type = 0;
      if(bo.find(s[i]) != string::npos){
	if(i>0 && bo.find(s[i-1]) != string::npos)len = 1, type = 6;
	else len = 1, type = 1;
      }else{
	if(i+1<(int)s.size()){
	  if(s[i+1] == '\'')len = 2, type = 5;
	  else if(s[i+1] == s[i])len = 1, type = 4;
	  else if(s[i+1] == 'y')len = 3, type = 3;
	  else if(bo.find(s[i+1]) != string::npos)len = 2, type = 2;
	  else len = 1, type = 5;
	}else len = 1, type = 5;
      }
      haku.push_back(make_pair(s.substr(i,len), type) );
      i += len-1;
    }

    vector<int> par(haku.size(),0);
    rep(i,haku.size()){
      if( (haku[i].second == 2 || haku[i].second == 3)
	 && musei.find(haku[i].first[0]) != string::npos){
	if(haku[i].first.back() == 'i' || haku[i].first.back() == 'u'){
	  if(i+1==(int)haku.size() || musei.find(haku[i+1].first[0]) != string::npos){
	    par[i] = 1;
	  }
	}
	if(haku[i].first.back() == 'a' || haku[i].first.back() == 'o'){
	  if(i+1<(int)haku.size() && (haku[i+1].second == 2 || haku[i+1].second == 3)
	     && musei.find(haku[i+1].first[0]) != string::npos
	     && haku[i+1].first.back() == haku[i].first.back()){
	    par[i] = 1;
	  }
	}
      }
    }

    int prv = 0;
    rep(i,haku.size()){
      if(bo.find(haku[i].first.back()) != string::npos){
	if(par[i] && !prv){
	  cout << haku[i].first.substr(0,haku[i].first.size()-1) << "(" << haku[i].first.back() << ")";
	  prv = 1;
	}else{
	  cout << haku[i].first;
	  prv = 0;
	}
      }else{
	cout << haku[i].first;
      }	
    }
    cout << endl;
  }
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}

const ll mod = 1e9 + 7;

int main(){
    long long n;
    cin >> n;
    ll sum = 0,ans = 0;
    vector<long long> a(n);
    for (int i = 0;i < n;i++){
        cin >> a[i];
    }
    vector<int> b(70);
    for (int i = 0;i < 60;i++){
        ll one = 0,zero = 0;
        for (auto v : a){
            if ((v >> i) & 1) one++;
            else zero++;
        } 
        sum = 1LL << i;
        sum %= mod;
        sum *= (zero*one)%mod;
        ans += sum;
        ans %= mod;

    }
    
    cout << ans << endl;
}

Measured memory_bytes: 2560
/**
 *      ABC 43 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-20 07:01:10
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s; cin >> s;
    vector<int> answer;
    int sizes = s.size();
    for (auto i = 0; i < sizes; ++i) {
        if (s[i] == '0'){
            answer.push_back(0);
        }
        else if (s[i] == '1'){
            answer.push_back(1);
        }
        else if (s[i] == 'B'){
            if (answer.size() > 0) answer.pop_back();
        }
    }
    int sizea = answer.size();
    for (auto i = 0; i < sizea; ++i) {
        cout << answer[i];
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int n;
	int w[110];
	cin >> n;
	int sum = 0;
	rep(i, n) {
		cin >> w[i];
		sum += w[i];
	}
	int s1 = 0, s2 = 0;
	int ans = INF;
	rep(i, n) {
		s1 += w[i];
		s2 = sum - s1;
		ans = min(ans, abs(s1 - s2));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import Text.Printf

main :: IO()
main = do
  _ <- getLine
  h <- map read . words <$> getLine
  printf "%s" $ slv h True

slv :: [Integer] -> Bool -> String
slv (h:hh:hs) s | hh - h > 0 = slv (hh:hs) True
                | hh - h == 0 = slv (hh:hs) s
                | s == False = "No"
                | hh - h < -1 = "No"
                | otherwise = slv (hh:hs) False
slv (h:hs) s = "Yes"


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

const ll INF = 1e18;
ll dp[100005][3];
ll A[200005];

int main() {
  int n;
  cin >> n;
  //vector<ll> A(n);
  rep(i, n) cin >> A[i];
  ll ans = -INF;
  if (n%2 == 0) {
    for (int i = 0; i < n/2; ++i) {
      dp[i+1][0] += dp[i][0] + A[i*2];
      dp[i+1][1] += dp[i][1] + A[i*2+1];
    }
    rep(i, n/2+1) ans = max(ans, dp[i][0]+dp[n/2][1]-dp[i][1]);
  } else {
    rep(i, n/2+1) rep(j, 3) dp[i][j] = -INF;
    rep(i, 3) dp[1][i] = A[i];
    for (int i = 1; i < n/2; ++i) {
      dp[i+1][0] = dp[i][0] + A[i*2];
      dp[i+1][1] = max(dp[i][0] + A[i*2+1], dp[i][1] + A[i*2+1]);
      rep(j, 3) dp[i+1][2] = max(dp[i+1][2], dp[i][j] + A[i*2+2]);
    }
    rep(i, 3) ans = max(ans, dp[n/2][i]);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

class Solution {
public:
	void solve() {
		int n, m, l;
		cin >> n >> m >> l;
		cout << l << " " << n << " " << m << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

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

	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;

	vector<int> near(n + 1);
	int ls = 0;
	for(int i = n; i >= 0; --i){
		if(s[i] == '0') ls = i;
		near[i] = ls;
	}
	// debug() << near ;

	vector<int> moves;
	int it = n;
	while(it > 0){
		int lf = max(0, it - m);
		if(s[lf] == '1') lf = near[lf];
		// debug() << it << " " << lf;
		if(lf == it) return puts("-1"), 0;
		moves.push_back(it - lf);
		it = lf;
	}

	reverse(all(moves));
	for(auto &x :moves) cout << x << " ";

	
	return 0;
}

Measured memory_bytes: 1480
# coding: utf-8
import copy

n, k = map(int, input().split())
v = list(map(int, input().split()))
rev = copy.copy(v)
rev.reverse()

ans = -10**20
for l in range(n+1):
  for r in range(n+1-l):
    able = True
    d = k - ( l + r )
    if d < 0:
      able = False
      break
    t = v[0:l] + rev[0:r]
    m = sum(t)
    t.sort()
    d = min(d,l+r)
    for i in range(d):
      if 0 > t[i]:
        m -= t[i]
      else:
        break
    ans = max(ans,m)

print(ans)

Measured memory_bytes: 3572
#include <stdio.h>

int main() {
	
	int N=0;
	scanf("%d", &N);
	float i=2;
	if(N%2==0){
		N/i/N;
		printf("%f\n", N/i/N);
	}
	else {
		(N/i+0.5)/N;
		printf("%f\n", (N/i+0.5)/N);
	}
	return 0;
}

Measured memory_bytes: 128
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    N = len(S)

    ans = 0

    for i in range(N):
        for j in range(i, N):
            for k in range(i, j + 1):
                if S[k] not in ("A", "C", "G", "T"):
                    break
            else:
                ans = max(ans, j - i + 1)

    print(ans)


if __name__ == '__main__':
    main()


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

const int INF = 1e+8;
const int MAX_M = 16;
const int MAX_N = 20001;

// dp[i][y] := i 番目までの差分の総和
int dp[MAX_N][256];

int main(){
	int N, M;
	while( cin >> N >> M, N || M ){
		int C[MAX_M] = {0};
		
		for(int i=0 ; i < M ; i++ ){
			cin >> C[i];
		}
		
		// 初期化
		for(int i=0 ; i <= MAX_N ; i++ ){
			for(int j=0 ; j < 256 ; j++ ){
				dp[i][j] = INF;
			}
		}
		dp[0][128] = 0;
		
		for(int i=1 ; i <= N ; i++ ){
			int x;
			cin >> x;
			for(int prev=0 ; prev < 256 ; prev++ ){
				for(int m=0 ; m < M ; m++ ){
					int next = prev + C[m];
					if( next < 0 ) next = 0;
					if( next > 255 ) next = 255;
					int diff = (next - x) * (next - x);
					dp[i][next] = min( dp[i][next] , dp[i-1][prev] + diff );
				}
			}
		}
		int ans = INF;
		for(int i=0 ; i < 256 ; i++ ){
			ans = min( ans , dp[N][i] );
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 20000
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    A, B, T = i2nn()
    n = (T // A) * B
    print(n)

main()


Measured memory_bytes: 38256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main
{
    @SuppressWarnings("unchecked")
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int V = in.nextInt();
        int E = in.nextInt();

        used = new boolean[V];
        lEdge = new List[V];
        for (int i = 0; i < V; i++)
        {
            lEdge[i] = new ArrayList<Edge>();
        }

        for (int i = 0; i < E; i++)
        {
            addEdge(in.nextInt(), in.nextInt(), in.nextInt());
        }

        int res = 0;
        while (true)
        {
            Arrays.fill(used, false);
            int ret = dfs(0, V - 1, Integer.MAX_VALUE);
            if (ret == 0) break;
            res += ret;
        }
        System.out.println(res);
    }

    static List<Edge>[] lEdge;

    static void addEdge(int fr, int to, int cap)
    {
        lEdge[fr].add(new Edge(to, cap, lEdge[to].size()));
        lEdge[to].add(new Edge(fr, 0, lEdge[fr].size() - 1));
    }

    static class Edge
    {
        int to, cap, rev;

        public Edge(int to, int cap, int rev)
        {
            this.to = to;
            this.cap = cap;
            this.rev = rev;
        }
    }

    static boolean[] used;

    static int dfs(int fr, int to, int f)
    {
        if (fr == to) return f;
        used[fr] = true;

        for (int i = 0; i < lEdge[fr].size(); i++)
        {
            Edge e = lEdge[fr].get(i);
            if (!used[e.to] && e.cap > 0)
            {
                int dist = dfs(e.to, to, Math.min(f, e.cap));
                if (dist > 0)
                {
                    e.cap -= dist;
                    lEdge[e.to].get(e.rev).cap += dist;
                    return dist;
                }
            }
        }
        return 0;
    }

}


Measured memory_bytes: 34560
#include<bits/stdc++.h>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int n,k,a[100005];
int ans;
int main()
{
    n=read();k=read();
    register int i;
    for(i=1;i<=n;++i) a[i]=read();
    ans=1e9;
    for(i=1;i<=n-k+1;i++)
    {
        if(a[i]<=0&&a[i+k-1]<=0) ans=min(ans,-a[i]);
        if(a[i]<=0&&a[i+k-1]>=0) ans=min(ans,-a[i]+a[i+k-1]+min(-a[i],a[i+k-1]));
        if(a[i]>=0&&a[i+k-1]>=0) ans=min(ans,a[i+k-1]);
    }
    return 0*printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 640
N = int(input())
X = 'abcdefghijklmnopqrstuvwxyz'

d, m = divmod(N - 1, 26)
ans = X[m]
while d > 26:
    d, m = divmod(d - 1, 26)
    ans = X[m] + ans

if d != 0:
    ans = X[d - 1] + ans
print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> L(m);
    vector<int> R(m);
    rep(i, m) {
        cin >> L[i] >> R[i];
    }
    int min = 1;
    int max = 100000;

    rep(i, m) {
        if(min < L[i]) {
            min = L[i];
        }
        if(R[i] < max) {
            max = R[i];
        }
    }
    int ans = max - min + 1;

    if(ans <= 0) {
        cout << 0;
    }
    else {
        cout << ans;
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax=200010;
//ll a[Nmax];
//int* P = new int[N];

int main() {
	int N,a;
	cin >> N;
	set<int> set;
	for(int i=0;i < N;i++){
      cin >> a;
      set.insert(a);
    }
	cout << set.size() <<endl;
	
	return 0;
}

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

using namespace std;

const int INF = 200000000;

int dp[2][2][5002];
int n;
int cost[10000];

main(){
  cin >> n;
  for(int i=0;i<n-1;++i){
    cin >> cost[i];
  }
  fill(dp[0][0], dp[2][0], INF);
  dp[0][0][1] = 0;
  dp[0][1][0] = 0;
  for(int i=0;i<n-1;++i){
    int now = i%2;
    int next = (i+1)%2;
    for(int j=0;j<=n/2;++j) dp[next][0][j] = dp[next][1][j] = INF;
    for(int j=0;j<=n/2;++j){
      dp[next][0][j+1] = min(dp[next][0][j+1], dp[now][0][j]);
      dp[next][0][j+1] = min(dp[next][0][j+1], dp[now][1][j] + cost[i]);
      dp[next][1][j] = min(dp[next][1][j], dp[now][1][j]);
      dp[next][1][j] = min(dp[next][1][j], dp[now][0][j] + cost[i]);
    }
  }
  cout << min(dp[1][0][n/2], dp[1][1][n/2]) << endl;
  return 0;
}

Measured memory_bytes: 944