akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        List<BigInteger> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            BigInteger bi = new BigInteger(in.next());
            if (bi.equals(BigInteger.ZERO)) {
                out.println(0);
                return;
            }
            a.add(bi);
        }
        BigInteger th = new BigInteger("1000000000000000000");
        BigInteger ans = BigInteger.ONE;
        for (BigInteger bi : a) {
            ans = ans.multiply(bi);
            if (ans.compareTo(th) > 0) {
                out.println(-1);
                return;
            }
        }
        out.println(ans);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 61220
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def mn(n):
    c = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i != 1:
                c += 1
            if i != n // i:
                c += 1
    return c
N = int(input())
r = mn(N-1)
rs = set()
for k in make_divisors(N):
    if k == 1:
        continue
    M = N
    while M%k == 0: 
        M //= k
    if (M-1) % k == 0:
        rs.add(k)
        r += 1

print(r)


Measured memory_bytes: 39280
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(1) {
        if ( x > y ) break;
        x = x * 2;
        ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func cnt(a, b int) int {
	var cnt int = 0
	for b > a {
		a *= 2
		cnt++
	}
	return cnt
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	var ans float64
	for i := 1; i <= n; i++ {
		win := cnt(i, k)
		ans += math.Pow(1.0/2.0, float64(win)) * 1.0 / float64(n)
	}

	fmt.Printf("%.12f\n", ans)
}

Measured memory_bytes: 1832
#include <stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	int h;
	int bl;
	int i, j;
	
	
	while (scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]) != EOF){
		scanf("%d %d %d %d", &b[0], &b[1], &b[2], &b[3]);
		
		h = 0;
		bl = 0;
		for (i = 0; i < 4 ; i++){
			if (a[i] == b[i]){
				h++;
			}
		}
	
		for (i = 0; i < 4 ; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j] && a[i] != b[i]){
					bl++;
				}
			}
		}
		printf("%d %d\n", h, bl);
	}

	
	return (0);
}
		

Measured memory_bytes: 592
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
signed main(){
    int n,m,x,y; cin >> n >> m >> x  >> y;
    int _x = -INF,_y = INF;
    rep(i,n+m){
        int t; cin >> t;
        if(i<n)cmax(_x,t); else cmin(_y,t);
    }
    cout << (_x < _y  and x < _y and _y <= y? "No War":"War") << endl;
}




Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n, k;
	cin >> n >> k;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	vector<vector<bool>> v(n, vector<bool>(48, false));
	for (ll i = 0; i < n; i++) {
		ll power2 = pow(2, 47);
		for (ll j = 0; j < 48; j++) {
			if (a[i] >= power2) {
				v[i][j] = true;
				a[i] -= power2;
			}
			power2 /= 2;
		}
	}

	vector<bool> kk(48, false);
	ll power2 = pow(2, 47);
	for (ll j = 0; j < 48; j++) {
		if (k >= power2) {
			kk[j] = true;
			k -= power2;
		}
		power2 /= 2;
	}

	bool broke = false;
	for (ll i = 0; i < 48; i++) {
		if (!broke) {
			if (kk[i]) {
				ll x = 0, y = 0;
				for (ll j = 0; j < n; j++) {
					if (v[j][i]) x++;
					else y++;
				}
				if (x >= y) {
					kk[i] = false;
					broke = true;
				}
			}
		}
		else {
			ll x = 0, y = 0;
			for (ll j = 0; j < n; j++) {
				if (v[j][i]) x++;
				else y++;
			}
			kk[i] = !(x >= y);
		}
	}

	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		power2 = pow(2, 47);
		for (ll j = 0; j < 48; j++) {
			if (v[i][j] ^ kk[j]) ans += power2;
			power2 /= 2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8064
s = input()
l = set(s)
ans = 10**10
for x in l:
    tmp, chk = 0, 0
    for i in s:
        if i != x:
            tmp += 1
        else:
            chk = max(chk, tmp)
            tmp = 0
    chk = max(chk, tmp)
    ans = min(chk, ans)
print(ans)

Measured memory_bytes: 9052
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <numeric>
 
using namespace std;

int main() {
    int k;
    cin>>k;
    long long sum=0;
    for (int a=1;a<=k;++a){
        for (int b=1;b<=k;++b){
            auto g=gcd(a,b);
            for (int c=1;c<=k;++c){
                sum+=gcd(g,c);
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

void abc_170a();

void abc_171a();

void abc_172a();

int main()
{
  //abc_170a();
  //abc_171a();
  abc_172a();

}

void abc_170a()
{
  vector<int> x(5);
  for (int i = 0; i < 5; ++i) cin >> x[i];

  for (int i = 0; i < 5; ++i)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << "\n";
      return;
    }
  }
}


void abc_171a()
{
  char c;
  cin >> c;

  if (c == tolower(c)) cout << "a\n";
  else cout << "A\n";
}

void abc_172a()
{
  int a;
  cin >> a;

  cout << a + a * a + a * a * a << "\n";
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define MOD1 1000000007
#define MOD2 1000000009
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ffl fflush(stdout);
#define all(x) (x).begin,(x).end()
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
typedef long long int ll;
typedef long int li;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main() 
{
	#ifndef ONLINE_JUDGE
	freopen("G:/coding/CPP/input.txt", "r", stdin);
	freopen("G:/coding/CPP/output.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	#endif
	unordered_map<string,int> hasher;
	int n;
	cin>>n;
	string s;
	for(int i=0;i<n;i++) {
		cin>>s;
		hasher[s]++;
	}
	cout<<"AC x "<<hasher["AC"]<<endl;
	cout<<"WA x "<<hasher["WA"]<<endl;
	cout<<"TLE x "<<hasher["TLE"]<<endl;
	cout<<"RE x "<<hasher["RE"]<<endl;

}


Measured memory_bytes: 3664
n,m=map(int,input().split())
l=[{} for k in range(n)]
for i in range(m):
    p,y=map(int,input().split())
    l[p-1][y]=i
for k in range(n):
    l[k]=sorted(l[k].items(), key=lambda x:x[0])
s=[0]*m
for k in range(n):
    for r, p in enumerate(l[k]):
        s[p[1]]=[k,r]
for i in s:
    print('{:06}{:06}'.format(i[0]+1,i[1]+1))

Measured memory_bytes: 57928
#include <bits/stdc++.h>
#define tam 100010
#define inf 1000000000

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

bool comp(int a, int b) {
	return a > b;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int arr[n];
	vi dp (n, inf);
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i + 1; j < i + 3 && j < n; ++j)
		{
			dp[j] = min(dp[j], dp[i] + abs(arr[j] - arr[i]));
		}
	}
	cout << dp[n - 1] << "\n";
	return 0;
}


Measured memory_bytes: 1024
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();
    let mut b: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    let mut ans = 0;
    for k in 0..30 {
        let t = 1 << k;
        let t2 = t * 2;
        let t2m = t2 - 1;

        b.sort_by_key(|x| x & t2m);

        let mut count = 0;
        for i in 0..n {
            let ai = a[i] & t2m;
            let pos2 = b.binary_search_by_key(&(2 * t * 2 - 1), |bi| (ai + (bi & t2m)) * 2)
                .err()
                .unwrap();
            let pos1 = b.binary_search_by_key(&(1 * t * 2 - 1), |bi| (ai + (bi & t2m)) * 2)
                .err()
                .unwrap();
            let pos3 = b.binary_search_by_key(&(3 * t * 2 - 1), |bi| (ai + (bi & t2m)) * 2)
                .err()
                .unwrap();
            count += n - pos3 + pos2 - pos1;
        }
        ans |= (count % 2) << k;
    }

    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



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

using namespace std;

//#define MD 100010

int main(){
    string s;
    cin>>s;
    string ans;
    for(int i=0;i<s.length();i++){
        char c=s[i];
        if(c=='0'){
            ans.push_back('0');
        }else if(c=='1'){
            ans.push_back('1');
        }else if(c=='B' && ans.empty()==0){
            ans.pop_back();
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t


int main(void){
    int n,m;
    string s;
    cin >> n >> m;
    
    for(int i = 0 ; i < n ; i++ ){
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
min_num = 0
max_num = 0
for i in range(K):
    min_num += i
    max_num += N - i
ans = max_num - min_num + 1
for i in range(K, N+1):
    min_num += i
    max_num += N - i
    ans += max_num - min_num + 1
print(ans%(10**9 + 7))


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

int main(){
int n =0;
  cin >> n;
  
  vector<int> veca(n);
  for (int i=0; i < n; i++){
   cin >> veca.at(i); 
  }
  int ans =0;
  int count = 0;
  int minimum = 99999999;
  
  for(int i=0; i<n; i++){
    if(i==0){
      minimum = veca.at(i);
      ans++;
     continue; 
    }else if(minimum < veca.at(i) ){
      
    }else if (minimum > veca.at(i) ){
     ans++;
      minimum = min(minimum , veca.at(i));
    }
  }

  cout << ans;
  
}

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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int s, w;
    cin >> s >> w;
    if(w >= s)
    {
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3656
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n, m;
	cin >> n >> m;
	vi h(n);
	cin >> h;
	vvi M(n);
	rep(i,0,m)
	{
		int x, y;
		cin >> x >> y;
		x--, y--;
		M[x].push_back(y);
		M[y].push_back(x);
	}
	int ans = 0;
	rep(i,0,n)
	{
		ans++;
		for(int x : M[i])
			if(h[x] >= h[i])
			{
				ans--;
				break;
			}
	}
	cout << ans;
}


Measured memory_bytes: 8744
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0044
"""

from math import sqrt, ceil, pow
import bisect
import sys


# https://github.com/mccricardo/sieve_of_atkin/blob/master/sieve_of_atkin.py
class SieveOfAtkin:
    def __init__(self, limit):
        self.limit = limit
        self.primes = []
        self.sieve = [False] * (self.limit + 1)

    def flip(self, prime):
        try:
            self.sieve[prime] = True if self.sieve[prime] == False else False
        except KeyError:
            pass

    def invalidate(self, prime):
        try:
            if self.sieve[prime] == True: self.sieve[prime] = False
        except KeyError:
            pass

    def isPrime(self, prime):
        try:
            return self.sieve[prime]
        except KeyError:
            return False

    def getPrimes(self):
        testingLimit = int(ceil(sqrt(self.limit)))

        for i in range(testingLimit):
            for j in range(testingLimit):
                # n = 4*i^2 + j^2
                n = 4 * int(pow(i, 2)) + int(pow(j, 2))
                if n <= self.limit and (n % 12 == 1 or n % 12 == 5):
                    self.flip(n)

                # n = 3*i^2 + j^2
                n = 3 * int(pow(i, 2)) + int(pow(j, 2))
                if n <= self.limit and n % 12 == 7:
                    self.flip(n)

                # n = 3*i^2 - j^2
                n = 3 * int(pow(i, 2)) - int(pow(j, 2))
                if n <= self.limit and i > j and n % 12 == 11:
                    self.flip(n)

        for i in range(5, testingLimit):
            if self.isPrime(i):
                k = int(pow(i, 2))
                for j in range(k, self.limit, k):
                    self.invalidate(j)

        self.primes = [2, 3] + [x for x in range(len(self.sieve)) if self.isPrime(x) and x >= 5]
        return self.primes




def solve1(num, primes):
    #
    i = bisect.bisect_left(primes, num)
    lt = primes[i-1]
    i = bisect.bisect_left(primes, num+1)
    gt = primes[i]
    return lt, gt


if __name__ == '__main__':
    A = SieveOfAtkin(55000)
    A.getPrimes()
    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        num = int(line)
        lt, gt = solve1(num, A.primes)
        print('{} {}'.format(lt, gt))

Measured memory_bytes: 8184
#include<iostream>
using namespace std;
struct Tree
{
	int key;
	Tree* parent, * left, * right;
};
Tree* root, * NIL;
void insert(Tree* k) {
	Tree* d = root;
	Tree* m = d;
	while (d!= NIL)
	{
		m = d;
		if (k->key > d->key) {
			d = d->right;
		}
		else {
			d = d->left;
		}
	}
	k->parent = m;
	if (k->key > m->key) {
		m->right = k;
	}
	else {
		m->left = k;
	}
}
void midle(Tree *t) {
	if (t == NIL) return;
	midle(t->left);
	cout <<" "<< t->key ;
	midle(t->right);
}
void pre(Tree* t) {
	if (t == NIL) return;
	cout << " " << t->key;
	pre(t->left);
	pre(t->right);
}
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string m;
		cin >> m;
		if (m == "insert") {
			int key;
			cin >> key;
			Tree* k = new Tree();
			k->left = NIL;
			k->right = NIL;
			k->key = key;
			k->parent = NIL;
			if (root == NULL) {
				root = k;
			}
			else {
				insert(k);
			}
		}
		else {
			midle(root);
			cout << endl;
			pre(root);
			cout << endl;
		}
	}
	return 0;
}


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

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

    sort(all(b));
    b.erase( unique (  b.begin() , b.end() ) , b.end() );

    map <int,long> table;
    rep(i,n){
        if(table.count(a[i])) table.at(a[i]) ++;
        else table[a[i]] = 1;
    }

    long sum = 0;
    for(int x:b){
        sum += table.at(x) *(table.at(x) - 1) /2;
    }

    vector <long> ans(n);

    for(int i=0; i<n; i++){
        ans[i] = sum - table.at(a[i]) * (table.at(a[i]) - 1) /2 + (table.at(a[i]) -1) * (table.at(a[i]) -2)/2; 
    }

    rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 13568
X = gets.to_i

a = 0
b = 0
loop do
  a5 = a ** 5
  b5 = a5 - X
  break if b5 == 0

  flg = false
  if b5 > 0
    b = 1
    while b ** 5 <= b5
      if b ** 5 == b5
        flg = true
        break
      end

      b += 1
    end
  else
    b = -1
    while b ** 5 >= b5
      if b ** 5 == b5
        flg = true
        break
      end

      b -= 1
    end
  end

  break if flg

  a += 1
end

puts "#{a} #{b.to_i}"


Measured memory_bytes: 14400
#include<iostream>
#include<cassert>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 100001
using namespace std;
struct P
{
  int color,w;
  P(int color=-inf,int w=-inf):color(color),w(w){}
};
P par[MAX];
void init(){ rep(i,MAX)par[i] = P(i); }

P find(int x)
{
  if(x == par[x].color)return par[x];
  P p = find(par[x].color);
  if(par[x].w == -inf)par[x].w = 0;
  par[x].w += p.w,par[x].color = p.color;
  return par[x];
}

void unit(int x,int y,int w)//x <= y
{
  P X = find(x); 
  P Y = find(y);
  par[X.color].color = par[Y.color].color;
  if(par[X.color].w == -inf)par[X.color].w = 0;
  if(par[Y.color].w == -inf)par[Y.color].w = 0;
  par[X.color].w = par[X.color].w + (par[y].w-w - par[x].w);
}

int N,M;

int main()
{
  while(cin >> N >> M,N|M)
    {
      init();
      char c;
      int a,b,w;
      rep(_,M)
	{
	  cin >> c;
	  if(c == '!')
	    {
	      cin >> a >> b >> w;
	      unit(a,b,w);
	    }
	  else
	    {
	      cin >> a >> b;
	      P B = find(b),A = find(a);
	      if(B.color != A.color)cout << "UNKNOWN" << endl;
	      else cout << B.w-A.w << endl;
	    }
	}
    }
  return 0;
} 

Measured memory_bytes: 2980
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	for(int i=0;i<3;i++){
		if(s[i]=='1'){
			s[i]='9';
		}
		else if(s[i]=='9'){
			s[i]='1';
		}
	}
	cout << s<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,f,n) for(int i=f; i<(n); i++)
int main()
{
  ll n = 0, ans = 0;;
  cin >> n;
  ll mae=0;
  REP(i,0,n){
    ll ima;
    cin >> ima;
    if(i>0 && mae - ima > 0){
      ans += mae - ima;
      ima = mae;
    }
    mae = ima;
  }
  cout << ans << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

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

int kaijo(int n) {
    int ans = 1;
    for (int i = 1; i <= n; i++) ans *= i;
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> r(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    rep(i,n) r[i] = i+1;
    int a, b = 0;
    int count = 1;
    do {
        bool p_ok = true;
        bool q_ok = true;
        rep(i,n){
            if (r[i]!=p[i]) p_ok = false;
            if (r[i]!=q[i]) q_ok = false;
        }
        if (p_ok) a = count;
        if (q_ok) b = count;
        count++;
    } while (next_permutation(r.begin(), r.end()));
    cout << abs(a-b) << endl;
    return 0;
}


Measured memory_bytes: 3648
L = int(input())

"""
Z = 0

n = 100000
step = n*L
V_array = []

for i in range(step):
    Z += (1/n) * i
    V = (L-2*Z)*Z**2
    V_array.append(V)
    
V_max = max(V_array)
"""

V = (L**3)/27  
print(V)

Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
from math import atan, pi
import sys
from collections import defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

a, b, x = inpl()

tand = 2*(b/a - x/(a**3))

if a*tand > b:
    tand = a*b*b/2/x

print(180*atan(tand)/pi)

Measured memory_bytes: 3316
p=[2];A=1000
for L in range(3,A):
    chk=True
    for L2 in p:
        if L%L2 == 0:chk=False
    if chk==True:p.append(L)
n = int(input())
ll = [[0]*len(p) for _ in [0]*(n+1)]
for i in range(1,n+1):
  for j in range(len(p)):
    ll[i][j] = ll[i-1][j]
    tmp = i
    while True:
      if tmp%p[j] == 0:
        ll[i][j] += 1
        tmp = tmp//p[j]
      else:
        break
ans = 1
for i in ll[-1]:
  ans*=(i+1)
print(ans%(10**9+7))

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll dp[55][55*55*2]={};

int main(void) {
  ll i, j, k;
  ll N, A;
  cin >> N >> A;
  ll x[55];
  
  for(i=0; i<N; i++) {
    cin >> x[i];
    x[i]-=A;
  }
  
  dp[0][2500]=1;
  for(i=0; i<N; i++) {
    for(j=0; j<55*55*2; j++) {
      dp[i+1][j]+=dp[i][j];
      dp[i+1][j+x[i]]+=dp[i][j];
    }
  }
  
  pt(dp[N][2500]-1); //-1: 1枚も選ばない場合
}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL dp[4010][4010];
LL acc[4010];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  VL xs(N*2);
  REP(i,N){
	cin >> xs[i];
	xs[i+N] = xs[i];
  }
  REP(i,N*2) acc[i+1] = acc[i] + xs[i];

  REP(i,N*2) REP(j,N*2) dp[i][j] = -1e18;

  REP(i,N*2)
	dp[i][i+1] = xs[i];
  for(int i=0;i+2<=N*2;++i)
	dp[i][i+2] = max(xs[i], xs[i+1]);

  for(int l=3;l<=N;++l){
	for(int b=0;b+l<=2*N;++b){
	  int e = b + l;
	  if(xs[b+1] < xs[e-1])
		maxi(dp[b][e], xs[b] + dp[b+1][e-1]);
	  else
		maxi(dp[b][e], xs[b] + dp[b+2][e]);

	  if(xs[b] < xs[e-2])
		maxi(dp[b][e], xs[e-1] + dp[b][e-2]);
	  else
		maxi(dp[b][e], xs[e-1] + dp[b+1][e-1]);
	}
  }
  LL ans = 0;
  REP(i,N) maxi(ans, dp[i][i+N]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 128516
#include <stdio.h>

int main(void){
  int s, d, i;

  while(scanf("%d", &d) != EOF){
    s = 0;
    for(i = d; i < 600; i += d){
      s += i * i * d;
    }
    printf("%d\n", s);
  }
  return 0;
}

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

#include <math.h>
#include <stdlib.h>


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



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int q; cin >> q;

    bool norm = true;
    string rf = "";
    
    for(int i = 0; i < q; i++){
        int n; cin >> n;
        if(n == 1) {
            norm = !norm;
            continue;
        }

        int f; char c; cin >> f >> c;
        if(!norm) f = 3 - f;
        
        if(f == 1) rf.push_back(c);
        else s.push_back(c);
    }

    reverse(rf.begin(), rf.end());
    string ans = rf + s;
    if(!norm) reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1328
// ABC159 D

#include <iostream>
#include <vector>

using namespace std;

int main(){
    long long int n, tmp, sum = 0;
    cin >> n;
    vector <long long int> a, num_list(n, 0);
    for(int i=0; i<n; i++){
        cin >> tmp;
        a.push_back(tmp);
        num_list.at(tmp-1)++;
    }

    for(int i=0; i<n; i++){
        sum += num_list.at(i)*(num_list.at(i)-1)/2;
    }

    for(int i=0; i<n; i++){
        tmp = a.at(i);
        cout << sum - num_list.at(tmp-1) + 1 << endl;
    }
    return 0;
}

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

#define int long long
const int mod = 1e9 + 7;

signed main() {
    int N;
    cin >> N;
    int A[N][N];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }

    int dp[1<<N];
    for (int i = 0; i < 1<<N; i++) dp[i] = 0;
    dp[0] = 1;

    for (int S = 1; S < 1<<N; S++) {
        int i = __builtin_popcount(S);
        for (int j = 1; j < N+1; j++) {
            if (S>>(j-1) & 1 && A[i-1][j-1]) {
                dp[S] += dp[S^(1<<(j-1))];
                dp[S] %= mod;
            }
        }
    }

    int ans = dp[(1<<N) - 1];
    cout << ans << endl;
}

Measured memory_bytes: 16640
#include<stdio.h>
	int main(){
		int i,k,a,b,c[12]={31,29,31,30,31,30,31,31,30,31,30,31};
		while(1){
k=0;
scanf("%d %d",&a,&b);
if(a==0)break;
			for(i=0;i<a-1;i++)
				k+=c[i];
			i=(k+b)%7;
			switch (i) {
				case 0 : printf("Wednesday\n");
				break;
				case 1 : printf("Thursday\n");
				break;
				case 2 : printf("Friday\n");
				break;
				case 3 : printf("Saturday\n");
				break;
				case 4 : printf("Sunday\n");
				break;
				case 5 : printf("Monday\n");
				break;
				case 6 : printf("Tuesday\n");
				break;
			}
		}
		return 0;
}

Measured memory_bytes: 0
def dot(x, y):
    return (x.conjugate() * y).real
    
def is_orthogonal(x, y):
    if abs(dot(x, y)) < 1e-10:
        return True
    return False
        
import sys

for line in sys.stdin:
    li = list(map(float, line.split()))
    p = []
    for i in range(0, len(li), 2):
        p.append(complex(li[i], li[i+1]))
    d1 = p[1] - p[0]
    d2 = p[3] - p[2]
    
    if is_orthogonal(d1, d2):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7428
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define INF 10000000000
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N,M,X,money=INF;
	bool swi;
	cin>>N>>M>>X;
	vector<ll> C(N);
	vector<vector<ll>> A(N,vector<ll>(M));
	rep(i,N){
		cin>>C[i];
		rep(j,M) cin>>A[i][j];
	}
	for(ll bit=0;bit<(1<<N);bit++){
		swi=true;
		ll mon=0;
		vector<ll> R(M);
		for(ll i=0;i<N;i++){
			if(bit & (1<<i)){
				mon+=C[i];
				rep(j,M) R[j]+=A[i][j];
			}
		}
		rep(x,M){
			if(R[x]<X){
				swi=false;
				break;
			}
		}
		if(swi) money=min(money,mon);
	}
	if(money==INF) cout<<"-1"<<endl;
	else cout<<money<<endl;
	return 0;
}

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


int main() {
   int N, M;
   cin >> N >> M;
   vector<int> s(M),c(M);
   rep(i, M){
       cin >> s[i] >> c[i];
   }
   rep(i, M){
       if(s[i] == 1 && c[i] == 0 && N != 1){
           cout << "-1";
           return 0;
       }
   }
   rep(i, M){
       rep(j, M){
           if(s[i] == s[j] && c[i] != c[j]){
               cout << "-1";
               return 0;
           }
       }
   }

   if(N == 1){
       if(M == 0){
           cout << 0;
           return 0;
       }
       int min = 10;
       rep(i, M){
           if(min > c[i]){
               min = c[i];
           }
       }
       if(min == 10) min = 0;
       cout << min;
       return 0;
   }
   if(N == 2){
       if(M == 0){
           cout << 10;
           return 0;
       }
       int min1 = 10;
       int min2 = 10;
       rep(i, M){
           if(s[i] == 1){
               if(min1 > c[i]){
                   min1 = c[i];
               }
           }
           else if(s[i] == 2){
               if(min2 > c[i]){
                   min2 = c[i];
               }
           }
       }
       if(min1 == 10) min1 = 1;
       if(min2 == 10) min2 = 0;
       cout << min1 << min2;
       return 0;
   }
   if(N == 3){
       if(M == 0){
           cout << 100;
           return 0;
       }
       int min1 = 10;
       int min2 = 10;
       int min3 = 10;
       rep(i, M){
           if(s[i] == 1){
               if(min1 > c[i]){
                   min1 = c[i];
               }
           }
           else if(s[i] == 2){
               if(min2 > c[i]){
                   min2 = c[i];
               }
           }
           else if(s[i] == 3){
               if(min3 > c[i]){
                   min3 = c[i];
               }
           }
       }
       if(min1 == 10) min1 = 1;
       if(min2 == 10) min2 = 0;
       if(min3 == 10) min3 = 0;
       cout << min1 << min2 << min3;
   }

}
    


Measured memory_bytes: 256
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let mut nmx = read_line().split_whitespace().map(|e|e.parse().unwrap())
	.collect::<Vec<i32>>();
	let A = read_line().split_whitespace().map(|e|e.parse().unwrap())
	.collect::<Vec<i32>>();

	let mut A2 = A.clone();
	A2.push(nmx[0]);
	A2.push(nmx[2]);

	if nmx[2] < A[0] {
		for i in 0..nmx[2] {
			A2.push(i);
		}
	}

	A2.sort();

	let start = A2.binary_search(&nmx[2]).unwrap();
	let mut zero = 0;
	let mut n = 0;
	let C = &A2[start..A2.len()].to_vec();
	let mut B = &A2[0..start+1].to_vec();
	for i in C.iter() {

		if *i < A[0] {
			break;
		}

		if *i != nmx[0] && *i != nmx[2] {
			n+=1;
		}
	}

	for i in B.iter() {

		if *i < A[0] {
			break;
		}

		if *i == nmx[2] {
			break;
		}

		if *i != nmx[0] && *i != nmx[2] {
			zero+=1;
		}
	}

	if zero >= n {
		println!("{}",n);
	}else{
		println!("{}",zero);
	}

}


Measured memory_bytes: 4352
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		BigInteger a = scanner.nextBigInteger();
		BigInteger b = scanner.nextBigInteger();
		String ans = "";

		if (a.compareTo(b) == -1) {
			ans = "LESS";
		} else if (a.compareTo(b) == 0) {
			ans = "EQUAL";
		} else {
			ans = "GREATER";
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    edge =  [[] for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        edge[A].append(H[B])
        edge[B].append(H[A])
    ans = 0
    for i in range(N):
        if not edge[i]:
            ans += 1
        elif H[i] > max(edge[i]):
            ans += 1

    print(ans)
        


    

        


if __name__ == "__main__":
    main()

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

int main(){
    long long int K, A, B;
    cin >> K >> A >> B;

    if(A >= B || K < A+1){
        cout << K+1 << endl;
    }else{
        long long int ans = 0;

        if(B > A+1){
            ans += B;
            K -= A+1;
        }else{
            cout << K+1 << endl;
            return 0;
        }

        if(B-A > 2){
            ans += (K/2)*(B-A);
            ans += K%2;
            cout << ans << endl;
        }else{
            cout << ans+K << endl;;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[2][2][2], dp1[2][2][2], s[99];
int modulo(1e9 + 7);
int main() {
	long long n;
	cin >> n;
	int len(0);
	while(n) {
		s[len++] = n % 2;
		n /= 2;
	}
	dp[1][1][0] = 1;
	for(int i(61); i >= 0; i--) {
		memset(dp1, 0, sizeof(dp1));
		for(int j(0); j < 2; j++) {
			for(int k(0); k < 2; k++) {
				for(int l(0); l < 2; l++) {
					for(int a(0); a < 2; a++) {
						for(int b(0); b <= a; b++) {
							for(int c(0); c < 2; c++) {
								if((a + b + c) / 2 != l || j == 1 && s[i] < (a ^ b) || k == 1 && (a + b + c) % 2 > s[i]) {
									continue;
								}
								(dp1[j && s[i] == (a ^ b)][k && (a + b + c) % 2 == s[i]][c] += dp[j][k][l]) %= modulo;
							}
						}
					}
				}
			}
		}
		memcpy(dp, dp1, sizeof(dp1));
	}
	int ans(0);
	for(int i(0); i < 2; i++) {
		for(int j(0); j < 2; j++) {
			(ans += dp[i][j][0]) %= modulo;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
use std::cmp;
use std::collections::BinaryHeap; // 優先度付きキュー
use std::collections::HashMap; // 連想配列
use std::collections::HashSet; // 連想配列 キーのみ
use std::collections::VecDeque; // キュー or スタック
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize
    }

    if n / 100 == 7 || (n % 100) / 10 == 7 || n % 10 == 7 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2268
#include <cstdio>
int main(){
	int n, x, c;
	while(true){
		c = 0;
		fscanf(stdin, "%d%d", &n, &x);
		if(!n) return 0;
		for(int i = 1; i < n-1; i++){
			for(int j = i+1; j < n; j++){
				for(int k = j+1; k < n+1; k++){
					if(i+j+k==x) c++;
				}
			}
		}
		printf("%d\n", c);
	}
}


Measured memory_bytes: 2716
#include<stdio.h>
int main()
{
    int a,b,c,d,e,i;
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&b);
        if(i==0)c=2000000000;
        d=b-c;
        if(b<c)c=b;
        if(i==0)e=d;
        if(d>e)e=d;
    }
    printf("%d\n",e);
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(){
  int a,b,a1;
  int r;
  
  scanf("%d %d",&a,&b);
  if(a<b){
    a1 = a;
    a  = b;
    b  = a1;
  }
  r = a % b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  printf("%d\n",b);
  
  return 0;
}



Measured memory_bytes: 2140
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();
        int count = 0;
        int a = Integer.parseInt(scan.next());

        for(int i = 0;i<a;i++){
            list.add(Integer.parseInt(scan.next()));
        }
        for(int i = 0;i<a;i++){
            list2.add(Integer.parseInt(scan.next()));
        }
        for(int i = 0;i<a;i++){
            if(list.get(i) - list2.get(i) > 0){
              count += (list.get(i) - list2.get(i));
            }
        }
       PrintWriter out = new PrintWriter(System.out);
        out.println(count);
        out.flush();
        scan.close();
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fore(x,a,b) for(int x=a,qwe=b; x<qwe; x++)
using namespace std;
typedef long long ll;

const int MXN=301;
ll N, A[MXN][MXN], K[MXN][MXN];
ll B[MXN][MXN];

int main(){
  cin >> N;
  vector<pair<int,int>> edges;
  fore(x,0,N)fore(y,0,N)if(x!=y)
    B[x][y]=1e9+1;
  fore(x,0,N)fore(y,0,N)cin>>A[x][y];
  fore(x,0,N)fore(y,x+1,N){
    K[x][y]=x;
    fore(z,0,N){
      if(A[x][y]==A[x][z]+A[z][y] && x!=z && y!=z)
        K[x][y]=z;
    }
    if(K[x][y]==x)B[x][y]=B[y][x]=A[x][y], edges.pb({x,y});
  }
  fore(k,0,N)fore(i,0,N)fore(j,0,N)
    B[i][j]=min(B[i][j],B[i][k]+B[k][j]);
  bool can=1;
  fore(i,0,N)fore(j,0,N)can&=A[i][j]==B[i][j];
  if(can){
    ll sum=0;
    for(auto p : edges)
      sum += A[p.first][p.second];
    cout << sum << "\n";
  }else cout << "-1\n";
}


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

int main()
{
  int N, X, D;
  D = 0;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int count = 1;
  for (int i = 0; i < N; i++) {
    D = D + L[i];
    if (D <= X) count++;
  }
  cout << count << endl;
  
  return 0;
}
    

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(M)]
AB.sort(key=lambda ab:(ab[1],ab[0]))
ans = 0
pre = 0
for a, b in AB:
    if pre <= a:
        pre = b
        ans += 1
print(ans)

Measured memory_bytes: 24604
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, a[100000], i;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<n;i++){
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n;
    cin >> n;
    while (n--) {
        int y, m, d, cnt = 0;
        cin >> y >> m >> d;

        while (y < 1000) {
            d++;  cnt++;
            if (y % 3 == 0 && d == 21) {
                m++;  d = 1;
                if (m == 11) {
                    y++;  m = 1;
                }
            }
            if (y % 3 != 0 && m % 2 == 1 && d == 21) {
                m++;  d = 1;
                if (m == 11) {
                    y++;  m = 1;
                }
            }
            if (y % 3 != 0 && m % 2 == 0 && d == 20) {
                m++;  d = 1;
                if (m == 11) {
                    y++;  m = 1;
                }
            } 
        }
        cout << cnt << endl;

    }
}



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

bool kaibun(string s) {
   bool flag = true;
   int n = s.length();
   for(int i = 0;i < n;i++) {
      if(s[i] != s[n-i-1]) {
         flag = false;
      }
   }
   return flag;
}

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int a, b;
   cin >> a >> b;
   int count = 0;
   for(int i = a;i <=b;i++) {
      if(kaibun(to_string(i))) {
         count++;
      }
   }
   cout << count << endl;
   return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  while(getline(cin,s),s!="0"){
    stringstream ss(s);
    int x=0,i,ans,k;
    int si=0;
    vector<int> v;
    v.clear();
    v.push_back(0);
    
    while(ss>>x){
      si=v.size();
      vector<int> n;
      for(i=0;i<si;i++){
	
	if(x==1){
	  k=v[i];
	  n.push_back(k+11);
	  v[i]++;
	}else if(x>10){
	  v[i]+=10;
	}else {
	  v[i]+=x;
	}
	
      }
      for(i=0;i<n.size();i++) v.push_back(n[i]);
      n.clear();
      
      sort(v.begin(),v.end());
      v.erase(unique(v.begin(),v.end()),v.end());
      v.erase(lower_bound(v.begin(),v.end(),22),v.end());
    }
    
    sort(v.begin(),v.end());
    ans=0;
    for(i=0;i<v.size();i++){
      if(v[i]<=21) ans=v[i];
    }
    cout << ans << endl;
    s="";
  }  
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#define INF            1e9
#define REP(i,n)       for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)      for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n)  for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPR(i,n)      for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)     for(lint i=(n);i>0;--i)
#define REPRI(i,ini,n) for(lint i=(ini)-1,i##_len=(n);i>=i##_len;--i)
#define REPC(i,obj)    for(auto i:obj)
#define R_UP(a,b)      (((a)+(b)-1)/(b))
#define ALL(obj)       (obj).begin(),(obj).end()
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
signed main()
{
	int n = in();
	map<string, bool>dic;
	REP(i, n)
	{
		string cmd = in<string>();
		if (cmd == "insert")
		{
			string str = in<string>();
			dic[str] = true;
		}
		else if (cmd == "find")
		{
			string str = in<string>();
			cout << (dic[str] ? "yes" : "no") << endl;
		}
	}
}


Measured memory_bytes: 52432