akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <limits>
#include <queue>

using Pair = std::pair<long long, long long>;
using PP = std::pair<Pair, long long>;
constexpr long long INF = std::numeric_limits<long long>::max();
constexpr long long MINF = std::numeric_limits<long long>::min();

int r, c;
int n;
std::set<PP> points;

bool check() {
    std::map<long long, std::vector<Pair>> edges;
    std::set<long long> pts;
    std::vector<long long> Min(c + 100, INF);

    long long prevY = INF;
    long long prevX = INF;
    long long prevV = INF;
    for(auto&& p : points) {
        if(p.first.first != prevY) {
            prevY = p.first.first;
            prevX = p.first.second;
            prevV = p.second;
        }else {
            edges[p.first.second].push_back({prevX, prevV - p.second});
            edges[prevX].push_back({p.first.second, p.second - prevV});
        }
        pts.insert(p.first.second);
        Min[p.first.second] = std::min(Min[p.first.second], p.second);
    }

    while(pts.size()) {
        std::queue<long long> que;
        std::map<long long, long long> costs;

        que.push(*pts.begin());
        costs[*pts.begin()] = 0;

        long long M = Min[*pts.begin()];
        long long Medge = INF;
        pts.erase(*pts.begin());
        while(!que.empty()) {
            long long x = que.front(); que.pop();

            auto& e = edges[x];

            for(int i = 0; i < e.size(); ++i) {
                if(pts.count(e[i].first))
                    pts.erase(e[i].first), que.push(e[i].first);

                if(costs.count(e[i].first)) {
                    if(costs[e[i].first] != e[i].second + costs[x]) {
//                        std::cout << e[i].first << " " << e[i].second << std::endl;
//                        std::cout << costs[e[i].first] << " " << e[i].second + costs[x] << std::endl;
//                        std::cout << x << std::endl;
//                        std::cout << x << " " << e[i].first << std::endl;

                        return false;
                    }
                }else {
                    auto c = e[i].second + costs[x];
                    costs[e[i].first] = c;

                    M = std::min(M, Min[e[i].first] - c);

                    Medge = std::min(c, Medge);
                }
            }
        }

        if(Medge != INF && 0 > M + Medge) {
//            std::cout << M + Medge << std::endl;
            return false;
        }
    }

    return true;
}

int main() {
    std::cin >> r >> c >> n;

    for(int i = 0; i < n; ++i) {
        PP v;

        std::cin >> v.first.first >> v.first.second >> v.second;
        --v.first.first, --v.first.second;

        points.insert(v);
    }

    if(!check()) {
        std::cout << "No" << std::endl;

        return 0;
    }

    std::set<PP> ns;

    for(auto&& pp : points) {
        ns.insert({{pp.first.second, pp.first.first}, pp.second});
    }

    std::swap(ns, points);

    std::swap(r, c);

    if(!check()) {
        std::cout << "No" << std::endl;
    }else {
        std::cout << "Yes" << std::endl;
    }
}

Measured memory_bytes: 24724
#include <iostream>
#include <cmath>

using namespace std;

const int INF = 1e9;



int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int len = s.length();

  int i = 0;
  while (i < (int)s.length()-1) {
    if (s[i] == '0' && s[i+1] == '1') {
      s.erase(i, 2);
      if (i > 0) i -= 1;
      continue;
    }
    if (s[i] == '1' && s[i+1] == '0') {
      s.erase(i, 2);
      if (i > 0) i -= 1;
      continue;
    }
    i += 1;
  }
  cout << len - s.length() << endl;
}

Measured memory_bytes: 512
class Ele
    attr_reader :data
    def initialize(data)
        @data = data
    end
    
    def <=>(t)
        @data[1] <=> t.data[1]
    end
end

gets
a = gets.split(" ").map{ |x| Ele.new(x) }

def bubble(d)
    a = d.clone
    a.size.times do |i|
        (a.size - i - 1).times do |j|
            if (a[j] <=> a[j + 1]) > 0 then
                a[j], a[j + 1] = a[j + 1], a[j]
            end
        end
    end
    
    a
end

def select(d)
    a = d.clone
    
    b = true
    a.size.times do |i|
        x = i
        ((i + 1)...a.size).each do |j|
            if (a[j] <=> a[x]) < 0 then
                x = j
            elsif (a[j] <=> a[x]) == 0 then
            end
        end

        (x - 1).downto(i + 1) do |k|
            if (a[k] <=> a[x]) == 0 || (a[k] <=> a[i]) == 0 then
                b = false
            end
        end

        a[i], a[x] = a[x], a[i]
    end
    
    return b, a
end

print bubble(a).map{ |x| x.data }.join(" "), "\n"
print "Stable\n"
b = false
b, a = select(a)
print a.map{ |x| x.data }.join(" "), "\n"
print b ? "Stable\n" : "Not stable\n"



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


Measured memory_bytes: 11796
#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>;


template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> pi(n+1,-1); //最後にでてきたときの番号を記録。
  vector<vector<int>> ps(n);//二つの区間を記録。具体的には(i, j)区間をps[i]にjをpushbackする形。
  rep(i,n) {
    int l = pi[a[i]];
    if (l != -1) ps[l].push_back(i);//すでにみたことあったら記録する。
    pi[a[i]] = i;
  }

  vector<vector<P>> qs(n);//クエリを記録。
  rep(qi,q) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r,qi);//クエリの番号も管理する。
  }

  vector<int> ans(q);
  BIT<int> d(n);
  for (int x = n-1; x >= 0; --x) {//平面走査
    for (int y : ps[x]) d.add(y,1);//点のy座標を記録．
    for (P query : qs[x]) {
      int r = query.first, i = query.second;
      ans[i] = (r-x+1) - d.sum(r);//sumのところは，記録されている点のうち，y座標がr以下のものの個数．
      /* 区間の中の個数から重複分を引く．*/
    }
  }

  rep(i,q) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 59832
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
h = {}
for x in a:
    if x not in h:
        h[x] = 0
    h[x] += 1
b = []
for x in h:
    if h[x]>=2:
        b.append(x)
b.sort()
if len(b)>=1 and h[b[-1]]>=4:
    print(b[-1]*b[-1])
elif len(b)<2:
    print(0)
else:
    print(b[-1]*b[-2])


Measured memory_bytes: 68760
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, s, a) for (int i = s; i < a; i++)
#define llint long long int
using namespace std;

const int N_MAX = 505;
const llint INF = 999999999999999;

int main()
{
    int n, k;
    cin >> n >> k;
    if (n % k == 0) cout << 0;
    else cout << 1;
     cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define ULL unsigned long long
using namespace std;

int main() {
    int a, b;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    if (op == '+')
        printf("%d\n", a+b);
    else if (op == '-')
        printf("%d", a-b);
    return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> k(m), p(m);
	int s[10][10];
	for (int i = 0; i < m; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for (int i = 0; i < m; i++)
		cin >> p[i];
		
	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		int count = 0;
		for (int j = 0; j < m; j++) {
			int on = 0;
			for (int i = 0; i < k[j]; i++)
				if (bit & (1 << s[j][i]))
					on++;
			if (on % 2 == p[j])
				count++;
		}
		if (count == m)
			ans++;
	}

		cout << ans << endl;
		return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

struct edge {
	int to, cost;
	edge(int to_, int cost_):to(to_), cost(cost_) {}
};

typedef vector<vector<edge>> graph;

pair<int, int> dfs(int v, const graph &G, int parent = -1, int sum = 0) {
	pair<int, int> res(sum, v);
	for(const auto &e : G[v]) {
		if(e.to != parent) chmax(res, dfs(e.to, G, v, sum + e.cost));
	}
	return res;
}

int diameter(const graph &G) {
	const int s = dfs(0, G).second;
	return dfs(s, G).first;
}

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

	for(int n; cin >> n && n;) {
		vector<int> p(n, -1), degree(n, 0);

		REP(i, 1, n) {
			cin >> p[i];
			--p[i];
			++degree[p[i]];
			++degree[i];
		}

		vector<int> d(n, 0);
		REP(i, 1, n) {
			cin >> d[i];
		}

		const int broken_cost = accumulate(ALL(d), 0);

		unordered_map<int, int> idx;
		rep(i, n) {
			if(degree[i] >= 2) idx.insert({i, idx.size()});
		}

		const int V = idx.size();
		graph G(V);
		int sum_dist = 0;

		REP(i, 1, n) {
			if(degree[i] == 1 || degree[p[i]] == 1) continue;

			const int v = idx[i];
			const int u = idx[p[i]];
			G[v].emplace_back(u, d[i]);
			G[u].emplace_back(v, d[i]);
			sum_dist += d[i];
		}

		const int move_cost = 2 * sum_dist - diameter(G);
		cout << move_cost + broken_cost << endl;
	}
  
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1372
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll H,W;
    cin>>H>>W;
    vector<vi> c(10,vi(10));
    REP(i,10)REP(j,10)cin>>c[i][j];
    vi n(10,0);
    REP(i,H)REP(j,W){
        ll x;
        cin>>x;
        if(x>=0)n[x]++;
    }
    // WF
    REP(k,10)REP(i,10)REP(j,10){
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
    }
    REP(i,10){
        ans+=c[i][1]*n[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N,M;
    cin >> N >> M;
    int ac = 0;
    int wa = 0;
    map <int, int[2]> mp;
    map <int, bool> mp2;

    for (int i = 0; i < M; i++){
        int x;
        string s;
        cin >> x >> s;
        if(s == "WA" && !mp2.count(x)){
            mp[x][1]++;
        } else {
            mp[x][0]++;
            mp2[x] = false;
        }
    }

    for (int i = 1; i <= N; i++){
        if(mp[i][0] != 0){
            ac++;
            wa += mp[i][1];
        }
    }

    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 11136
#include<iostream>
using namespace std;
#define MAXN 1000000001

int prime[MAXN];
int main(){
    int m;cin>>m;
    int n=m;
    int p=0;
    for(int i=2;i*i<=n;i++)if(m%i==0){
        while(m%i==0){
            prime[p++]=i;
            m/=i;
        }
    }
    if(m!=1) prime[p++]=m;
    cout<<n<<":";
    for(int i=0;i<p;i++){
        cout<<' '<<prime[i];
    }
    cout<<endl;
    return 0;
}


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

int main() {

    int K,N;

    cin >> K >> N;

    vector<int> A(N);

    for(int i=0; i<N; i++){

        cin >> A.at(i);
    }
    vector<int> S(N-1);

    for(int i=0; i<N-1; i++){

        int l = A.at(i+1)-A.at(i);

        S.at(i)=l; 
    }
    int B=K-A.at(N-1)+A.at(0);

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

    int big=S.at(N-2);

    if(big<=B){

        cout << K-B << endl;
    }

    else{

        cout << K-big << endl;
    }
}

Measured memory_bytes: 1792
N = int(input())
r=0
n=0
d={"1":3,"2":5,"3":7}
while True:
    n+=1
    n2 = n
    l=[]
    while n2 >= 4 :
        l.append(str(n2 % 4) )
        n2 //= 4
    l.append(str(n2))
    if "0" in l:
        continue
    w=0
    m=0
    for k in l:
        m +=  d[k]*10**w
        w += 1
    if m<=N and "1" in l and "2" in l and "3" in l:
        r += 1

    elif m>N:
        break

print(r)

Measured memory_bytes: 3064
//gcc -std=gnu11 -O2 -o a.out Main.c -lm
//http://abc047.contest.atcoder.jp/tasks/abc047_b
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include <math.h>
#include <string.h>

int main(void)
{
#define N_MAX 100  //

	int i,j;
	int x,y;
	int ret;
	int W,H,n;
	int k;
	int ans;
	struct {
		int x;
		int y;
		int a;
	}param[N_MAX];
	
	unsigned char matrix[100][100];

	//-------------------------------------
	//Init process
	//-------------------------------------
	memset(&matrix[0][0], 0x00, sizeof(matrix));

	//-------------------------------------
	//Input process
	//-------------------------------------
	ret = scanf("%d%d%d", &W, &H, &n);
	for(i=0;i<n;i++){
		ret = scanf("%d%d%d", &param[i].x, &param[i].y, &param[i].a);
	}

	//printf("n=(%d)\n",n);

	//-------------------------------------
	//Calc process
	//-------------------------------------
	for(i=0;i<n;i++){
		switch(param[i].a){
			case 1:
				for(x=0;x<param[i].x;x++){
					for(y=0;y<H;y++){
						matrix[x][y] = 1;
					}
				}
				break;
			case 2:
				for(x=(param[i].x);x<W;x++){
					for(y=0;y<H;y++){
						matrix[x][y] = 1;
					}
				}
				break;
			case 3:
				for(x=0;x<W;x++){
					for(y=0;y<param[i].y;y++){
						matrix[x][y] = 1;
					}
				}
				break;
			case 4:
				for(x=0;x<W;x++){
					for(y=(param[i].y);y<H;y++){
						matrix[x][y] = 1;
					}
				}
				break;
			default:
				break;
		}
	}

	ans = 0;
	for(x=0;x<W;x++){
		for(y=0;y<H;y++){
			if(matrix[x][y]){
				ans++;
			}
#if(0)
			if(matrix[x][y]){
				printf("O");
			}else{
				printf("X");
			}
#endif
		}
//		printf("\n");
	}


	//-------------------------------------
	//Output process
	//-------------------------------------
	printf("%d\n", (W * H) - ans);
	return(0);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> work(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        work[i] = {a, b};
    }
    sort(work.begin(), work.end());
    int ans = 0;
    int j = 0;
    priority_queue<int> que;
    for (int i = 1; i <= m; ++i) {
        for (; j < work.size() && work[j].first <= i; ++j) {
            que.push(work[j].second);
        }

        if (que.size() > 0) {
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

int main(){
	bool a = 0;
	string n;
	cin >> n;
	for(int i = 0 ; i < 2; i++){
		if(n[i] == n[i + 1] && n[i] == n[i+2])
			a =1;
	}
	if(a)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}

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

int N;
int dfs(ll x,bool a,bool b,bool c){
  if(x > N) return 0;
  int ret = 0;
  if(a && b && c) ret++;
  ret += dfs(10*x+3,true,b,c);
  ret += dfs(10*x+5,a,true,c);
  ret += dfs(10*x+7,a,b,true);
  return ret;
}

int main(){
  cin>>N;
  cout<<dfs(0,0,0,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    println! ("{}", a + (a * a) + (a * a * a));
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！

int main(){
    int n,k;
    cin>>n>>k;
    std::vector<bool>  a(n,0);
    rep(i,k){
        itn d;
        std::cin >> d;
        rep(j,d){
            int dd;
            std::cin >> dd;
            a[dd-1]=1;
        }
    }
    int ans=0;
    rep(i,n){
        if(!a[i])ans++;
    }
    std::cout << ans << std::endl;
}

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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    string S;
    char c[4];

    cin >> S;

    S.copy(c, 4);

    vector<int> C(begin(c), end(c));

    sort(all(C));

    cout << (C[0] == C[1] && C[1] != C[2] && C[2] == C[3] ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll x,y,xx,yy;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>x>>y>>xx>>yy;
    string ans;
    rep(i,xx-x){
        ans.pb('R');
    }
    rep(j,yy-y){
        ans.pb('U');
    }
    rep(i,xx-x){
        ans.pb('L');
    }
    rep(j,yy-y){
        ans.pb('D');
    }
    ans.pb('L');
    rep(i,yy-y+1){
        ans.pb('U');
    }
    ans.pb('R');
    rep(i,xx-x){
        ans.pb('R');
    }
    ans.pb('D');
    ans.pb('R');
    rep(i,yy-y+1){
        ans.pb('D');
    }
    ans.pb('L');
    rep(i,xx-x){
        ans.pb('L');
    }
    ans.pb('U');
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h> 
using namespace std;
typedef long long ll;
ll n;
struct stt
{
	ll a;
	ll b;
}st[100000+100];
bool cmp(stt aa,stt bb)
{
	return aa.b>bb.b;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>st[i].a;
	}
	int sum=0;
	st[n].b=0;
	for(int i=n-1;i>=1;i--)
	{
		if(st[i].a>=st[i+1].a)
		{
			st[i].b=sum+1;
			sum++;
		}
		else
		sum=0;
	}
	sort(st+1,st+n+1,cmp);
	printf("%lld\n",st[1].b);
	return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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

int main(){
    string S; cin >> S;
    REP(i, S.length()-1){
        if(S[i]=='A' && S[i+1]=='C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);


//Inputdata
static const int D = 365;
vector<int> c(D);
int s[D][26];
ll ans;
int last[26];  //コンテストが最後に行われた日
vector<int> t(D);

int checkScore(int d, int t){
 ans += s[d][t];
 last[t] = d;
 REP(i,26){
   ans -= c[i] * (d - last[i]);
 }
 return ans;
}

void input(){
  //input data
  int _;
  cin >> _;

  REP(i,26) cin >> c[i];
  REP(d,D){
    REP(i,26){
      int x;
      cin >> x;
      s[d][i] = x;
    }
  }

}

void initial(){
  REP(i,26) last[i] = -1;
  ans = 0;
}




int main(){
  input();

  initial();


  //cout << endl << "==ans==" << endl;

  // REP(d,D){
  //   int t;
  //   int score;
  //   cin >> t;
  //   --t;
  //   score = checkScore(d,t);
  //   cout << score << endl;
  // }

  ans = 0;
  int MX_score = 0;

  //maxscore
  REP(d,D){
    MX_score = 0;
    REP(i,26){
      int score;
      ans = 0;
      score = checkScore(d, i);
      if(score > MX_score){
        MX_score = max(MX_score, score);
        t[d] = i + 1;
      }
    }
  }

  REP(d,D) cout << t[d] << endl;


  return 0;
}

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

const int mod = 1e9+7;

ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}

ll nikou(ll n, ll m){
    if(m == 0) return 1;
    ll ans = 1, cnt = m;
    while(cnt > 0){
        ans *= n-cnt+1;
        ans %= mod;
        cnt--;
    }
    while(m > 0){
        ans *= modinv(m, mod);
        ans %= mod;
        m--;
    }
    return ans;
}

int main(){
    int x, y;
    cin >> x >> y;
    if((x+y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    int n, m;
    n = (2*y - x) / 3;
    m = (x - n) / 2;
    if(n < 0 || m < 0){
        cout << 0 << endl;
        return 0;
    }
    cout << nikou(n+m, m) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int numX = sc.nextInt();
		int numY = sc.nextInt();
		
        int numC = (2 * numX) - (numY / 2);
	    int numT = numX - numC;
		
		if ((numX == numC + numT) && (numY == 2 * numC + 4 * numT)) {
		    if ((numC < 0) || (numT < 0)) {
		        System.out.println("No");
		    }else if (((numC > 0) && (numC < 1)) || ((numT > 0) && (numT < 1))) {
		        System.out.println("No");
		    } else if ((numC >= 0) && (numT >= 0)) {
		        System.out.println("Yes");
		    } else {
		        System.out.println("No");
		    }
		} else {
		    System.out.println("No");
		}
		
	}
}

Measured memory_bytes: 35876
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    map<ll,ll> mp;
    map<ll,ll> used;
    for(ll p=2;p*p<=n;p++){
        if(n%p==0){
            mp[p]++;
            if(used.find(p)==used.end())used[p]=0;
            if(mp[p]>used[p]){
                ans++;
                used[p]=mp[p];
                mp[p]=0;
            }
            n/=p;
            p--;
        }
    }
    if(n!=1){
        mp[n]++;
        if(used.find(n)==used.end())used[n]=0;
        if(mp[n]>used[n]){
            ans++;
            used[n]=mp[n];
            mp[n]=0;
        }
    }
    puta(ans);
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main() {
  long long int n;
  scanf("%lld", &n);

  int i = 0;
  char c[50];
  while(n > 0) {
    c[i] = --n % 26 + 'a';
    n /= 26;
    i++;
  }

  for(int j = i - 1; j >= 0; j--) {
    printf("%c", c[j]);
  }
  return 0;
}


Measured memory_bytes: 1624
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    vector<P> v(n);
    vector<P> v2(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i].first >> v[i].second;
        v2[i] = v[i];
        swap(v2[i].first, v2[i].second);
    }
    sort(v.begin(), v.end());
    sort(v2.begin(), v2.end());
    
    if (n % 2)
    {
        ll mi = v[n / 2].first;
        ll ma = v2[n / 2].first;
        cout << ma - mi + 1ll << endl;
    }
    else
    {
        ll mi = v[n / 2].first + v[n / 2 - 1].first;
        ll ma = v2[n / 2].first + v2[n / 2 - 1].first;
        cout << ma - mi + 1ll << endl;
    }
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  rep(i,N)
    cin >> vec[i];
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int Alice = 0, Bob = 0;
  rep(i,N) {
    Alice += vec[i];
    i++;
    Bob += vec[i];
  }

  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  reverse(all(a));
  rep(i, n) {
    cout << a[i];
    if (i != n - 1) cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>
int main(void){
   int t,n;
   for(int i=0;i<4;i++){
       scanf("%d %d",&t,&n);
       if(t==1) printf("%d\n",6000*n);
       else if(t==2) printf("%d\n",4000*n);
       else if(t==3) printf("%d\n",3000*n);
       else printf("%d\n",2000*n);
   }
 return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  sort(a.begin(), a.end());
  double ans = a[0];
  for(int i = 1; i < n; i++)ans = (ans + a[i]) / 2;
  printf("%.10lf\n", ans);
}

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

#define VI vector<int>
#define REP(i,n) for(int i=0; i<int(n); i++)
#define REREP(i,n) for(int i=int(n-1); i>=0; i--)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define Cout(str) cout << str << endl

int main(){
	int N;
	VI vi;
	int index;
	int table[101]={};

	cin >> N;

	vi.push_back(4);
	vi.push_back(7);

	while(!vi.empty()){
		index = vi.back();
		vi.pop_back();
		if(index <= N){
			table[index] = 1;
			vi.push_back(index+7);
			vi.push_back(index+4);
		}
	}

	if(table[N]) Cout("Yes");
	else Cout("No");

	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

c = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            node = [l[i], l[j], l[k]]
            node.sort()
            if node[0] != node[1] and node[1] != node[2] and node[2] < node[1] + node[0]:
                c += 1

print(c)

Measured memory_bytes: 68300
import java.util.Scanner

//
fun _Do() {

    val N_ = scan.nextInt()
    
    var c = 0
    
    for(i in 0 until N_){
        var a = scan.nextInt()
        a -= scan.nextInt()
        c += (-a+1)
    }
    
    println( c )

}

var scan = Scanner(System.`in`)

fun strings(N:Int):Array<String>{
    var _s = Array(N,{""})
    for (i in _s.indices) {
        _s[i] = scan.next()
    }
    return _s
}

fun ints(N:Int):Array<Int>{
    var _s = Array(N,{0})
    for (i in _s.indices) {
        _s[i] = scan.nextInt()
    }
    return _s
}

fun longs(N:Int):Array<Long>{
    var _s = Array<Long>(N,{0})
    for (i in _s.indices) {
        _s[i] = scan.nextLong()
    }
    return _s
}
//
fun main( argv : Array<String> ) {
    _Do()
}


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

using namespace std;
 
const int inf = 1e8;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	double x;
	cin >> x;
	double y = x/3;
	cout << fixed << setprecision(13) << y * y * y << endl; 
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.util.Scanner;
// https://atcoder.jp/contests/abs/tasks/abc081_b
public class Main {
  public static void main(String[] args){
    System.out.println(new Main().excute(System.in)); 
  }

  public String excute(InputStream f) {
    Scanner scan = new Scanner(f);
    long a = scan.nextLong();
    long b = scan.nextLong();
    
    return "" + ((a * b) / gcd(a, b));
  }

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

}


Measured memory_bytes: 22484
a, b, c, n = gets.split.map(&:to_i)
s = 2 * (a * b +  b * c + c * a)
removed = {}
n.times do
    x, y, z = gets.split.map(&:to_i)
    s += x > 0     && !removed[[x - 1, y, z]] ? 1 : -1
    s += x < a - 1 && !removed[[x + 1, y, z]] ? 1 : -1
    s += y > 0     && !removed[[x, y - 1, z]] ? 1 : -1
    s += y < b - 1 && !removed[[x, y + 1, z]] ? 1 : -1
    s += z > 0     && !removed[[x, y, z - 1]] ? 1 : -1
    s += z < c - 1 && !removed[[x, y, z + 1]] ? 1 : -1
    removed[[x, y, z]] = 1
end
p s



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

int main()
{
    ll n;
    cin >> n;
    vector<ll> x,l;
    pair<ll,ll> arm[100000];
    for( int i = 0; i < n; i++ )
    {
        ll a,b;
        cin >> a >> b;
        arm[i].second = a - b;
        arm[i].first = a + b;
    }
    
    sort(arm,arm+n); 
    ll keep = -1000000000;
    ll ans = 0;
    for( int i = 0; i < n; ++i )
    {
        if( arm[i].second >= keep )
        {
            keep = arm[i].first;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1792
import math

h, w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    exit()

mini_w = int(w/2)
maxi_w = math.ceil(w/2)
mini_h = int(h/2)
maxi_h = math.ceil(h/2)
print(maxi_w*maxi_h + mini_w*mini_h)

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 50, M = 500, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int n;  cin >> n;
    cout << (800 * n) - (n / 15) * 200;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int N, X[110];
	int i,j, max = 0, min = 1000;
	int ans=100000000000, quasi=0;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> X[i];
		if (X[i] > max) { max = X[i]; }
		if (X[i] < min) { min = X[i]; }
	}
	for (i = min; i < max + 1; ++i) {
		for (j = 0; j < N; ++j) {
			quasi = quasi + (X[j] - i) * (X[j] - i);
		}
		if (ans > quasi) {
			ans = quasi;
		}
		quasi = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int bowl,stone;
  int mayor[50] ;
  int n,i;

  while(1){
    scanf("%d %d",&n,&stone);
    bowl = stone;

    if(n == 0 && stone == 0){
      break;
    }

    for(i = 0;i < n;i++){
        mayor[i] = 0;
    }

    i = 0;

    while(1){
      if(bowl != 0){
        mayor[i] = mayor[i] + 1;
        bowl = bowl - 1;
        if(mayor[i] == stone){
          break;
        }
      }
      else{
        bowl = mayor[i];
        mayor[i] = 0;
      }
      i++;

      if(i == n){
        i = 0;
      }
    }

    printf("%d\n",i);
  }

  return 0;
}

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

int main() {

  long double a, b, c, valA, valB;

  cin >> a >> b >> c;
  valA = sqrtl(a);
  valB = sqrtl(b);

  if (a + b + 2 * valA * valB < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,k,x,y,i,sum=0;
  cin>>n;
  cin>>k;
  cin>>x;
  cin>>y;
  for(i=1;i<=n;i++)
  {
    if(i<=k)
    {
      
    sum+=x;
      
    }
    else
    {
      sum+=y;
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n, k;
    cin >> n >> k;

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

    int t[2] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[j] > a[i]) t[j >= i]++;
        }
    }

    cout << ((ll)k * t[0] + (ll)k * (k - 1) / 2 % P * (t[0] + t[1])) % P << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

int main (){
    int r;
    cin >> r;
    cout << r*r;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pie 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define ff first
#define ss second
#define INF 1ll<<63 - 1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
#define pl pair<ll,ll>
#define pi pair<int,int>
#define pll pair<pair<ll,ll>, ll> 
#define pii pair< int, pair<int,int> >
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; 
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll aa[300005];
ll dp[300005][60];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,x,y,q,z,k,n,m,xx,yy;
    cin>>n;
    rep(i,1,n){
    	cin>>aa[i];
	}
	nrep(i,n,1){
		rep(j,0,59){
			dp[i][j] = dp[i+1][j];
			if((1ll<<j)&aa[i]) dp[i][j]++;
		}
	}
	ll ans = 0;
	rep(i,1,n){
		rep(j,0,59){
			z = n - i;
			if((1ll<<j)&aa[i]){
				z -= dp[i+1][j];
				ans = (ans%N  + (z*power(2,j,N))%N)%N;
			}else{
				z = dp[i+1][j];
				ans = (ans%N  + (z*power(2,j,N))%N)%N;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 146464
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
ab = list(input().split())
# print(ab)
#a = int(ab[0])
ans = Decimal(ab[0]) * Decimal(ab[1])
print(math.floor(ans))


Measured memory_bytes: 73128
def num_handler(num, up, down)
  result = 0
  for new_number in 0..num
    tmp = 0
    a = new_number.to_s.split("").map!{|i| i.to_i}
    a.each { |e|
      tmp += e
    }
    if tmp >= up && tmp <= down
      result += new_number
    end
  end
  p result
end

a, b, c = gets.chomp.split.map(&:to_i)
num_handler(a, b, c)

Measured memory_bytes: 2044
# 逆に考えるんだ
n = int(input())
arr = list(reversed(list(map(int, input().split()))))
ans = [0 for _ in range(n)]
for i in range(1, n):
    if arr[i - 1] <= arr[i]:
        ans[i] = ans[i - 1] + 1

print(max(ans))


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int dx[] = { -1,0,1,-1,0,1,-1,0,1 };
int dy[] = { -1,-1,-1,0,0,0,1,1,1 };
int main() {
	int h, w;
	cin >> h >> w;
	VE<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	VV ans(h, V(w, 0));
	auto exist = [&](int y, int x) {
		return 0 <= x && x < w && 0 <= y && y < h;
	};
	rep(i, h) rep(j, w) {
		if (s[i][j] == '#') {
			rep(dir, 9) {
				if (exist(i + dy[dir], j + dx[dir])) ans[i + dy[dir]][j + dx[dir]]++;
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '#') cout << '#';
			else cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<fstream>
#include<vector>
#include<initializer_list>
#include<string>
using namespace std;
  int main(){
 int N;
 cin >> N;
    if (N ==1)
    {cout << N << endl;}
else if (N%2 !=0)
{cout<< N/2*(N+2)+1<<endl;}
    
else {cout << N/2*(N+1)<<endl;}





}

Measured memory_bytes: 256