akhauriyash/Code-Regression huggingface dataset:
// GRL_2_A
#include<cstdio>
#include<algorithm>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )

struct edge
{
	int from, to, cost;

	edge( int from, int to, int cost )
	:	from( from ), to( to ), cost( cost )
	{}

	bool operator< ( const edge& e ) const
	{
		return cost < e.cost;
	}
};

int v, e;
std::vector<edge> es;

int par[10000], rank[10000];

void init()
{
	rep( i, v )
		par[i] = i, rank[i] = 0;

	return;
}

int find( int x )
{
	if( x == par[x] )
		return x;
	else
		return par[x] = find( par[x] );
}

void unite( int x, int y )
{
	x = find( x );
	y = find( y );
	if( x == y )
		return;

	if( rank[x] < rank[y] )
		par[x] = y;
	else
	{
		par[y] = x;
		if( rank[x] == rank[y] )
			++rank[x];
	}
}

bool same( int x, int y )
{
	return find( x ) == find( y );
}

int main()
{
	scanf( "%d%d", &v, &e );
	rep( i, e )
	{
		int s, t, w;
		scanf( "%d%d%d", &s, &t, &w );
		es.push_back( edge( s, t, w ) );
	}

	std::sort( es.begin(), es.end() );

	init();

	int ans = 0;
	rep( i, e )
	{
		if( !same( es[i].from, es[i].to ) )
		{
			ans += es[i].cost;
			unite( es[i].from, es[i].to );
		}
	}

	printf( "%d\n", ans );

	return 0;
}

Measured memory_bytes: 2564
#include <iostream>

using namespace std;

const int MAX = 50;

class UnionFind {
public:
  // O(N)
  UnionFind(int n) {
    for (int i = 0; i < n; i++) {
      data[i] = i;
    }
    num_subtrees = n;
  }

  // O(N)
  int root(int x) {
    int rx = data[x];
    while(rx != data[rx]) {
      rx = data[rx];
    }
    return rx;
  }

  // O(N)
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    data[ry] = rx;
    num_subtrees--;
    return;
  }

  // O(1)
  bool complete() {
    return num_subtrees == 1;
  }

private:
  int data[MAX];
  int num_subtrees;
};

int main() {
  int N, M; cin >> N >> M;

  int a[MAX], b[MAX];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  int ans = M;
  
  // O(N^3)
  // Choose which to omit
  for (int i = 0; i < M; i++) {
    UnionFind uf(N);
    for (int j = 0; j < M; j++) {
      if (i == j) continue;
      uf.unite(a[j], b[j]);
    }
    if (uf.complete()) {
      ans--;
    }
  }

  cout << ans << endl;
}

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

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

using namespace std;

int main(){
	int n,d[100]; cin>>n;
	rep(i,n) cin>>d[i];

	sort(d,d+n);
	cout<<unique(d,d+n)-d<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

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

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;

#define pb push_back
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define fast_cin() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

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

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

bool bit(int n, int i) { return (n >> i) & 1; }

int faltu;

const int mod = 1e9+7;
const ll inf = 5e18;
const int N = 2e5 + 100;

int n, m, q;

int main()
{
	fast_cin();
	srand(time(0));

	cin >> n;
	vector <pii> ans;
	if(n % 2 == 0) {
		for(int i = 1; i <= n; i++) {
			for(int j = i + 1; j <= n; j++) {
				if(i + j != n + 1) {
					ans.pb({i, j});
				}
			}
		}
	} else {
		for(int i = 1; i <= n - 1; i++) {
			ans.pb({i, n});
			for(int j = i + 1; j <= n - 1; j++) {
				if(i + j != n) {
					ans.pb({i, j});
				}
			}
		}
	}
	cout << ans.size() << endl;
	for(auto &x: ans) {
		cout << x.F << ' ' << x.S << endl;
	}

	return 0;
}

Measured memory_bytes: 384
import bisect
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        l = bisect.bisect_left(L, b - a + 1)
        r = bisect.bisect_left(L, b + a)
        ans += r - l - 1 - (b < a * 2)
print(ans // 3)


Measured memory_bytes: 48992
K,N = list(map(int,input().split()))
A = [int(N) for N in input().split()]

length = []

nuke = (K - A[N-1]) + A[0]
length.append(nuke)

for i in range(N-1):
    lengthh = A[i+1] - A[i]
    length.append(lengthh)

M = max(list(length))
print(K - M)


Measured memory_bytes: 87756
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


public class Main {
    public static boolean gcd(int a,int b){
        if(a==1||b==1){
            return false;
        }
        while(1>0){
            int t = a%b;
            if(t == 0){
                break;
            }
            else{
                a=b;
                b=t;
            }

        }
        if(b>1)	return true;
        else{
            return  false;
        }
    }
    public static boolean pan(long a){
        long x,y;
        x=a%10;
        a=a/10;
        while(a>0){
            y=a%10;
            if(Math.abs(x-y)>1){
                return false;
            }
            x=y;
            a=a/10;
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        long[] num= new long[1000010];
        for(int i = 1; i <= 9; i++){
            num[i] = i;
        }
        int cnt=10;
        int x=0;
        for(int i=1; i<=9; i++){
            long d = num[i]%10;
            if(d == 0){
                num[cnt++]=num[i]*10;
                num[cnt++] =num[i]*10+1;
                x+=2;
            }
            else if(d==9){
                num[cnt++]=num[i]*10+8;
                num[cnt++] =num[i]*10+9;
                x+=2;
            }
            else{
                num[cnt++]=num[i]*10+d-1;
                num[cnt++]=num[i]*10+d;
                num[cnt++]=num[i]*10+d+1;
                x+=3;
            }
        }
        int l=10,r=10+x;
        x = 0;
        for(int i = l; i <= r; i++){
            long d = num[i]%10;
            if(d == 0){
                num[cnt++]=num[i]*10;
                num[cnt++]=num[i]*10+1;
                x+=2;
            }
            else if(d==9){
                num[cnt++] =num[i]*10+8;
                num[cnt++] =num[i]*10+9;
                x+=2;
            }
            else{
                num[cnt++]=num[i]*10+d-1;
                num[cnt++]=num[i]*10+d;
                num[cnt++] =num[i]*10+d+1;
                x+=3;
            }
        }
        for(int k = 1; k <= 7; k++){
            l = r+1;
            r = l+x;
            x = 0;
            for(int i = l; i <= r; i++){
                long d = num[i]%10;
                if(d == 0){
                    num[cnt++]=num[i]*10;
                    num[cnt++]=num[i]*10+1;
                    x+=2;
                }
                else if(d==9){
                    num[cnt++]=num[i]*10+8;
                    num[cnt++] =num[i]*10+9;
                    x+=2;
                }
                else{
                    num[cnt++]=num[i]*10+d-1;
                    num[cnt++]=num[i]*10+d;
                    num[cnt++]=num[i]*10+d+1;
                    x+=3;
                }
            }
        }
        int n = cin.nextInt();
        System.out.println(num[n]);


    }
}

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

struct StronglyConnectedComponents {
  int n;
  vector<vector<int>> oG, rG;
  vector<int> comp, order, used;
  vector<pair<int, int>> edges;

  StronglyConnectedComponents(int n)
      : n(n), oG(n), rG(n), comp(n, -1), used(n, 0) {}

  int operator[](int k) { return comp[k]; }

  void add_edge(int u, int v) {
    oG[u].push_back(v);
    rG[v].push_back(u);
    edges.emplace_back(u, v);
  }

  void dfs(int v) {
    if (used[v])
      return;
    used[v] = true;
    for (int to : oG[v])
      dfs(to);
    order.push_back(v);
  }

  void rdfs(int v, int k) {
    if (~comp[v])
      return;
    comp[v] = k;
    for (int to : rG[v])
      rdfs(to, k);
  }

  void build(vector<vector<int>> &t) {
    for (int i = 0; i < n; ++i)
      dfs(i);

    reverse(order.begin(), order.end());
    int k = 0;
    for (int i : order)
      if (comp[i] == -1)
        rdfs(i, k++);

    t.resize(k);
    set<pair<int, int>> connect;
    for (auto &e : edges) {
      int u = comp[e.first], v = comp[e.second];
      if (u == v || connect.count({u, v}))
        continue;
      t[u].push_back(v);
      connect.emplace(u, v);
    }
  }
};

bool a[10101], b[10101];

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

  StronglyConnectedComponents G(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    G.add_edge(u, v);
  }

  vector<vector<int>> v;
  G.build(v);

  if (v.size() == 1) {
    cout << 0 << endl;
    return 0;
  }

  memset(a, true, sizeof(a));
  memset(b, true, sizeof(b));
  for (int i = 0; i < v.size(); ++i) {
    for (auto to : v[i]) {
      a[i] = false;
      b[to] = false;
    }
  }

  int acnt = 0, bcnt = 0;
  for (int i = 0; i < v.size(); ++i) {
    if (a[i])
      acnt++;
    if (b[i])
      bcnt++;
  }

  cout << max(acnt, bcnt) << endl;
}

Measured memory_bytes: 11476
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    string a, b;
    cin >> a >> b;
    
    if(a.size() > b.size()) puts("GREATER");
    else if(a.size() < b.size()) puts("LESS");
    else if(a > b) puts("GREATER");
    else if(a < b) puts("LESS");
    else puts("EQUAL");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,s=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			for(int k=0;k<=c;k++)
			{
				if(500*i+100*j+50*k==x)
				{
					s++;
				}
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		vector<string> v(n);
		REP(i, n) cin >> v[i];
		vi cnt(n,0);
		vi b;
		REP(i, n) {
			REP(j, v[i].size()) {
				if (v[i][j] == '.')cnt[i]++;
				else break;
			}
		}
		REP(i, n) {
			FOR(j,i+1,n) {
				if (cnt[i] == cnt[j]) {
					int flag = 1;
					REP(k, j - i) {
						if (cnt[i + k] < cnt[i])flag = 0;
					}
					if (flag) {
						REP(k, j - i) {
							v[i + k][cnt[i] - 1] = '|';
						}
					}
				}
			}
		}
		REP(i, n) {
			if(i!=0)v[i][cnt[i] - 1] = '+';
		}
		REP(i, n) {
			REP(j, v[i].size()) {
				if (v[i][j] == '.')v[i][j] = ' ';
			}
		}
		REP(i, n) {
			cout << v[i] << endl;
		}
	

	}
	return 0;
}

Measured memory_bytes: 3392
#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(){
    int n;
    cin >> n;
    ll t[n], a[n];
    ll tkh ,ao = 0; 
    rep(i,n) {
        cin >> t[i] >> a[i];
        if(i == 0) tkh = t[i], ao = a[i];
        else {
            ll m = 0;
            if(t[i] != 0) m = (tkh+t[i]-1)/t[i];
            if(a[i] != 0) m = max(m,(ao+a[i]-1)/a[i]);
            tkh = t[i]*m;
            ao = a[i]*m; 
        }
    }
    cout << tkh + ao << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k = na()
aaa = na()
c = Counter(aaa)
if len(c.keys()) <= k:
    print(0)
else:
    vvv = sorted(c.values())
    print(sum(vvv[:-k]))


Measured memory_bytes: 34848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  char b=s.at(0);
    char c=s.at(1);
    char d=s.at(2);
    char e=s.at(3);
  if(b==c&&d==e&&b!=d)
    cout<<"Yes";
    else if(b==d&&c==e&&b!=c)
    cout<<"Yes";
    else if(b==e&&c==d&&b!=c)
    cout<<"Yes";
  
  else
    cout<<"No";
  }


Measured memory_bytes: 256
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : July 06, 2020 9:53 AM
 *    Problem Name  : B - Judge Status Summary
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc173/tasks/abc173_b
**/

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

int main(){
    ios_base::sync_with_stdio(false);
    
    int n,cnt_ac=0, cnt_tle=0, cnt_wa=0, cnt_re=0;
    cin >> n;

    for(int i=1; i<=n; i++){
	    string s;
	    cin >> s;

	    if (s == "AC") cnt_ac ++;
	    else if ( s == "TLE") cnt_tle++;
	    else if (s == "WA") cnt_wa++;
            else if ( s == "RE") cnt_re ++;
    }

    cout << "AC x " << cnt_ac << endl;
    cout << "WA x " << cnt_wa << endl;
    cout << "TLE x " << cnt_tle << endl;
    cout << "RE x " << cnt_re << endl;

    return 0 ;
}


Measured memory_bytes: 3628
main :: IO ()
main = do
  s <- getLine
  putStrLn (f s)

f :: String -> String
f s
  | length s < 26 = g s
  | otherwise = reverse $ h (reverse $ s) []

g :: String -> String
g s = let x = head $ filter (`notElem` s) ['a'..'z']
      in s ++ [x]

h :: String -> String -> String
h []    _ = "1-"
h (c:t) acc = let ts = filter (> c) acc
              in
                if null ts
                then h t (c:acc)
                else let c = minimum ts
                     in c:t



Measured memory_bytes: 380
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}


int main(){
	ll n, w;
	cin >> n >> w;
	vector<pll> line(n);
	foreach(i, line)cin>>i.first>>i.second;
	sort(all(line), [](const pii &a, const pii &b){
			return (double) a.first / a.second > (double) b.first / b.second;
			});
	
	double ans = 0;
	foreach(i, line){
		ll num = min(w, i.second);
		ans += (double)i.first * ((double)num / i.second);
		w -= num;
		if(!w)break;
	}
	printf("%.8lf\n", ans);

	return 0;
}



Measured memory_bytes: 4408
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Bytes []byte

func (b Bytes) Len() int {
	return len(b)
}

func (b Bytes) Swap(i, j int) {
	b[i], b[j] = b[j], b[i]
}

func (b Bytes) Less(i, j int) bool {
	return b[i] < b[j]
}

func main(){
	var N int
	fmt.Scan(&N)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	arr := make([]string, N)
	for i := range arr {
		sc.Scan()
		s := []byte(sc.Text())
		sort.Sort(Bytes(s))
		arr[i] = string(s)
	}

	// s -> count
	m := map[string]int{
		arr[0]: 0,
	}
	total := 0
	for i := 1; i < len(arr); i++ {
		s := arr[i]
		if count, ok := m[s]; ok {
			m[s] = count+1
		}else{
			m[s] = 0
		}
		total += m[s]
	}
	fmt.Println(total)
}


Measured memory_bytes: 12800
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    }

    let mut map = HashMap::new();
    for i in 0..ab.len() {
        let current = map.entry(ab[i].0).or_insert(vec![]);
        current.push(ab[i].1);
        let current = map.entry(ab[i].1).or_insert(vec![]);
        current.push(ab[i].0);
    }
    let mut done = vec![0; n + 1];
    let mut cnt = 0;
    dfs(1, &mut done, &map, 0, &mut cnt);
    println!("{}", cnt);
}

fn dfs(
    cn: usize,
    done: &mut Vec<usize>,
    map: &HashMap<usize, Vec<usize>>,
    pn: usize,
    cnt: &mut usize,
) {
    if done[cn] != 0 {
        return;
    }
    done[cn] = 1;
    done[0] += 1;
    if done[0] == map.len() {
        *cnt += 1;
    }
    for i in map.get(&cn).unwrap() {
        if pn == *i {
            continue;
        }
        if done[*i] != 0 {
            continue;
        }
        let mut donec = done.clone();
        dfs(*i, &mut donec, map, cn, cnt);
    }
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
#define ll long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define msit1(a) map<string,int>::iterator a
#define miit(a) map<int,int>::iterator a
#define msit2(a) map<int,string>::iterator a
#define IT iterator
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
ll S(ll x){
    ll ans=0;
    string s=to_string(x);
    REP(i,0,s.size())ans+=(s[i]-'0');
    return ans;
}
int main(){
  ll k;
  cin>>k;
  ll ans=1;
  ll d=1;
  REP(i,0,k){
    cout<<ans<<endl;
    if(1.0*(ans+d)/S(ans+d)>d) d*=10;
    ans+=d;
  }
  return 0;
}

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

int main() {
  string a,b;
  cin>>a>>b; 
  if(a.size()>b.size()){
    cout<<"GREATER"<<endl;
  }
  else if(a.size()<b.size()){
    cout<<"LESS"<<endl;
  }
  else{
    bool ex=true;
    rep(i,a.size()){
      int c=a.at(i)-'0';
      int d=b.at(i)-'0';
      if(c>d){
        cout<<"GREATER"<<endl;
        ex=false;
        break;
      }
      else if(c<d){
        cout<<"LESS"<<endl;
        ex=false;
        break;
      }
    }
    if(ex){
      cout<<"EQUAL"<<endl;
    }
  }
}

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

using ll = long long;
const ll INF = 1e18;

const int S = 1 << 17;
const int MAXN = 1.1e5;
const int MAXM = 1.1e5;
const int MAXV = 4 * S + MAXM;

int N, M, V;

vector<pair<int, int>> adj[MAXV];
ll dist[MAXV];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> M;
	V = 4 * S + M;
	for (int i = 1; i < S; i++) {
		adj[2*i].emplace_back(i, 0);
		adj[2*i+1].emplace_back(i, 0);
		adj[2*S+i].emplace_back(2*S+2*i, 0);
		adj[2*S+i].emplace_back(2*S+2*i+1, 0);
	}
	for (int i = 1; i <= N; i++) {
		adj[3*S+i].emplace_back(S+i, 0);
	}
	for (int v = 4 * S; v < V; v++) {
		int l, r, c; cin >> l >> r >> c;
		r++;
		for (int a = l + S, b = r + S; a < b; a /= 2, b /= 2) {
			if (a & 1) {
				adj[a].emplace_back(v, c);
				adj[v].emplace_back(2*S+a, 0);
				a++;
			}
			if (b & 1) {
				b--;
				adj[b].emplace_back(v, c);
				adj[v].emplace_back(2*S+b, 0);
			}
		}
	}

	for (int i = 0; i < V; i++) {
		dist[i] = INF;
	}
	dist[S+1] = 0;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
	pq.emplace(dist[S+1], S+1);
	while (!pq.empty()) {
		ll d; int cur; tie(d, cur) = pq.top();
		pq.pop();
		if (d != dist[cur]) continue;
		for (auto it : adj[cur]) {
			int nxt = it.first;
			ll nd = d + it.second;
			if (nd < dist[nxt]) {
				dist[nxt] = nd;
				pq.emplace(dist[nxt], nxt);
			}
		}
	}

	ll ans = dist[S+N];
	if (ans == INF) ans = -1;
	cout << ans << '\n';

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll m = 1000;
    ll stock = 0;
    ll price = a[0];
    bool flag = false;
    for (int i = 1; i < n; i++) {
        if (flag == false && a[i-1] < a[i]) {
            flag = true;
            stock = m / a[i-1];
            m %= a[i-1];

        }
        if (flag == true && a[i-1] > a[i]) {
            flag = false;
            m += a[i-1] * stock;
            stock = 0;
        }
    }
    m += a[n-1] * stock;

    cout << m << endl;
    return 0; 
}

Measured memory_bytes: 3552
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]

X = [0] * N
Y = [0] * N
Z = [0] * N
for i in range(N):
    x,y,z = [int(x) for x in stdin.readline().rstrip().split()]
    X[i] = x
    Y[i] = y
    Z[i] = z

ans = 0
for a in [1,-1]:
    for b in [1,-1]:
        for c in [1,-1]:
            tmp = []
            for i in range(N):
                tmp.append(X[i]*a + Y[i]*b + Z[i]*c)
            ans = max(ans,sum(sorted(tmp)[::-1][:M]))
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<cmath>

bool isPrime(int x){
    if(x == 2) return true;
    if(x % 2 == 0) return false;
    int th = std::sqrt(x);
    for(int j = 3; j <= th; j += 2){
        if(x % j == 0){
            return false;
        }
    }
    return true;
}

int main(){
    int x;
    std::cin >> x;
    for(int i = x;; i++){
        if(isPrime(i)){
            std::cout << i << std::endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;

vector<int> v[100005];
bool vis[100005];
int f = -1, c = 0;

void dfs(int s){
    if(s == 2) f = c;
    c++;
    vis[s] = 1;
    for(auto i : v[s]) if(!vis[i]) dfs(i);
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int n;
    cin >> n;
    repp(i, 1, n){
        int x;
        cin >> x;
        v[i].pb(x);
    }
    dfs(1);
    cout << f;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


Measured memory_bytes: 8960
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		int N = sc.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++)
			p[i] = sc.nextInt()-1;
		
		int[] ad = new int[N];
		int[] bd = new int[N];
		
		for(int i=0; i<N; i++) {
			ad[p[i]] += i+1;
			if(p[i]<N-1)
				bd[p[i]+1] -= i+1;
		}
		int a=1;
		for(int i=0; i<N; i++) {
			a += ad[i];
			pw.print(a + (i<N-1 ? " " : "\n"));
		}
		int b=1000000000;
		for(int i=0; i<N; i++) {
			b += bd[i];
			pw.print(b + (i<N-1 ? " " : "\n"));
		}
		
		sc.close();
		pw.close();
	}
}


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

class Pg
{
  static void Main(string[] args)
  {
    string input = Console.ReadLine();
    int length = input.Length;
    string pref, suf, prefA, prefB, sufA, sufB;
    int cnt = 0;
    
     pref = input.Substring(0,(length-1)/2 );
     suf = input.Substring((length+3)/2 -1, length-(length+3)/2 + 1);
	var a = suf.Reverse();
    suf = string.Join("", suf.Reverse());
    
    length = pref.Length;
     prefA = pref.Substring(0,(length-1)/2);
     sufA = pref.Substring((length+3)/2 -1 , length-(length+3)/2 + 1);
    	var b = sufA.Reverse();
    sufA = string.Join("", sufA.Reverse());
    if(pref.Length % 2 == 0){
     prefA = pref.Substring(0,(length-1)/2+ 1);
    }
    
    prefB = suf.Substring(0,(length-1)/2 );
     sufB = suf.Substring((length+3)/2 -1, length-(length+3)/2+1);
        	var c = sufB.Reverse();
    sufB = string.Join("", sufB.Reverse());
        if(suf.Length % 2 == 0){
     prefB = suf.Substring(0,(length-1)/2+ 1);
    }
    if(!pref.Equals(suf)){cnt ++;}
    if(!prefA.Equals(sufA)){cnt ++;}
    if(!prefB.Equals(sufB)){cnt ++;}
    
    string ans;
    if(cnt == 0){ans = "Yes";}else{ans = "No";}
    
    Console.WriteLine(ans);

  }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef int Weight;
const int INF = 1e9;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
        src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

pair<Weight, Edges> minimumSpanningForest(const Graph &g) {
    int n = g.size();
    UnionFind uf(n);
    priority_queue<Edge> Q;
    REP(u, n) FOR(e, g[u]) if (u < e->dst) Q.push(*e);

    Weight total = 0;
    Edges F;
    while (F.size() < n-1 && !Q.empty()) {
        Edge e = Q.top(); Q.pop();
        if (uf.unionSet(e.src, e.dst)) {
            F.push_back(e);
            total += e.weight;
        }
    }
    return pair<Weight, Edges>(total, F);
}

int main()
{
    int n, m;
    char ch;

    while (cin >> n, n) {
        Graph g(n);
        pair<Weight, Edges> ans;

        cin >> m;
        for (int i = 0; i < m; i++) {
            int u, v, w;

            cin >> u >> ch >> v >> ch >> w;
            w = w / 100 - 1;
            g[u].push_back(Edge(u, v, w));
            g[v].push_back(Edge(v, u, w));
        }
        ans = minimumSpanningForest(g);

        cout << ans.first << endl;
    }

    return 0;
}

Measured memory_bytes: 1480
#include<stdio.h>

int main(void){
    struct {
        int p1;
        int p2;
        int p3;
        int p4;
        int p5;
        int p6;
    } dice;
    int label[6], tmp;
    char order;
    for(int i=0; i<6; i++) scanf("%d", &label[i]);
    while(scanf("%c", &order)!=EOF){
        if(order=='N'){
            tmp = label[0];
            label[0] = label[1];
            label[1] = label[5];
            label[5] = label[4];
            label[4] = tmp;
        }
        else if(order=='E'){
            tmp = label[0];
            label[0] = label[3];
            label[3] = label[5];
            label[5] = label[2];
            label[2] = tmp;
        }
        else if(order=='S'){
            tmp = label[0];
            label[0] = label[4];
            label[4] = label[5];
            label[5] = label[1];
            label[1] = tmp;
        }
        else if(order=='W'){
            tmp = label[0];
            label[0] = label[2];
            label[2] = label[5];
            label[5] = label[3];
            label[3] = tmp;
        }
    }
    printf("%d\n", label[0]);
    return 0;
}


Measured memory_bytes: 2076
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long int k,sum=0,a; 
    cin>>k;
    for(long long int i=1;i<=k;i++)
    {
      for(long long int j=1;j<=k;j++)
      {
        for(long long int l=1;l<=k;l++)
          {
            a=__gcd(i,j);
            sum+=__gcd(a,l);
          }
      }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <set>
#include <cmath>
using namespace std;

typedef set<int> S;

const int NMAX = 500;
const double EPS = 1.0e-6;
const double INF = 1.0e10;

int N;
double R;
double x[NMAX];
double y[NMAX];
double r[NMAX];
double v[NMAX];

bool input() {
  cin >> R >> N;
  if (!R && !N) {
    return false;
  }
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i] >> r[i] >> v[i];
  }
  return true;
}

void solve() {
  S s;
  for (int i = 0; i < N; ++i) {
    s.insert(i);
  }

  int ans = 0;
  while (!s.empty()) {
    int t = -1;
    double td = INF;
    for (S::iterator it = s.begin(); it != s.end();) {
      int n = *it;
      double d = sqrt(x[n] * x[n] + y[n] * y[n]);
      double nd = d - v[n];
      if (nd < R + EPS) {
        s.erase(it++);
        ++ans;
        continue;
      }
      if (td > nd) {
        td = nd;
        t = n;
      }
      x[n] *= nd / d;
      y[n] *= nd / d;
      ++it;
    }
    if (t == -1) {
      break;
    }
    double zt = atan2(y[t], x[t]);
    for (S::iterator it = s.begin(); it != s.end();) {
      int n = *it;
      double xr = x[n] * cos(zt) + y[n] * sin(zt);
      double yr = x[n] * -sin(zt) + y[n] * cos(zt);
      if (yr > r[n] - EPS || yr < EPS - r[n]) {
        ++it;
        continue;
      }
      double dk = sqrt(r[n] * r[n] - yr * yr);
      double k1 = xr + dk;
      if (k1 > R - EPS) {
        s.erase(it++);
      } else {
        ++it;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  while (input()) {
    solve();
  }
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A.at(i);
    }

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

    int sum = 0;

    for (int i = 0; i < K; ++i) {
        sum += A.at(i);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
#define rep(n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;

int main()
{
    int x, y;
    cin >> x >> y;

    string ans = "No";
    for (int i = 0; i <= x; i++)
    {
        if(2*i + 4*(x-i) == y) {
            ans = "Yes";
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


string solve(){
    string res;
    ll N,C,K; cin >> N >> C >> K;
    vector<ll> T(N); for(auto& in:T) cin >> in;
    sort(T.begin(),T.end());
    ll cnt = 1;
    
    ll nowcnt = 0;
    ll t = 0;
    for(int i = 0; i < N;i++){
        if(nowcnt == C){
            cnt++;
            nowcnt = t = 0;
        }
        if(nowcnt == 0){
            nowcnt++;
            t = T[i];
        }else{
            if(T[i] <= t + K){
                nowcnt++;
            }else{
                cnt++;
                nowcnt = 1;
                t = T[i];
            }
        }
    }
    res = to_string(cnt);
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

int	main()
{
	int	a, b, res;
	cin >> a >> b;

	res = 0;
	for (int i = a; i <= b; i++)
	{
		int	one, two, three, four;
		four = i % 10;
		three = i / 10 % 10;
		two = i / 1000 % 10;
		one = i / 10000;
		if (one == four && two == three)
			res++;
	}
	cout << res << endl;
}


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

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;

int main()
{
    int n, m; cin >> n >> m;
    vector<mint> x(n), y(m);
    for(int i = 0; i < n; i++)cin >> x[i];
    for(int i = 0; i < m; i++)cin >> y[i];
    mint sum_x = 0, sum_y = 0;

    for(int i = 0; i < n; i++) {
        sum_x -= x[i] * (n - i - 1);
        sum_x += x[i] * (i);
    }

    for(int i = 0; i < m; i++) {
        sum_y -= y[i] * (m - i - 1);
        sum_y += y[i] * (i);
    }
    cout << sum_x * sum_y << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K%2==0){
        cout << A-B << endl;
    }else{
        cout << B-A << endl;
    }
    return 0;
}

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

public class Main{

	public static void main(String[] args) throws IOException
	{
		int a,b,q;
		String str;

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

		str = br.readLine();

		q = Integer.parseInt(br.readLine() );

		for(int i=0; i<q; i++)
		{
			String[] strSplit = br.readLine().split(" ");

			a = Integer.parseInt(strSplit[1]);
			b = Integer.parseInt(strSplit[2]) + 1;

			if(strSplit[0].equals("replace") )
			{
				StringBuffer sb_rep = new StringBuffer(str).replace(a, b, strSplit[3]);
				str = sb_rep.toString();
			}
			else if(strSplit[0].equals("reverse") )
			{
				StringBuffer sb_str = new StringBuffer(str);
				StringBuffer sb_rev = new StringBuffer(str.substring(a, b) );

				sb_rev = sb_rev.reverse();

				StringBuffer sb_revp = sb_str.replace(a, b, sb_rev.toString() );
				str = sb_revp.toString();
			}
			else if(strSplit[0].equals("print") )
			{
				System.out.println(str.substring(a, b) );
			}

		}
		
	}
}

Measured memory_bytes: 24984
#include <stdio.h>
int main() {
  int r,D,x2000,i=0,newx;
  scanf("%d%d%d", &r, &D,&x2000);
  for(i=0;i<10;i++){
    newx=r*x2000-D;
    printf("%d\n",newx);
    x2000=newx;
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int gcd(int c, int d) { 
   if (d == 0) 
      return c; 
   return gcd(d, c % d);  
} 

int main() {
         long long a,b,c,d;
         cin>>a>>b>>c>>d;
         long long l,m,lcm;
	l=c*d;
	m=gcd(c,d);
	lcm=l/m;
	long long divc=b/c-(a-1)/c;
	long long divd=b/d-(a-1)/d;
	long long res= b/lcm-(a-1)/lcm;
	cout<< (b-a+1)-divc-divd+res<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		br.close();

		char[] c = s.toCharArray();
		int n = c.length + 1;
		int[] a = new int[n];
		for (int i = 0; i < c.length; i++) {
			if (c[i] == '<') {
				a[i + 1] = a[i] + 1;
			}
		}
		for (int i = c.length - 1; i >= 0; i--) {
			if (c[i] == '>') {
				a[i] = Math.max(a[i], a[i + 1] + 1);
			}
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += a[i];
		}
		System.out.println(ans);
	}
}


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

int doubleup(int num,int goal);

int main()
{
	int i,j,k=0;
	char s[110]={0};
	int slng=0;
    char charmap[110]={0};
    int nummap[110]={0};
	int charnum=0;
    scanf("%s",s);
	scanf("%d" ,&k);
	slng=strlen(s);

	char nextx;
	charmap[charnum]=s[0];
	nummap[charnum]=1;

	for(i=1;i<slng;i++)
    {
	    if(s[i]==charmap[charnum])
        {
            nummap[charnum]++;
        }
	    else
        {
	        charnum++;
	        charmap[charnum]=s[i];
	        nummap[charnum]=1;
        }
    }
/*
	if(charmap[0]==charmap[charnum])
    {
	    nummap[0]+=nummap[charnum];
	    charnum--;
    }
    */
	int a;
    long long int ans=0;
	for(a=0;a<=charnum;a++)
    {
	    ans+=nummap[a]/2;
    }
	long long int llk=(long long int)(k);
	ans*=llk;
    if(charmap[0]==charmap[charnum]&&(nummap[0]/2+nummap[charnum]/2)<((nummap[0]+nummap[charnum])/2))ans+=(llk-1);

    if(charnum==0)ans=(long long int)(slng)*llk/2;

	printf("%lld",ans);

}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
	int x1,x2,y1,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3,y3,x4,y4;
	x3 = x2 - (y2 - y1);
	y3 = y2 + (x2 - x1);
	x4 = x1 - (y2 - y1);
	y4 = y1 + (x2 - x1);
	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
b=[]
mx = 0
for i in range(n):
  a = [int(x) for x in input().split()]
  b.append(a)
b.sort(key = lambda x: x[0]+x[1]+x[2],reverse = True)
mx = max(mx, sum([x[0]+x[1]+x[2] for x in b[:m]]))

b.sort(key = lambda x: x[0]+x[1]-x[2],reverse = True)
mx = max(mx, sum([x[0]+x[1]-x[2] for x in b[:m]]))

b.sort(key = lambda x: x[0]-x[1]+x[2],reverse = True)
mx = max(mx, sum([x[0]-x[1]+x[2] for x in b[:m]]))

b.sort(key = lambda x: x[0]-x[1]-x[2],reverse = True)
mx = max(mx, sum([x[0]-x[1]-x[2] for x in b[:m]]))

b.sort(key = lambda x: -x[0]+x[1]+x[2],reverse = True)
mx = max(mx, sum([-x[0]+x[1]+x[2] for x in b[:m]]))

b.sort(key = lambda x: -x[0]+x[1]-x[2],reverse = True)
mx = max(mx, sum([-x[0]+x[1]-x[2] for x in b[:m]]))

b.sort(key = lambda x: -x[0]-x[1]+x[2],reverse = True)
mx = max(mx, sum([-x[0]-x[1]+x[2] for x in b[:m]]))

b.sort(key = lambda x: -x[0]-x[1]-x[2],reverse = True)
mx = max(mx, sum([-x[0]-x[1]-x[2] for x in b[:m]]))
print(mx)

Measured memory_bytes: 3324
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
def resolve():
    N, K = map(int, input().split())
    print(len(Base_10_to_n(N, K)))
resolve()

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

int main() {
  int N,D;
  cin >> N >> D;
  if (N%(2 * D + 1) != 0){cout << N / (2 * D + 1) + 1 << endl;}
  else if (N%(2 * D + 1) == 0){cout << N / (2 * D + 1) << endl;}
}


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

int cup[100],stat[100],sum[100],wat[200];
int N,SET;

int search(int cc,int left,int look,int num){
	int i;

	if(look<N)stat[look]=1;

	if(left==0){
		if(cc<N)stat[cc]=2;
		if(num==0)return 1;
		for(i=N-1;i>=0;i--){
			if(stat[i]==0)break;
			if(stat[i]==1 && search(i,cup[i],99,num))return 1;
		}
		if(look<N)stat[look]=0;
		stat[cc]=1;
		return 0;
	}

	int ccc=(look<N) ? look:cc;

	for(i=ccc-1;i>=0;i--){
		if(left<cup[i])continue;
		//if(sum[i]<left)break;
		if(stat[i]==0 && search(cc,left-cup[i],i,num-1))return 1;
		if(i==cc-1 && stat[i]==0)break;
	}

	if(look<N)stat[look]=0;

	return 0;
}

int main(){
    int i,j,k;

    while(scanf("%d",&N)*N){
		SET++;

		for(i=0;i<=100;i++)wat[i]=0;
		for(i=0;i<N;i++){
			scanf("%d",&k);
			wat[k]++;
		}
		for(i=0,j=0,k=0;i<=100,j<N;i++){
			for(;wat[i]>0;wat[i]--){
				k+=i;
				cup[j]=i;
				stat[j]=0;
				sum[j]=k;
				j++;
			}
		}

		if(search(99,0,N-1,N-1))printf("YES\n"); else printf("NO\n");

    }
 
    return 0;
}

Measured memory_bytes: 588
N=int(input())
A=[int(x) for x in input().split()]
for i in range(N):
  A[i]=A[i]-1-i
A.sort()
if N==1:
  print(0)
else:
  b=A[N//2]
  c=A[(N//2)+1]
  ans1,ans2=0,0
  for i in range(N):
    ans1+=abs(A[i]-b)
    ans2+=abs(A[i]-c)
  print(min(ans1,ans2))

Measured memory_bytes: 26128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

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

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

ll mod(ll val, ll M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    vector<ll> Sum(N + 1);
    for(int i = 0;i < N;i++) {
        Sum.at(i + 1) = Sum.at(i) + vec.at(i);
    }
    ll ret = 0;
    for(int i = 0;i < N;i++) {
        ll cnt = Sum.at(N) - Sum.at(i + 1);
        cnt %= MOD;
        ret += vec.at(i) * cnt;
        ret %= MOD;
    }
    cout << ret << endl;
}

Measured memory_bytes: 6424
#include <stdio.h>

typedef struct {
	int id;
	int kcal;
	int a;
	int b;
	int c;
} NUTRITION;

int main(void)
{
	NUTRITION sweet[1000];
	NUTRITION limit;
	int i, n, f;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d %d", &sweet[i].id, &sweet[i].a, &sweet[i].b, &sweet[i].c);
			sweet[i].kcal = sweet[i].a * 4 + sweet[i].b * 9 + sweet[i].c * 4;
		}
		
		scanf("%d %d %d %d", &limit.a, &limit.b, &limit.c, &limit.kcal);
		
		for (i = 0, f = 0; i < n; i++){
			if (
			sweet[i].a <= limit.a &&
			sweet[i].b <= limit.b &&
			sweet[i].c <= limit.c &&
			sweet[i].kcal <= limit.kcal
			){
				f = 1;
				printf("%d\n", sweet[i].id);
			}
		}
		
		if (!f){
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 632