akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long

typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

struct UF{
    int N;
    vint par,sz;
    void init(int n){
        N=n;
        par.resize(N);
        sz.resize(N);
        for(int i=0;i<N;i++)par[i]=i,sz[i]=1;
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int N,M;
UF uf;
signed main(){
    cin>>N>>M;
    uf.init(N);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }

    int x=0,y=0;
    rep(i,N)if(uf.find(i)==i){
        if(uf.sz[uf.find(i)]==1)y++;
        else x++;
    }

    cout<<abs(x-y)<<endl;
    return 0;
}

Measured memory_bytes: 1212
n = int(input())
a = [int(i) for i in input().split()]
na = [abs(i) for i in a]
m = min(na)
s = sum(na)
cnt = 0

for i in a:
    if i < 0:
        cnt += 1
if cnt%2 == 0 or m == 0:
    ans = s
else:
    ans = s-2*m

print(ans)

Measured memory_bytes: 14252
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    slen = len(s)

    firstx = -1
    lastz = slen

    for i in range(slen):
        if firstx == -1 and s[i] == 'A':
            firstx = i
        if s[i] == 'Z':
            lastz = i
    
    print(lastz - firstx +1)
    
solve()


Measured memory_bytes: 3516
a = []
for i in range(3):
    val = list(map(int, input().split()))
    a.append(val)

n = int(input())

v = []
for j in range(n):
    v.append(int(input()))

for k in v:
    for i in range(3):
        for j in range(3):
            if a[i][j] == k:
                a[i][j] = -1

bingo = False
for i in range(3):
    if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
        bingo = True
    if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
        bingo = True

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    bingo = True
elif a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    bingo = True

if bingo:
    print('Yes')
else:
    print('No')



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

int main(){
	int a, b;
	while(cin >> a >> b){
		if(a+b<10) cout << "1" << endl;
		else if(a+b<100) cout << "2" <<endl;
		else if(a+b<1000) cout << "3" <<endl;
		else if(a+b<10000) cout << "4" <<endl;
		else if(a+b<100000) cout << "5" <<endl;
		else if(a+b<1000000) cout << "6" <<endl;
		else if(a+b<10000000) cout << "7" <<endl;
	}
}

Measured memory_bytes: 1156
from collections import Counter, deque

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
con = Counter(t)
ans = con['r'] * p + con['s'] * r + con['p'] * s
dic = {'r': p, 's': r, 'p': s}
for i in range(k):
    target = list(t[i::k])
    hp = 0
    count = 1
    for j in range(len(target)):
        hn = target[j]
        if hn == hp:
            count += 1
        elif count > 1:
            ans -= count // 2 * dic[hp]
            count = 1
        hp = hn
    else:
        ans -= count // 2 * dic[hp]
print(ans)


Measured memory_bytes: 4340
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;

  int total = P + Q + R;
  int ans = min(min(total -P, total -Q), total -R);

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>

typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}
int main(){
	ll a,b;
	cin>>a>>b;
	ll ans=1;
	while(a<=b){
		if(2*a<=b){
			a*=2;
			ans++;
		}
		if(a*2>b){
			break;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3632
S = list(input())
Q = int(input())
Query = [list(input().split()) for i in range(Q)]

ans = S
X = []
Y = []
state = 1

for k in range(Q):
    if Query[k][0]=="1":
        state *= -1
    elif Query[k][0]=="2":
        if Query[k][1]=="1":
            if state == 1:
                X.append(Query[k][2])
            else:
                Y.append(Query[k][2])
        else:
            if state == 1:
                Y.append(Query[k][2])
            else:
                X.append(Query[k][2])

if state == 1:
    X = list(reversed(X))
    ans = X + ans + Y
else:
    Y = list(reversed(Y))
    ans = list(reversed(ans))
    ans = Y + ans + X

print("".join(ans))

Measured memory_bytes: 36576
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int yakusu(int x){ //O(n)
    int cnt = 0;
    for(int i = 1; i <= x; i++){
        if(x % i == 0)cnt++;
    }
    return cnt;
}


int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i+=2){
        if(yakusu(i) == 8)cnt++;
    }
    
    cout << cnt << endl;

}

Measured memory_bytes: 3588
#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 h, w;
int c[10][10];
int a[210][210];

void warshall_floyd() {
    int n = 10;
    for (int k = 0; k < n; k++)
	for (int i = 0; i < n; i++)
	    for (int j = 0; j < n; j++)
		c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
}

int solve() {
    warshall_floyd();
    int res = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (0 <= a[i][j] && a[i][j] != 1) {
                res += c[a[i][j]][1];
            }
        }
    }
    return res;
}

void input() {
    cin >> h >> w;
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++)
            cin >> c[i][j];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> a[i][j];
}

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

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


Measured memory_bytes: 384
n = int(input())
N = 55556

memo = [1] * N
memo[0] = 0
memo[1] = 0

for i in range(2, N):
    if memo[i]:
        for j in range(2, N):
            if i * j >= N:
                break
            memo[i*j] = 0

ans = []
for i in range(2, N):
    if memo[i]:
        if i % 5 == 1:
            ans.append(str(i))

print(' '.join(ans[:n]))




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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int a, b;
  cin >> a >> b;
  reps(x, 10000) {
    if (a == x * 8 / 100 && b == x * 10 / 100) {
      cout << x << endl;
      return;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
/**
 *  author: Behradm
 *  Created: 2020.06.27 16:30:10
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a;
  cin >> a;
  cout << a + a * a + a * a * a << '\n';
  return 0;
}


Measured memory_bytes: 3636
namespace VainZero.Procon.FSharp

open System
open System.Collections.Generic

[<AutoOpen>]
module Operators =
  let read f = Console.ReadLine().Split([|' '|]) |> Array.map f

module Program =
  [<EntryPoint>]
  let main _ =
    let [|a; b; c|] = read int

    let rec gcd m n =
      if m < n then
        gcd n m
      else if n = 0 then
        m
      else
        gcd (m % n) n

    let calc () =
      // a * x + b * y = c となる (x, y) がある
      // ⇔ gcd(a, b) | c
      let g = gcd a b
      c % g = 0

    printfn "%s" (if calc () then "YES" else "NO")

    0


Measured memory_bytes: 14044
#!/usr/bin/env python3
import sys
import functools
INF = float("inf")

MOD = 1000000007  # type: int


class Combination(object):
    """
    組み合わせを求める。
    cmbで使いうる最大のNまでを前処理で準備。
    """

    def __init__(self, N, mod=10**9+7):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k]*self.finv[n-k] % self.MOD) % self.MOD


def solve(N: int, K: int, A: "List[int]"):

    cmb = Combination(N, mod=MOD)

    A.sort()

    ans = 0
    for i in range(N):
        # A[i]が最大として選ばれるケース
        if i >= K-1:
            ans += cmb(i, K-1)*A[i]
            ans %= MOD

        # A[i]が最小として選ばれるケース
        if N-i-1 >= K-1:
            ans -= cmb(N-i-1, K-1)*A[i]
            ans %= MOD
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61580
N = int(input())


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


prime = get_sieve_of_eratosthenes(55555)
prime = [str(i) for i in prime if i % 5 == 1]

print(' '.join(prime[:N]))

Measured memory_bytes: 4468
#include <stdio.h>

int isprime( int n ) {
	int i;
	for ( i = 2 ; i * i <= n; i++) {
		if( n % i == 0) return 0;
	}
	return 1;
}

int main() {
	int i, n, p1, q1;
	while(1) {
		scanf("%d", &n);
		if(n == 0) break;
		for( i = n; i > 1; i--) {
			if(isprime(i) == 1 && isprime(i - 2) == 1) break;
		}
		p1 = i - 2;
		q1 = i;
		printf("%d %d\n", p1, q1);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    if(A == 0 || B == 0) {
        cout << "Zero";
        return 0;
    }
    if(B < 0) {
        if((B - A) % 2 == 1) {
            cout << "Positive";
            return 0;
        } else {
            cout << "Negative";
            return 0;
        }
    }
    if(A < 0) {
        cout << "Zero";
        return 0;
    }
    cout << "Positive";
    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 K = sc.nextInt();
        int L;
        int res = -1;
        if (K % 7 == 0) {
            L = 9 * K / 7;
        } else {
            L = 9 * K;
        }
        if (!(L % 2 == 0 || L % 5 == 0)) {
            int now = 10;
            for (int i = 1; i <= L; i++) {
                if (now % L == 1) {
                    res = i;
                    break;
                }
                now = (now % L) * 10;
            }
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 35536
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define spause() system("pause")

using namespace std;
typedef long long llong;
typedef pair<int, int> prdd;
typedef map<int, int> mpdd;

int n, svs = -1;
int ns[3], sv[3];
bool ans = true;

int main()
{
	scanf("%d", &n);
	if (n % 3 != 0)
		for (int i = 1; i <= n; i++)
		{
			int tp;
			scanf("%d", &tp);
			if (tp != 0)
				ans = false;
		}
	else
	{
		for (int i = 1; i <= n; i++)
		{
			int tp, ap = 0;
			scanf("%d", &tp);
			for (int i = 0; i <= svs; i++)
				if (sv[i] == tp)
				{
					ns[i]++;
					ap = 1;
				}
			if (ap == 0)
				if (svs < 2)
				{
					sv[++svs] = tp;
					ns[svs]++;
				}
				else
				{
					ans = false;
				}
		}
		if (ans)
			if (svs == 2)
				ans = ((sv[0] ^ sv[1] ^ sv[2]) == 0 && (ns[0] == ns[1] && ns[1] == ns[2]));
			else if (svs == 1)
				ans = ((sv[1] == 0 && ns[1] * 2 == ns[0]) || (sv[0] == 0 && ns[0] * 2 == ns[1]));
			else
				ans = (sv[0] == 0);
	}
	if (ans)
		printf("Yes");
	else
		printf("No");
	//spause();
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    const i64 mod=1000'000'007;
    i64 N,M;
    cin >> N >> M;
    vector<i64> A(N),B(M);

    rep(i,0,N) cin >> A[i];
    rep(i,0,M) cin >> B[i];

    vector<vector<bool>> used(N,vector<bool>(M));
    vector<bool> used2(N*M+1);
    rep(i,0,N){
        rep(j,0,M){
            if(A[i]==B[j]){
                used[i][j]=true;
                if(used2[A[i]]){
                    cout << 0 << endl;
                    return;
                }
                used2[A[i]]=true;
            }
        }
    }

    vector<vector<i64>> g(N,vector<i64>(M,inf64));
    rep(i,0,N){
        rep(j,0,M){
            g[i][j]=min(g[i][j],A[i]);
        }
    }
    rep(j,0,M){
        rep(i,0,N){
            g[i][j]=min(g[i][j],B[j]);
        }
    }

    vector<i64> v(N*M+1);

    rep(i,0,N){
        rep(j,0,M){
            ++v[g[i][j]];
        }
    }

    map<i64,i64> mp;
    rep(i,0,N){
        rep(j,0,M) {
            ++mp[g[i][j]];
        }
    }

    i64 ans=1,rem=0;
    for(i64 i=N*M; i>=1; --i){
        rem+=v[i];
        if (rem == 0) {
            print(i);
            cout << 0 << endl;
            return;
        }
        if(used2[i]){
        }else if(mp.find(i)!=mp.end()){
            ans *= mp[i];
            ans %= mod;
        }else {
            ans *= rem;
            ans %= mod;
        }
        --rem;

    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 16384
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S, &T)

	var cnt int = len(T)
	var cnt_save int = len(T)

	for i := 0; i <= len(S) - len(T); i++{
		cnt = len(T)
			for j := 0; j < len(T); j++{
				if S[i + j:i + j + 1] == T[j:j + 1]{
					cnt--;
				}
			}
		if cnt_save > cnt{
			cnt_save = cnt;
		}
	}

	fmt.Println(cnt_save)

}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  int n,k; cin >> n >> k;
  string s; cin >> s;
  int boundary_num = 0;
  rep(i,s.size()-1){
    if(s.at(i) != s.at(i+1)){
      boundary_num++;
    }
  }
  if(boundary_num/2+boundary_num%2 <= k){
    cout << s.size() - 1 << endl;
  }
  else{
    cout << s.size()-1-boundary_num+2*k << endl;
  }
  return 0;
}


Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    aa = sorted([LI() for _ in range(n)])
    r = 0
    for a,b in aa:
        t = min(b,m)
        r += a * t
        m -= t

    return r


print(main())




Measured memory_bytes: 24896
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
using namespace std;
#define int long long
struct str{
	int x,y;
}st[150009];
bool cmp(str a,str b){
	return a.y>b.y;
}
map<int,int> mp;
stack<int> s;
signed main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>st[i].x>>st[i].y;
	}
	sort(st+1,st+1+n,cmp);
	int maxn=0;
	int type=0;
	int sum=0;
	for(int i=1;i<=k;i++){
		if(!mp[st[i].x]){
			mp[st[i].x]=1;
			type++;
		}
		else
			s.push(st[i].y);
		sum+=st[i].y;
		maxn=max(maxn,type*type+sum);	
	}
	for(int i=k+1;i<=n;i++){
		if(s.empty())
			break;
		if(mp[st[i].x])
			continue;
		mp[st[i].x]=1;
		type++;
		sum-=s.top();
		s.pop();
		sum+=st[i].y;
		maxn=max(maxn,type*type+sum);	
	}
	cout<<maxn;
	return 0;
}

Measured memory_bytes: 6016
#include <stdio.h>

int main(){
  int n,i,j,b=0,m=0,a;
  scanf("%d",&n);
  for(i=1; i<=n; i++){
    if(i%10==0)m+=1;
    a=i;
    for(j=0; j<m; j++){
      if(a%10==3){
	b=1;
	break;
      } 
      a/=10;
    }
    if(i%3==0||b)printf(" %d",i);
    b=0;
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

class Main{
	static class System{
		private static final InputStream in=java.lang.System.in;
		private static final PrintWriter out=new PrintWriter(java.lang.System.out,false);
	}
	public static void main(String[]$){
		new Main().solve();
		System.out.flush();
	}
	static Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static int gInt(){return s.nextInt();}
	static long gLong(){return s.nextLong();}
	static long gDouble(){return s.nextLong();}

	static IntStream ints(int n){return REPS(n).map(i->gInt());}
	static Stream<String> strs(int n){return REPS(n).mapToObj(i->s.next());}

	private void solve(){
		int n=gInt(),m=gInt();
		int v=1900*m+100*(n-m);
		int k=1;
		for(int i=0;i<m;++i) {
			k*=2;
		}
		System.out.println(v*k);
	}
}

Measured memory_bytes: 23636
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, k;
	string s; cin >> n >> s >> k;
	char x = s[k - 1];
	rep(i, n)
	{
		if (s[i] != x)cout << '*';
		else cout << x;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(void){
  char str[201] = {};
  char tmp_str[201] = {};
  int shuff_count, shuff_num, length;
  
  while(1){
      scanf("%s %d", str, &shuff_count);
      if(strcmp(str, "-") == 0){
          break;
      }
      for(int i=0; i<shuff_count; i++){
          scanf("%d", &shuff_num);
          length = strlen(str);
          strcpy(tmp_str, str);
          strcpy(str, &tmp_str[shuff_num]);
          strncpy(str+(length-shuff_num), tmp_str, shuff_num);
      }
      printf("%s\n", str);
  }
  
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

string s;

signed main()
{
    cin >> s;
    
    int len = s.length();
    int start = 0, end = len - 1;
    while (s[start] != 'A') start++;
    while (s[end] != 'Z') end--;
    
    cout << end - start + 1 << endl;
}


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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> cnt(n, 0);
    for (int i = 0; i < q; i++){
        int x;
        cin >> x;
        x--;
        cnt[x]++;
    }
    for (int i = 0; i < n; i++){
        if (cnt[i] > q - k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
/*input
5
10 10 10 10 10
*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

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

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

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

/******************************** START *********************************/
const int N = 405;
vector < ll > v;
ll dp[N][N];

int main()
{
  ifalse;
  int n;
  cin >> n;
  v.resize(n + 1);
  for(int i = 0; i < n; i ++) {
    cin >> v[i + 1];
  }
  for(int i = 1; i <= n; i ++) {
    v[i] += v[i - 1];
  }

  for(int i = 0; i <= n; i ++) {
    for(int j = 0; j <= n; j ++) {
      if(i == j) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = INF;
      }
    }
  }

  ll ans = 0;
  for(int i = n - 1; i >= 1; i --) {
    for(int j = i + 1; j <= n; j ++) {
      for(int k = i; k < j; k ++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + v[j] - v[i - 1]);
      }
    }
  }

  cout << dp[1][n], nl;
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}


template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T lcm(T a, T b) {return a*b/gcd(a,b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,m);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact,ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {
            fact[i+1] = fact[i]*(i+1) % M;
            ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;
        }
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;
        if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b] * ifact[b] % M;
        return tmp * fact[a] % M;
    }
};


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

    ll N,K;
    cin >> N >> K;
    
    combination C(N);
    
    ll ans = 1;
    
    for(ll i = 1; i < min(N,K+1); i++){
        ll an = C.com(N,i);
        //ll aa = modpow<ll>(N-i,i,mod);
        ll aaa = C.com(N-1,i);
        ans += an*aaa%mod;
        ans %= mod;
    }
    cout << ans << endl;
    
    
    
    

    return 0;
}


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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while (b<=a)
	{
		b*=2;
		k--;
	}
    while (c<=b)
	{
		c*=2;
		k--;
	}
    cout<<((k>=0)?"Yes":"No")<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    if((y-2*x) < 0 || ((y-2*x) % 2 != 0) || (4*x-y) < 0 || ((4*x-y) % 2 != 0)) {
        cout << "No" << endl;
    }else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int a, b; char op;
    cin >> a >> op >> b;
    if(op=='+'){
        cout << a+b << endl;
    }else{
        cout << a-b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int G[55][55];

int main() {
    int n, m; cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a][b]++;
        G[b][a]++;
    }
    int ans;
    for (int i = 0; i < n; i++) {
        ans = 0;
        for (int j = 0; j < n; j++) {
            if (G[i][j]) ans += G[i][j];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
def gcd(a, b)
  if a % b == 0
    return b
  else
    return gcd(b, a % b)
  end
end
while (str = gets)
  a, b = str.split(" ").map(&:to_i)
  puts [gcd(a, b), (a * b) / gcd(a, b)].join(" ")
end


Measured memory_bytes: 6852
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e5+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int n;
	cin >> n;

	cout << 3 * n * n << endl;
	return 0;
}

Measured memory_bytes: 256
A , B , C , X , Y = map(int,input().split())
# 場合分けして考える
# 全てABピザ、
# 可能な限りAB、余りをA or B
# 全てA or B
# 上記の３パターンのうち、最も小さな金額が回答？
AB = max(X, Y) * 2 * C
ABandAorB = min(X,Y)* 2 * C + ( ((X-Y)* A  ) if  X > Y else ((Y -X) *B))
AorB = X * A + Y * B
print(min(AB,ABandAorB ,AorB ))

Measured memory_bytes: 3064
// 2011/08/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		char C[10000];
		for(int i=0; i<n; i++)
			C[i] = '#';

		for(int i=0; i<m; i++){
			char a;
			cin >> a;

			if(a=='A'){
				for(int j=0; j<n; j++)
					if(C[j]=='#'){
						C[j] = a;
						break;
					}
			}
			else if(a=='B'){
				bool flg = false;
				for(int j=n-1; j>=0; j--)
					if(C[j]=='#'&&(j==0||C[j-1]!='A')&&(j==n-1||C[j+1]!='A')){
						C[j] = a;
						flg = true;
						break;
					}
				if(!flg)
					for(int j=0; j<n; j++)
						if(C[j]=='#'){
							C[j] = a;
							break;
						}
			}
			else if(a=='C'){
				if(i==0){
					C[n/2] =a;
				}
				else{
					for(int j=0; j<n; j++)
						if(C[j]!='#'&&j!=n-1&&C[j+1]=='#'){
							C[j+1] = a;
							break;
						}
						else if(C[j]!='#'&&j!=0&&C[j-1]=='#'){
							C[j-1] = a;
							break;
						}
				}
			}
			else if(a=='D'){
				if(i==0){
					C[0] = a;
				}
				else{
					int D[10000];
					int d = 10000;
					for(int j=0; j<n; j++)
						if(C[j]!='#'){
							d = 0;
							D[j] = d;
						}
						else{
							d++;
							D[j] = d;
						}
					d = 10000;
					for(int j=n-1; j>=0; j--)
						if(C[j]!='#'){
							d = 0;
							continue;
						}
						else{
							d++;
							if(D[j]>d)
								D[j] = d;
						}
					int max_d = -1;
					int max_j = -1;
					for(int j=0; j<n; j++)
						if(D[j]>max_d){
							max_d = D[j];
							max_j = j;
						}
					C[max_j] = a;
				}
			}
		}

		for(int i=0; i<n; i++)
			cout << C[i];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,t;
  cin>>n>>t;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(a[i+1]>=a[i]+t) ans+=t;
    else ans+=a[i+1]-a[i];
  }
  ans+=t;
  cout<<ans<<endl;
  return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, X;
int L[110];

signed main() {
    cin >> N >> X;
    rep(i, N) {
        cin >> L[i];
    }
    int d = 0;
    int ans = 0;
    rep(i, N) {
        if (d <= X)ans++;
        d += L[i];
    }
    if (d <= X)ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

ans = 0
cost = 0
time_list = [int(input()) for i in range(5)]
for i in time_list:
    if math.ceil(i / 10) * 10 - i != 0:
        cost = max(cost,math.ceil(i / 10) * 10 - i)
    ans += math.ceil(i / 10) * 10
print(ans - cost)


Measured memory_bytes: 3060
/*******************************\
   Name:    REAJUL HAQUE REAYZ  |
   School:  COMILLA UNIVERSITY  |
            CSE (5TH BATCH)     |
********************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define mem(x,y) memset(x , y , sizeof(x))
using namespace std;
typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const ll MOD = 1000000007;
const int MAX = 100005;

struct data {
    ll x, y, z;
};
vector<data>v;
int n, m;
ll sum() {
    ll sumx = 0, sumy = 0, sumz = 0;
    for (int i = 0; i < m; i++) {
        sumx += v[i].x;
        sumy += v[i].y;
        sumz += v[i].z;
    }
    ll ans = abs(sumx) + abs(sumy) + abs(sumz);
    return ans;
}
bool cmp1(const data& a, const data& b){ return a.x + a.y + a.z > b.x + b.y + b.z; }
bool cmp2(const data& a, const data& b){ return a.x + a.y - a.z > b.x + b.y - b.z; }
bool cmp3(const data& a, const data& b){ return a.x - a.y + a.z > b.x - b.y + b.z; }
bool cmp4(const data& a, const data& b){ return -a.x + a.y + a.z > -b.x + b.y + b.z; }
bool cmp5(const data& a, const data& b){ return -a.x - a.y + a.z > -b.x - b.y + b.z; }
bool cmp6(const data& a, const data& b){ return a.x - a.y - a.z > b.x - b.y - b.z; }
bool cmp7(const data& a, const data& b){ return -a.x + a.y - a.z > -b.x + b.y - b.z; }
bool cmp8(const data& a, const data& b){ return -a.x - a.y - a.z > -b.x - b.y - b.z; }
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    for(int i = 0; i < n; i++) {
        ll x, y, z;
        cin>>x>>y>>z;
        data tmp = {x, y, z};
        v.push_back(tmp);
    }
    ll ans = 0;
    sort(all(v),cmp1); ans = max(ans, sum());
    sort(all(v),cmp2); ans = max(ans, sum());
    sort(all(v),cmp3); ans = max(ans, sum());
    sort(all(v),cmp4); ans = max(ans, sum());
    sort(all(v),cmp5); ans = max(ans, sum());
    sort(all(v),cmp6); ans = max(ans, sum());
    sort(all(v),cmp7); ans = max(ans, sum());
    sort(all(v),cmp8); ans = max(ans, sum());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()

    n_dot_right = S.count('.')
    n_hash_left = 0

    ans = [n_dot_right + n_hash_left]

    for c in S:
        if c == '.':
            n_dot_right -= 1
        else:
            n_hash_left += 1
        ans.append(n_dot_right + n_hash_left)

    print(min(ans))
    

main()


Measured memory_bytes: 11140
#include <bits/stdc++.h>
using namespace std;
double pi = 2 * acos(0.0);
int main(){
        map<string, int> m;
        m["SAT"] = 1, m["SUN"] = 2, m["MON"] = 3; m["TUE"] = 4, m["WED"] = 5, m["THU"] = 6, m["FRI"] = 7;
        string s; cin >> s;
        if (m[s] >= 2) cout << 2 + (7-m[s]);
        else cout << 2 - m[s];
    return 0;
}



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

void Main()
{
    int n, q;
    cin >> n;
    unordered_map<int, long> am;
    for (int i = 0; i < n; i++)
    {
        long a;
        cin >> a;
        am[a]++;
    }
    cin >> q;
    long sum = -1;
    for (int i = 0; i < q; i++)
    {
        int b, c;
        cin >> b >> c;
        am[c] = am[b] + am[c];
        long diff = am[b] * (c-b);
        am.erase(b);

        if(sum < 0){
            sum = 0;
            for(auto j: am)
                sum += j.first * j.second;
        }else{
            sum = sum + diff;
        }
        cout << sum << endl;
    }

    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 6688
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  ll x[n+1]={};
  ll y[m+1]={};
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<m;i++) cin>>y[i];

  ll sumx=0,sumy=0;
  for(int i=1;i<=n;i++){
    sumx=sumx+(((i-1)*x[i-1])%MOD-(n-i)*x[i-1]%MOD+MOD)%MOD;
    sumx%=MOD;
  }
  for(int i=1;i<=m;i++){
    sumy=sumy+(((i-1)*y[i-1])%MOD-(m-i)*y[i-1]%MOD+MOD)%MOD;
    sumy%=MOD;
  }
  cout<<sumx*sumy%MOD<<endl;
  return 0;
}


Measured memory_bytes: 1792
using System;

class Program
{
    static void Main(string[] args)
    {
		string[] input = Console.ReadLine().Split();
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		int c = int.Parse(input[2]);

		Console.WriteLine(Math.Max(c -(a - b), 0));
	}
}


Measured memory_bytes: 11092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int main () {
  int a;
  cin >> a;
  cout << 3*a*a;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

constexpr int MAX_N = 100;
int N, K;
int x[MAX_N];

void _main() {
  cin >> N >> K;
  rep(i, 0, N) cin >> x[i];

  int ans = 0;
  rep(i, 0, N) {
    ans += min(x[i], abs(K-x[i])) * 2;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<math.h>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
   int N; cin >> N;
   vector<string> s(N);
   rep(i,N){
       cin >> s[i];
       sort(s[i].begin(),s[i].end());
   }
   sort(s.begin(),s.end());
   ll ans = 0;
   ll now = 0;
   repr(i,1,N){
       if(s[i] == s[i-1]) now++;
       else{
           ans += now*(now+1)/2;
           now = 0;
       }
   }
   ans += now*(now+1)/2;
   cout << ans <<endl;
}


Measured memory_bytes: 7296
package main

import (
	"fmt"
)

func gcd(x, y int) int {
	if y == 0 {
		return x
	} else {
		x = x % y
		return gcd(y, x)
	}
}
func main() {
	var n int
	fmt.Scan(&n)
	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}
	result := list[0]
	for i := 0; i < n; i++ {
		result = gcd(result, list[i])
	}

	fmt.Println(result)
}


Measured memory_bytes: 5504
n = int(input())

a = [0] + list(map(int, input().split())) + [0]

s = sum(abs(a[i] - a[i - 1]) for i in range(1, n + 2))

for i in range(1, n + 1):
    l, r = min(a[i - 1], a[i + 1]), max(a[i - 1], a[i + 1])
    if l <= a[i] <= r:
        print(s)
    elif a[i] <= l:
        print(s-2*(l-a[i]))
    else:
        print(s-2*(a[i]-r))

Measured memory_bytes: 14172
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
  
struct Node{
    int key;
    Node *right,*left,*parent;
};
  
Node *root,*NIL;
  
Node *find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}
  
void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
      
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
      
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
      
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}
  
void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
  
void preorder(Node *u){
        if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
  
int main(){
    int n,i,x;
    string com;
      
    scanf("%d",&n);
      
    for(i=0;i<n;i++){
        cin>>com;
        if(com[0]=='f'){
            scanf("%d",&x);
            Node *t=find(root,x);
            if(t!=NIL)printf("yes\n");
            else printf("no\n");
        }else if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
      
    return 0;
}


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

int main() {
  int a;
  cin >> a;
  int b1 = 0, b2= 0, b3= 0;
  b1 = a / 100;
  b2 = (a-b1*100) / 10;
  b3 = a-b1*100-b2*10;
  cout << b1+b2+b3 << endl;
}

Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;

int main(){
   int r;
   
   cin >> r;
   cout << r*r << endl;;
   
   
   return 0;
}

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

using namespace std;

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

	int ans = 0;

	vector<int> a(n), b(n), c(n);

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


	int last = a[0];

	for (int i = 0; i < n - 1; i++) {
		if (a[i] + 1 == a[i + 1]) {
			ans += c[a[i]-1];
		}
	}

	cout << ans;

	return 0;

}

Measured memory_bytes: 256