akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <climits>
#include <utility>
#include <map>
#include <set>
#include <complex>
#include <numeric>

#include <time.h>
#include <float.h>

#define loop(i, start, end) for(i = (start); i <= (end); i++)
#define loopIterators(it, vec) for(it = (vec).begin(); it != (vec).end(); it++)
#define loopIteratorsRev(it, vec) for(it = (vec).rbegin(); it != (vec).rend(); it++)
#define loopRev(i, start, end) for(i = (start); i >= (end); i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PNN1(n) cout << (n) << endl
#define PNN2(a, b) cout << (a) << " " << (b) << endl
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define PrintArray(ar, n) for(i = 0; i < n; i++) cout << ar[i] << " "; cout << endl
#define PrintObject(ar, it) loopIterators(it, ar) cout << *it << " "; cout << endl
#define PrintMap(map, it) loopIterators(it, map) PNN2(it->first, it->second)
#define sz(a) sizeof(a)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define SWAP(a, b, c) c = a; a = b; b = c
#define STRSP(s) scanf("%[^\n]%*c", s)
#define ENTER PNN1("")
#define MOD7 1000000007
#define MOD9 10000009
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int, int>
#define ONLINE_JUDGE

typedef long long int lli;
typedef long int li;
typedef unsigned long long int ulli;
typedef long double ld;

using namespace std;

int main(void){
	FLASH

	#ifndef ONLINE_JUDGE
		freopen("input-stream.txt", "r", stdin);
		freopen("output-stream.txt", "w", stdout);
	#endif

	int k, n, i;
	IN2(k, n);
	int ar[n];
	loop(i, 0, n - 1) IN1(ar[i]);
	std::sort(ar, ar + n);

	int cur = INT_MIN;
	loop(i, 0, n - 2) {
		cur = max(cur, ar[i + 1] - ar[i]);
	}

	cur = max(cur, k - ar[n - 1] + ar[0]);

	PNN1(k - cur);


	#ifndef ONLINE_JUDGE
		fclose(stdin);
		fclose(stdout);
	#endif

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b; cin >> r >> g >> b;
    cout << ((g*10+b)%4==0 ? "YES" : "NO");
    cout << endl;
    return 0;
}



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

#define D 1000000007

long long pw(long long n,long long k){
	long long res = 1;
	for(int i = 0; i < n; i++){
		res *= k;
		res %= D;
	}
	return res;
}

int main(){
	long long n,k;
	cin >> n >> k;
	cout << pw(n,k) << endl;

	return 0;
}



Measured memory_bytes: 3112
import math

K = int(input())
check = {}
ans = 0

for i in range(201):
    check[i] = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        check[math.gcd(a, b)] += 1

for c in range(1, K+1):
    for k in check.keys():
        num = math.gcd(c, k) * check[k]
        ans += num

print(ans)

Measured memory_bytes: 9196
N, K, C = map(int, input().split())
S = input()
length = len(S)

INF = float('inf')
Ls = [-INF]
n = 0
for i, c in enumerate(S):
    if c == 'o' and i - Ls[-1] > C:
        Ls.append(i)
        n += 1
        if n >= K: break

Rs = [INF]
n = 0
for i, c in enumerate(reversed(S)):
    if c == 'o' and Rs[-1] - (length-1-i) > C:
        Rs.append(length-1-i)
        n += 1
        if n >= K: break
Rs.reverse()

for l, r in zip(Ls[1:], Rs[:-1]):
    if l == r:
        print(l+1)


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
    basic_ostream<charTDummy, traitsDummy> &(
      basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif


int N, A, B, C;
int ans = INT_MAX;
vi bamboo;

void calc(vi v) {
  int tmp = 0;
  vi abcd(4, 0), count(4, 0);
  REP(i, N) {
    abcd[v[i]] += bamboo[i];
    count[v[i]]++;
  }
  if(count[0] == 0 || count[1] == 0 || count[2] == 0) return;
  REP(i, 3) {
    tmp += (count[i] - 1) * 10;
  }
  tmp += abs(A - abcd[0]);
  tmp += abs(B - abcd[1]);
  tmp += abs(C - abcd[2]);
  chmin(ans, tmp);
}

void dfs(int depth, vi v) {
  if (depth == N) {
    calc(v);
    return;
  }
  for (int i = 0; i < 4; i++) {
    v[depth] = i;
    dfs(depth+1, v);
  }
}

signed main() {
  cin >> N >> A >> B >> C;
  vi v(N, 0);
  REP(i, N) bamboo.PB(read());
  dfs(0, v);
  print(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	printf("100 100\n");
    int m,n;
    scanf("%d%d",&m,&n);
    /*
    .*.*.*
    ******
    *.*.*.
    ......
    */
    /*for(int i=0;i<50;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(m<n&&(m-n)%2==0)
            {
                m--;
                printf(".");
            }
            else printf("#");
        }
        printf("\n");
    }*/
    for(int i=0;i<50;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(m!=1&&i%2==0&&j%2==0)
            {
                m--;
                printf(".");
            }
            else printf("#");
        }
        printf("\n");
    }
	/*
    for(int i=50;i<100;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(m>n&&(m-n)%2==0)
            {
                n--;
                printf("#");
            }
            else printf(".");
        }
        printf("\n");
    }*/
    for(int i=50;i<100;i++)
    {
        for(int j=0;j<100;j++)
        {
            if(n!=1&&i%2!=0&&j%2!=0)
            {
            	printf("#");
                n--;
            }
            else printf(".");
        }
        printf("\n");
    }
}

Measured memory_bytes: 256
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {

    int n,m;
    
    cin >> n >> m;


    int mat[n][m];

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> mat[i][j];
        }
    }

    int vec[m];
    
    for(int j=0; j<m; j++)
        cin >> vec[j];

    int ans_vec[n];
    
    for(int i=0; i<n; i++)
        ans_vec[i] =0;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++)
                ans_vec[i] += mat[i][j]*vec[j];
    }
            
    for(int i=0; i<n; i++)
            cout << ans_vec[i] << endl;




    
    
    
    
    return 0;
    
}



Measured memory_bytes: 3108
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let mut x: u64 = sc.read();
    let mut ans = 0;

    let c500 = x / 500;
    ans += c500 * 1000;
    x %= 500;

    let c5 = x / 5;
    ans += c5 * 5;
    x %= 5;
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
# coding: utf-8

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.append(X)
y.append(Y)

# print(x)
# print(y)

max_x = max(x)
min_y = min(y)

if max_x < min_y:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
#include <iostream>
#include <ctype.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void func_A() {

    char s;
    cin >> s;

    if (isupper(s)) cout << "A";
    else cout << "a";

}

void func_B() {

    int n, k;
    cin >> n >> k;
    vector<int> p(n);

    for (int i = 0; i < n; ++i) cin >> p[i];
    sort(p.begin(), p.end());
    long long ans = 0;
    for (int i = 0; i < k; ++i) ans += p[i];

    cout << ans;
}


void func_C() {

    unsigned long long n;
    cin >> n;
    string ans = "";

    while (n > 0) {


        int temp = n % 26;
        n /= 26;
        if (temp == 0) {
            temp = 26;
            --n;
        }
        char c = 'a' - 1 + temp;
        ans += c;
    }

    reverse(ans.begin(), ans.end());
    cout << ans;
}

int main() {

    //func_A();
    //func_B();
    func_C();

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, K;
  std::cin >> N >> K;
  std::cout << N-K+1<< '\n';
  return 0;
}

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

int main() {
	while(1){
		int n,a,sum=0;
		cin>>n;
		if(n==0)
			break;
		for(int i=1; i<=9; i++){
			cin>>a;
			sum+=a;
		}
		cout<<n-sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	r := 0
	xs := A[0]
	cs := A[0]
	for l := 0; l < N; l++ {
		for r < N-1 && xs^A[r+1] == cs+A[r+1] {
			r++
			xs ^= A[r]
			cs += A[r]
		}
		result += r - l + 1
		xs ^= A[l]
		cs -= A[l]
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 4608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll MAXN=2e5+10;
const ll MOD=1e9+7;
const ll INV2=500000004;
const ll INV6=166666668;
ll solve(ll n,ll k){
    return k+(1+n)*(1+k)%MOD*k%MOD*INV2%MOD-k*(k+1)%MOD*(2*k+1)%MOD*INV6%MOD;
}
int main(){
    ll n,k;scanf("%lld %lld",&n,&k);
    if(k==1){
        printf("%lld\n",(solve(n,n+1)%MOD+MOD)%MOD);
    }else{
        printf("%lld\n",((solve(n,n+1)-solve(n,k-1))%MOD+MOD)%MOD);
    }
    return 0;
}


Measured memory_bytes: 3232
using System;
using System.Linq;

namespace C
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var a1n = Console.ReadLine().Split().Select(int.Parse).ToList();
			var a2n = Console.ReadLine().Split().Select(int.Parse).ToList();

			var result = a1n[0] + a2n.Sum();
			var tmpResult = result;
			for (var i = 0; i < n - 1; i++)
			{
				tmpResult += a1n[i + 1] - a2n[i];
				if (tmpResult > result) { result = tmpResult; }
			}

			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 13396
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

long long pw(long long e, long long x) {
  if (x == 0)
    return 1;
  if (x == 1)
    return e;
  if (x % 2 == 0)
    return pw(e * e, x / 2);
  return e * pw(e, x - 1);
}

int main() {
  long long n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  long long ans = 1;
  if (n > 1000000) {
    cout << 1 << endl;
    return 0;
  }
  for (long long i = 2; pw(i, n) <= p; i++) {
    if (p % pw(i, n) == 0)
      ans = i;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int min = *min_element(a.begin(), a.end());
  int max = *max_element(a.begin(), a.end());
  int minCost = INT_MAX;
  for(int i=min;i<=max;i++) {
    int cost = 0;
    for(int j=0;j<n;j++) {
      cost += (i - a[j]) * (i - a[j]);
    }
    if(cost < minCost) minCost = cost;
  }

  cout << minCost << endl;
}

Measured memory_bytes: 256
n_room = 10     # 1フロアの部屋の数
n_floor = 3     # 1棟ごとの階数
n_blds = 4      # 棟の数
cnt1 = 0           # 配列作成時のカウンタ
ary = []        # 配列を作成

# 配列を0で埋めた状態で作成
ary = [[[0]*n_room for i in range (0,n_floor)] for k in range (0,n_blds)]

n = int(input())    # データ数を取得
cnt2 = 0            # データ取得用カウンタの初期化

while True:
    b,f,r,v = map(int, input().split())
    ary[b-1][f-1][r-1] += v
    cnt2 += 1
    if cnt2 == n:
        break
    
x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(ary[i][a][b]),end = "")
        print()




Measured memory_bytes: 5628
import java.util.*;
import java.io.*;

public class Main {
	static long[] memo = new long[100];
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		out.println(lucas(n));
	
		out.close();
	}
	static long lucas(int n) {
		if (n == 0) return 2;
		if (n == 1) return 1;
		if (memo[n] != 0) return memo[n];
		else  return memo[n] = lucas(n - 1) + lucas(n - 2);
	}


static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 23252
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
uf=UnionFind(n)
ab=ab[::-1]
ans=[n*(n-1)//2]
for i in range(m-1):
  if uf.same(ab[i][0]-1,ab[i][1]-1):
    ans.append(ans[-1])
  else:
    s=uf.size(ab[i][0]-1)
    t=uf.size(ab[i][1]-1)
    ans.append(ans[-1]-s*t)
    uf.union(ab[i][0]-1,ab[i][1]-1)
ans=ans[::-1]
for i in range(m):
  print(ans[i])
 

Measured memory_bytes: 35624
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, A;
  cin >> N >> A;

  int sum = N % 500;

  if (sum <= A)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const int INF = 1e9 + 5;
const long long MAXN=2e5 + 5;;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
	return (a + b) < (b + a);
}

vector<int> Reversed(const vector<int>& s){
   vector<int> d = s;
   reverse(all(d));
   return d;
}

void solve(){
    string s;
    cin >> s;
    int l = s.size();
    if(s[0] == s[l - 1]){
        if(l % 2 == 0)
            cout << "First";
        else cout << "Second";
    }
    else{
        if(l % 2 == 0)
            cout << "Second";
        else cout << "First";
    }
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


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

class Program
{
    static long mod = (long)1e9 + 7;

    static long n;
    static long m;
    static long[] x;
    static long[] y;

    static void Main()
    {
        long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        n = input[0];
        m = input[1];
        x = Console.ReadLine().Split().Select(long.Parse).ToArray();
        y = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long x_min = x.Min();
        x = x.Select(s => s - x_min).ToArray();
        long y_min = y.Min();
        y = y.Select(s => s - y_min).ToArray();

        /* yがらみのΣの処理 */
        long ys = 0;
        for (int i = 1; i < m; i++)
        {
            ys += i * y[i] % mod;
            ys %= mod;
        }
        for (int i = 0; i < m - 1; i++)
        {
            ys -= (m - 1) * y[i] % mod;
            ys += (ys < 0) ? mod : 0;
            ys %= mod;
        }
        for (int i = 1; i < m - 1; i++)
        {
            ys += i * y[i] % mod;
            ys %= mod;
        }

        /* xがらみのΣの処理 */
        long xs = 0;
        for (int i = 1; i < n; i++)
        {
            xs += i * x[i] % mod;
            xs %= mod;
        }
        for (int i = 0; i < n - 1; i++)
        {
            xs -= (n - 1) * x[i] % mod;
            xs += (xs < 0) ? mod : 0;
            xs %= mod;
        }
        for (int i = 1; i < n - 1; i++)
        {
            xs += i * x[i] % mod;
            xs %= mod;
        }

        Console.WriteLine(xs * ys % mod);
    }
}

Measured memory_bytes: 42720
use std::io;
use std::collections::HashMap;
use std::cmp;

fn procon_num_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let n:i32 = procon_num_read().pop().unwrap();
	let mut s: Vec<(String, i32)> = Vec::new();
	let mut map: HashMap<(String, i32), i32> = HashMap::new();
	for i in 0..n {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let mut iter = buf.split_whitespace();
		let a = iter.next().unwrap().to_string();
		let b = iter.next().unwrap().parse::<i32>().ok().unwrap();
		s.push((a, b));
	}
	for i in 0..n {
		map.insert(s[i as usize].clone(), i+1);
	}
	for i in 0..(n-1) {
		for j in (i+1)..n {
			let (a, b) = s[i as usize].clone();
			let (c, d) = s[j as usize].clone();
			match &a.cmp(&c) {
				cmp::Ordering::Greater => {
					s[i as usize] = (c, d);
					s[j as usize] = (a, b);
				},
				cmp::Ordering::Equal => {
					if d > b {
						s[i as usize] = (c, d);
						s[j as usize] = (a, b);
					}
				},
				_ => (),
			}
		}
	}
	for (a, b) in s {
		println!("{}", map.get(&(a, b)).unwrap());
	}
}

Measured memory_bytes: 2160
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const ll mod=1e9+7;
  const ll MAX=1e5+10;
  ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}
  //
  //    
    ll solve(){
        ll n,k;
        cin>>n>>k;
        vll vec(n+1,0);
        rep(i,0,k){
            ll x,y;
            cin>>x>>y;
            vec[x]+=1;
            vec[y+1]+=-1;
        }
        ll ans=0;
        rep(i,1,n+1){
            vec[i]+=vec[i-1];
            // if(vec[i]==0)
                // return cout<<0,0;
            ans+=vec[i]==k;
        }
        cout<<ans;
    }
    int main(){ 
        hs;
        ll t;
        // cin>>t;
        t=1;
        while(t--)
            solve();
    return 0; 
} 

Measured memory_bytes: 1024
import math
import itertools
N = int(input())
m = math.factorial(N)
a = []
for _ in range(N):
    a.append(list(map(int, input().split())))
sum = 0
for i in itertools.permutations(a):
    for k in range(N-1):
        sum += math.sqrt(((i[k][0]-i[k+1][0])**2)+((i[k][1]-i[k+1][1])**2))
print(sum/m)

Measured memory_bytes: 3064
S = [i for i in input()]
cnt = 0

for i in range(len(S)):
    if i%2==0:
        if S[i]=='R' or S[i]=='U' or S[i]=='D':
            cnt += 1
    if i%2==1:
        if S[i]=='L' or S[i]=='U' or S[i]=='D':
            cnt += 1

if cnt==len(S):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a += mod - rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        is >> rhs.a;
        return is;
    }
};
using mint = ModInt<MOD>;

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

    mint ans = 0;
    ans += ((mint)10).pow(n);
    ans -= ((mint)9).pow(n);
    ans -= ((mint)9).pow(n);
    ans += ((mint)8).pow(n);

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

Measured memory_bytes: 3664
n=int(input())
A=list(map(int,input().split()))
s=sum(A)
t=0
Ans=[0]*n
for i in range(1,n,2):
    t+=A[i]*2
Ans[0]=s-t
for i in range(1,n):
    Ans[i]=A[i-1]*2-Ans[i-1]
print(*Ans)

Measured memory_bytes: 64484
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a, b, c; cin >> a >> b >> c;
	string ans = ""; 
	ans += toupper(a[0]);
	ans += toupper(b[0]);
	ans += toupper(c[0]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
long long x[100005],y[100005];
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g=0,m,n,k,i,j,t,p,q;
    cin>>n>>m;
    string s;
    for(i=0;i<m;i++){
        cin>>a>>s;
        if(x[a])continue;
        else if(s=="WA"){
            y[a]++;
        }
        else if(s=="AC"){x[a]=1;f++;}
    }
    for(i=0;i<=100003;i++){
        if(x[i]){
            g+=y[i];
        }
    }
    cout<<f<<' '<<g<<'\n';
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int[] check= new int[101];
        Arrays.fill(check,0);
        int answer = 0;
        for(int i=0;i<n;i++){
            int buf  = scn.nextInt();
            if(check[buf]==0){
                check[buf]++;
                answer++;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=5e4+10;
ll n,m;
ll pre[maxn];
void init(){
    for(ll i=1;i<=n;++i)
        pre[i]=i;
}
ll fin(ll x){
    return x==pre[x]?x:pre[x]=fin(pre[x]);
}
void mer(ll a,ll b){
    ll aa=fin(a);
    ll bb=fin(b);
    if(aa==bb)return;
    pre[aa]=bb;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    cin>>s>>t;
    s+=s;
    if(s.find(t)!=string::npos)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

ll n, arr[100001], rarr[100001];
ll ans, ans2;

int main(){
    scanf("%lld", &n);
    for(ll i=0; i<n; i++)
        scanf("%lld", &arr[i]);
    sort(arr, arr+n);
    
    if (n%2==1){
        for(ll i=0; i<n/2; i++){
            rarr[2*i] = arr[n-1-i];
            rarr[2*i+1] = arr[i];
        }
        for(ll i=1; i<n-1; i++)
            ans += abs(rarr[i] - rarr[i-1]);
        ll a =  abs(rarr[0] - arr[n/2]);
        ll b =  abs(rarr[n-2] - arr[n/2]);
        ans += a>b?a:b;
    }
    else{
        for(ll i=0; i<=n/2; i++){
            rarr[2*i] = arr[n-1-i];
            rarr[2*i+1] = arr[i];
        }
        for(ll i=1; i<n-1; i++)
            ans += abs(rarr[i] - rarr[i-1]);
        ll a =  abs(rarr[0] - rarr[n-1]);
        ll b =  abs(rarr[n-2] - rarr[n-1]);
        ans += a>b?a:b;
    }

    if (n%2==1){
        for(ll i=0; i<n/2; i++){
            rarr[2*i] = arr[i];
            rarr[2*i+1] = arr[n-1-i];
        }
        for(ll i=1; i<n-1; i++)
            ans2 += abs(rarr[i] - rarr[i-1]);
        ll a =  abs(rarr[0] - arr[n/2]);
        ll b =  abs(rarr[n-2] - arr[n/2]);
        ans2 += a>b?a:b;
    }
    else{
        for(ll i=0; i<=n/2; i++){
            rarr[2*i] = arr[i];
            rarr[2*i+1] = arr[n-1-i];
        }
        for(ll i=1; i<n-1; i++)
            ans2 += abs(rarr[i] - rarr[i-1]);
        ll a =  abs(rarr[0] - rarr[n-1]);
        ll b =  abs(rarr[n-2] - rarr[n-1]);
        ans2 += a>b?a:b;
    }

    printf("%lld", ans>ans2?ans:ans2);
    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long 

signed main(void){
    int x; cin >> x;
    int a = x/100;
    if(100*a <= x && x<=105*a){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int H, W; cin >> H >> W;
  vector<string> lines(H);
  for(auto& line : lines) {
    cin >> line;
  }

  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(lines[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for(int i = 0; i < H; i++) {
    if(!row[i]) {
      continue;
    }
    for(int j = 0; j < W; j++) {
      if(row[i] && col[j]) {
        cout << lines[i][j];
      }
    }

    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
int main(){
  int i,n,cnt[4]={0};
  string s;
  cin >> s;
  n = s.size();
  rep(i,n){
    switch(s[i]){
      case 'N':
        cnt[0]++;
        break;
      case 'W':
        cnt[1]++;
        break;
      case 'S':
        cnt[2]++;
        break;
      case 'E':
        cnt[3]++;
        break;
    }
  }
  int flag=1;
  for(i=0;i<4;i++){
    if(cnt[i]>=1 && cnt[(i+2)%4]==0){
      flag=0;
      break;
    }
  }
  cout << (flag==1 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int Q,H,S,D,N;

int main(){
	cin>>Q>>H>>S>>D>>N;
	H=min(H,2*Q);
	S=min(S,2*H);
	D=min(D,2*S);
	printf("%lld\n",1LL*N/2*D+1LL*N%2*S);
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    if(n < 25){
        int a[26] {0};
        for(int i = 0; i < 26; i++){
            a[s[i] - 'a']++;
        }
        for(int i = 0; i < 26; i++){
            if(a[i] == 0){
                char last = 'a' + i;
                cout << s << last << endl;
                return 0;
            }
        }
    }
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    string ss[26];
    string ans = "zz";
    for(int i = 0; i < 26; i++){
        char l = s[i];
        ss[i] = s;
        bool f = false;
        for(int j = i - 1; j >= 0; j--){
            if(ss[i][j] < l){
                ss[i] = ss[i].substr(0, j) + l;
                f = true;
                break;
            }
        }
        if(!f) ss[i] = "zz";
        ans = min(ans, ss[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import  java.util.*;

import static java.lang.System.in;

class Main{
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        char[] dic = new char[128];
        dic['b'] = 'd'; dic['d']='b';
        dic['p'] = 'q'; dic['q']='p';
        char[] a = new char[n];
        for(int i=0;i<n;i++) a[i]=s.charAt(n-1-i);
        for(int i=0;i<n;i++) a[i]=dic[a[i]];
        String ans = s.equals(new String(a))?"Yes":"No";
        System.out.println(ans);
    }
}



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

int main(){
    int h,w,a,b; cin >> h >> w >> a >> b;
    int th = 0,tw = 0;
    while(th +a<= h){
        th += a;
    }
    while(tw + b <= w){
        tw += b;
    }
    cout << h*w - th*tw << "\n";
}


Measured memory_bytes: 3112
import math
import operator as op
from functools import reduce
from fractions import Fraction as frac

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""
# t=int(input())
n=int(input())
A=[]
for i in range(n):
    x=list(map(int,input().split()))
    A.append(x)
dp=[[0,0,0] for i in range(n+1)]
for i in range(1,n+1):
    dp[i][0]=max(dp[i-1][1]+A[i-1][1],dp[i-1][2]+A[i-1][2])
    dp[i][1]=max(dp[i-1][0]+A[i-1][0],dp[i-1][2]+A[i-1][2])
    dp[i][2]=max(dp[i-1][1]+A[i-1][1],dp[i-1][0]+A[i-1][0])
print(max(dp[n]))

Measured memory_bytes: 49520
n = int(input())
a = list(map(int,input().split()))
flag= 0
for i in range(n):
    if a[i]%2==0 :
        if a[i]%3==0 or  a[i]%5==0:
            continue
        else:
            flag=1

if flag==0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	

	void solve(){

		
		ini(n);
		out(n+n*n+n*n*n);
		
		


			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

int main()
{
    int n, qu, tmp, st;
    string s, ts;
    queue <string> q1;
    queue <int> q2;
    st = 0;
    cin >> n >> qu;
    for(int i = 1; i <= n; i++)
    {
        cin >> s >> tmp;
        q1.push(s);
        q2.push(tmp);
    }
    while(!q2.empty())
    {
        if(q2.front() > qu)
        {
            tmp = q2.front() - qu;
            st += qu;
            q2.pop();
            q2.push(tmp);
            ts = q1.front();
            q1.pop();
            q1.push(ts);
        }
        else
        {
            st += q2.front();
            cout << q1.front() << " " << st << endl;
            q1.pop();
            q2.pop();
        }
    }
    return 0;
}



Measured memory_bytes: 6092
import java.util.Scanner;

public class Main {
	public static String left = "qwertasdfgzxcvb";
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String s = sc.next();
			if (s.equals("#")) {
				break;
			}
			int ans = 0;
			int bef = -1;
			for(int i=0;i<s.length();i++) {
				int now = -1;
				if (isLeft(s.charAt(i))) {
					now = 0;
				}else{
					now = 1;
				}
				if (bef != -1 && bef != now) {
					ans++;
				}
				bef = now;
			}
			System.out.println(ans);
		}
	}

	public static boolean isLeft(char c) {
		return left.indexOf(c) >= 0;
	}

}

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

int main() {
    int r,D,x_zero;
    cin >> r >> D >> x_zero;
    vector<int> data(11);
    data.at(0) = x_zero;
    for(int i = 1; i < 11; i++) {
        data.at(i) = r * data.at(i-1) - D;
        data.push_back(data.at(i));
    } 
    for(int i = 1; i <= 10; i++) {
        cout << data.at(i) << endl;
    }
}

Measured memory_bytes: 256
def main():
    n = input()
    if int(n[-1]) in [2, 4, 5, 7, 9]:
        print("hon")
    elif int(n[-1]) in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[100];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=a[i]*a[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a, -1*(-heapq.heappop(a)//2))
print(sum(a)*-1)


Measured memory_bytes: 20144
#include<bits/stdc++.h>
int i,j,p,n,q,a[9]={5,7,5,7,7,-1},d[50];char s[50];
main(){for(;scanf("%d\n",&n),n;){for(i=0;i<n;)d[i++]=strlen(gets(s));
for(i=j=0;j<6;i++)for(p=i,j=q=0;q>=0;)for(q=a[j++];q>0;q-=d[p++]);
printf("%d\n",i);
}}

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


int main() {
    string s;
    cin >> s;
    int a, z;
    for (int i = 0; i < s.size(); ++i) {
        if (s.at(i) == 'A') {
            a = i;
            break;
        }
    }
    for (int i = 0; i < s.size(); ++i) {
        if (s.at(i) == 'Z') {
            z = i;
        }
    }
    cout <<  z-(a-1) << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.HashSet;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        UnionFind uf = new UnionFind(n);

        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            int z = sc.nextInt();

            uf.union(x, y);

            // System.out.println(uf.get_tree(n));
        }

        System.out.println(uf.get_tree(n));

        sc.close();
    }
}

class UnionFind {

    int[] parent;
    int[] rank;

    public UnionFind(int size) {
        this.parent = new int[size];
        this.rank = new int[size];

        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    public void makeSet(int i) {
        parent[i] = i;
        rank[i] = 0;
    }

    public void union(int x, int y) {
        int xRoot = find(x);
        int yRoot = find(y);

        if (rank[xRoot] > rank[yRoot]) {
            parent[yRoot] = xRoot;
        } else if (rank[xRoot] < rank[yRoot]) {
            parent[xRoot] = yRoot;
        } else if (xRoot != yRoot) {
            parent[yRoot] = xRoot;
            rank[xRoot]++;
        }
    }

    public int find(int i) {
        if (i != parent[i]) {
            parent[i] = find(parent[i]);
        }
        return parent[i];
    }

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

    int get_tree(int size) {
        HashSet<Integer> st = new HashSet<>();
        for (int i = 0; i < size; i++) {
            st.add(find(i));
        }
        return st.size();
    }

}

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

typedef long long LL;

const double PI = acos(-1.0);

const LL M = 1e9+7;
int len;
char s[100800];
LL f[100800][10][13];

int work() {
    scanf("%s", s);
    len = strlen(s);

    for (int i = 0; i < 10; ++i)
        for (int j = 0; j < 13; ++j)
            f[len-1][i][j] = (i==j ? 1 : 0);

    int p = 1;
    for (int k = len-2; k >= 0; --k) {
        p = p * 10 % 13;
        for (int i = 0; i < 10; ++i)
            for (int j = 0; j < 13; ++j) {
                if (s[k+1] == '?') {
                    for (int l = 0; l < 10; ++l) {
                        int r = (130 - p * i + j) % 13;
                        f[k][i][j] += f[k+1][l][r];
                        f[k][i][j] %= M;
                    }
                } else {
                    int t = s[k+1]-'0';
                    int r = (130 - p * i + j) % 13;
                    f[k][i][j] = f[k+1][t][r];
                }
            }
    }

    LL ans = 0;
    if (s[0] == '?') {
        for (int l = 0; l < 10; ++l)
            ans += f[0][l][5], ans %= M;
    } else {
        ans = f[0][s[0]-'0'][5];
    }

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

}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 102656
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;

struct UnionFind
{
  vi p,r;
  UnionFind(int n){
    p.resize(n, -1);
    r.resize(n,1);
  }
  int find(int x){
    if(p[x] == -1)return x;
    else return p[x] = find(p[x]);
  }
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(r[x] > r[y]){
      swap(x,y);
    }
    if(r[x] == r[y]){
      r[y]++;
    }
    p[x] = y;
  }
};



int main(){
  int n, m, x, y, cnt=0;
  cin >> n >> m;

  UnionFind uf(n+1);
  vi p(n+1);
  for(int i=1; i<=n; i++){
    cin >> p[i];
  }
  for(int i=0; i<m; i++){
    cin >> x >> y;
    uf.unite(x,y);
  }
  for(int i=1; i<=n; i++){
    if(uf.find(p[i]) == uf.find(i)){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Console_Cs_Test
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] line1 = Console.ReadLine().Trim().Split(' ');
            int H = int.Parse(line1[0]);
            int W = int.Parse(line1[1]);
            List<string> list = new List<string>();
            for (int i = 0; i < H; ++i)
            {
                list.Add(Console.ReadLine().Trim());
            }

            // 出力
            string 枠 = "#";
            string 外行 = string.Empty;

            for (int i = 0; i < W + 2; ++i)
            {
                外行 += 枠;
            }

            List<string> resultList = new List<string>();
            resultList.Add(外行);
            foreach (var item in list)
            {
                resultList.Add($"{枠}{item}{枠}");
            }
            resultList.Add(外行);
            foreach (var item in resultList)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268