akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};

int main(){
	int a, b , c; cin>> a >> b >> c;
	if(a+b+c >= 22)
		cout<<"bust";
	else
		cout<<"win";
	return 0;
	
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)
	m := make(map[string]int, 5000*5)
	for i := 0; i < len(s); i++ {
		for j := i + 1; j <= i+k && j <= len(s); j++ {
			m[s[i:j]]++
		}
	}
	ks := make([]string, 0)
	for k := range m {
		ks = append(ks, k)
	}
	sort.Strings(ks)
	fmt.Println(ks[k-1])
}


Measured memory_bytes: 2560
#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>;
#define chmax(x,y) x = max(x,y)

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
  int R, C, n;
  cin >> R >> C >> n;
  rep(i,n) {
    int r, c, v;
    cin >> r >> c >> v;
    a[r-1][c-1] = v;
  }

  rep(i,R)rep(j,C) {
    for (int k = 2; k >= 0; k--) {
      chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
    }
    rep(k,4) {
      chmax(dp[i+1][j][0], dp[i][j][k]);
      chmax(dp[i][j+1][k], dp[i][j][k]);
    }
  }

  ll ans = 0;
  rep(k,4) chmax(ans, dp[R-1][C-1][k]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 320620
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N;
  cin >>N;
  vector<long long int> A(N);
  vector<long long int> B(N);//0~4
  for(long long int i = 0; i < N; i++){
    cin>>A.at(i);
    B.at(i)=0;
    if(!(i == 0)){
      if(A.at(i-1) < A.at(i))B.at(i - 1)=1;
      else if(A.at(i-1) > A.at(i))B.at(i - 1)=2;
    }
  }
  
  long long int G = 1000;
  long long int K = 0;

  for(long long int i = 0; i < N - 1; i++){
    if(B.at(i) == 1){
      //かう
      K += G / A.at(i);
      G = G % A.at(i);
    }
    else if(B.at(i) == 2){
      //うる
      G += K * A.at(i);
      K = 0;
    }
    

  }
  //ラスト売る
  G += K * A.at(N - 1);

  cout << G << endl;
}

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

bool is_prime(int n, int max_v) {
    for (int i = 2; i <= max_v; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int x;
    cin >> x;
    int x_sqrt = sqrt(x);

    while (!is_prime(x, x_sqrt)) x++;
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define all(a) a.begin(),a.end()
using namespace std;

int main(){
  ll n,x;
  cin>>n;
  cout<<(n*(n-1))/2<<endl;
}

Measured memory_bytes: 256
import math
a,b,C=map(int,input().split(" "))
S=a*b*math.sin(math.radians(C))*0.5
L=a+b+math.sqrt((a**2)+(b**2)-(2*a*b*math.cos(math.radians(C))))
h=2*S/a
print(S)
print(L)
print(h)


Measured memory_bytes: 5712
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long N, std::vector<long long> A){
    map<ll, ll> CNT;
    set<ll> R;
    set<ll> Test(ALL(A));
    REP(i, N){CNT[A[i]]++;}
    for(auto x: CNT){
        if(x.second == 1) R.insert(x.first);
    }
    ll ans = 0;
    for(ll x: R){
        if( x == 1 ) {ans = 1; break;}
        bool isGood = true;
        for(ll t = 1; t*t <= x; t++){
            if(x % t != 0) continue; // not divisor
            if(Test.count(t)) {isGood = false; break;}
            if(t != 1) {
                if(Test.count(x/t)) {isGood = false; break;}
            }
        }
        if(isGood) ans ++;
    }
    cout<<ans<<endl;
}
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 35460
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;

  ll ans = 0;
  rep(i, N + 1) {
    if (i % 2 == 1) {
      vll v = divisor(i);
      if (v.size() == 8) {
        ans++;
      }
    }
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3668
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pd pair<ld,ld>
#define ft first
#define sd second
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define FOR(i,a,b) for(int i=(a); i<=(b);i++)
#define F(i,a,b) FOR(i,(a),(b)-1)
#define REV(i,a,b) for(int i=(a); i>=(b);i--)
#define VI vector<int>
#define VPI vector<pi>
#define VPD vector<pd>
#define PI 3.14159265
#define all(x) (x).begin(), (x).end()
#define sz(a) (int)((a).size())
#define int long long

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
mt19937 r(chrono::steady_clock::now().time_since_epoch().count());
int rand_range(int a, int b)
{
    assert(a<=b);
    return a+r()%(b-a+1);
}
const long long K = 1000;
const long long KK = K*K;
const long long MIL = KK*K;
const long long INF = MIL*MIL;
const long long MOD = MIL+7;
const long long N = 1e6 + 10, M=10;

void solve(){
    int n;
    string s;
    cin >> n >> s;
    s += s;
    for(int i = 0; i < n / 2; i++) {
        if(s.substr(i, n/2) == s.substr(i + n/2, n/2) && (n % 2 == 0)) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}

int32_t main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    cout<<setprecision(9)<<fixed;
    cerr<<setprecision(6)<<fixed;
    int test = 1, f;
    //cin>>test;
    F(_test, 0, test){
        //cout<<"Case #"<<_test + 1<<": ";
        solve();
//		if(_test == 1)
//            return 0;
    }
}


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

typedef long long ll;
#define pii pair<int ,int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005


int main()
{
    _FastIO;
    ll x;
    cin >> x;
    ll k = x / 500;
    ll ans = k * 1000;
    x %= 500;
    k = x / 5;
    cout << ans + 5 * k << endl;
    return 0;
}


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

int main(){
    long int H,R,h,r;
    cin >> H >> R;
    r=2*R;
    
    if(H<0){
        h=H*-1;
        if(h>R || r<h){
           cout << "-1" << '\n';
        }else if(h<=R){
            cout << "0" << '\n'; 
         }
    }else if(H>0){
         if(H>=R || H<r){
            cout << "1" << '\n'; 
         } else if(H<R){
           cout << "0" << '\n';
        }
        
    }else if(H==0){
        cout << "1" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 3e3+9;

int n;
double p[SIZE];
double dp[SIZE][SIZE];

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> p[i];


    dp[0][0] = 1;
    for(int coin = 0; coin <= n; coin++) {
        for(int heads = 0; heads <= coin; heads++) {
            dp[coin+1][heads] += dp[coin][heads] * (1 - p[coin+1]);
            dp[coin+1][heads+1] += dp[coin][heads] * p[coin+1];
        }
    }

    double ans = 0.0;
    for(int heads = 0; heads <= n; heads++) {
        if(heads * 2 > n)
            ans += dp[n][heads];
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 69120
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll A, B;
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	r.Scan(true)
	/*
		0・9以外が0回以上, 0, 9以外が0回以上, 9, 任意が残り
	*/
	MOD := pow(10, 9, 0) + 7

	pre := []int{1, 0, 0}
	for i := 0; i < n; i++ {
		cur := make([]int, 3)
		cur[0] = pre[0] * 8 % MOD
		cur[1] = (pre[0] + pre[1]*9%MOD) % MOD
		cur[2] = (pre[1] + pre[2]*10%MOD) % MOD
		pre = cur
	}

	fmt.Fprintln(stdout, pre[2]*2%MOD)
}


Measured memory_bytes: 6384
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    N = read_int()
    g = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = read_int_array()
        g[a-1].append(b-1)
        g[b-1].append(a-1)
    C = read_int_array()
    C.sort()
    labels = [None]*N
    labels[0] = C.pop()
    M = sum(C)
    q = [0]
    for x in q:
        for ch in g[x]:
            if labels[ch] is None:
                q.append(ch)
                labels[ch] = C.pop()

    print(M)
    print(' '.join(map(str, labels)))





# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")


def read():
    return input()


def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)


def read_int():
    return int(read())


def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 34540
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        try {
            int n = scanner.nextInt();
             String[] a = new String[n];
             String[] b = new String[n];


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

                a[i] = scanner.next();
                b[i] = a[i];
            }


            //System.out.println(Arrays.toString(b));
            //  int count = 0;

            swap(a);
            for (int i = 0; i < n - 1; i++) {
                System.out.printf(a[i] + " ");
            }
            System.out.printf(a[n - 1]);
            System.out.println();
            System.out.println("Stable");

           // System.out.println(Arrays.toString(b));
            swap1(b);
            for (int i = 0; i < n - 1; i++) {
                System.out.printf(b[i] + " ");
            }
            System.out.printf(b[n - 1]);
            System.out.println();




            boolean flag = true;
            for (int i = 0; i < n; i++) {
                if (!a[i].equals(b[i])) {
                    flag = false;
                }

            }
            System.out.println(flag ? "Stable" : "Not stable");


        } catch (Exception e) {

        } finally {

        }

    }

    public static void swap(String[] a) {
        int count = 0;
        for (int i = a.length - 1; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if ((int) a[j].charAt(1) > (int) a[j + 1].charAt(1)) {
                    String s = a[j];
                    a[j] = a[j+1];
                    a[j+1] = s;
                   // System.out.println(s);
                }
            }
        }
      //  System.out.println(count);

    }


    public static void swap1(String[] b) {

        /*for (int i = b.length-1; i > 0; i--) {
            int lrg = 0;
            int j;
            for (j = 1; j <= i; j++) {
                if (b[j].charAt(1)>b[lrg].charAt(1)){
                    lrg = j;
                }

            }
            if (b[i].charAt(1)!=b[lrg].charAt(1)) {
                String s = b[lrg];
                b[lrg] = b[i];
                b[i] = s;
              //  System.out.println(s);
            }
        }*/

        int count1 = 0;
        for (int i = 0; i <  b.length; i++) {
            int mini = i;
            for (int j = i; j < b.length; j++) {
                if ((int)b[j].charAt(1)<(int)b[mini].charAt(1)){
                    mini = j;
                   // System.out.println(min);
                }
            }
            if(i!=mini) {
                String s = b[i];
                b[i] = b[mini];
                b[mini] = s;

                //  System.out.println(s);
            }


        }


       // System.out.println(count1);
    }
}




Measured memory_bytes: 26284
import queue
import numpy as np
import math

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)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



dir4 = [[-1, 0], [1, 0], [0, -1], [0, 1]]

a = int(input())
# n, k = map(int, input().split())
# maze = [list(input()) for _ in range(H)]
# a = list(map(int, input().split()))

if a == 1:
    print(0)
else:
    print(1)



Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int sumA, sumB;
  sumA=0;
  sumB=0;
  cin >> N;
  vector<int> card(N);
  for (int i=0;i<N;i++){
    cin >> card.at(i);
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  if(N%2==0){
    for(int m=0;m<N/2;m++)
      sumA+=card.at(2*m);
  }
  if(N%2==1){
    for(int q=0;q<N/2+1;q++)
      sumA+=card.at(2*q);
  }
  for(int r=0;r<N/2;r++)
    sumB+=card.at(2*r+1);
  cout << sumA-sumB << endl;
}

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

using namespace std;

const int MOD = 1e9 + 7;

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

	vector<int> A(N);
	int neg = 0;
	int pos = 0;
	bool hasZero = false;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		if(A[i] < 0) {
			neg++;
		} else if(A[i] > 0) {
			pos++;
		} else if(A[i] == 0) {
			hasZero = true;
		}
	}

	bool canMakePos = true;
	if((neg % 2 == 1 && K == N) || (K % 2 == 1 && pos == 0)) {
		canMakePos = false;
	}

	sort(A.begin(), A.end(), [](int &a, int &b) {
		return abs(a) > abs(b);
	});

	long long result = 1;
	if(!canMakePos) {
		if(hasZero) {
			result = 0;
		} else {
			for(int i = 0; i < K; i++) {
				result = (result * abs(A[N - 1 - i])) % MOD;
			}
			result = (MOD - result) % MOD;
		}
	} else {
		int negc = 0;
		int lastNeg = -1;
		int lastPos = -1;
		bool isZero = false;
		for(int i = 0; i < K; i++) {
			if(A[i] < 0) {
				negc++;
				lastNeg = i;
			} else if(A[i] > 0) {
				lastPos = i;
			} else {
				isZero = true;
			}
		}

		const bool isNeg = (negc % 2 == 1);
		if(isZero) {
			result = 0;
		} else if(!isNeg) {
			for(int i = 0; i < K; i++) {
				result = (result * abs(A[i])) % MOD;
			}
		} else {
			int nextPos = -1;
			int nextNeg = -1;
			for(int i = K; i < N; i++) {
				if(A[i] < 0) {
					nextNeg = i;
					break;
				}
			}
			for(int i = K; i < N; i++) {
				if(A[i] >= 0) {
					nextPos = i;
					break;
				}
			}

			// 全部NEG
			if(lastPos == -1) {
				for(int i = 0; i < K - 1; i++) {
					result = (result * abs(A[i])) % MOD;
				}
				result = (result * abs(A[nextPos])) % MOD;
			}
			// POS to NEG強制
			else if(nextPos == -1) {
				for(int i = 0; i < K; i++) {
					if(i != lastPos)
						result = (result * abs(A[i])) % MOD;
				}
				result = (result * abs(A[nextNeg])) % MOD;
			}
			// NEG to POS強制
			else if(nextNeg == -1) {
				for(int i = 0; i < K; i++) {
					if(i != lastNeg)
						result = (result * abs(A[i])) % MOD;
				}
				result = (result * abs(A[nextPos])) % MOD;
			}
			// 両者の比較
			else {
				if((long long)abs(A[lastNeg]) * abs(A[nextNeg]) < (long long)A[lastPos] * A[nextPos]) {
					// NEG to POS
					for(int i = 0; i < K; i++) {
						if(i != lastNeg)
							result = (result * abs(A[i])) % MOD;
					}
					result = (result * abs(A[nextPos])) % MOD;
				} else {
					for(int i = 0; i < K; i++) {
						if(i != lastPos)
							result = (result * abs(A[i])) % MOD;
					}
					result = (result * abs(A[nextNeg])) % MOD;
				}
			}
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 4004
// JOI14-quest5.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <stdio.h>
#include <stdlib.h>
#include <queue>

int height, width;
int beach[1000][1000] = { 0 };

using namespace std;
queue<int> que_i, que_j;

int power(int i, int j) {
	int count = 0;

	if (beach[i - 1][j] == 0) {
		count++;
	}
	if (beach[i][j + 1] == 0) {
		count++;
	}
	if (beach[i + 1][j] == 0) {
		count++;
	}
	if (beach[i][j - 1] == 0) {
		count++;
	}

	if (beach[i - 1][j + 1] == 0) {
		count++;
	}
	if (beach[i + 1][j + 1] == 0) {
		count++;
	}
	if (beach[i + 1][j - 1] == 0) {
		count++;
	}
	if (beach[i - 1][j - 1] == 0) {
		count++;
	}

	return count;
}

void around(int i, int j) {
	if (beach[i - 1][j] != 0) {
		if (beach[i - 1][j] <= power(i - 1, j)) {
			que_i.push(i - 1);
			que_j.push(j);
		}
	}
	if (beach[i][j + 1] != 0) {
		if (beach[i][j + 1] <= power(i, j + 1)) {
			que_i.push(i);
			que_j.push(j + 1);
		}
	}
	if (beach[i + 1][j] != 0) {
		if (beach[i + 1][j] <= power(i + 1, j)) {
			que_i.push(i + 1);
			que_j.push(j);
		}
	}
	if (beach[i][j - 1] != 0) {
		if (beach[i][j - 1] <= power(i, j - 1)) {
			que_i.push(i);
			que_j.push(j - 1);
		}
	}

	if (beach[i - 1][j + 1] != 0) {
		if (beach[i - 1][j + 1] <= power(i - 1, j + 1)) {
			que_i.push(i - 1);
			que_j.push(j + 1);
		}
	}
	if (beach[i + 1][j + 1] != 0) {
		if (beach[i + 1][j + 1] <= power(i + 1, j + 1)) {
			que_i.push(i + 1);
			que_j.push(j + 1);
		}
	}
	if (beach[i + 1][j - 1] != 0) {
		if (beach[i + 1][j - 1] <= power(i + 1, j - 1)) {
			que_i.push(i + 1);
			que_j.push(j - 1);
		}
	}
	if (beach[i - 1][j - 1] != 0) {
		if (beach[i - 1][j - 1] <= power(i - 1, j - 1)) {
			que_i.push(i - 1);
			que_j.push(j - 1);
		}
	}
}

int main(void)
{
	

	scanf("%d %d", &height, &width);

	char c;
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			c = getchar();
			if (c == '\n') {
				j--;
				continue;
			}
			else if (c == '.') {
				beach[i][j] = 0;
			}
			else {
				beach[i][j] = c - 48;
			}
		}
	}

	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			if (beach[i][j] != 0) {
				if (beach[i][j] <= power(i, j)) {
					que_i.push(i);
					que_j.push(j);
				}
			}
		}
	}

	int wave = 0, x[1000], y[1000], count, save, size;
	while (que_i.empty() == false) {
		wave++;
		count = 0;
		size = que_i.size();
		for (int i = 0; i < size; i++) {
			if (beach[que_i.front()][que_j.front()] != 0) {
				
				beach[que_i.front()][que_j.front()] = 0;
				y[count] = que_i.front();
				x[count] = que_j.front();
				count++;
			}
			que_i.pop();
			que_j.pop();
		}

		for (int i = 0; i < count; i++) {
			around(y[i], x[i]);
		}
	}

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

	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    int a, b;
    inc(i, 0, n){
        if(s[i] == 'A'){
            a = i;
            break;
        }
    }
    dec(i, 0, n){
        if(s[i] == 'Z'){
            b = i;
            break;
        }
    }
    cout << b-a+1 << endl;
    return 0;
}


Measured memory_bytes: 720
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int oddw=0;
        int oddb=0;
        int evenw=0;
        int evenb=0;
        for(int i=0;i<s.length();i++){
            if(i%2==0){
                if(s.charAt(i)=='1'){
                    evenw++;
                }else{
                    evenb++;
                }
            }else{
                if(s.charAt(i)=='1'){
                    oddw++;
                }else{
                    oddb++;
                }
            }
        }
        System.out.println(Math.min(oddb+evenw, oddw+evenb));
    }

}


Measured memory_bytes: 25684
#include<iostream>
#include<string>
using namespace std;
struct Node {
	int key;
	Node* left, * right, * parent;
};
Node* root, * NILL;
void insert(int k) {
	Node* p = NILL;
	Node* id = root;
	Node* z;
	z = new Node;
	z->key = k;
	z->left = NILL;
	z->right = NILL;
	while (id != NILL) {
		p = id;
		if (z->key < id->key) {
			id = id->left;
		}
		else {
			id = id->right;
		}
	}
	z->parent = p;
	if (p == NILL) {
		root = z;
	}
	else if (z->key < p->key) {
		p->left = z;
	}
	else if (z->key > p->key) {
		p->right = z;
	}
}
void find(int k) {
	Node* x = root;
	while (x != NILL && k != x->key) {
		if (k < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	if (x != NILL) {
		cout<<"yes"<<endl;;
	}
	else {
		cout << "no" << endl;
	}
}
void Preorder(Node* u) {
	if (u == NILL) return;
	else {
		cout << " " << u->key;
		Preorder(u->left);
		Preorder(u->right);
	}
}
void Inorder(Node* u) {
	if (u == NILL) return;
	else {
		Inorder(u->left);
		cout << " " << u->key;
		Inorder(u->right);
	}

}
int main() {
	int n, value;
	string command;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> command;
		if (command == "insert") {
			cin >> value;
			insert(value);
		}
		else if (command == "print") {
			Inorder(root);
			cout << endl;
			Preorder(root);
			cout << endl;
		}
		else if (command == "find") {
			cin >> value;
			find(value);
		}
	}
	return 0;
}


Measured memory_bytes: 21916
h,w = gets.chomp.split(" ").map(&:to_i)
maze = h.times.map{gets.chomp}

MAX = 10 ** 9
dp = Array.new(h) { Array.new(w, MAX) }
dp[0][0] = maze[0][0] == "#" ? 1 : 0

(0..h-1).each do |y|
  (0..w-1).each do |x|
    # 下 or 右
    [[1, 0], [0, 1]].each do |(dy, dx)|
      tmp_y = y + dy
      tmp_x = x + dx
      next if tmp_y >= h || tmp_x >= w
      if maze[tmp_y][tmp_x] == "#" && maze[y][x] == "."
        dp[tmp_y][tmp_x] = [dp[tmp_y][tmp_x], dp[y][x] + 1].min
      else
        dp[tmp_y][tmp_x] = [dp[tmp_y][tmp_x], dp[y][x]].min
      end
    end
  end
end

puts dp[-1][-1]


Measured memory_bytes: 14384
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS
    int k,x;
    cin>>k>>x;
    if(k*500>=x)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
typedef long long ll;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	int n, k;
	string s;
	cin >> n >> k >> s;
	int ans = 0;
	s = "*" + s + "*";
	for(int i=1; i<=n; i++){
		if (s[i]=='L') {
			if (s[i-1] == 'L') ans++;
		} else {
			if (s[i+1] == 'R') ans++;
		}
	}
	// what_is(ans);
	ans = min(n-1, ans + 2*k);
	cout << ans << endl;
	return 0;
}
/*
Link Editorial: https://codeforces.com/blog/entry/69629#comment-541532
*/


Measured memory_bytes: 512
N, X, Y= map(int, input().split())
List=N*[0]

for i in range(1,N+1,1):
	for j in range(i,N+1,1):
		saitan = min(abs(i-j), abs(i-X)+abs(Y-j)+1, abs(i-Y)+abs(X-j)+1)
		List[saitan] += 1


for i in range(1,N):
    	print(List[i])

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

int main() {
	int N; cin >> N;
	int A[N]; for (int i = 0 ; i < N ; i++) cin >> A[i];
	if (N == 1){
		cout << 0 << '\n';
		return 0;
	}
	sort(A, A + N);
	long long int res = A[N - 1];
	int c = N - 2;
	for (int i = N - 2 ; i >= 0 ; i--) {
		c --;
		if (c < 0) break;
		res += A[i];
		c --;
		if (c < 0) break;
		res += A[i];
	}
	cout << res;
}

Measured memory_bytes: 4448
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	int n; cin >> n;
	int a[n] = {};
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	int circle_len = (n + 1) / 2;
	ll ans = 0;
	for (int i = 0; i < circle_len - 1; i++) {
		// cout << a[n - 1 - i] << "\n";
		ans += a[n - 1 - i];
	}
	if (n & 1) {
		for (int i = 0; i < n - circle_len; i++) {
			// cout << a[n - 2 - i] << "\n";
			ans += a[n - 2 - i];
		}
	} else {
		for (int i = 0; i < n - circle_len; i++) {
			if (i == n - circle_len - 1) {
				// cout << a[n - 2 - i + 1] << "\n";
				ans += a[n - 2 - (i - 1)];
			}
			else {
				// cout << a[n - 2 - i] << "\n";
				ans += a[n - 2 - i];
			}
		}
	}
	cout << ans << "\n";
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;

    for(int i = 0; i < S.length(); i++) cout << (char) ((S[i] - 'A' + N) % 26 + 'A');
    cout << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m = 3;
  int a[m][m];
  int k[m][m];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      k[i][j] = 0;
    }
  }
  int n;
  cin >> n;
  set <int> s;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.insert(x);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      if (s.count(a[i][j])) k[i][j] = 1;
    }
  }
  bool good = false;
  for (int i = 0; i < m; i++) {
    bool ok = true;
    for (int j = 0; j < m; j++) ok &= k[i][j];
    good |= ok;
  }
  for (int i = 0; i < m; i++) {
    bool ok = true;
    for (int j = 0; j < m; j++) ok &= k[j][i];
    good |= ok;
  }
  bool ok = true;
  for (int i = 0; i < m; i++) {
    ok &= k[i][i];
  }
  good |= ok;
  ok = true;
  for (int i = 0; i < m; i++) {
    ok &= k[i][m - i - 1];
  }
  good |= ok;
  cout << (good ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ld long double
#define tc() ll t;cin>>t;while(t--)
#define inp(n) ll n;cin>>(n)
#define inp2(n,m) ll n,m;cin>>(n);cin>>(m)
#define inp3(n,m,g) ll n,m,g;cin>>(n);cin>>(m);cin>>(g)
#define inps(s) string s;cin>>(s)
#define fr(i,n) for(ll i=0;i<n;i++)
#define rf(n,i) for(ll i=n-1;i>=0;i--)
#define vi vector<int >
#define vl vector<ll>
#define vd vector<ld>
#define vs vector<string >
#define pii pair<int,int>
#define pci pair<char ,int>
#define pic pair<int ,char>
#define psi pair<string ,int>
#define mii map<int ,int >
#define mci map<char ,int>
#define msi map<string ,int>
#define si set<int >
#define ss set<string>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007

int main() {
    fast
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    ll ans = max({a*c,a*d,b*c,b*d});
    
    cout<<ans<<endl;
    
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
constexpr int MOD = 1e9+7;
const int MAX= 1e5+5;
using namespace std;


//ll gcd(int a, int b)
//{ 
//    if (a == 0) 
//        return b;  
//    return gcd(b % a, a);  
// } 
// 
//ll lcm(int a, int b)  
// {  
//    return a/gcd(a, b) *b;  
// }
//  
//int prime(int n)
//{
//	rep(i,2,n+1)
//	{
//		if(n%i==0)return i;
//	}
//	
//vector<unordered_set<int> > prime_factors(MAX,unordered_set<int>());
//int primes[MAX];
//int prefix[MAX][6];
//void sieve(){
//    //primes i stores the largest prime factor of a number....
//    for(int i=2;i<MAX;++i){
//        if(primes[i]!=0){
//            continue;
//        }
//        primes[i] = i;
//        for(int j=2*i;j<MAX;j+=i){
//            primes[j] = i;
//        }
//    }
//    
//    for(int i=2;i<MAX;++i){
//        int current = i;
//        
//        while(current!=1){
//            prime_factors[i].insert(primes[current]);
//            current = current/primes[current];
//        }
//    }
//    
//    for(int i=1;i<MAX;++i){
//        for(int k=1;k<=5;++k){
//            prefix[i][k] = prefix[i-1][k] + (prime_factors[i].size()==k);
//        }
//    }
//    
//}
void solve() 
{
	map<string ,int>m;
	int n;
	cin>>n;
	while(n--)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
}



int main()
{
	hello777;

	int q=1;
	
//    cin>>q;
    while(q--)
    {   
      solve();
    }
}

 

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int count(const std::vector<std::string>& flag, const std::vector<std::string>& pattern, int i, int j) {
	if (i < 0) return 0;
	if (j < 0) return 0;
	if (i + 1 >= flag.size()) return 0;
	if (j + 1 >= flag[i].size()) return 0;
	for (auto di = 0; di < 2; ++di) for (auto dj = 0; dj < 2; ++dj) if (flag[i + di][j + dj] != pattern[di][dj]) {
		return 0;
	}
	return 1;
}

int main() {
	int m, n; std::cin >> m >> n;
	std::vector<std::string> flag(m), pattern(2); for (auto& line : flag) std::cin >> line;
	for (auto& line : pattern) std::cin >> line;
	int initial_count = 0;
	for (auto i = 0; i < m; ++i) for (auto j = 0; j < n; ++j) {
		initial_count += count(flag, pattern, i, j);
	}
	int diff_max = 0;
	for (auto i = 0; i < m; ++i) for (auto j = 0; j < n; ++j) {
		const auto origin = flag[i][j];
		const int origin_count = count(flag, pattern, i - 1, j - 1) + count(flag, pattern, i - 1, j) + count(flag, pattern, i, j - 1) + count(flag, pattern, i, j);
		for (const auto changed : "JOI") {
			flag[i][j] = changed;
			const int new_count = count(flag, pattern, i - 1, j - 1) + count(flag, pattern, i - 1, j) + count(flag, pattern, i, j - 1) + count(flag, pattern, i, j);
			diff_max = std::max(diff_max, new_count - origin_count);
		}
		flag[i][j] = origin;
	}
	std::cout << initial_count + diff_max << std::endl;
}








Measured memory_bytes: 4004
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;
 
 
 
/*
string fs(string str1, string str2)
{    if (str1.length() > str2.length())
        swap(str1, str2);
      string str = "";
    int n1 = str1.length(), n2 = str2.length();
    int diff = n2 - n1;
      int carry = 0;
      for (int i=n1-1; i>=0; i--)
    {
 
        int sum = ((str1[i]-'0') +
                   (str2[i+diff]-'0') +
                   carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      for (int i=n2-n1-1; i>=0; i--)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }
      if (carry)
        str.push_back(carry+'0');
      reverse(str.begin(), str.end());
 
    return str;
}*/
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first<y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
 
#include <array>
//include<bits/stdc++.h>
 
int main()
{ fastio;
//freopen("test_input (1).txt", "r", stdin); 
//freopen("output.txt", "w", stdout);

ll n;cin>>n;
ll x=1000-n%1000;
x%=1000;
cout<<x;


 
 
return 0;
}
 
 
 
 
 
 
 
 

Measured memory_bytes: 3596
import math

def get_divisor(n):
    sn = math.sqrt(n)
    i = 1
    divisor = []
    while i <= sn:
        if n % i == 0:
            divisor.append(i)
            if i != n // i:
                divisor.append(n // i)
        i += 1
    return divisor

n = int(input())
if n == 2:
    print(1)
    exit()
d1 = get_divisor(n)
d2 = get_divisor(n - 1)
ans = -1
for i in d1:
    tmp = int(n)
    if i == 1:
        continue
    while tmp % i == 0:
        tmp //= i
    if tmp % i == 1:
        ans += 1
ans += len(d2)
print(ans)

Measured memory_bytes: 3316
dX = [2,2,2,1,0,-1,-2,-2,-2,-1,0,1]
dY = [-1,0,1,2,2,2,1,0,-1,-2,-2,-2]
def solve(x,y,XY):
	xy = XY[:]
	if len(xy) == 0: return "OK"
	sx,sy = xy.pop(0),xy.pop(0)
	for dx,dy in zip(dX,dY):
		if doa(x+dx,y+dy,sx,sy): 
			r = solve(x+dx,y+dy,xy)
			if r: return r

def doa(x,y,sx,sy):
	if not (0 <= x <= 9 and 0 <= y <= 9): return False
	return True if abs(x-sx) < 2 and abs(y-sy) < 2 else False

while 1:
	x,y = map(int,raw_input().split())
	if x == y == 0: break
	n = input()
	xy = map(int,raw_input().split())
	ans = solve(x,y,xy)
	print ans if ans else "NA"

Measured memory_bytes: 4272
#include <stdio.h>

#define MAX 100

int main(){
  int n,a[MAX],ans = 0,i,j,tmp;

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a+i);
  }

  for(i = 0 ; i < n ; i++){
    for(j = n-1 ; j > i ; j--){
      if(a[j] < a[j-1]){
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	ans++;
      }
    }
  }

  for(i = 0 ; i < n ; i++){
    if(i != n-1){
      printf("%d " ,a[i]);
    }else{
      printf("%d\n%d\n" ,a[i],ans);
    }
  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int N,i,j,ans,ans1=0;
    cin>>N;
    ll a[N];
    for(i=0;i<N;i++) { cin>>a[i]; }
    sort(a,a+N);
    for(i=0;i<N;i++)
    {
        for(j=i+1;j<N;j++)
        {
            int t=a[i]+a[j]; ans=N;
            int l=j+1,r=N-1;
            while(l<=r)
            {
                int mid=(l+r)/2;
                if(a[mid]<t) { ans=mid; l=mid+1; }
                else { r=mid-1; }
            }
            if(ans<N)
            {
            	if(a[ans]<t) ans1+=ans-j;
            }
        }
    }
    cout<<ans1<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
mylist = [0, 1]
n = int(input().rstrip())

mise = [list(map(int, input().rstrip().split())) for i in range(n)]
mine = [list(map(int, input().rstrip().split())) for i in range(n)]

maxnum = - float('inf')
for i in itertools.product(mylist, repeat = 10):
    if sum(i) == 0:
        continue
    sell = 0
    for j, k in zip(mise, mine):
        temp = 0
        for l in range(10):
            if j[l] == i[l] and j[l] == 1:
                temp += 1
        sell += k[temp]
    maxnum = max(maxnum, sell)
print(maxnum)

Measured memory_bytes: 3064
local n, k = io.read("*n", "*n")
local r = n // k
if k % 2 == 0 then
  if k <= (n % k) * 2 then
    r = r * r * r + (r + 1) * (r + 1) * (r + 1)
  else
    r = 2 * r * r * r
  end
else
  r = r * r * r
end
print(r)


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

int main() {

	ll n; cin >> n;

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

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n,p=map(int,input().split())
pp=p
if n==1:
    print(p)
    exit()

li = [0]*(int(math.sqrt(p))+6)
for i in range(2,int(math.sqrt(pp))+2):
    while(p%i==0):
        p = p//i
        li[i] += 1
ans=1
for i in range(2,int(math.sqrt(pp))+2):
    ans *= max(pow(i,li[i]//n),1)
print(ans)

Measured memory_bytes: 10868