akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

using graph = vector<vector<int>>;


bool dfs(graph const& g, int v, vector<int>& flag) {
    bool res = true;
    if(flag[v] == 1) {
        res = false;
    } else if(flag[v] == 0) {
        flag[v] = 1;
        for(int i=0; i<g[v].size(); ++i) {
            res &= dfs(g, g[v][i], flag);
        }
        flag[v] = 2;
    }
    return res;
}

int main() {
    int M, N;
    cin >> M >> N;
    vector<vector<int>> ul(M, vector<int>(N, -1)), ll(M, vector<int>(N, -1));
    bool ok = true;
    for(int i=0; i<M; ++i) {
        int K;
        cin >> K;
        for(int j=0; j<K; ++j) {
            int s, t;
            string cond;
            cin >> s >> cond >> t;
            --s;
            if(cond == "<=") {
                if(ll[i][s] > t) {
                    ok = false;
                }
                if(ul[i][s] == -1) {
                    ul[i][s] = t;
                } else {
                    ul[i][s] = min(ul[i][s], t);
                }
            } else {
                if(ul[i][s] != -1 && ul[i][s] < t) {
                    ok = false;
                }
                if(ll[i][s] == -1) {
                    ll[i][s] = t;
                } else {
                    ll[i][s] = max(ll[i][s], t);
                }
            }
        }
    }

    if(ok) {
        graph g(M);
        vector<int> flag(M, 0);
        for(int i=0; i<M; ++i) {
            for(int j=0; j<M; ++j) {
                if(i == j) {
                    continue;
                }
                bool ok = false;
                for(int k=0; k<N; ++k) {
                    ok |= (ul[i][k] < ll[j][k]) && ul[i][k] != -1 && ll[j][k] != -1;
                }
                if(ok) {
                    g[i].push_back(j);
                }
            }
        }
        for(int i=0; i<M; ++i) {
            if(flag[i] == 0) {
                if(!dfs(g, i, flag)) {
                    ok = false;
                    break;
                }
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}


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

const int N = 1e3 + 10;
const int M = 1e5 + 10; 

int n, w;
ll dp[N][M];
ll weight[N], value[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> n >> w;
	for (int i = 1; i <= n; ++i) cin >> weight[i] >> value[i];
	
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= w; ++j) {
			if (i==0 || j==0) {
				dp[i][j] = 0;
			} else if (weight[i] <= j) {
				dp[i][j] = max(value[i] + dp[i-1][j-weight[i]], dp[i-1][j]);
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}

	cout << dp[n][w] << "\n";

	return 0;
}


Measured memory_bytes: 80128
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define fi first
#define se second

#ifdef _DEBUG
ifstream ifs("input");
#define input ifs
#else
#define input cin
#endif
#define DEBUG(x) cout<<#x<<": "<<x<<endl

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

const double PI = (1*acos(0.0)); 
const double INF = 1e9;
const double EPS = 1e-9;
const ll mod = 1e9 + 7;


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

    ll x,n,acc=0,ans=1;
    vector<pii> AB;
    input >> n;
    rep(i, n) input >> x, AB.push_back(pii(x, 1));
    rep(i, n) input >> x, AB.push_back(pii(x, -1));
    sort(AB.begin(), AB.end());
    rep(i, AB.size()){
        if(acc > 0 && AB[i].se < 0) ans = (ans * acc) % mod;
        else if(acc < 0 && AB[i].se > 0) ans = (ans * -acc) % mod;
        acc += AB[i].se;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break



Measured memory_bytes: 26424
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

int h,w,n,ans,x,y,p[200005];

map <pi,int> m;

vector <pi> g;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> h >> w >> n; ans=h;
    for(int i=1;i<=n;i++){
        cin >> x >> y;
        m[{x,y}]=1;
        g.pb({x,y});
    }
    y=1; p[1]=1;
    for(int i=2;i<=h;i++){
        if(!m[{i,y+1}]) y++;
        p[y]=i;
    }
    for(int i=y+1;i<=w;i++) p[i]=h;
    for(pi i : g){
        if(i.x>p[i.y]) ans=min(ans,i.x-1);
    }
    cout << ans;
}


Measured memory_bytes: 24944
#include<bits/stdc++.h>
using namespace std;
bool s[1300000];
int main(){
  for(int i=2;i*i<1299709;i++)
    if(!s[i])for(int j=2;j*i<1299709;j++)s[i*j]=1;
  int n;
  while(cin>>n&&n){
    int an=0;
    for(int i=n;s[i];i++)an++;
    for(int i=n;s[i];i--)an++;
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 2428
#include <stdio.h>
#include <math.h>
int main() {
    int d, n;
    scanf("%d%d", &d, &n);
    n = n == 100 ? n + 1 : n;
    for (int i = 0; i < d; i++) {
        n *= 100;
    }
    printf("%d\n", n);
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  string s;
  cin >> s;
  cout << (s == "AAA" || s == "BBB" ? "No" : "Yes") << endl;
}


Measured memory_bytes: 3504
#include<stdio.h>
int main(void)
{
    int S, h, m, s;
    scanf("%d",&S);
    if(S<60){printf("0:0:%d\n",S);
    }
    else if(S>=60 && S<3600){
    m=S/60;
    s=S%60;
    printf("0:%d:%d\n",m,s);
    }
    else{
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    printf("%d:%d:%d\n",h,m,s);
    }
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 998244353;
 
int dx[]={-1, 0, 1, 0,1,-1,1,-1};
int dy[]={0, -1, 0, 1,1,-1,-1,1};




int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 



int n,k;
cin>>n>>k;

n%=k;
cout<<min(k-n,n)<<"\n";



}


Measured memory_bytes: 256
n, m = map(int, input().split())
cave = [[] for i in range(n+1)]
for i in range(m):
  a, b = map(int, input().split())
  cave[a].append(b)
  cave[b].append(a)

que = []
seen = [-1 for i in range(n+1)]
back = [-1 for i in range(n+1)]

seen[1] = 0
que.append(1)

while len(que) != 0:
  now = que.pop(0)
  
  for nxt in cave[now]:
    if seen[nxt] != -1:
      continue
    
    seen[nxt] = seen[now] + 1
    back[nxt] = now
    que.append(nxt)
    
flag = True
for i in back[2:]:
  if i == -1:
    flag = False

if flag == True:
  print("Yes")
  for i in back[2:]:
    print(i)
else:
  print("No")

Measured memory_bytes: 35224
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())

  p := make([]int, n)

  for i := 0; i < n; i++ {
    sc.Scan()
    p[i], _ = strconv.Atoi(sc.Text())
  }

  num := 0
  for i := 0; i < n - 2; i++ {
    if p[i + 1] > p[i] && p[i + 1] < p[i + 2] {
      num++
    }
    if p[i + 1] < p[i] && p[i + 1] > p[i + 2] {
      num++
    }
  }

  fmt.Println(num)

}



Measured memory_bytes: 640
from fractions import gcd

N = int(input())
A = [int(i) for i in input().split(" ")]

if N == 2:
    print(max(A))
    import sys
    sys.exit()

g = gcd(A[0], A[1])
lmax = 1
num = 0
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
A = A[1:] + [A[0]]
g = gcd(A[0], A[1])
for i in range(2,N):
    cand = gcd(g, A[i])
    if cand < g:
        l = int(g / cand)
        g = cand
        if lmax < l:
            lmax = l
            num = A[i]
if num == A[0]:
    A = A[1:]
    flag = False
    N -= 1
elif num == A[1]:
    A = [A[0]] + A[2:]
    flag = False
    N -= 1
else:
    flag = True
g = gcd(A[0], A[1])
for i in range(2,N):
    if A[i] == num and flag:
        flag = False
    else:
        g = gcd(g, A[i])
print(g)

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

vector<long long>A, B;
long long K;


int main(void) {

	long long N, M, tmp, ans = 0, time = 0, total = 0, b_max;


	cin >> N >> M >> K;

	vector<long long> A_sum(N+1,0), B_sum(M+1,0);


	A_sum.push_back(0);
	for (long long i = 1; i <= N; i++) {
		cin >> tmp;
		A.push_back(tmp);
		A_sum[i] = A_sum[i - 1] + tmp;
	}

	B_sum.push_back(0);
	for (long long i = 1; i <= M; i++) {
		cin >> tmp;
		B.push_back(tmp);
		B_sum[i] = B_sum[i - 1] + tmp;
	}

	ans = 0;
	long long tmp_m = M ;
	for (long long i = 0; i <= N; i++) {
		for (long long j = tmp_m; j >= 0; j--) {
			if (A_sum[i] + B_sum[j] <= K) {
				if (ans < i + j) {
					ans = i + j;
				}
				tmp_m = j;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 11532
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

string S;
list<char> L;
int Q, T;
char F, C;

int main() {

	cin >> S >> Q;

	rep(i, S.size()) L.push_back(S[i]);
	bool reversed = false;

	rep(q, Q) {
		cin >> T;
		if (T == 1) reversed = !reversed;
		else {
			cin >> F >> C;
			if ((F - '1') ^ reversed) {
				L.push_back(C);
			}
			else {
				L.push_front(C);
			}
		}
	}

	vector<char> v;
	for (auto l : L) v.push_back(l);

	if (reversed) {
		rep(i, v.size()) cout << v[v.size() - 1 - i];
	}
	else {
		for (auto vv : v) cout << vv;
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 10492
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(int argc, char const *argv[])
{
	int H,W,a,b;
	scanf("%d%d%d%d",&H,&W,&a,&b);
	printf("%d\n",(H - a) * (W - b));
	return 0;
}

Measured memory_bytes: 128
def p_d():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] * N
    ans = []

    for i in reversed(range(1, N + 1)):
        target = N // i
        v = sum([B[i * j - 1] for j in range(1, target + 1)])
        if v % 2 != A[i - 1]:
            B[i - 1] = 1
            ans.append(i)

    print(len(ans))
    if ans:
        print(" ".join(map(str, ans)))


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 96860
#pragma region Header
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b <= a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

// {waapu, h, w}
using p = tuple<int, int, int>;

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

    int h_size, w_size;
    cin >> h_size >> w_size;
    int h_from, w_from;
    cin >> h_from >> w_from;
    --h_from;
    --w_from;
    int h_to, w_to;
    cin >> h_to >> w_to;
    --h_to;
    --w_to;
    vector can_go(h_size, vector<bool>(w_size));
    rep(h, h_size)
    {
        rep(w, w_size)
        {
            char c;
            cin >> c;
            can_go[h][w] = (c == '.');
        }
    }

    // dijkstra
    int ans = -1;
    vector dist(h_size, vector<int>(w_size, 1000'000));
    priority_queue<p, vector<p>, greater<p>> pq;
    vector used(h_size, vector<bool>(w_size, false));
    pq.emplace(0, h_from, w_from);
    while (not pq.empty())
    {
        auto [cost, h, w] = pq.top();
        pq.pop();
        if (h == h_to and w == w_to)
        {
            ans = cost;
            break;
        }
        if (used[h][w])
        {
            continue;
        }
        used[h][w] = true;
        FOR(dh, -2, 2)
        {
            FOR(dw, -2, 2)
            {
                auto h_new = h + dh, w_new = w + dw;
                if (h_new < 0 or h_new >= h_size or w_new < 0 or w_new >= w_size)
                {
                    continue;
                }
                if (not can_go[h_new][w_new] or used[h_new][w_new])
                {
                    continue;
                }
                int dcost = (abs(dh) + abs(dw) > 1);
                if (not chmin(dist[h_new][w_new], cost + dcost))
                {
                    continue;
                }
                pq.emplace(cost + dcost, h_new, w_new);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8380
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();

	    int min=Integer.MAX_VALUE;
	    for (int i=0; i<=Math.floorDiv(N, 9);i++) {
	    	int nN=9*i;
	    	int sN=6*Math.floorDiv(N-nN, 6);
	    	int oN=N-nN-sN;
	    	String nNs=Nsin(nN,9);
	    	String sNs=Nsin(sN,6);
	    	int v=oN;
	    	for (int j=0; j<nNs.length();j++) {
	    		int m=Integer.valueOf(nNs.substring(j,j+1));
	    		v+=m;
	    	}
	    	for (int j=0; j<sNs.length();j++) {
	    		int m=Integer.valueOf(sNs.substring(j,j+1));
	    		v+=m;
	    	}
	        if(v<min)min=v;
	    }

	    System.out.println(min);
//        if (f) {
//    	    String a=Sq.substring(0, S.lastIndexOf(T)) + T + Sq.substring(S.lastIndexOf(T)+T.length());
//    	    System.out.print(a.replaceAll("\\?", "a"));
//        }else {
//        	System.out.print("UNRESTORABLE");
//        }
	}

	// s進数で表した時の文字列
	public static String Nsin(int n, int s) {
		if(n==0) return "0";

		StringBuffer sb=new StringBuffer();
		while(n!=0) {
			int a=n%s;
			sb.append(a);
			n=(n-a)/s;
		}

		return sb.reverse().toString();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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



int main() {
   long long n, k;
   cin >> n >> k;
   vector<int> a(n);
   for (int i=0; i<n; i++) {
      cin >> a[i];
   }
   vector<int> s;
   vector<int> ord(n+1,-1);
   int c = 1, l = 0;

   int v = 1;
   while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
   }
   c = s.size() - ord[v];
   l = ord[v];

   if (k < l) cout << s[k] << endl;
   else {
      k -= l;
      k %= c;
      cout << s[l+k] << endl;
   }
   return 0;
}

Measured memory_bytes: 5892
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int a = 0;
    for(int i = 0; i < 6; i++){
        char c = getchar();
        if(c-'0'==1) a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
#便利そうなので置いとく
import fractions 
import functools 
#再帰関数を使うときは、再帰上限を上げておこうね！
import sys
sys.setrecursionlimit(200000000)
# my functions here!
def pin(type=int):
    return map(type,input().split())
"""
------------------------------------------------------------------
|OBJECTIVE:                                                      |
|Educatinal DP contest("https://atcoder.jp/contests/dp")を解こう!|
------------------------------------------------------------------
"""
#solution:
INF = float("inf")
"""
|#遷移式を考える
|   つまり、漸化式みたいに i回目までの結果を保存して、i+1回目の評価を行う
"""
def Flog_1(N,H):
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    dp[1]=abs(H[1]-H[0])#ほら、"2段前"がないから…
    for i in range(2,N):
        hop1=dp[i-1]+abs(H[i-1]-H[i]) 
        hop2=dp[i-2]+abs(H[i-2]-H[i]) 
        #print(hop1,hop2)
        dp[i]=hop1 if hop1<hop2 else hop2
    return dp
def Flog_1_Another(N,H):#"配る"DP
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    for i in range(0,N):
        for k in [1,2]:
            if i+k <N:
                dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    return dp
"""
|# Flog1との違い:飛ぶ段数に（1個か2個という）制限がない
|    
"""    
def Flog_2(N,K,H):#pypy回答でなんとかおｋ
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0,default position
    for i in range(1,N):#k段前から飛んでくることを考えよ
        temp = INF
        for k in range(1,K+1):
            if i-k < 0:break
            else:
                #print("*",i-k)
                temp = min(temp,(dp[i-k]+abs(H[i-k]-H[i])))
                
        dp[i]=temp
        #print("*",dp)
    return dp
def Flog_2_Another(N,K,H):#"配る"DP
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    for i in range(0,N):
        for k in range(1,K+1):
            if i+k <N:
                dp[i+k]=min(dp[i+k],dp[i]+abs(H[i+k]-H[i]))
    return dp
def Flog_2_YETAnother(N,K,H):#python提出やりたい再帰関数やりたいよお
    #つまり、つまりf2Y(N,K,H)->f2Y((0 or enough value to be default),K,H)に持っていく関数を書くぞ
    if N == 1:
        return 0
    else:
        map(min,[Flog_2_YETAnother(N-i,K,H) for i in range(1,N+1)])
    #詰んだ

def vacation(N):
    #これは二次元で書けばいいですね？
    dp=[[0]*3 for i in range(N)]#[i]+1日目にある行動をした時にできる幸福度の最大値 
    dp[0]=list(pin())
    #print(dp[0])
    for i in range(1,N):
        #めんどいのでfor分かかない、ごめんね
        temp=list(pin())
       # print("*",temp)
        dp[i][0]= max(dp[i-1][1],dp[i-1][2])+temp[0]
        dp[i][1]= max(dp[i-1][2],dp[i-1][0])+temp[1]
        dp[i][2]= max(dp[i-1][0],dp[i-1][1])+temp[2]
        #print(dp[i])
    return max(dp[-1])
#input
N,=pin()

#output
print(vacation(N))

Measured memory_bytes: 24756
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    if (A < 1 or A > 9 or B < 1 or B > 9){
        cout << -1 << endl;
    }
    else{
        cout << A*B << endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define txt                        \
    freopen("ip.txt", "r", stdin); \
    freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i, n) for (int i = 0; i < (int)n; i++)
#define rep(i, k, n) for (int i = k; k < (int)n ? i < (int)n : i > (int)n; k < (int)n ? i += 1 : i -= 1)
#define quickie                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define div2(a) (!(a & 1))
#define deb(x) cout << (#x) << " " << (x) << "\n";
#define newl cout << "\n"
#define all(s) s.begin(), s.end()
#define pi 3.14159265358979323846
#define fp(x) fixed << setprecision(x) <<
template <class T>
T mod(T a)
{
    if (a < 0)
    {
        a += 1000000007;
    }
    return a % 1000000007;
}
template <class T>
T addmod(T a, T b)
{
    return (mod(a) + mod(b)) % 1000000007;
}
template <class T>
T prodmod(T a, T b)
{
    return (mod(a) * mod(b)) % 1000000007;
}
template <class T>
T bin_exp(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b % 2 == 0)
        res = bin_exp(a * a, b / 2);
    else
    {
        res *= a;
        temp = bin_exp(a, --b);
    }
    return res * temp;
}
template <class T>
T bin_expmod(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b % 2 == 0)
        res = bin_expmod(prodmod(a, a), b / 2);
    else
    {
        res = prodmod(a, res);
        temp = bin_exp(a, --b);
    }
    return prodmod(res, temp);
}

template <class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template <class T>
int sumAllInts(T n)
{
    int a = 1;
    int su = 0;
    while (n)
    {
        su += n % 10;
        n /= 10;
    }
    return su;
}
template <class T>
void split(char c, T s)
{
    int n = s.size();
    int i = 0;
    while ((cout << s[i], i += 1) && (i < n) && (cout << c << ' '))
        ;
}
void print(vi &vec)
{
    for (int i = 0; i < vec.size(); i++)
    {
        cout << vec[i] << " ";
    }
}

void solve()
{
    int n,t;
    cin>>n>>t;
    int temp;cin>>temp;
    ll ans = t;
    fo(i,n-1){
        int te; cin>>te;
        int diff = te - temp;
        ans+=min(diff,t);
        temp = te;
    }
    cout<<ans;
}
int main()
{
    quickie;
    //txt;
    int t = 1;
    while (t--)
    {
        solve();
        newl;
    }
    return 0;
}

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

string solve(int m, int n)
{
	vector<int> f(20000, 0);
	m = abs(m);
	n = abs(n);
	if (m > n) swap(m, n);
	
	int t = m * m + n * n;
	
	for (int i = 0; i * i <= t; i++){
		for (int j = i; i * i + j * j <= t; j++){
			f[i * i + j * j] = 1;
		}
	}
	
	for (int i = 0; i <= t; i++){
		for (int j = i; i * i + j * j <= t; j++){
			int s = i * i + j * j;
			if (s == 0) continue;
			if (t % s) continue;
			if (i == 0 && j == 1) continue;
			if (i == m && j == n) continue;
			if (f[t / s]) return "C";
		}
	}
	
	return "P";
}

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++){
		int m, n;
		cin >> m >> n;
		cout << solve(m, n) << endl;
	}
}

Measured memory_bytes: 1272
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;

	for (int i = 0; i < 4; i++)
	{
		cout << s[i];
	}

	cout << " ";

	for (int i = 4; i < s.size(); i++)
	{
		cout << s[i];
	}

	cout << endl;

	
	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> x(N), y(N);
    rep(i, N) {
        cin >> A[i];
        rep(j, A[i]) {
            x[i].push_back(0);
            y[i].push_back(0);
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    /*rep(i, N) {
        cout << A[i];
        rep(j, A[i]) {
            cout << x[i][j] << y[i][j];
        }
    }*/
    int ans = 0;
    rep(i, 1 << N) {
        bool f = true;
        int s = 0;
        rep(j, N) {
            if ((i >> j & 1) == 0) continue;
            s++;
            rep(k, A[j]) {
                if (y[j][k] == 1 && (i >> x[j][k] & 1) == 0) f = false;
                if (y[j][k] == 0 && (i >> x[j][k] & 1) == 1) f = false;
            }
        }
        if (f) ans = max(ans, s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import math

def calc(x1, x2):
    ans = 0
    for i in range(len(x1)):
        ans += (x1[i]-x2[i])**2
    return float(math.sqrt(ans))

def solve():
    N, D = list(map(int, input().split()))
    X = []
    for i in range(N):
        X.append(list(map(int, input().split())))

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ret = calc(X[i], X[j])
            if ret.is_integer():
                ans += 1

    print(ans)



if __name__ == "__main__":
    solve()


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

int main(){
   int a,b,i;
   string s;
   cin>>a>>b;
   cin>>s;
   for(i=0;i<=a+b;i++)
   {
       if(i==a&&s[i]!='-')break;
       if(i!=a&&s[i]=='-')break;
   }
   if(i!=a+b+1)cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 888
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long ll;
typedef std::pair<int, int> pii;

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 1e5 + 5;
 
int n;
int m;
pii a[maxn];
long long sum[maxn];


void exec()
{
    read(n);
    for (int i = 1; i <= n; ++ i) {
        read(a[i].first);
        a[i].second = i;
    }
    std::sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++ i) {
        sum[i] = sum[i - 1] + a[i].first;
    }
    int ans = 0;
    for (int i = n; i; -- i) {
        if (2 * sum[i] >= a[i + 1].first) ++ ans;
        else break;
    }
    write(ans);
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll x, y;
  cin >> x >> y;
  if(x % y == 0) cout << -1 << endl;
  else{
    cout << x << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;

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

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n,w;
    cin >> n >> w;
    if(n == w) cout << "Yes" << endl;
    else cout << "No" << endl;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
max_i=0
ret = 0
p_s=sum(p[0:k])
s_max=p_s
for i in range(n-k):
  p_s=p_s-p[i]+p[i+k]
  if s_max<p_s:
    s_max=p_s

print(s_max/2+k/2)

Measured memory_bytes: 25060
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    #
    n, k = map(int, input().strip().split())  # """ 街数n, 移動回数k """
    a = list(map(lambda x: int(x) - 1, input().strip().split()))  # """ 転送先 : 街i から街a[i]"""

    #
    eprint("a", end=':\n')
    eprint(a)
    #
    path = []
    visitedlist = [False for _ in range(n)]
    pos = 0
    cnt=0   # 現在位置posに来るまでの，「移動回数」

    while True:
        if cnt==k:
            print(pos+1)
            return
        if visitedlist[pos]:
            start = pos
            break
        cnt+=1
        path.append(pos)
        visitedlist[pos] = True
        pos = a[pos]

    eprint('path ', end=':\n')
    eprint(path)

    for i in range(len(path)):
        if path[i] == start:
            cycle = path[i:]

    eprint('cycle ',end=':\n')
    eprint(cycle)

    m=len(cycle)
    cnt1=k-cnt
    cnt2=cnt1%m
    print(cycle[cnt2]+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 151340
N = int(input())
A = list(map(int, input().split()))

A_max = max(A)
#A = sorted(A)
dp = [True for i in range(A_max)]
counter = [0 for i in range(A_max)]
# count
for a in A:
    counter[a - 1] += 1

for a in A:
    multiple = a + a
    while (multiple <= A_max):
        dp[multiple - 1] = False
        multiple = multiple + a
ans = 0

for i in A:
    if dp[i - 1] and counter[i - 1] <= 1:
        ans += 1

print(ans)

        

Measured memory_bytes: 35028
#include <stdio.h>
#include <stdlib.h>
#define N 200000
int max(int, int);
int min(int, int);

int main(){
  int i, j, n, R[N], maxv, minv;
  scanf("%d",&n);
  if(n < 2 || n > N)exit(1);
  for(i = 0; i <= n - 1; i++){
    scanf("%d",&R[i]);
    if(R[i] < 1 || R[i] > 10*10*10*10*10*10*10*10*10)exit(2);
  }
  minv = R[0];
  maxv = R[1] - R[0];
  for(j = 1; j <= n - 1; j++){
    maxv = max(maxv, R[j] - minv);
    minv = min(minv, R[j]);
  }
  printf("%d\n",maxv);
  return 0;
}

int max(int maxv, int R1){
  if(maxv > R1)return maxv;
  else return R1;
}

int min(int minv, int R2){
  if(minv < R2)return minv;
  else return R2;
}



Measured memory_bytes: 2636
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

int main()
{
	int n;
	std::cin >> n;
	
	std::vector<int> a(n);
	std::vector<int> b(n);
	
	double d1 = 0;
	double d2 = 0;
	double d3 = 0;
	double dm = 0;
	
	for (int i = 0; i < n; ++i)
	{
		std::cin >> a[i];
	}
		
	for (int i = 0; i < n; ++i)
	{
		std::cin >> b[i];
	}
		
	for (int i = 0; i < n; ++i)
	{
		double ab = a[i] - b[i];
		
		d1 += std::abs(ab);
		d2 += std::pow(std::abs(ab), 2);
		d3 += std::pow(std::abs(ab), 3);
		dm = std::max(dm, std::abs(ab));
	}
	
	d2 = std::sqrt(d2);
	d3 = std::pow(d3, 0.33333333333333);
	
	std::cout << std::fixed << std::setprecision(5);
	std::cout << d1 << "\n" << d2 << "\n" << d3 << "\n" << dm << std::endl;
	
	return 0;
}


Measured memory_bytes: 3468
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n,a,b;
    while(cin>>n>>a>>b){
        cout<<min(a,b)<<" "<<(a+b>n?(a+b)-n:0)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	ll T[1001] = {};
	ll A[1001] = {};
	T[0] = 1;
	A[0] = 1;

	repe(i, 1, N) {
		cin >> T[i] >> A[i];
	}
	ll x = 1, y = 1;
	repe(i, 1, N) {
		ll b = max((x - 1) / T[i] + 1, (y - 1) / A[i] + 1);
		x = b * T[i];
		y = b * A[i];
	}
	cout << x + y << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

int n;

int to[200005];
int head[100005];
int next[200005];
int cost[200005];
long long d[100005];
const long long INF = 1000000000000000;
int x[100005];
int y[100005];
long long ans[100005];

int dfs(int crt){
    int edge = head[crt];
    while (edge != -1){
        if (d[to[edge]] > d[crt] + cost[edge]){
            d[to[edge]] = d[crt] + cost[edge];
            dfs(to[edge]);
        }
        edge = next[edge];
    }
    return 0;
}

int main(void){
    scanf("%d", &n);
    int a, b, c;
    for (int i = 1; i <= n; i++){
        head[i] = -1;
        d[i] = INF;
    }
    for (int i = 0; i < (n-1)*2; i += 2){
        scanf("%d %d %d", &a, &b, &c);
        next[i] = head[a];
        head[a] = i;
        to[i] = b;
        cost[i] = c;

        next[i+1] = head[b];
        head[b] = i+1;
        to[i+1] = a;
        cost[i+1] = c;
    }
    int q, k;
    scanf("%d %d", &q, &k);
    d[k] = 0;
    dfs(k);
    for (int i = 0; i < q; i++){
        scanf("%d %d", &x[i], &y[i]);
        ans[i] = d[x[i]]+d[y[i]];
    }

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


    return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s1,s2;
  cin>>s1>>s2;
  for(int i=0;i<n;i++)
  {
    cout<<s1[i]<<s2[i];
  }
  return 0;
}

Measured memory_bytes: 256
/*
** Vishal Raj Roy
** Indian Institute of Technology Kharagpur
*/

#include <bits/stdc++.h>

using namespace std;

#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define gcd(X,Y) __gcd(X,Y)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define ifpresent(CON,VAL) (CON.find(VAL) != CON.end())
#define all(x) x.begin(),x.end()
#define at(X,N) get<N>(X)
#define ins insert
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define count_ones __builtin_popcountl
#define nl cout<<"\n";
#define name(X) (#X)
#define watch(X) cout << (#X) << " is " << (X) << "\n"
#define sqr(x) ((x)*(x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mem(x,val) memset((x),(val),sizeof(x))
#define rite(X) freopen(X,"w",stdout)
#define read(X) freopen(X,"r",stdin)
//FOR(i,1,10) gives 1,2,3,....,9 and FOR(i,10,1) gives 9,8,....,1 also FOR(it, end(v), begin(v)) and FOR(it, begin(v), end(v))
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define SEL(X,C) for( auto & X : C )
#define ima INT_MAX
#define imi INT_MIN
#define lma LLONG_MAX
#define lmi LLONG_MIN
using st = string; typedef long long int li; typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef tuple<int,int> i2; typedef tuple<int,int,int> i3; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<i2> vi2; typedef vector<i3> vi3; typedef vector<iii> viii; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef pair<li, li> ll; typedef pair<li, ll> lll; typedef tuple<li,li> l2; typedef tuple<li,li,li> l3; typedef vector<li> vl; typedef vector<ll> vll; typedef vector<l2> vl2; typedef vector<l3> vl3; typedef vector<lll> vlll; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef double db; typedef complex<db> cd; typedef vector<cd> vcd; template <class S> using ve = vector<S>; template <class S> using gr = greater<S>; template <class S> using le = less<S>;

const double pi = 2 * acos(0.0);
const int oo = 0x3f3f3f3f; // don't use for long long
const double inf = 1.0/0.0;


int main() {
    ios_base::sync_with_stdio(0);
    int r; cin>>r; cout<<3*r*r<<"\n";
    return 0;
}


Measured memory_bytes: 256
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,l,r,m,now,ans,ai
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    call merge_sort(a,1,n)
    ans=0
    do i=1,n-2
        ai=a(i)
        do j=i+1,n-1
            now = ai+a(j)
            l=j
            r=n+1

            do while (r-l > 1)
                m = (l+r)/2
                if (a(m) < now) then
                    l=m
                else
                    r=m
                end if
            end do
            ans=ans+l-j
        end do
    end do
    print'(i0)', ans
contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst,lst
        integer(int32):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst, mdl, lst
        integer(int32),allocatable:: tmp(:)
        integer(int32):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(int32),intent(inout):: x,y
        integer(int32):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program name

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(lcm(a,b));
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 22868
/*
      author  : nishi5451
      created : 14.08.2020 14:15:14
*/

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


int main(){
    int n;
    cin >> n;
    int res = 1;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    while(1){
        if(res*2 > n){
            break;
        }
        res*=2;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3616
// ------------------------------------
// Date:2018/ 3/31
// Problem:Range Product _ d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  string ans;
  CIN(a, b);
  if ((a > 0 && b > 0)) ans = "Positive";
  else if (a <= 0 && b >= 0) ans = "Zero";
  else {
    if ((b - a + 1) & 1) ans = "Negative";
    else ans = "Positive";
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	long long N,M;
	cin>>N>>M;
	
	vector<long long> A(N);
	
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	sort(A.begin(),A.end());
	
	int ok = 0;
	int ng = 200001;
	
	while(ng-ok>1){
		int mid = (ok+ng)/2;
		long long cnt = 0;
		for(int j=0;j<N;j++){
			int ind = distance(A.begin(),lower_bound(A.begin(),A.end(),mid-A[j]));
			ind = N-ind;
			cnt += ind;//*2;
		}
		if(cnt >= M)ok = mid;
		else ng = mid;
	}
	//cout<<ok<<endl;
	ok ++;
	vector<long long> sum(N+1,0);
	for(int i=0;i<N;i++){
		sum[i+1] = A[i];
		sum[i+1] += sum[i];
	}
	
	long long ans = 0;
	
	for(int i=0;i<N;i++){
		int ind = distance(A.begin(),lower_bound(A.begin(),A.end(),ok-A[i]));
		ind = N-ind;
		ans += (sum[N] - sum[N-ind]);
		ans += A[i] * ind;
		M -= ind;
	}
	//cout<<ans<<endl;
	
	ans += (ok-1)*M;
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> yoko(h,vector<int>(w,0)),tate(h,vector<int>(w,0));
    vector<string> s(h);
    for (int i = 0;i < h; i++)
    {
        cin >> s[i];
    }

    for (int i = 0; i < h;i++)
    {
        int start = 0;
        for (int j = 0; j < w;j++){
            if(s[i][j]=='.'){
                yoko[i][start]++;
                if (j == w - 1){
                    for (int k = start; k < w;k++)
                    {
                        yoko[i][k] = yoko[i][start];
                    }
                }
            }else{
                for (int k = start; k < j;k++){
                    yoko[i][k] = yoko[i][start];
                }
                start = j+1;
            }

        }     
    }
    for (int i = 0; i < w; i++)
    {
        int start = 0;
        for (int j = 0; j < h; j++)
        {
            if (s[j][i] == '.')
            {
                tate[start][i]++;
                if (j == h - 1)
                {
                    for (int k = start; k < h; k++)
                    {
                        tate[k][i] = tate[start][i];
                    }
                }
            }
            else
            {
                for (int k = start; k < j; k++)
                {
                    tate[k][i] = tate[start][i];
                }
                start = j + 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h;i++){
        for (int j = 0; j < w; j++){
            if(tate[i][j]!=0&&yoko[i][j]!=0){
                ans = max(ans, tate[i][j] + yoko[i][j] - 1);
            }
        }
    }
        cout << ans << endl;
}

Measured memory_bytes: 35712
_MULTITEST = False
##
def solve():
    n = int(input())
    k = (n // 1000) + (1 if n % 1000 != 0 else 0)
    print(k*1000 - n)

##
if __name__ == "__main__":
    t = (int(input()) if _MULTITEST else 1)
    for tt in range(t):
        solve()

Measured memory_bytes: 61648