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

int main(void){
	int N, M;
	int t[1000], n[1000], m[1000], s[1000];
	while(cin >> N >> M, N | M){
		int r, q;
		cin >> r;
		for(int i=0; i < r; i++){
			cin >> t[i] >> n[i] >> m[i] >> s[i];
		}

		cin >> q;
		for(int i=0; i < q; i++){
			int st, et, p;
			cin >> st >> et >> p;
			int ans = 0, B;
			int A = 0;
			for(int j=0; j < r; j++){
				if(m[j] == p){
					if(s[j] == 1){
						A++;
            if(A == 1)
              B = t[j];
					}else{
						A--;
            if(A==0 && st<=t[j] && B<=et){
              ans+=(min(et, t[j]) - max(st, B));
            }
					}
				}
			}
      cout << ans << endl;
			
		}
	}
  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double theta;
    if (2 * x > a * a * b) theta = atan(2*b/a - 2*x/a/a/a);
    else theta = atan(a*b*b/2/x);
    theta = theta * 180 / M_PI;
    printf("%.7f\n", theta);
    return 0;
}

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

struct TProcess
{
	string Name;
	int    Time;
};

struct TFinished
{
	string Name;
	int    Time;
};

queue<TFinished> RoundRobin(queue<TProcess> X, int q)
{
	queue<TFinished> Y;
	int TotalTime = 0;
	while(!X.empty()){
		if(X.front().Time <= q){
			TotalTime += X.front().Time;
			TFinished Finished;
			Finished.Name = X.front().Name;
			Finished.Time = TotalTime;
			X.pop();
			Y.push(Finished);
		}else{
			TotalTime += q;
			X.front().Time -= q;
			X.push(X.front());
			X.pop();
		}
	}
	return Y;
}

int main()
{
	int n, q;
	cin >> n;
	cin >> q;
	queue<TProcess> Input;
	for(int i = 0; i < n; i++){
		TProcess Process;
		cin >> Process.Name >> Process.Time;
		Input.push(Process);
	}
	queue<TFinished> Output = RoundRobin(Input, q);
	while(!Output.empty()){
		cout << Output.front().Name << " " << Output.front().Time << endl;
		Output.pop();
	}
	return 0;
}

Measured memory_bytes: 5228
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int Task4Core();

int main()
{
	cout << Task4Core();

	return 0;
}
int Task4Core()
{
	int N = 0;

	cin >> N;

	map<int, int> num; // 差分、個数
	
	for (int i = 0; i < N; ++i) {
		int n = 0;
		cin >> n;
		++num[n];
	}

	//　並び方は人数によって決まる。

	int numPower = N / 2;

	// int product = 1;
	int divisor = 1000000000 + 7;

	// map は key によりソートされているはず。

	const bool isOdd = (N % 2 == 0) ? false: true;
	int numP = (isOdd) ? 0 : 1;
	int product = 1;
	auto elem = num.begin();

	int limit = N / 2;
	if (isOdd) {
		++limit;
	}
	for (int i = 0; i < limit; ++i, numP += 2) {
		// numP += 2;

		if (isOdd && i == 0) {
			if (num[0] != 1) {
				return 0;
			}

		}
		else if (num[numP] != 2) {
			return 0;
		}
		if (isOdd == false || i != 0) {
			product = (product * 2) % divisor;
		}
	}
	
	return product;
}

Measured memory_bytes: 3200
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn sum(mut n: usize) -> usize {
    let mut res = 0;
    while n > 0 {
        res += n % 10;
        n /= 10;
    }
    res
}

fn main() {
    let (n, a, b): (usize, usize, usize);
    input!(n, a, b);
    let mut ans = 0;
    for i in 1..n + 1 {
        let r = sum(i);
        if a <= r && r <= b {
            ans += i;
        }
    }
    println!("{}", ans);
}


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

int main() {
  string  s;
  cin>>s;
  if(s=="RRR"){
    cout<<3<<endl;
  }
  else if(s=="RRS"||s=="SRR"){
    cout<<2<<endl;
  }
  else if(s=="SSS"){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }

}


Measured memory_bytes: 3584
#include<cstdio>

using namespace std;

int a, b, c, d, e, f;
int ans_all = 0, ans_sugar = 0;
int lst[30][1500];


void noudo(int n, int m, int s, int t){
    int water_ = n * a + m * b;
    int water = water_ * 100;
    int sugar = s * c + t * d;
    int all = water + sugar;

    if (ans_sugar * all <= sugar * ans_all) {
        ans_sugar = sugar;
        ans_all = all;
    }
    // puts("1.1");
    lst[water_][sugar] = 1;
    // puts("1.2");
    if (all + 100 * a <= f && lst[water_ + a][sugar] != 1) noudo(n+1,m,s,t);
    if (all + 100 * b <= f && lst[water_ + b][sugar] != 1) noudo(n,m+1,s,t);
    if (all + c <= f && (n * a + m * b) * e >= sugar + c && lst[water_][sugar + c] != 1) noudo(n,m,s+1,t);
    if (all + d <= f && (n * a + m * b) * e >= sugar + d && lst[water_][sugar + d] != 1) noudo(n,m,s,t+1);

}

int main(){
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);
    // puts("0");
    if (100 * a <= f) {
        noudo(1,0,0,0);
    }
    // puts("1");
    if (100 * b <= f) {
        noudo(0,1,0,0);
    }
    // puts("2");
    printf("%d %d\n", ans_all, ans_sugar);

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

int N, K;
string S;

int main()
{
    cin >> N >> K >> S;
    N = S.size();

    vector<int> lens;

    if (S[0] == '0') { lens.push_back(0); }

    int len = 0;

    for (int i=0;i<N;++i)
    {
        if (i - 1 >= 0 && S[i] != S[i - 1])
        {
            lens.push_back(len);
            len = 0;
        }

        ++len;
    }

    lens.push_back(len);

    lens.push_back(0);
    lens.push_back(0);
    lens.push_back(0);
    lens.push_back(0);

    int value = lens.size() >= 0 ? lens[0] : 0;

    const int length = min<int>(lens.size() / 2, K);

    for (int i=0;i<length;++i)
    {
        value += lens[i * 2 + 1] + lens[i * 2 + 2];
    }

    int ans = value;

    for (int i=0;(i+length+1)*2+1<lens.size();++i)
    {
        const int p = i;
        const int q = i + length;

        const int pp = lens[p * 2] + lens[p * 2 + 1];
        const int qq = lens[q * 2 + 1] + lens[q * 2 + 2];

        const int nextValue = value - pp + qq;

        value = nextValue;

        ans = max<int>(ans, value);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

int t=0;

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

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

bool check(vll &b, ll x)
{
    rep(i,62)
    {
        if(((1LL<<i)&x)==0)
            continue;
        if(b[i]!=-1)
            x^=b[i];
        else
        {
            b[i]=x;
            return true;
        }
    }
    return false;
}

void solve()
{
    int n;
    cin>>n;
    vll v(n);
    rep(i,n)
    {
        cin>>v[i];
    }
    string s;
    cin>>s;
    vll b(62,-1);
    repd(i,n-1,0)
    {
        bool hi=check(b,v[i]);
        if(hi && s[i]=='1')
        {
            cout<<1<<endl;
            return;
        }
    }
    cout<<"0\n";
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("hh.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
        tt++;
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3828
N, K = list(map(int, input().split()))
td = []
for i in range(N):
  td.append(list(map(int, input().split())))

td.sort(key = lambda x:x[1], reverse = True)

D = []
T = {}
d = 0

for i in range(K):
  D.append(td[i])
  d += td[i][1]
  t = td[i][0]
  if t in T:
    T[t] += 1
  else:
    T[t] = 1

D.sort(key = lambda x: x[1])

cnt = 0
flag = False
Ans = d + pow(len(T), 2)
for i in range(K, N):
  if td[i][0] in T:
    continue
  while T[D[cnt][0]] == 1:
    cnt += 1
    if cnt == K:
      flag = True
      break
  if flag:
    break

  T[td[i][0]] = 1
  T[D[cnt][0]] -= 1
  d -= D[cnt][1] - td[i][1]
  
  t = d + pow(len(T), 2)
  if Ans < t:
    Ans = t
  cnt += 1
  if cnt == K:
    break

print(Ans)

Measured memory_bytes: 33508
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    // n 左の本の数 m; 右の本の数 k; 読書時間
    int n = sc.nextInt();
    int m = sc.nextInt();
    int k = sc.nextInt();
    int[] leftBooks = new int[n];
    int[] rightBooks = new int[m];
    for (int i = 0; i < n; i++) {
      leftBooks[i] = sc.nextInt();
    }
    for (int j = 0; j < m; j++) {
      rightBooks[j] = sc.nextInt();
    }
    // しゃくとり法
    int right = m;
    int maxBooks = 0;
    long readTimeTmp = 0;
    // 右をすべて読む
    for (int i = 0; i < m; i++) {
      readTimeTmp += rightBooks[i];
    }
    for (int left = 0; left < n + 1; left++) {
      while (readTimeTmp > k && right > 0) {
        right--;
        readTimeTmp -= rightBooks[right];
      }
      // 右を減らせない状態でも時間がオーバー
      if (readTimeTmp > k) {
        break;
      }
      maxBooks = Math.max(maxBooks, left + right);
      // 最後はleft == n となってエラーなので回避
      if (left == n) {
        break;
      }
      readTimeTmp += leftBooks[left];
    }
    System.out.println(maxBooks);
  }
}

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

using namespace std;

int main() {
	int N,K;
	cin >> N >> K;
	int ans=0;
	
	if(K==1){
		ans =0;
	}
	else{
		ans = N-K;
	}

	cout << ans;
}

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

const ll INF = 1e15;

int main(){ 
  int n;
  cin>>n;
  vector<vector<pair<ll,int>>> g(n);
  rep(i,n-1){
    int a,b;
    ll c;
    cin>>a>>b>>c;
    a--; b--;
    g[a].pb({c,b});
    g[b].pb({c,a});
  }
  vector<ll> dist(n,INF);
  priority_queue<pair<ll,int>> que;
  
  int q,k;
  cin>>q>>k;
  k--;
  dist[k]=0;
  que.push({0,k});
  
  while(!que.empty()){
    int x = que.top().second;
    que.pop();
    
    for(auto nx:g[x]){
      if(dist[nx.second]<dist[x]+nx.first) continue;
      que.push({dist[x]+nx.first,nx.second});
      dist[nx.second] = dist[x]+nx.first;     
    }
  }
  rep(i,q){
    int x,y;
    cin>>x>>y;
    x--; y--;
    cout << dist[x]+dist[y] << endl;
  }
}

Measured memory_bytes: 11120
N,M = map(int,input().split())
A = [[int(i) for i in input().split()] for j in range(N)]
B = [ [] for i in range(8)]

for i,j,k in A:
    B[0].append(i+j+k)
    B[1].append(i-j+k)
    B[2].append(i+j-k)
    B[3].append(i-j-k)
    B[4].append(-i+j+k)
    B[5].append(-i-j+k)
    B[6].append(-i+j-k)
    B[7].append(-i-j-k)
    
C = [sorted(i,reverse = True)[:M] for i in B]

print(max([sum(i) for i in C]))


Measured memory_bytes: 3692
//
// Created by Ciafrino on 1/6/19.
//
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long lint;

int dp[3010][3010];

string get_lcs(string s, string t, int size_s, int size_t) {
    for (int i = 0; i <= size_s; ++i) {
        for (int j = 0; j <= size_t; ++j) {
            if (i == 0 || j == 0) dp[i][j] = 0;
            else if (s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int idx = dp[size_s][size_t];
    char lcs[idx+1];
    lcs[idx] = '\0';
    int i = size_s, j = size_t;
    while(i > 0 && j > 0) {
        if (s[i-1] == t[j-1]) {
            lcs[idx-1] = s[i-1];
            --i;
            --j;
            --idx;
        }
        else if (dp[i-1][j] > dp[i][j-1]) --i;
        else --j;
    }
    return lcs;
}

string read_string() {
    char *str;
    scanf("%ms", &str);
    string result(str);
    free(str);
    return result;
}

int main() {
    string s, t;
    s = read_string();
    t = read_string();
    int size_s = s.size(), size_t = t.size();
    string result = get_lcs(s, t, size_s, size_t);
    cout << result;
    return 0;
}

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

int main() {
  int N, ans = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}


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

using namespace std;

int main(int argc, char* argv[]) {
  long long X;
  cin >> X;

  long long n = sqrt(2 * X);
  while (true) {
    if (2 * X <= n * (n - 1))
      break;
    ++n;
  }

  cout << n - 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>

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

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

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

int main()
{
  long long N, P;
  std::string S;
  std::cin >> N >> P;
  std::cin >> S;
  long long ans = 0;
  std::reverse(S.begin(), S.end());
  if(P == 2 || P == 5)
  {
    for(int i=0; i<S.size(); ++i)
    {
      int val = S[i]-'0';
      if(val%P==0)
        ans += (S.size()-i);
    }
  }
  else
  {
    std::vector<long long> acc(N+1, 0);
    long long pow = 1;
    acc[0]=0;
    for(int i = 1; i <= N; ++i)
    {
      long long val = S[i-1]-'0';
      acc[i]=(acc[i-1]+pow*val)%P;
      pow = (pow*10)%P;
    }
    std::vector<long long> a(P, 0);
    for(int i = 0; i <= N; ++i)
    {
      ans += a[acc[i]];
      a[acc[i]]++;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<long long> A(n);
    for (int i=0; i<n; i++){
        cin >> A.at(i);
    }
    
    int ans = 0;
    
    while(true){
        bool exist_odd = false;
        for (int i=0; i<n; i++){
            if (A[i]%2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i=0; i<n; i++){
            A[i] /= 2;
        }

        ans = ans + 1;
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    ll a, b;

    cin >> a >> b;

    ll res = 0;

    for (ll i = 1; i < (1LL << 40); i *= 2)
    {
        ll c = ((a) / (i * 2)) * i;
        c += max(((a) % (i * 2)) - i, (ll)0);

        ll d = ((b + 1) / (i * 2)) * i;
        d += max(((b + 1) % (i * 2)) - i, (ll)0);

        if ((d - c) % 2 == 1)
            res += i;
    }

    cout << res << 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 int ll;
typedef pair<int, int> P;

struct UnionFind {
    vector<int> data;

    UnionFind(int sz){
        data.assign(sz, -1);
    }

    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(data[x] > data[y]) swap(x, y); //rank?
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int root(int x){
        if(data[x] < 0) return x;
        return data[x] = root(data[x]); //経路圧縮
    }

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

    int size(int x){
        return (-data[root(x)]);
    }
};

int n, m, k;
vector<vector<int>> fr(101010, vector<int>(0)), bl(101010, vector<int>(0));


int main()
{
    cin >> n >> m >> k;
    UnionFind uf(101010);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        fr[a].emplace_back(b);
        fr[b].emplace_back(a);
        uf.unite(a, b);
    }
    rep(i, k)
    {
        int c, d;
        cin >> c >> d;
        bl[c].emplace_back(d);
        bl[d].emplace_back(c);
    }

    for (int i = 1; i <= n; i++)
    {
        int res = uf.size(i) - 1;
        res -= fr[i].size();
        for(auto x : bl[i])
        {
            if(uf.same(i, x))
            {
                res--;
            }
        }
        cout << res << endl;
    }

    return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


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

    string s;
    cin >> s;

    int n = s.size();
    vector<int> prev(2019);
    int ans = 0;
    rep(i, n) {
        vector<int> next(2019);

        int k = s[i] - '0';
        next[k] += 1;

        rep(j, 2019) {
            int l = j * 10 + k;
            l = l % 2019;
            next[l] += prev[j];
        }
        prev = next;
        ans += prev[0];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3576
N, T = map(int, input().split())
t_list = list(map(int, input().split()))

X = T
prev_t = 0
for t in t_list:
    if t == 0:
        continue
    if prev_t + T > t:
        X += t - prev_t
    else:
        X += T
    prev_t = t
print(X)


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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n/2;i++){
    if(s[i]==s[n-1-i]) continue;
    else {cout<<"No"; return 0;}
  }
  int mid=n/2;
  for(int i=0;i<mid/2;i++){
    if(s[i]==s[mid-1-i]) continue;
    else {cout<<"No"; return 0;}
  }
  for(int i=mid+1;i<n;i++){
    if(s[i]==s[n-1-i]) continue;
    else {cout<<"No"; return 0;}
  }
  cout<<"Yes";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  char s[10010];
  cin>>s;
  int len=strlen(s);
  for(int i=0;i<len;i++){
    int x=s[i]-'A';
    x=(x+n)%26;
   putchar('A'+x);
}
  cout<<endl;
}

Measured memory_bytes: 256
a, b, c, x = [int(input()) for _ in range(4)]

count = 0
for i in range(a, -1, -1):
    i_tmp = i * 500
    for j in range(b, -1, -1):
        j_tmp = j * 100 + i_tmp
        for k in range(c, -1, -1):
            sum = k * 50 + j_tmp
            if sum == x:
                count += 1

print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define REP(i, a, b) for (i=(a); i<(b); ++i)
#define rep(i, n) REP(i, 0, n)
int main(void)
{
	int i, j, n;
	int a[100][100], b[100][100];
	while (scanf("%d", &n), n) {
		memset(b, 0, sizeof(b));
		rep(i, n) rep(j, n) scanf("%d", &a[i][j]);
		rep(i, n) {
			int m = (1 << 30);
			rep(j, n) if (a[i][j] < a[i][m]) m = j;
			rep(j, n) if (a[i][j] == a[i][m]) b[i][j]++;
		}
		rep(j, n) {
			int m = 0;
			rep(i, n) if (a[i][j] > a[m][j]) m = i;
			rep(i, n) if (a[i][j] == a[m][j]) b[i][j]++;
		}
		int res = 0;
		rep(i, n) rep(j, n) if (b[i][j] == 2) res = a[i][j];
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
  int N,cnt=1;
  char str[100000+1];
  cin >> N >> str;
  for(int i=0;i+1<N;i++){
    if(str[i]!=str[i+1])cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
void Main(){
    int N, ans = 0, it;
    cin >> N;
    vector<int> A(N), B(N, -1);
    for (auto& a:A) cin >> a;
    for (int i = 0; i<N; i++) {
        it = lower_bound(B.begin(), B.end(), A[i])-B.begin();
        B[it-1] = A[i];
    }
    for (auto b:B) if (b != -1) ans++;
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a != c) {
		cout << "Yes" << endl;
	}
	else if (a == c && a != b) {
		cout << "Yes" << endl;

	}
	else if (b == c && a != b) {
		cout << "Yes" << endl;

	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
vector<pair<string, pair<int, int>>> v;
string s;
int p;

int main(){
    cin >> n;
    REP(i, n){
        cin >> s >> p;
        v.emplace_back(make_pair(s, make_pair(-p, i + 1)));
    }
    sort(ALL(v));
    REP(i, n){
        cout << v[i].second.second << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

template<typename T>
constexpr std::vector<std::pair<T, T>> primeFactorization(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors;
	T quotient = number;
	for (T i = 2; i * i <= quotient; ++i) {
		if (quotient % i == 0) {
			T prime = i, power = 1;

			quotient /= i;
			while (quotient % i == 0) {
				++power;
				quotient /= i;
			}

			primeFactors.push_back(std::pair<T, T>(prime, power));
		}
	}
	if (quotient != 1) primeFactors.push_back(std::pair<T, T>(quotient, 1));

	return primeFactors;
}

template<typename T>
constexpr int countDivisor(std::vector<std::pair<T, T>> primeFactors) noexcept {
	int counter = 1;
	for (int i = 0; i < primeFactors.size(); ++i) {
		counter *= (primeFactors[i].second + 1);
	}

	return counter;
}

template<typename T>
constexpr std::vector<T> findDivisor(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors = primeFactorization(number);

	std::vector<T> divisor(countDivisor(primeFactors));
	divisor[0] = 1;

	int counter = 1;
	for (int i = 0; i < primeFactors.size(); ++i) {
		int currentSize = counter;
		for (int j = 1; j <= primeFactors[i].second; ++j) {
			T x = 1;
			for (int k = 0; k < j; ++k) {
				x *= primeFactors[i].first;
			}

			for (int k = 0; k < currentSize; ++k) {
				divisor[counter + k] = divisor[k] * x;
			}
			counter += currentSize;
		}
	}
	sort(divisor.begin(), divisor.end());

	return divisor;
}

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

	ll n;
	cin >> n;

	vector<ll> divisor = findDivisor(n);

	ll ans = 0;
	rep(i, divisor.size()-1) {
		if (divisor[i] >= divisor[divisor.size() - 1 - i] - 1) break;
		ans += divisor[divisor.size() - 1 - i] - 1;
	}

	cout << ans << "\n";

	return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    sort(h.begin(),h.end(),greater<int>());
    int minv=1000000005;
    rep(i,n-k+1) minv=min(minv,h[i]-h[i+k-1]);
    cout<<minv<<"\n";
    return 0;
}

Measured memory_bytes: 3788
# ABC094C - Many Medians (ARC095C)
def main():
    n = int(input())
    x = list(map(int, input().split()))
    # 偶数個の数から一つ数を取り除いたものの中央値はl,hのいずれか.
    l, h = sorted(x)[n // 2 - 1 : n // 2 + 1]
    ans = [h if e <= l else l for e in x] # l以下の値を取り除いたならば中央値はh
    print("\n".join(map(str, ans)))
if __name__ == "__main__":
    main()

Measured memory_bytes: 29764
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
    return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapfi(int i){
    int l = i * 2;
    int r = i * 2 + 1;
    int max = 0;
    int tmp = 0;
    if(l <= H && A[l] > A[i]) max = l;
    else max = i;
    if(r <= H && A[r] > A[max]) max = r;

    if(max != i){
        tmp = A[max];
        A[max] = A[i];
        A[i] = tmp;
        maxHeapfi(max);
    }
}

int extract(){
    int result = A[1];
    A[1] = A[H];
    A[H] = 0;
    H = H - 1;
    maxHeapfi(1);
    return result;
}

void insert(int key){
    A[H + 1] = key;
    H = H + 1;
    int now = H;
    int tmp = 0;
    while(1){
        if(now <= 1){
            break;
        }
        if(A[now] > A[now / 2]){
            tmp = A[now];
            A[now] = A[now / 2];
            A[now / 2] = tmp;
            now = now / 2;
        }else{
            break;
        }
    }
}

int main(){
    int key;
    char com[10];
    while(1){
        scanf("%s", com);
        if ( com[0] == 'e' && com[1] == 'n' ) break;
        if ( com[0] == 'i' ){
            scanf("%d", &key);
            insert(key);
        } else {
            printf("%d\n", extract());
        }
    }

    return 0;
}

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

int main(){
    int x, y;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }else{
            if(x < y){
                cout << x << " " << y << endl;
            }else{
                cout << y << " " << x << endl;
            }
        }
    }
}



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

const int N = 200005;

int n;
int ans[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int a;
    scanf("%d", &a);
    ++ans[--a];
  }

  for (int i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 4592
#include<iostream>
using namespace std;
int SumOfDigits(int x){
  int sum=0;
  while(x>0){
    sum+=x%10;
    x/=10;
  }
  return sum;
}
int main(){
  int N;cin>>N;
  int div=SumOfDigits(N);
  if(N%div==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int w, h;
	char str[101][101];
	int ch[100] = { 0 };
	int cw[100] = { 0 };

	cin >> h >> w;
	rep(i, 0, h) {
		rep(j, 0, w) {
			cin >> str[i][j];
		}
	}

	rep(i, 0, h) {
			rep(j, 0, w) {
				if(str[i][j]!='.'){
					break;

				}
				if (j == w - 1) { ch[i] = 1; }
			}
	}

	rep(i, 0, w) {
			rep(j, 0, h) {
				if (str[j][i] != '.') {
					break;

				}
				if (j == h - 1) { cw[i] = 1; }
			}
	}



	rep(i, 0, h) {
		if (ch[i] != 1) {
			rep(j, 0, w) {
				if (cw[j] != 1) cout << str[i][j];
			}
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<set>
#include<iostream>
#include<ctime>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<string.h>
#include<limits.h>
using namespace std;

int a[26];
signed main() {
	int b, c; cin >> b >> c;
	for (int i = 0; i < b; i++) {
		string d; cin >> d;
		for (char e : d) {
			a[e - 'a'] ++;
		}
	}
	priority_queue<int>Q;
	vector<int>V;
	for (int i = 0; i < 26; i++)Q.push(a[i]);
	for (int i = 0; i < (b+1) / 2; i++) {
		for (int j = 0; j < (c+1) / 2; j++) {
			int sum = 1;
			if (b % 2 == 1 && i == b / 2)sum *= 1;
			else sum *= 2;
			if (c % 2 == 1 && j == c / 2)sum *= 1;
			else sum *= 2;
			V.push_back(sum);
		}
	}
	sort(V.begin(), V.end(), greater<int>());
	for (int i : V) {
	   if (Q.size() == 0 || Q.top() < i) {
			puts("No"); return 0;
	   }
	   int k = Q.top();
	   Q.pop();
	   Q.push(k - i);
	}
	puts("Yes");
}

Measured memory_bytes: 256
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      max = @data[0]
      # popで末尾の要素を削除し、先頭に持ってくる
      @data[0] = @data.pop

      top_down

      return max
    end
  end

  def to_array
    @data
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)

    while (@data[parent_idx] < @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      # 頂点まで来たらブレーク
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      # あくまでもインデックスなので最初は1,2 次は3,4か5,6
      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a] >= @data[b] ? a : b
      end

      if @data[target_idx] < @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end


n, m = gets.chop.split.map(&:to_i)
a = gets.chop.split.map(&:to_i)

pq = PriorityQueue.new(a)


m.times do |i|
  tmp = pq.pop
  pq.push(tmp/2)
end

p pq.to_array.inject(:+)




Measured memory_bytes: 13076
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<int> g[200010];
int main() {
  int n;
  cin >> n;

  vector<P> e;
  int k = 0;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a;--b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
    e.emplace_back(a,b);
    k = max(k,(int)g[a].size());
    k = max(k,(int)g[b].size());
  }

  map<P,int> cmap;
  map<int,int> cpar;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int x = q.front(); q.pop();
    int c = 1;
    for (int nx : g[x]){
      P p1 = P(x,nx), p2 = P(nx,x);
      if(cmap[p1] != 0) {
        continue;
      }
      if (c==cpar[x]) ++c;
      cmap[p1] = c;
      cmap[p2] = c;
      cpar[nx] = c;
      q.push(nx);
      ++c;
    }
  }
  cout << k << endl;
  rep(i,n-1) cout << cmap[e[i]] << endl;
}


Measured memory_bytes: 23284
s = input()
t = ""
while len(t) < len(s):
    target_len = len(s) - len(t)

    if s[len(t)] == 'd':
        if target_len == 5:
            t += "dream"
        elif target_len == 7:
            t += "dreamer"
        elif target_len > 7:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 7 + 1] != "era":
                t += "dreamer"
            else:
                t += "dream"
        else:
            break
    else:
        if target_len == 5:
            t += "erase"
        elif target_len == 6:
            t += "eraser"
        elif target_len > 6:
            if s[len(t) + 5] != 'd' and s[len(t) + 5:len(t) + 6 + 2] != "era":
                t += "eraser"
            else:
                t += "erase"
        else:
            break

    if s[0:len(t)] != t:
        break

print("YES" if s == t else "NO")


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<string>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
using namespace std;

static const ll mod  = 1e9 + 7;
static const ll inf  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    ll r, D, x;
    cin >> r >> D >> x;
    FOR(i, 1, 11){
        x = r * x - D;
        p(x);
    }
}

Measured memory_bytes: 256
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,L,R) for(auto i=R-1;i>=L;i--)
#define show(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

vi dp(1e5),arr(1e5);

int main() 
{
	int test;
//	cin>>test;
//	while(test--)
	{
	    int n;
	    cin>>n;
	    F(i,0,n)
	        cin>>arr[i];
        dp[0]=0;
        dp[1]=abs(arr[1]-arr[0]);
        F(i,2,n)
        {
            dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]) , dp[i-2]+abs(arr[i]-arr[i-2]));
        }
	    
	    cout<<dp[n-1]<<"\n";
	    
	}

}




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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e5 + 123;
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, W, w[N], v[N];
ll dp[N];

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

	cin >> n >> W;

	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];

	for(int i = 1; i <= 1e5; i++)
		dp[i] = INF;
                       
	for(int i = 1; i <= n; i++) 
		for(int j = 1e5; j >= 0; j--) 
			if(j - v[i] >= 0 && dp[j - v[i]] != INF) {
				dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
			}

	for(int i = 1e5; i >= 0; i--)
		if(dp[i] <= W) return cout << i, 0;

    return 0;                                        
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        for(int i=1;;i++){
            int x = sc.nextInt();

            if(x==0){
                break;
            }else{
                System.out.printf("Case %d: %d\n",i,x);
            }
        }
    }
}


Measured memory_bytes: 61324
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>v[505];
int main(){
    int n,m,q,l,r;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0;i<m;i++){
        scanf("%d%d",&l,&r);
        v[l].push_back(r);
    }
    for(int i=1;i<505;i++)
    sort(v[i].begin(),v[i].end());
    while(q--){
        int st,ed;
        scanf("%d%d",&st,&ed);
        int res=0;
        for(int i=st;i<=ed;i++){
            if(v[i].size()==0||v[i][0]>ed) continue;
            l=0,r=v[i].size()-1;
            if(v[i][r]<=ed){
                res+=r+1;
                continue;
            }
            res+=upper_bound(v[i].begin(),v[i].end(),ed)-v[i].begin();
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 2176
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

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(){
    int n;
    cin >> n;
    int cnt = 1;

    rep(i, n){
        int a;
        cin >> a;
        if(a % 2 == 0)cnt *= 2;
    }

    cout << pow(3, n) - cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, n;
    cin >> h >> n;
    ll sum = 0;
    for(ll i = 0; i < n; i++) {
        ll a;
        cin >> a;
        sum += a;
    }
    cout << (sum >= h ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<int> g[100];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int u, k;
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; ++j) {
      int v;
      cin >> v;
      v--;
      g[u].push_back(v);
    }
  }
  vector<int> d(n, 1e9);
  queue<int> que;
  que.push(0);
  d[0] = 0;
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (auto u : g[v]) {
      if (d[u] == 1e9) {
        que.push(u);
        d[u] = d[v] + 1;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << i + 1 << " " << (d[i] == 1e9 ? -1 : d[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 3136