akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

void solve() {

    int n;
    SI(n);
    printf("%d\n", n*n);

}

void init() {
    


}

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


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

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

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            ostr << *itr;
            // ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    char a = 'a';

    ll n;
    cin >> n;

    vvc ans(1, vc(1, a));
    vll typ(1, 1);
    REP(i,n-1){
        vvc at;
        vll tt;
        REP(j,ans.size()){
            REP(k,typ[j]){
                at.emplace_back(ans[j]);
                at[at.size()-1].emplace_back((char)(a+k));
                tt.emplace_back(typ[j]);
            }
            at.emplace_back(ans[j]);
            at[at.size()-1].emplace_back((char)(a+typ[j]));
            tt.emplace_back(typ[j]+1);
        }
        ans = at;
        typ = tt;
    }
    cout << ans << endl;
    // cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 15540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//const ll N=1e5+5,mod=1e9+7;
const ll mod=1e9+7;
const ll NN = 51;
class matrix{
public:
    ll mat[NN][NN];
    ll r, c;
    matrix(){
        for(ll i=0;i<=NN - 1;i++)for(ll j=0;j<=NN - 1;j++)mat[i][j] = 0;
    }
    void setsize(ll _r, ll _c){ r = _r, c = _c; }
    inline matrix operator * (const matrix &a){
        matrix temp;
        temp.setsize(r, a.c);
        for(ll i=0;i<=r-1;i++){
            for(ll j=0;j<=a.c-1;j++){
                for(ll k=0;k<=a.r-1;k++){
                    temp.mat[i][j] += ( (ll)mat[i][k] * a.mat[k][j]) % mod;
                    if(temp.mat[i][j] >= mod)temp.mat[i][j] -= mod;
                }
            }
        }
        return temp;
    }
    inline matrix operator + (const matrix &a){
        matrix temp;
        temp.setsize(r, c);
        for(ll i=0;i<=r-1;i++){
            for(ll j=0;j<=c-1;j++){
                temp.mat[i][j] = mat[i][j] + a.mat[i][j] ;
                if(temp.mat[i][j] >= mod)temp.mat[i][j] -= mod;
            }
        }
        return temp;
    }
    inline matrix operator - (const matrix &a){
        matrix temp;
        temp.setsize(r, c);
        for(ll i=0;i<=r-1;i++){
            for(ll j=0;j<=c-1;j++){
                temp.mat[i][j] = mat[i][j] - a.mat[i][j];
                if(temp.mat[i][j]<0)temp.mat[i][j] += mod;
            }
        }
        return temp;
    }
    inline void operator = (const matrix &a){
        for(ll i=0;i<=r-1;i++)for(ll j=0;j<=c-1;j++)mat[i][j] = a.mat[i][j];
        r = a.r, c = a.c;
    }
    inline void print(){
        for(ll i=0;i<=r-1;i++){
            for(ll j=0;j<=c-1;j++){
                cout<<mat[i][j]<<" ";
            }
            cout<<"\n";
        }
    }
};
matrix pow(matrix a,ll k){
    matrix ans;
    for(ll i=0;i<=a.r-1;i++)ans.mat[i][i] = 1;
    ans.r=a.r;
    ans.c=a.r;
    while(k){
        if(k&1)ans = ans * a;
        a=a*a;
        k>>= 1;
    }
    return ans;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k;cin>>n>>k;
    matrix m;
    m.setsize(n,n);
    for(ll i=0;i<n;i++)for(ll j=0;j<n;j++)cin>>m.mat[i][j];
    matrix res = pow(m,k);
    ll ans = 0;
    for(ll i=0;i<n;i++)for(ll j=0;j<n;j++)ans+=res.mat[i][j],ans%=mod;
    cout<<ans;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
ans = [''] * N
for i in range(M):
    s, c = MAP()
    c = str(c)
    s -= 1
    if ans[s] != '' and ans[s] != c:
        print(-1)
        exit()
    if s == 0 and N != 1 and c == '0':
        print(-1)
        exit()
    ans[s] = c

for i in range(N):
    if i == 0 and N != 1 and ans[i] == '':
        ans[i] = '1'
    elif ans[i] == '':
        ans[i] = '0'
print(''.join(ans))


Measured memory_bytes: 3316
from collections import defaultdict
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=pow(10,9)+7
a0=0
d=defaultdict(lambda:0)
for i in range(n):
    a0+=len([s for s in a[:i] if s>a[i]])
    d[a[i]]+=1
keys=sorted(d.keys())
matagi=0
ni=n
for ky in keys:
    c=d[ky]
    ni-=c
    matagi+=ni*c
ans=(k*a0)%mod
ans+=(matagi*(k*(k-1))//2)%mod
print(ans%mod)

Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
int a[2010], b[2010];

vector<int> G[2010];

int solve() {
    for (int i = 0; i < n-1; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }

    int res = inf;
    bool used[2010];
    if (k % 2 == 0) {
        for (int i = 0; i < n; i++) {
            memset(used, false, sizeof(used));
            used[i] = true;
            queue<P> que;
            que.push(P(i, 0));
            while (!que.empty()) {
                P p =que.front(); que.pop();
                if (p.second >= k/2) continue;
                for (int v : G[p.first]) {
                    if (!used[v]) {
                        used[v] = true;
                        que.push(P(v, p.second+1));
                    }
                }
            }
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (used[i])
                    cnt++;
            }
            res = min(res, n-cnt);
        }
    } else {
        for (int i = 0; i < n-1; i++) {
            memset(used, false, sizeof(used));
            used[a[i]] = true;
            used[b[i]] = true;
            queue<P> que;
            que.push(P(a[i], 0));
            que.push(P(b[i], 0));
            while (!que.empty()) {
                P p =que.front(); que.pop();
                if (p.second >= k/2) continue;
                for (int v : G[p.first]) {
                    if (!used[v]) {
                        used[v] = true;
                        que.push(P(v, p.second+1));
                    }
                }
            }
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (used[i])
                    cnt++;
            }
            res = min(res, n-cnt);
        }
    }
    return res;
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < n-1; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  static bool F[100001];
  static int A[100];
  for (auto i = 0; i < N; ++i)
    cin >> A[i];
  for (auto i = 1; i <= K; ++i)
    for (auto j = 0; j < N && A[j] <= i; ++j)
      F[i] |= !F[i - A[j]];
  cout << (F[K] ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 384
import itertools
n = input()
p = "".join(input().split())
q = "".join(input().split())
availables = ["".join(t) for t in list(itertools.permutations([str(i+1) for i in range(int(n))]))]
idx_p = availables.index(p)
idx_q = availables.index(q)
print(abs(idx_p-idx_q))

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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int max = int.MaxValue;
            for (int i = -100; i <= 100; i++)
            {
                int tmp = 0;
                for (int j = 0; j < n; j++)
                {
                    tmp += (int)Math.Pow((i - a[j]), 2);
                }
                if(tmp<max)
                {
                    max = tmp;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 2776
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] A = in.ii(N);
        int max = 0;
        for (int i = 0; i < N; i++) {
            max = Math.max(max, A[i]);
        }
        int[] cnt = new int[max + 2];
        int[] score = new int[N];

        long ans = 1;
        cnt[0] = 3;
        for (int i = 0; i < N; i++) {
            if (cnt[A[i] + 1] > 2 || (score[i] = cnt[A[i]] - cnt[A[i] + 1]++) <= 0) {
                ans = 0;
            }
        }

        for (int i = 0; i < N; i++) {
            ans = ans * score[i] % 1_000_000_007;
        }

        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36252
# coding: utf-8
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
    
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]
ans = float("inf")
for i in range(4**N):
    bits = Base_10_to_n(i, 4).zfill(N)
    a, b, c = 0, 0, 0
    cost = 0
    for j in range(len(bits)):
        if bits[j] == "0":
            pass
        elif bits[j] == "1":
            a += L[j]
            cost += 10
        elif bits[j] == "2":
            b += L[j]
            cost += 10
        else:
            c += L[j]
            cost += 10
    if min(a, b, c) > 0:
        ans = min(ans, cost + abs(a-A)+abs(b-B)+abs(c-C) - 10*3)
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>

typedef struct {
	char suit;
	char value;
} Card;

Card C1[101], C2[101];
static int n;

void trace(Card *c) {
	int i;

	for (i = 1; i <= n; i++) {
		if (i > 1) {
			printf(" ");
		}
		printf("%c%c", c[i].suit, c[i].value);
	}
	printf("\n");

}

void sortingJudge(Card *c) {
	int i, cnt = 0;

	for (i = 0; i < n; i++) {
		if (C1[i].value == c[i].value && C1[i].suit == c[i].suit) {
			cnt++;
		}
	}

	if (cnt == n) {
		printf("Stable\n");
	} else {
		printf("Not stable\n");
	}

}

void swap(Card *x, Card *y) {
	Card tmp;

	tmp = *x;
	*x = *y;
	*y = tmp;
}

void BubbleSort() {
	int i, j;

	for (i = 0; i < n; i++) {
		for (j = n; j > i + 1; j--) {
			if (C1[j].value < C1[j - 1].value) {
				swap(&C1[j], &C1[j - 1]);
			}
		}
	}

}

void SelectionSort() {
	int i, j, mini;

	for (i = 0; i < n; i++) {
		mini = i;
		for (j = i; j <= n; j++) {
			if (C2[j].value < C2[mini].value) {
				mini = j;
			}
		}
		if (C2[i].value > C2[mini].value) {
			swap(&C2[i], &C2[mini]);
		}
	}

}

int main() {
	int i;
	char ch;

	scanf("%d%c", &n, &ch);
	for (i = 1; i <= n; i++) {
		scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
		C2[i] = C1[i];
	}

	BubbleSort();
	trace(C1);
	sortingJudge(C1);

	SelectionSort();
	trace(C2);
	sortingJudge(C2);

	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[])
{
  int n,m,k;
  scanf("%d %d %d",&n,&m,&k);
  int tmp=0;
  for (int i = 0; i < m+1; i++) {
    for (int j = 0; j < n+1; j++) {
      if(n*i+m*j-2*i*j==k){
	printf("Yes\n");
	return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, i;

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


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    char a, b;
    cin >> a >> b;
    bool c = (a == 'H' && b == 'H') || (a == 'D' && b == 'D');
    cout << (c ? "H" : "D") << '\n';
}


Measured memory_bytes: 3552
#define _GIBCXX_DEBUG
#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()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;

  if (a == b) {
    ans = c;
  } else if (b == c) {
    ans = a;
  } else if (c == a) {
    ans = b;
  }

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

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


public class Main {
	public static void main(String[] aegs){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = 0,c=0;
		String t = "";
		double counta =0,countb = 0;
		double rad = 90.0;
		double PI = Math.PI;
		
		while(true){
		
			try {
				t = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
			
			String[] tt = t.split(",",0);
			a = Integer.parseInt(tt[0]);
			c = Integer.parseInt(tt[1]);
			if(a == 0 && c == 0){
				break;
			}
			
			
			counta +=  (a * Math.sin(rad*PI/180d));
			countb +=  (a * Math.cos(rad*PI/180d));
			rad = rad - c;
			
		}
		System.out.println((int)countb);
		System.out.println((int)counta);
		
	}


}

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

int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    
    char arr[h][w];

    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>arr[i][j];
        }
    }
    int count=0;
    for(int i=0;i<pow(2,h);i++)
    {
        for(int j=0;j<pow(2,w);j++)
        {
            int blackcount=0;
            for(int m=0;m<h;m++)
            {
                for(int l=0;l<w;l++)
                { 
                    if((i&(1<<m))==0 && (j&(1<<l))==0)
                    {
                        if(arr[m][l]=='#')
                        {
                            blackcount++;
                        }
                    }
                    
                }
                
            }
            if(blackcount==k)
            {
                count++;
            }

        }

    }
    cout<<count;
}

Measured memory_bytes: 4104
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
const int maxn = 555;
char grid[2][maxn];
long long dp[maxn][5][5], mod = 1000000007;
int n;
long long solve(int cur, int corA, int corB){
    if(cur > n) return 1;
    if(dp[cur][corA][corB] != -1) return dp[cur][corA][corB];
    long long ans = 0;
    if(grid[0][cur] == grid[1][cur]){
        for(int e = 1; e <= 3; e++){
            if(e != corA && e != corB){
                ans += solve(cur + 1, e, e);
                ans %= mod;
            }
        }
    } else {
        for(int e = 1; e <= 3; e++){
            for(int f = 1; f <= 3; f++){
                if(e != f && corA != e && corB != f){
                    ans += solve(cur + 2, e, f);
                    ans %= mod;
                }
            }
        }
    }
    return dp[cur][corA][corB] = ans;
}
int M(){
    if(!~scanf("%d", &n))
        return 0;
    for(int e = 0; e < 2; e++)
        for(int f = 1; f <= n; f++){
            scanf(" %c", & grid[e][f]);
        }
    memset(dp, -1, sizeof(dp));
    cout << solve(1, 0, 0) << endl;
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,a[55];
long double ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	ans=a[1];
	for(int i=1;i<=n;i++)
		ans=(ans+a[i])/2;
	printf("%.10Lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ;
const int mod = 1e9 + 7;
int binpow(int a, int b) {
    a %= mod;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
int mul(int a , int b){
   return ((a % mod) * (b % mod )) % mod; 
} 
int divi(int a, int b){
    return(mul(a, binpow(b, mod - 2)) % mod);
}
int32_t main(){
 L_T_S_K;
    int n , k;
    cin >> n >> k;
    int a[n];
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    int inv[n] ,ans = 0;
    for(int i = 0 ; i < n ; i++){
        int cnt = 0;
        for(int j = i + 1 ; j < n ; j++){
            cnt+=(a[i] > a[j]);
        }
        inv[i] = cnt;
       // ans= ( ans % mod + cnt % mod)%mod;
    }
    int small[n] = {};
    for(int i = n - 1 ; i >= 0 ; i-- ){
        int cnt = 0;
        for(int j = i - 1 ; j >= 0 ; j--){
            cnt+=(a[i] > a[j]);
        }
        small[i] = cnt;
    }
    for(int i = 0 ; i < n ; i++){
        int r = ( ( inv[i] % mod + small[i] % mod) % mod );
        int t = ( mul(k , inv[i]) + divi( mul( mul(k , k - 1) , r ) , 2) ) % mod; 
        ans = ( ans % mod + t % mod)%mod;
    }   
    cout << ans << " ";
 return 0;
}




Measured memory_bytes: 256
#include <iostream>  
#include<math.h>
#include<algorithm>
using namespace std ;   
 
long long int gcd ( long long int x , long long int     y , long long int z )                             
{
  return __gcd ( x , __gcd ( y , z ));
}
 int main ()
 {
  long long int sum = 0 , n ;          
  cin >> n ;
  for ( int i = 1 ; i <= n ; i ++)        
  {
    for ( int j = 1 ; j <= n ; j ++)        
    {
      for ( int k = 1 ; k <= n ; k ++)        
      {
        sum += gcd ( i , j , k );  
      }
    }
  }
  cout << sum << endl ;
   return 0 ; 
}

Measured memory_bytes: 3636
fn main() {
    let summary = read_vec::<u32>();
    let words = read_vec2::<String>(*summary.get(0).unwrap());
    let words = quick_sort(&words);
    let mut res = String::new();
    for word in words {
        res = format!("{}{}", res, word);
    }
    println!("{}", res);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<T> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().parse().ok().unwrap();
        v2.push(v);
    }
    v2
}

fn quick_sort(list: &Vec<String>) -> Vec<String> {
    if list.len() == 0 { return Vec::new(); }

    let pivot = list.len() / 2;
    let pivot_val = list.get(pivot).unwrap();
    
    let mut left : Vec<String> = Vec::new();
    let mut center : Vec<String> = Vec::new();
    let mut right : Vec<String> = Vec::new();

    for val in list {
        if val < pivot_val { left.push(val.to_string()); }
        if val == pivot_val { center.push(val.to_string()); }
        if val > pivot_val { right.push(val.to_string()); }
    }

    let mut sorted = quick_sort(&left);
    sorted.append(&mut center);
    sorted.append(&mut quick_sort(&right));
    sorted
}

Measured memory_bytes: 4352
#include<algorithm>
#include<cstdio>


using namespace std ;


int main( void )
{
	int a ,b ,c ,d ;
	scanf( "%d %d %d %d" ,&a ,&b ,&c ,&d ) ;

	a = ( a + b + c + d ) - min( a ,min( b ,min( c ,d ) ) ) ;

	scanf( "%d %d" ,&b ,&c ) ;

	printf( "%d\n" ,a + max( b ,c ) ) ;


	return 0 ;
}

Measured memory_bytes: 2684
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#include <stack>
#include <cstdlib>
#include <queue>
#define endl '\n'
#define ll long long
#define NCONS 100001

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int alice = 0, bob = 0;
    vector<int> vec; int N; cin >> N;
    for(int i = 0; i < N; i++)
    {
        int temp; cin >> temp; vec.push_back(temp);
    }
    sort(vec.begin(), vec.end(), greater<int>());
    
    for(int i = 0; i < N; i++)
    {
        if(i % 2 == 0)
        {
            alice += vec[i];
        }
        else
        {
            bob += vec[i];
        }
    }
    cout << alice - bob << endl;
    return 0;
}


Measured memory_bytes: 504
# Problem B - 文字列大好きいろはちゃん

# input
n, l = map(int, input().split())
s_list = []
for i in range(n):
    s_list.append(input())

# initialization
ans_str = ""
s_list = sorted(s_list)

# integrate
for s in s_list:
    ans_str += s

# output
print(ans_str)


Measured memory_bytes: 38384
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int d = a - b, e = b - c, f = a - c;
	if(d < 0){
		d *= -1;
	}
	if(e < 0){
		e *= -1;
	}
	if(f < 0){
		f *= -1;
	}
	cout << d + e + f - max(max(d, e), f) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] A = { 1, 3, 5, 7, 8, 10, 12 };
        int[] B = { 4, 6, 9, 11 };
        int[] C = { 2 };
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        if ((A.Contains(n[0]) && A.Contains(n[1])) ||
            (B.Contains(n[0]) && B.Contains(n[1])))
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");

    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int a, b;

int main()
{
    cin >> a >> b;
    int i = 1;
    int mx = (a > b) ? a : b;
    while (i < mx) {
        if (abs(a - i) == abs(b - i)) {
            printf("%d\n", i);
            break;
        }
        ++i;
    }
    if (i == a || i == b) printf("IMPOSSIBLE\n");

    return 0;
}
    

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

Q = 10**9+7

from collections import defaultdict
from math import gcd
def main():
    N = int( input())
    AB = [ tuple( map( int, input().split())) for _ in range(N)]
    d = defaultdict( int)
    for a, b in AB:
        if a == 0 and b == 0:
            d[(0,0)] += 1
            continue
        if a == 0:
            d[(0,1)] += 1
            continue
        if b == 0:
            d[(1,0)] += 1
            continue

        g = gcd(a, b)
        a //= g
        b //= g
        if a < 0:
            a = -a
            b = -b
        d[(a,b)] += 1
    # print(d)
    ans = 1
    K = list( d.keys())
    for k in K:
        # print(ans)
        # print("|",k)
        a, b = k
        if a == 0 and b == 0:
            continue
        if a*b == 0:
            ans *= (pow(2,d[(1,0)],Q) + pow(2,d[(0,1)],Q) -1)%Q
            ans %= Q
            d[(1,0)] = 0
            d[(0,1)] = 0
            continue
        if b > 0 and d[(a,b)] > 0 and d[(b,-a)] > 0:
            ans *= (pow(2,d[(a,b)],Q) + pow(2,d[(b,-a)],Q) - 1)%Q
            ans %= Q
            continue
        if b < 0 and d[(a,b)] > 0 and d[(-b,a)] > 0:
            continue
        ans *= pow(2,d[(a,b)],Q)
        ans %= Q
    
    ans -= 1
    ans += d[(0,0)]
    ans %= Q
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 107852
#include <bits/stdc++.h>
 
using namespace std; 
 
#define MAX 500000 
#define SENTINEL 2000000000 // 番兵 
 
int L[MAX / 2 + 2], R[MAX / 2 + 2]; 
int cnt; 
 
void merge(int A[], int left, int mid, int right) { 
  int n1 = mid - left; 
  int n2 = right - mid; 
  for (int i = 0; i < n1; i++) L[i] = A[left + i]; 
  for (int i = 0; i < n2; i++) R[i] = A[mid + i]; 
  L[n1] = R[n2] = SENTINEL; 
  int i = 0, j = 0; 
  for (int k = left; k < right; k++) { 
    cnt++; 
    if (L[i] <= R[j]) { 
      A[k] = L[i++]; 
    } else { 
      A[k] = R[j++]; 
    } 
  } 
} 
 
void mergeSort(int A[], int left, int right) { 
  if (left + 1 < right) { 
    int mid = (left + right) / 2; 
    mergeSort(A, left, mid); 
    mergeSort(A, mid, right); 
    merge(A, left, mid, right); 
  } 
} 
int main() { 
  int A[MAX], n; 
  cnt = 0; 
  cin >> n; 
 
  for (int i = 0; i < n; i++) cin >> A[i]; 

  mergeSort(A, 0, n); 
 
  for (int i = 0; i < n; i++) { 
    if ( i ) cout << " "; 
    cout << A[i]; 
  } 
  cout << endl; 
  cout << cnt << endl; 
  return 0; 
} 


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

void print(int A[], int n){
	for(int i = 0; i < n; i++){
		cout << A[i];
		if(i!=n-1) cout << " ";
	}
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	int A[n+7];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	print(A, n);
	for (int i = 1 ; i < n; i++){
		int key = A[i];
	    /* insert A[i] into the sorted sequence A[0,...,j-1] */
	    int j = i - 1;
	    while (j >= 0 && A[j] > key){
	    	A[j+1] = A[j];
	        j--;
		}  
	    A[j+1] = key;
	    print(A, n);
	}    
}
    



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> a, b;
    int a_max = 0;
    int a_idx = -1;
    for(int i = 0; i < n; i++) {
        int at, bt;
        cin >> at >> bt;
        a.push_back(at);
        b.push_back(bt);
        if(a[i] > a_max) {
            a_max = a[i];
            a_idx = i;
        } else if(a[i] == a_max && b[i] > b[a_idx]) {
            a_max = a[i];
            a_idx = i;
        }
    }
    int count = 0;
    int b_sum = 0;
    for(int i = 0; i < n; i++) {
        if(b[i] > a_max || a_idx == i) {
            b_sum += b[i];
            count++;
        }
    }
    if((h - b_sum) >= 0) {
        count += (h - b_sum) / a_max;
        if((h - b_sum) % a_max != 0) count++; 
        cout << count << endl;
    } else if((h - b_sum) < 0) {
        count = 0;
        sort(b.begin(),b.end(),greater<int>());
        for(int i = 0; i < n; i++) {
            h -= b[i];
            count++;
            if(h <= 0) break;
        }
        cout << count << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1276
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = 0;
        int max;
        int maxNum = 0;
        int minNum = 0;
        int min;
        int sum;
        List<Integer> list = new ArrayList<Integer>();

        while (true) {
            n = sc.nextInt();
            max = -1;
            min = 1001;
            sum = 0;

            //入力終了
            if (n == 0) {
                break;
            }

            int[] nums = new int[n];

            //得点入力
            for (int i = 0; i < n; i++) {
                nums[i] = sc.nextInt();
                if (max <= nums[i]) {
                    max = nums[i];
                    maxNum = i;
                }
                if (nums[i] <= min) {
                    min = nums[i];
                    minNum = i;
                }
            }

            //最高得点と最低得点を0に
            nums[maxNum] = 0;
            nums[minNum] = 0;

            for (int num : nums) {
                sum += num;
            }

            list.add(sum / (n - 2));
        }
        for (int num : list) {
            System.out.println(num);
        }
        sc.close();
    }

}



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

int main(){
	int h, w; cin >> h >> w;
	string s[h + 1];
	for(int i = 0; i < h; ++i){
		cin >> s[i + 1];
	}
	for(int i = 1; i <= 2 * h; ++i){
		cout << s[(i + 1) / 2] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        if(r < 1200) {
            System.out.println("ABC");
        } else if(r < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 21844
X, K, D = gets.split.map(&:to_i)


tikadukerukaisuu = (X / D).abs
if K <= tikadukerukaisuu
  if X.positive?
    puts((X - D * K).abs)
    exit
  else
    puts((X + D * K).abs)
    exit
  end
end

nokorinokaisuu = K - tikadukerukaisuu
amari = X % D

if nokorinokaisuu.even?
  puts amari
  exit
end

if nokorinokaisuu.odd?
  puts (amari - D).abs
  exit
end


Measured memory_bytes: 14408
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if (a == b && a != c) || (a == c && a != b) || (b == c && b != a) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

int main() {
  string s; cin >> s;
  int cnt = 0;
  rep(i, s.size()) {
    if (s[i] == '1') {
      cnt++;
    } 
  }
  cout << cnt << endl;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    int i,n,cnt=0;
    string s;
    MSI mp;
    cin >> n;
    while(n--)
    {
        cin >> s;
        ++mp[s];
        cnt=max(cnt,mp[s]);
    }
    V<string>v;
    for(PSI x : mp)
    {
        if(x.SE == cnt)v.PSB(x.FI);
    }
    sort(v.B,v.E);
    for(string bal : v)cout << bal << '\n';
    return 0;
}


Measured memory_bytes: 27632
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long N;
	cin >> N;

	vector<long long> A(N, 0);
	vector<long long> B(N, 0);

	for (long long i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	long long ans = 0;
	for (long long i = N - 1; i >= 0; i--) {
		A[i] += ans;
		ans += (B[i] - A[i] % B[i]) % B[i];
	}

	cout << ans << endl;

	return 0;
}

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

static const auto fast_io = [] {
 ios_base::sync_with_stdio(false); 
 cin.tie(nullptr); cout.tie(nullptr); 
 return nullptr;
}();

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class A> 
A rnd() {
 return uniform_int_distribution<A> (1, (int) 1e9) (rng);
}

template<class A> 
A rnd(A x, A y) {
 return uniform_int_distribution<A> (x, y) (rng);
}

string to_string(string s) {
 return '"' + s + '"';
}

string to_string(const char* ch) {
 return to_string((string)ch);
}

string to_string(char ch) {
 return (string)"'" + ch + (string)"'";
}

string to_string(bool b) {
 return (b ? "true" : "false");
}

template<class A, class B>
string to_string(pair<A, B> p) {
 return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<class A>
string to_string(A a) {
 string res = "{";
 bool first = true;
 for(const auto& x: a) {
  if(first == false) res += ", ";
  first = false;
  res += to_string(x);
 }
 res += "}";
 return res;
}

template<class A, class B, class C>
string to_string(priority_queue<A, B, C> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(priority_queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(stack<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 return to_string(res);
}

template<class A>
string to_string(queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.front());
  a.pop();
 }
 return to_string(res);
}

vector<string> __vector_tuple;
template<int index, class... A>
struct print_tuple {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<index>(a)));
  print_tuple<index-1, A...>{}(a);
 }
};

template<class... A>
struct print_tuple<0, A...> {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<0>(a)));
 }
};

template<class... T>
string to_string(tuple<T...> a) {
 const int ttsz = tuple_size<decltype(a)>::value;
 print_tuple<ttsz-1, T...>{}(a);
 string __ss = to_string(__vector_tuple);
 __vector_tuple.clear();
 return __ss;
}

void debug() {cerr << "]\n";}

template<class H, class... T>
void debug(H head, T... tail) {
 cerr << to_string(head) << " ";
 debug(tail...);
}

#ifdef LOCAL
 #define debug(...) cerr << "[" << #__VA_ARGS__ << " ] = ["; debug(__VA_ARGS__);
#else 
 #define debug(...) 
#endif

typedef long long int ll;

int main()
{
 int n;
 cin >> n;
 int ans = 0;
 while(n % 1000 != 0) n++, ans++;
 cout << ans << '\n';
 return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

int CountUpMines(vector<string>, int, int);

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> map;

	stringstream edge_ss;
	string edge;
	for (int j = 0; j < W + 2; j++) {
		edge_ss << '.';
	}
	edge = edge_ss.str();
	map.push_back(edge);

	for (int i = 0; i < H; i++) {
		string faker, faker_in;
		stringstream faker_ss;
		cin >> faker_in;
		faker_ss << '.' << faker_in << '.';
		faker = faker_ss.str();
		map.push_back(faker);
	}
	map.push_back(edge);

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			int num_mines = 0;
			num_mines = CountUpMines(map, i, j);
			if (num_mines == -1) { 
				cout << '#'; 
				if (j == W)cout << endl;
			}
			else {
				cout << num_mines;
				if (j == W)cout << endl;
			}
		}
	}

	return 0;
}

int CountUpMines(vector<string> map, int i, int j) {
	if (map[i][j] == '#') return -1;
	else {
		int count = 0;
		for (int ite_j = -1; ite_j <= 1; ite_j++) {
			for (int ite_i = -1; ite_i <= 1; ite_i++) {
				if (ite_i == 0 && ite_j == 0) continue;
				if (map[i + ite_i][j + ite_j] == '#')count++;
			}
		}
		return count;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define max_heap priority_queue<int>
#define min_heap priority_queue<int,vector<int>,greater<int>>
using ll = long long;
#define int long long
#define endl "\n"
#define vi vector<int>
#define pb push_back
#define inp_arr(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define out_arr(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";
#define deb(n) cerr << #n << " = " << n << "\n";
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
ll mypower(ll x,ll n,ll c){
    if(n == 0)
        return 1;
    ll temp = mypower(x,n/2,c)%c;
    if(n%2)
        return (n<0)? (1/x)*temp*temp%c: ((x*temp)%c)*temp%c;
    else
        return temp*temp%c;
}
bool codejam = 0;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	ll n;
	cin>>n;
	cout<<1-n<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int md=1000000007;
int n,i,j,r,cnt,was,cc,c[5050],x[5050],f[5050][5050],num[2];
long long a[2][5050],fact[5050];
vector<int> g[5050];
long long pw(long long a, int b) {
  if (b==0) return 1LL;
  if (b&1) return (pw(a,b-1)*a)%md;
  long long x=pw(a,b/2);
  return (x*x)%md;
}
void dfs(int i) {
  c[i]=cc; ++cnt;
  if (x[i]==-1) was=1;
  for (int j=0; j<g[i].size(); j++) if (!c[g[i][j]]) dfs(g[i][j]);
}
int main() {
  scanf("%d",&n);
  for (fact[0]=i=1; i<=n; i++) {
    scanf("%d",&x[i]);
    if (x[i]>0) {
      g[i].push_back(x[i]);
      g[x[i]].push_back(i);
    }
    fact[i]=(fact[i-1]*i)%md;
  }
  for (i=1; i<=n; i++) if (!c[i]) {
    ++cc; cnt=was=0;
    dfs(i);
    a[1-was][num[1-was]++]=cnt;
  }
  f[0][0]=1;
  for (i=0; i<num[0]; i++) for (j=0; j<=i; j++) if (f[i][j]) {
    f[i+1][j]=(f[i+1][j]+f[i][j])%md;
    f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*a[0][i])%md;
  }
  for (i=0; i<num[0]; i++) if (a[0][i]>1) r=(r+pw(n-1,num[0]-1)*(a[0][i]-1))%md;
  for (i=0; i<num[1]; i++) r=(r+pw(n-1,num[0]))%md;
  for (j=2; j<=num[0]; j++) r=(r+(f[num[0]][j]*fact[j-1])%md*pw(n-1,num[0]-j))%md;
  printf("%d\n",int(((pw(n-1,num[0])*n)%md+md-r)%md));
  return 0;
}


Measured memory_bytes: 70916
from functools import lru_cache
import sys
sys.setrecursionlimit(1000000)
P = 10**9+7
@lru_cache(maxsize=None)
def subcalc(l, r):
    if l < 0 or r < 0:
        print("ERROR")
        print("l, r =", l, r)
        print(1//0)
    if l > r: return 0
    if r == 0: return 1
    aa, bb = l.bit_length(), r.bit_length()
    if aa == bb:
        return subcalc(l-(1<<aa-1), r-(1<<bb-1))
    if (r & (r+1) == 0) and (l == 0):
        return pow(3, r.bit_length(), P)
    t = (subcalc(l, r-(1<<bb-1)) + subcalc(l, (1<<bb-1)-1) + subcalc(0, r-(1<<bb-1))) % P
    # print("subcalc", l, r, t)
    return t
 
@lru_cache(maxsize=None)
def calc(L, R):
    if L < 0 or R < 0:
        print("ERROR")
        print("l, r =", l, r)
        print(1//0)
    if L > R: return 0
    a = L.bit_length()
    b = R.bit_length()
    if b > a:
        t = (calc(L, (1<<b-1)-1) + calc(1<<b-1, R)) % P
        # print("calc", L, R, t)
        return t
    
        
        
    a = 1 << L.bit_length() - 1 if L else 0
    t = subcalc(L-a, R-a)
    # print("calc", L, R, t)
    return t
 
L, R = map(int, input().split())
print(calc(L, R))

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

int main() {
    int H, W;
    int N;
    cin >> H >> W;
    cin >> N;

    vector<int> a(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }

    int c[H][W];
    int n = 0;
    int i = 0, j = 0;
    int color = 1;
    while (n < H * W) {
        if (j == 0) {
            while (j != W) {
                if (a[color] == 0) color++;
                c[i][j] = color;
                a[color]--;
                j++;
            }
            j--;
        } else {
            while (j >= 0) {
                if (a[color] == 0) color++;
                c[i][j] = color;
                a[color]--;
                j--;
            }
            j++;
        }
        i++;
        n += W;
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll 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(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];

  int cnt = 0;
  rep(i,n){
    if(a[i] - b[i] == 0) cnt++;
  }

  if(cnt == n){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  ll m = 1e9;
  rep(i,n){
    ans += a[i];
    if( a[i] > b[i] ) m = min<ll>(m,b[i]);
  }
  cout << ans-m << endl;
  return 0;
}


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

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::vector<int> v;

  // decomposit s[0] = s[1] * K + r[1]
  // s[1] = s[2] * K + r[2]
  // ...
  // finally, s[n] r[n] r[n-1] ... r[1] is the answer.
  int s = N;
  while(s >= K) {
    int r = s % K;
    s /= K;
    v.push_back(r);
  }
  std::string ret = std::to_string(s);
  for(auto it=v.rbegin(); it!=v.rend(); it++) {
    ret += std::to_string(*it);
  }

  std::cout << ret.size() << std::endl;
  return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

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

    int num= 1;
    while(n > num*1000){
        num++;
    }
    cout << num*1000 - n << endl;
    return 0;
}

Measured memory_bytes: 3616