akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;
  if (s.size() == 3) {
    reverse(begin(s), end(s));
  }
  cout << s << "\n";
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int M = 1000000000;

int n, k, s;

int main()
{
    scanf("%d%d%d", &n, &k, &s);
    if (s != M)
    {
        for (int i = 0; i < k; ++i)
            printf("%d ", s);
        for (int i = 0; i < (n - k); ++i)
            printf("%d ", M);
        printf("\n");
    }
    else
    {
        for (int i = 0; i < k; ++i)
            printf("%d ", s);
        for (int i = 0; i < (n - k); ++i)
            printf("1 ");
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
int a, b, c, d, e, f;
struct A
{
    double water;
    double suger;
    double w;
};
A cup[5000];
int fun(int maxs)
{
    int cup1 = c;
    int cup2 = d;
    int Max = 0;
    for(int i = 0; i*cup1 <= maxs; i++)
    {
        for(int j = 0; j*cup2 <= maxs; j++)
        {
            if(cup1*i + cup2*j > maxs)break;
            if(cup1*i+cup2*j > Max)
            {
                Max = cup1*i+cup2*j;
            }

        }
    }
//    cout << Max << endl;
    return Max;
}
int cmp(A a, A b)
{
    return a.w > b.w;
}
int main()
{
    cin >> a >> b >> c >> d >> e >> f;
    int ji = 0;
    for(int i = 0; i*100 <= f; i++)
    {
        int water = 0;
        for(int j = 0; j*100 <= f; j++)
        {
            water = a*100*i + b*j*100;
            if(water > f)break;
            if(water == 0)continue;
            int maxs = water/100;
            if(water + maxs*e <= f)maxs = maxs*e;
            else maxs = f - water;
            int sugers = fun(maxs);
            if(water+sugers > f)
            {
//                cout << ji;
                cup[ji].water = water;
                cup[ji].suger = 0;
                cup[ji].w = (cup[ji].suger*1.0)/(cup[ji].water*1.0)*100;
                ji++;
                break;
            }
            cup[ji].water = water + sugers;
            cup[ji].suger = sugers;
            cup[ji].w = (cup[ji].suger*1.0)/(cup[ji].water*1.0)*100;
            ji++;
        }
    }
    sort(cup, cup+ji, cmp);
//    for(int i = 0; i < ji; i++)
//    {
//        cout << cup[i].water-cup[i].suger << ' ' << cup[i].suger << ' ' << cup[i].w << endl;
//    }
    cout << cup[0].water << ' ' << cup[0].suger << endl;
    return 0;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if a+b==c||a+c==b||b+c==a{"Yes"}else{"No"})
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ld n, x, t;
    cin >> n >> x >> t;

    COUT(int(ceil(n / x) * t));

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 3740
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray().Select(x => x.ToString()).ToList();
            var result = 0;
            var current = s[0];

            for (var i = 0; i < s.Count; i++)
            {
                if(s[i] != current)
                {
                    result++;
                    current = s[i];
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 30400
using System;

class B12{
  const int max = 100;
  const int inf = (1<<21);
  const int white = 0;
  const int gray = 1;
  const int brack = 2;

  static int n;
  static int[,] m = new int[max,max];

  public static void Calc(){
    int min;
    int[] d = new int[max];
    int[] color = new int[max];

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

    d[0] = 0;
    color[0] = gray;
    while(true){
      min = inf;
      int u = -1;
      for(int i = 0;i < n;i++){
        if(min > d[i] && color[i] != brack){
          u = i;
          min = d[i];
        }
      }
      if(u == -1) break;
      color[u] = brack;
      for(int v = 0;v < n;v++){
        if(color[v] != brack && m[u,v] != inf){
          if(d[v] > d[u] + m[u,v]){
            d[v] = d[u] + m[u,v];
            color[v] = gray;
          }
        }
      }
    }
    for(int i = 0;i < n;i++){
      Console.WriteLine("{0} {1}",i,d[i] == inf ? -1 :d[i]);
    }
  }

  public static void Main(){
    n = int.Parse(Console.ReadLine());
    for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++){
        m[i,j] = inf;
      }
    }

    int k,c,u,v;
    for(int i = 0;i < n;i++){
      string[] str = Console.ReadLine().Split(' ');
      u = int.Parse(str[0]);
      k = int.Parse(str[1]);
      for(int j = 0;j < k;j++){
        v = int.Parse(str[2 + j * 2]);
        c = int.Parse(str[3 + j * 2]);
        m[u,v] = c;
      }
    }
    Calc();
  }
}



Measured memory_bytes: 15976
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int n,m;
int g[700][700];
int vis[700];

bool dfs( int curr, int val, int cnt[2])
{
    assert(val==1 || val==2);
    if(vis[curr]) {
        if(vis[curr]!=val) return false;
        return true;
    }
    vis[curr]=val;
    cnt[val-1]++;

    int i;
    for(i=0; i<n; i++) {
        if(curr!=i && g[curr][i]==0) {
            if( !dfs( i, 3-val, cnt) ) {
                return false;
            }
        }
    }

    return true;
}

int dp[700][700];

int main(int argc, char* argv[])
{
    scanf("%d%d", &n, &m);

    int i,j;
    for(i=0; i<m; i++) {
        int a,b;
        scanf("%d%d", &a, &b); a--; b--;
        g[a][b]=g[b][a]=1;
    }

    vector<int> save;
    for(i=0; i<n; i++) {
        if(vis[i]) continue;
        int cnt[2]={0};
        if(!dfs(i, 1, cnt)) {
            printf("-1\n"); return 0;
        }
        save.push_back(abs(cnt[1]-cnt[0]));
    }

    int siz=(int)save.size();
    dp[0][0]=1;
    for(i=0; i<siz; i++) {
        for(j=0; j<=n; j++) {
            if(dp[i][j]) {
                dp[i+1][abs(j+save[i])]=1;
                dp[i+1][abs(j-save[i])]=1;
            }
        }
    }
    for(j=0; j<=n; j++) {
        if(dp[siz][j]) break;
    }
    int tmp0=(n+j)/2;
    int tmp1=(n-j)/2;
    printf("%d\n", tmp0*(tmp0-1)/2 + tmp1*(tmp1-1)/2);

    return 0;
}



Measured memory_bytes: 4096
//run: g++ -std=c++14 -o run_sol.exe solution.cpp -DLOCAL_JUDGE
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;

#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;

VLL nums;
vector<vector<VLL>> memo;

LL solve (int ini, int fin, int player) {
    if (ini + 1 == fin) {
        return nums[ini] * player;
    }
    if (memo[player][ini][fin] > -1) {
        return memo[player][ini][fin];
    }
    LL res = 0;
    if (player == 1) {
        res = max(solve(ini + 1, fin, 1 - player) + nums[ini], 
                    solve(ini, fin - 1, 1 - player) + nums[fin - 1]);
    } else {
        res = min(solve(ini + 1, fin, 1 - player), 
                    solve(ini, fin - 1, 1 - player));
    }

    return memo[player][ini][fin] = res;
}

int main() {
    #ifdef LOCAL_JUDGE
        freopen("../input.txt", "rt", stdin);
        freopen("../output.txt", "wt", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    for (int n; cin >> n; ) {
        nums.assign(n, 0);
        memo.assign(2, vector<VLL>(n + 1, VLL(n + 1, -1)));
        LL sum = 0;
        for (auto& val : nums) {
            cin >> val;
            sum += val;
        }

        cout << 2 * solve(0, n, 1) - sum << "\n";
    }
return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    complex<int> p1(x1,y1), p2(x2,y2), p3, p4, i(0,1);
    p3 = (p1 - p2) * (-i) + p2;
    p4 = (p2 - p1) * i + p1;
    printf("%d %d %d %d\n",real(p3),imag(p3),real(p4),imag(p4));
}

Measured memory_bytes: 256
#include <iostream>
#define MAX 25
#define NIL -1

using namespace std;

struct Node{
  int parent,left,right;
};

Node nodes[25];

void pre(int id){
  printf(" %d",id);
  if(nodes[id].left!=NIL) pre(nodes[id].left);
  if(nodes[id].right!=NIL) pre(nodes[id].right);
}

void ino(int id){
  if(nodes[id].left!=NIL) ino(nodes[id].left);
  printf(" %d",id);
  if(nodes[id].right!=NIL) ino(nodes[id].right);
}

void pos(int id){
  if(nodes[id].left!=NIL) pos(nodes[id].left);
  if(nodes[id].right!=NIL) pos(nodes[id].right);
  printf(" %d",id);
}

int main(){
  int n;cin>>n;

  for(int i=0;i<n;i++){
    nodes[i].parent = nodes[i].left = nodes[i].right = NIL;
  }

  for(int i=0;i<n;i++){
    int id,l,r;
    cin>>id>>l>>r;
    nodes[id].left = l;
    nodes[id].right = r;
    if(l!=-1) nodes[l].parent = id;
    if(r!=-1) nodes[r].parent = id;
  }

  int root;
  for(int i=0;i<n;i++){
    if(nodes[i].parent==NIL){root=i;break;}
  }
  printf("Preorder\n");
  pre(root);
  printf("\n");

  printf("Inorder\n");
  ino(root);
  printf("\n");

  printf("Postorder\n");
  pos(root);
  printf("\n");

}

Measured memory_bytes: 3172
import heapq as hq
import sys

k=int(input())
if k<10:
    print(k)

else:
    A=[1,2,3,4,5,6,7,8,9]
    hq.heapify(A)
    now=9
    while True:
        a=hq.heappop(A)
        r=a%10
        if r==0:
            for i in range(2):
                p=a*10+i
                hq.heappush(A,p)
                now+=1
                if k==now:
                    print(p)
                    sys.exit()
        elif r==9:
            for i in range(2):
                p=a*10+8+i
                hq.heappush(A,p)
                now+=1
                if k==now:
                    print(p)
                    sys.exit()
        else:
            for i in range(3):
                p=a*10+r+i-1
                hq.heappush(A,p)
                now+=1
                if k==now:
                    print(p)
                    sys.exit()

Measured memory_bytes: 50908
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
  int r,d,a;
  cin>>r>>d>>a;
  for(int i=1;i<=10;i++){
    a=a*r-d;
    cout<<a<<endl;
}
}

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

int main() {
  string str;
  cin >> str;

  int i = 0;
  for (auto c : str) {
    if (c == '+') {
      ++i;
    }
    else {
      --i;
    }
  }

  cout << i << endl;
}


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

int digit_sum(int n) {
  int ans = 0;
  while(n > 0) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for(int i = 1; i <= N; ++i) {
    auto sum = digit_sum(i);
    if(A <= sum && sum <= B) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();

	int H, W; cin >> H >> W;
	int N; cin >> N;
	vector<int>a(N);
	rep(i, 0, N)cin >> a[i];
	int k = 0;
	Graph ans(H, vector<int>(W, 0));
	rep(i, 0, H) {
		if (i % 2 == 0) {
			rep(j, 0, W) {
				if (a[k] <= 0)++k;
				ans[i][j] = k + 1;
				--a[k];
			}
		}
		else {
			rREP(j, 0, W) {
				if (a[k] <= 0)++k;
				ans[i][j] = k + 1;
				--a[k];
			}
		}
	}
	rep(i, 0, H) {
		rep(j, 0, W) {
			cout << ans[i][j];
			if (j != W - 1)cout << " ";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

typedef tuple<int, int, int, int> TP;
TP narabi(int a, int b, int c, int d) {
	TP kari[4];
	kari[0] = tie(a, b, c, d);
	kari[1] = tie(b, c, d, a);
	kari[2] = tie(c, d, a, b);
	kari[3] = tie(d, a, b, c);
	return *min_element(kari, kari + 4);
}

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


	int N;
	cin >> N;
	TP C[400];
	int cnum[1000] = {};
	rep(i, N) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		C[i] = narabi(a, b, c, d);
		cnum[a]++;
		if(a != b) cnum[b]++;
		if(c != a && c != b) cnum[c]++;
		if(d != a && d != b && d != c) cnum[d]++;
	}

	sort(C, C + N);
	int kazu[400] = {};
	rep(i, N) {
		int k = i;
		while (k + 1 < N && C[k + 1] == C[i]) k++;
		kazu[i] = k - i + 1;
		i = k;
	}

	ll kotae = 0;
	rep(i, N) {
		int inum = lower_bound(C, C + N, C[i]) - C;
		kazu[inum]--;
		rep(j, N) if (i != j) {
			int bairitu = kazu[inum] + 1;
			int jnum = lower_bound(C, C + N, C[j]) - C;
			bairitu *= kazu[jnum]--;

			int a, b, c, d, e, f, g, h;
			a = get<0>(C[i]);
			b = get<1>(C[i]);
			c = get<2>(C[i]);
			d = get<3>(C[i]);
			e = get<0>(C[j]);
			f = get<1>(C[j]);
			g = get<2>(C[j]);
			h = get<3>(C[j]);
			if (cnum[a] <= 2 || cnum[b] <= 2 || cnum[c] <= 2 || cnum[d] <= 2 || cnum[e] <= 2 || cnum[f] <= 2 || cnum[g] <= 2 || cnum[h] <= 2) {
				j += kazu[jnum]++;
				continue;
			}

			rep(x, 4) {
				TP D[4];
				D[0] = narabi(a, d, f, e);
				D[1] = narabi(a, e, h, b);
				D[2] = narabi(b, h, g, c);
				D[3] = narabi(c, g, f, d);
				TP* itr[4];
				rep(k, 4) itr[k] = lower_bound(C, C + N, D[k]);
				ll kari = bairitu;
				rep(k, 4) {
					if (itr[k] != C + N && *(itr[k]) == D[k]) {
						kari *= kazu[itr[k] - C]--;
						if (get<0>(D[k]) == get<2>(D[k]) && get<1>(D[k]) == get<3>(D[k])) {
							kari *= 2;
							if (get<1>(D[k]) == get<2>(D[k])) kari *= 2;
						}
					}
					else {
						kari = 0;
						break;
					}
				}
				rep(k, 4) {
					if (itr[k] != C + N && *itr[k] == D[k]) {
						kazu[itr[k] - C]++;
					}
					else break;
				}
				kotae += kari;

				int tmp = e;
				e = f;
				f = g;
				g = h;
				h = tmp;
			}
			j += kazu[jnum]++;
		}
		i += kazu[inum]++;
	}
	co(kotae / 6);

	Would you please return 0;
}

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

int replace_count = 0;

void kaibun_counter(std::string s) {
    if (s.length() <= 1) { return; }
    if (s[0] != s[s.length()-1]) { replace_count ++; }
    s = s.erase(0,1);
    s = s.erase(s.length()-1,1);
    kaibun_counter(s);
}

int main() {
    std::string s;
    cin >> s;
    kaibun_counter(s);
    cout << replace_count << endl;
}

Measured memory_bytes: 256
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
int Xiaobo()
{
	ll h,sum=0;
	scanf("%lld",&h);
	int cnt=0;
	ll x=h;
	while(x) {
		cnt++;
		x/=2;
	}
	//cout<<cnt<<'\n';
	sum=pow(2,cnt)-1;
	cout<<sum<<'\n';
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

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

bool flag[110000];
int cnt[110000];

int main(){
	int N, M;
	cin >> N >> M;
	int ans = 0;
	for(int i = 0; i < M; i++){
		int p;
		string S;
		cin >> p >> S;
		if(S == "WA" && !flag[p]){
			cnt[p] += 1;
		}
		if(S == "AC" && !flag[p]){
			flag[p] = true;
			ans += cnt[p];
		}
	}
	int acNum = 0;
	for(int i = 1; i <= N; i++){
		if(flag[i]){
			acNum += 1;
		}
	}
	cout << acNum << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);

    if( a>=1 && a<=9 && b>=1 && b<=9)
        printf("%d\n",a*b);
    else {
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int bubble_sort(int a[],int n){
  int c=0;
  for(int i=0;i<n;i++){
    for(int i=1;i<n;i++){
      if(a[i-1]>a[i]){
        c++;
        std::swap(a[i-1],a[i]);
      }
    }
  }
  return c;
}

int main(){
  int n,a[100];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int change = bubble_sort(a,n);
  for(int i=0;i<n-1;i++){
    cout << a[i] << ' ';
  }
  cout << a[n-1] << endl;
  cout << change << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
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; }

const int MOD = 1000000007;

long long POW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

vector<ll> memo(2005, -1);
ll sum(ll s) {
    if(memo[s] != -1) {
        return memo[s];
    } else {
        if(s < 3) {
            memo[s] = 0;
        } else if(s < 6) {
            memo[s] = 1;
        } else {
            memo[s] = 1;
            for(ll i = 3; s - i >= 3; ++i) {
                memo[s] += sum(i);
                memo[s] %= MOD;
            }
        }

        return memo[s] % MOD;
    }
}

int main() {
    ll S;
    cin >> S;

    cout << sum(S) << endl;

    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include <memory.h>
int main(void){
int kazu[100],how,i;
char id;
memset(kazu,0,sizeof(kazu));
scanf("%d",&how);
for(i=0;i<how;i++){
scanf("%d",&kazu[i]);
}
for(i=how-1;i>=0;i--){
if(i==0)
printf("%d",kazu[i]);
else
printf("%d ",kazu[i]);
}
printf("\n");
return 0;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];

    int S = accumulate(A.begin(), A.end(), 0);
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        if (A[i] * 4 * M >= S) {
            cnt ++;
        }
    }
    cout << (cnt >= M ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3584
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
print(sum(i - j for i, j in zip(V, C) if i > j))


Measured memory_bytes: 38384
#include <stdio.h>
int main(void)
{
    int N, num_of_subordinates[2 * 100000] = {0};
    scanf("%i", &N);
    for (int i = 0; i < N - 1; i++)
    {
        int tmp;
        scanf("%i", &tmp);
        num_of_subordinates[tmp - 1] += 1;
    }
    for (int i = 0; i < N; i++)
    {
        printf("%i\n", num_of_subordinates[i]);
    }
}

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

int main(){
    string s;
    cin >> s;

    if (s.find("7") != string::npos) 
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ull n,a,b,c,d;
ull tac;
map<ull, ull> mp;
ull dfs(ull x)
{
	if (x<2) return x*d;
	if (mp.count(x)) return mp[x];
	ull r=x*d;
	//cout <<r<<" ############\n";
	r=min(r,(x%2)*d+dfs(x/2)+a); 
	r=min(r,(x%3)*d+dfs(x/3)+b); 
	r=min(r,(x%5)*d+dfs(x/5)+c);
	r=min(r,(2-(x%2))*d+dfs((x+1)/2)+a); 
	r=min(r,(3-(x%3))*d+dfs((x+2)/3)+b); 
	r=min(r,(5-(x%5))*d+dfs((x+4)/5)+c); 
	return mp[x]=r;
}
void Main()
{
	mp.clear();
	cin >>n>>a>>b>>c>>d;
	cout <<dfs(n)<<"\n";
} 
int main()
{
	cin >>tac;
	while (tac--) Main();
	return 0;
}

Measured memory_bytes: 4380
#include <iostream>
using namespace std;
int main(){
    int a,b,c;cin>>a>>b>>c;
    int ans = 0;
    int ret = 1;
    while(true){
      if(ret%7==0)ans+=b;
      ans+=a;
      if(ans >= c){
        cout << ret << endl;
        return 0;
      }
      ret++;
    }
}


Measured memory_bytes: 3108
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



const int MAX_PRIME = 1299709;
bool is_prime[MAX_PRIME + 1];
void sieve(int n = MAX_PRIME)
{
	fill_n(is_prime, n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i * i <= n; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
}
vector<int> make_primes(int n = MAX_PRIME)
{
	vector<int> res;
	for (int i = 2; i <= n; ++i)
		if (is_prime[i])
			res.push_back(i);
	return res;
}
int main()
{
	sieve();
	vector<int> p = make_primes();
	int n;
	while (scanf("%d", &n), n)
	{
		if (is_prime[n])
			puts("0");
		else
		{
			int t = lower_bound(all(p), n) - p.begin();
			printf("%d\n", p[t] - p[t - 1]);
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact();
    int X, Y;
    cin >> X >> Y;
    if((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int move = (X + Y) / 3;
    X -= move;
    Y -= move;
    //cout << X << " " << Y << endl;
    cout << C(X + Y, X) << endl;

    return 0;
}


Measured memory_bytes: 16640
#include <iostream>
using namespace std;
int main() {
    int n = 0;
    int l = 0;
    int min = 99999999;
    int ans = 0;
    bool mr = true;
    cin >> n >> l;
    for (int i = 1; i <= n; ++i) {
        int r = l + i -1;
        if(min > abs(r) && r > 0){
            min = abs(r);
            mr = true;
        }else if(min > abs(r) && r <= 0){
            min = abs(r);
            mr = false;
        }
    }

    for (int j = 1; j <= n; ++j) {
        int r = l + j -1;
        ans += r;
    }
    if(mr == true) {
        ans -= min;
    } else{
        ans += min;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
vector<int> a;
vector<vector<int>> c;

int f(int u){
    if(c[u].size() == 0){
        return 0;
    }

    vector<int> vs;
    for(auto v : c[u]){
        vs.emplace_back(f(v));
    }
    sort(all(vs));
    reverse(all(vs));
    rep(i,vs.size()){
        vs[i] = vs[i] + i + 1;
    }
    return *max_element(all(vs));
}

int main(){
    cin >> N;
    a.resize(N);
    a[0] = -1;
    for(int i=1;i<N;i++){
        cin >> a[i];
        a[i]--;
    }
    c.resize(N);
    for(int i=1;i<N;i++){
        c[a[i]].emplace_back(i);
    }
    /* cout << c << endl; */
    cout << f(0) << endl;
    /* cout << "------------------" << endl; */
    /* rep(i,N){ */
    /*     cout << i << " " << f(i) << endl; */
    /* } */
}


Measured memory_bytes: 13952
import sys
for s in sys.stdin:
  y,m,d=map(int,s[:-1].split())
  x="%d%02d%02d"%(y,m,d)
  if x<"18680908":e="pre-meiji"
  elif x<"19120730":e="meiji %d %d %d"%(y-1867,m,d)
  elif x<"19261225":e="taisho %d %d %d"%(y-1911,m,d)
  elif x<"19890108":e="showa %d %d %d"%(y-1925,m,d)
  else:e="heisei %d %d %d"%(y-1988,m,d)
  print e

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

double sx,sy,tx,ty;
int n;
double xs[1252],ys[1252],rs[1252];
double dist[1252][1252];

double mnd[1252];
bool used[1252];

int main(){
  scanf("%lf%lf%lf%lf",&sx,&sy,&tx,&ty);
  scanf("%d",&n);
  REP(i,n)scanf("%lf%lf%lf",xs+i,ys+i,rs+i);
  REP(i,n)REP(j,n){
    double ax=xs[i],ay=ys[i], bx=xs[j],by=ys[j];
    double ar=rs[i], br=rs[j];
    double dr2 = (ar+br)*(ar+br);
    double d2 = (ax-bx)*(ax-bx)+(ay-by)*(ay-by);
    double di = d2<=dr2 ? 0.0 : sqrt(d2)-ar-br;
    dist[i][j] = di;
  }
  REP(i,n){
    double x=xs[i], y=ys[i], r=rs[i];
    double d2,dx,dy;
    dx = sx-x;
    dy = sy-y;
    d2 = dx*dx+dy*dy;
    dist[i][n] = dist[n][i] = d2<=r*r ? 0.0 : sqrt(d2)-r;
    dx = tx-x;
    dy = ty-y;
    d2 = dx*dx+dy*dy;
    dist[i][n+1] = dist[n+1][i] = d2<=r*r ? 0.0 : sqrt(d2)-r;
  }
  dist[n][n+1] = dist[n+1][n] = sqrt((sx-tx)*(sx-tx) + (sy-ty)*(sy-ty));
  typedef pair<double,int> pdd;
  priority_queue<pdd> Q;
  REP(i,n+2)mnd[i] = 1e18;
  mnd[n] = 0.0;
  Q.push(pdd(-0.0,n));
  while(!Q.empty()){
    int pos = Q.top().second; Q.pop();
    double now = mnd[pos];
    // DEBUG(pos);
    // DEBUG(now);
    used[pos] = true;
    REP(to,n+2){
      if(used[to])continue;
      double nxt = now + dist[pos][to];
      if(nxt >= mnd[to])continue;
      mnd[to] = nxt;
      Q.push(pdd(-nxt,to));
    }
  }
  printf("%.9f\n",mnd[n+1]);
  return 0;
}


Measured memory_bytes: 14320
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

pair<int, int> a[100'009];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, l;
    scanf("%d%d", &x, &l);
    a[i] = {x + l, x - l};
  }
  sort(a, a + n);
  int r = -2'000'000'000;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i].second >= r) {
      r = a[i].first;
      ++ans;
    }
  }
  printf("%d\n", ans);
}


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

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

  int n, d;
  cin >> n >> d;

  d = 2 * d + 1;
  cout << (n + d - 1) / d << '\n';
  return 0;
}

Measured memory_bytes: 256
N, Y = input().split()
N = int(N)
Y = int(Y)
i = 0
j = 0
k = N - i - j


for i in range(N+1):
    for j in range(N - i + 1):
        k = N - i - j
        SUM = 10000*i + 5000 * j + 1000 * k
        if SUM == Y:
            print(i, j, k)
            exit()
        else:
            continue
        
print('-1', '-1', '-1')

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string n;
  cin >> n;
  if (n[0] == n[1] && n[1] == n[2]) {
    cout << "Yes" << endl;
    return 0;
  }

  if (n[1] == n[2] && n[2] == n[3]) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef complex<double> Point;

struct Line{
	Point pos,dir;
	Line(){}
	Line(Point pos,Point dir):pos(pos),dir(dir){}
};

namespace std
{
	bool operator<(const Point& lhs,const Point& rhs)
	{
		if(real(lhs)==real(rhs))
			return imag(lhs)<imag(rhs);
		else
			return real(lhs)<real(rhs);
	}
}

const double EPS=1.0e-10;

inline int Signum(double x)
{
	return abs(x)<EPS?0:x>0?1:-1;
}

double Dot(Point p1,Point p2)
{
	return real(conj(p1)*p2);
}

double Cross(Point p1,Point p2)
{
	return imag(conj(p1)*p2);
}

int CCW(Point a,Point b,Point c)
{
	Point d1=b-a,d2=c-a;
	double sign=Signum(Cross(d1,d2));
	
	if(sign)
		return sign;	// 1:ccw,-1:cw
	if(Dot(d1,d2)<-EPS)
		return -2;		// c-a-b
	if(norm(d1)<norm(d2)-EPS)
		return 2;		// a-b-c
	return 0;			// a-c-b
}

void ConvexHull(const vector<Point> _points,vector<Point>& vertices)
{
	vector<Point> points(_points);
	vertices.clear();
	
	sort(allof(points));
	
	vector<Point> lv,uv;
	rep(i,points.size()){
		Point p=points[i];
		if(lv.size()<2){
			lv.push_back(p);
			continue;
		}
		Point p0=lv[lv.size()-2];
		Point p1=lv[lv.size()-1];
		if(CCW(p0,p1,p)==1)
			lv.push_back(p);
		else{
			lv.pop_back();
			i--;
		}
	}
	rep(i,points.size()){
		Point p=points[points.size()-1-i];
		if(uv.size()<2){
			uv.push_back(p);
			continue;
		}
		Point p0=uv[uv.size()-2];
		Point p1=uv[uv.size()-1];
		if(CCW(p0,p1,p)==1)
			uv.push_back(p);
		else{
			uv.pop_back();
			i--;
		}
	}
	rep(i,lv.size()-1)
		vertices.push_back(lv[i]);
	rep(i,uv.size()-1)
		vertices.push_back(uv[i]);
	//puts("lv");
	//rep(i,lv.size())
	//	cout<<real(lv[i])<<" "<<imag(lv[i])<<endl;
	//puts("uv");
	//rep(i,uv.size())
	//	cout<<real(uv[i])<<" "<<imag(uv[i])<<endl;
	//puts("finish");
}

int main()
{
	for(int n;cin>>n,n;){
		vector<Point> points(n);
		rep(i,n)
			scanf("%lf,%lf",&real(points[i]),&imag(points[i]));
		vector<Point> vertices;
		ConvexHull(points,vertices);
		//rep(i,vertices.size())
		//	cout<<real(vertices[i])<<" "<<imag(vertices[i])<<endl;
		cout<<points.size()-vertices.size()<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
taka_array = list(
    map(int,
        input().replace("L", "0").replace("R", "1").replace("U", "2").replace(
            "D", "3")))
aoki_array = list(
    map(int,
        input().replace("L", "0").replace("R", "1").replace("U", "2").replace(
            "D", "3")))
# print(list(taka_array))

limit_array = [0, 0, 0, 0]
size_array = [W, H]

for i, (taka, aoki) in enumerate(zip(taka_array[::-1], aoki_array[::-1])):
    if i != 0 and limit_array[(aoki // 2 * 4 + 1 - aoki)] != 0:
        limit_array[(aoki // 2 * 4 + 1 - aoki)] -= 1  # 0,1,2,3 -> 1,0,3,2

    limit_array[taka] += 1
    if limit_array[taka] == size_array[taka // 2]:
        print("NO")
        exit()
    # print(limit_array)
if 1 + limit_array[0] <= sc and W - limit_array[1] >= sc and 1 + limit_array[2] <= sr and H - limit_array[3] >= sr:
    print("YES")
else:
    print("NO")


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

int main(){

	int Num;
	int SubNum;
	for(Num=1;Num!=10;Num++)
	{for(SubNum=1;SubNum!=10;SubNum++){
	cout<<Num<<"x"<<SubNum<<"="<<Num*SubNum<<endl;
	}}

return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <memory.h>
#include<iomanip>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2 * 1000 + 47;

string a, b;
int A[MAX];
int B[MAX];
vector<PII> P;
int L[MAX];
int R[MAX];
int n;

void ADD(int& key, int val)
{
	key += val;
	if (key < 0) key += n;
	if (key >= n) key -= n;
}

int solve(vector<PII>& P, int sh)
{
	sort(ALL(P));
	int ans = INF;
	int mx = 0;
	RFOR(i, SZ(P), 0)
	{
		int val = P[i].first + 2 * mx + abs(P[i].first - sh);
		ans = min(ans, val);
		mx = max(mx, P[i].second);
	}

	ans = min(ans, mx * 2 + sh);
	// cout << "sh=" << sh << endl;
	// FOR(i,0, SZ(P))
	// {
	//     cout << P[i].first << " " << P[i].second << endl;
	// }
	// cout<< "ans=" << ans << endl;
	if (ans == INF) ans = 0;
	return ans;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> a >> b;
	n = SZ(a);
	int cntA = 0, cntB = 0;
	FOR(i, 0, n)
	{
		A[i] = a[i] - '0';
		B[i] = b[i] - '0';

		cntA += A[i];
		cntB += B[i];
	}

	if (cntB == 0 && cntA)
	{
		cout << -1 << endl;
		return 0;
	}

	FOR(i, 0, n)
	{
		FOR(d, 0, n)
		{
			int x = 0;
			ADD(x, i - d);
			if (B[x] == 1)
			{
				L[i] = d;
				break;
			}
		}

		FOR(d, 0, n)
		{
			int x = 0;
			ADD(x, i + d);
			if (B[x] == 1)
			{
				R[i] = d;
				break;
			}
		}
	}

	// FOR(i,0,n)
	// {
	//     cout << L[i] << " " << R[i] << endl;
	// }
	int ans = INF;
	FOR(i, 0, n)
	{
		P.clear();
		int cnt = 0;
		FOR(j, 0, n)
		{
			int x = 0;
			ADD(x, j - i);

			cnt += B[x] != A[j];
			if (B[x] == 0 && A[j] == 1)
			{
				P.PB(MP(L[j], R[j]));
			}
		}

		ans = min(ans, solve(P, i) + cnt);
		FOR(j, 0, SZ(P))
		{
			swap(P[j].first, P[j].second);
		}

		ans = min(ans, solve(P, n - i) + cnt);
	}

	cout << ans << endl;
}

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

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
	int N;
	scin(N)
	if(N % 2 == 0) printf("%lf\n",1. / 2.); else printf("%lf\n",double((N + 1) / 2) / double(N));
	
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

public static void main(String[] args) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = reader.readLine();
String[] array = str.split(" ");
int a = Integer.parseInt(array[0]);
int b = Integer.parseInt(array[1]);
System.out.println(a * b + " " + (a + b) * 2);
} catch (IOException e) {
e.printStackTrace();
}
}

}

Measured memory_bytes: 24196
N = int(input())
ans = 0
for n in range(1, N+1, 2):
    i = 1
    cnt = 0
    while(i*i <= n):
        if (n%i == 0):
            cnt += 1 + (n//i != i)
        i += 1
    ans += (cnt==8)
print(ans)


Measured memory_bytes: 38256
ptn=[
  [1,2,3,4,5,6],
  [2,6,3,4,1,5],
  [3,6,5,2,1,4],
  [4,6,2,5,1,3],
  [5,6,4,3,1,2],
  [6,2,4,3,5,1]
]

def diffDice(orgDice, newDice):
  flg = False   # diff
  tmpDice = [0,0,0,0,0,0]
  for i in range(6):
    #newDiceをptn1で並べ替え
    for idx, j in enumerate(ptn[i]):
      tmpDice[idx] = newDice[j-1]

    if orgDice[0] != tmpDice[0] and orgDice[5] != tmpDice[5]:
      continue
    
    if ((orgDice[0] == tmpDice[0] and orgDice[5] != tmpDice[5]) or
     (orgDice[0] != tmpDice[0] and orgDice[5] == tmpDice[5])):
      continue
      
    if (
    (orgDice[1:5] == [tmpDice[1],tmpDice[2],tmpDice[3],tmpDice[4]]) or 
    (orgDice[1:5] == [tmpDice[3],tmpDice[1],tmpDice[4],tmpDice[2]]) or 
    (orgDice[1:5] == [tmpDice[2],tmpDice[4],tmpDice[1],tmpDice[3]]) or 
    (orgDice[1:5] == [tmpDice[4],tmpDice[3],tmpDice[2],tmpDice[1]])): 
      flg = True
      break
  return flg
    

n = int(input())
dice1 = list(input().split(" "))
flg=False
for i in range(1,n):
  dice2 = list(input().split(" "))
  flg = diffDice(dice1,dice2)
  if flg == True:
    break

if flg:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 5612
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	long long N, K, cnt = 0;
	cin >> N >> K;
	while (N >= 1) {
		cnt++;
		N /= K;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256