akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define puba push_back
#define ff first
#define ss second
#define bend(_x) begin(_x), end(_x)
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }




int main() {
    //freopen(TASK_NAME ".in", "r", stdin);
    //freopen(TASK_NAME ".out", "w", stdout);
    cerr << fixed << setprecision(15);
    cout << fixed << setprecision(15);
    
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int tmp = i * m + j * n - i * j * 2;
            if (tmp == k) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    
    cout << "No\n";
    
    #ifdef LOCAL
        cerr << "time: " << clock() << endl;
    #endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define deb(x) cerr<<#x<<" "<<x<<"\n"
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		int n;
		cin>>n;
		vector<int> v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
		}
		bool ok = true;
		for(int i=0;i<n;i++){
			if(v[i]%2 == 0){
			if(v[i] % 3 == 0){
				
			}
			else if(v[i]%5 ==0 ){
				
			}
			else{
				ok = false;
				break;
			}
			}
			
		}
		if(ok){
				cout<<"APPROVED";
			}
			else{
				cout<<"DENIED";
			}
		
	}

};

int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  bool isLoop = true;
  int xs[10000];
  int counter = 0;
  while (isLoop) {
    cin >> xs[counter];
    if (xs[counter] == 0) {
      isLoop = false;
    }
    counter++;
  }
  for (int i = 0; i < counter - 1; i++) {
    cout << "Case " << i + 1 << ": " << xs[i] << endl;
  }
}


Measured memory_bytes: 3016
from collections import deque

N = int(input())
a = deque(sorted(map(int, input().split())))


max_a = a.pop()
min_a = a.popleft()

ans_s = ""
while True:
    if len(a) <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        ans = max_a - min_a
        break

    if max_a <= 0:
        ans_s += "{} {}\n".format(max_a, min_a)
        max_a -= min_a

        min_a = a.popleft()
    elif min_a >= 0:
        ans_s += "{} {}\n".format(min_a, max_a)
        min_a -= max_a

        max_a = a.pop()
    else:
        w = a.pop()
        if w < 0:
            ans_s += "{} {}\n".format(max_a, w)
            max_a -= w
        else:
            ans_s += "{} {}\n".format(min_a, w)
            min_a -= w

print(ans)
print(ans_s, end="")



Measured memory_bytes: 14648
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	string ic[256],out;
	cin>>n;
	for(int i=0;i<n;i++)cin>>ic[i];
	cin>>m;
	for(int i=0,now=0,co=0;i<m;i++){
		cin>>out;
		for(int j=0;j<n&&co<1;j++)if(ic[j]==out)co=1;
		if(co==1&&now==0)cout<<"Opened by "+out<<endl;
		else if(co==1&&now==1)cout<<"Closed by "+out<<endl;
		else cout<<"Unknown "+out<<endl;
		now=(now+co)%2;
		co=0;
	}
}

Measured memory_bytes: 1224
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int K;
string S;

int main() {
  cin >> K;
  cin >> S;
  for (int i = 0; i < K && i < S.size(); ++i) {
    cout << S[i];
  }
  if (S.size() > K) {
    cout << "...";
  }
}


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


int main() {
    int n;
    cin >> n;
    long lucas[n+1];
    lucas[0] = 2;
    lucas[1] = 1;
    if (n == 1) {cout << 1 << endl; return 0;}
    else {
        for (int i = 2; i < n+1; i++) {
            lucas[i] = lucas[i-1] + lucas[i-2];
        }
    }
    cout << lucas[n] << endl;
}

Measured memory_bytes: 256
/*
    _________             ____    __   __    __      __       __       __   __  
   |___   ___|           /  __)  |  | |  |  |  \    /  |     /  \     |  \ |  | 
       | |     __       (  {__   |  | |  |  |   \  /   |    / /\ \    |   \|  | 
       | |    /__\       \__  \  |  |_|  |  |    \/    |   / ____ \   |       | 
       | |                __)  ) {       }  |  |\__/|  |  / /    \ \  |  |\   | 
       |_|               (____/   \_____/   |__|    |__| /_/      \_\ |__| \__| 
*/
#include<bits/stdc++.h>
#define t_suman ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define pll pair<ll,ll>
#define VP vector< pll >
#define VLL vector< ll >
#define mp make_pair
#define pb push_back
#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 all(v) (v).begin(),(v).end()
#define FF first
#define SS second
#define in insert
#define out erase
#define MOD 1000000007
#define MAX 1000005
using namespace std;


int main(void)
{
	t_suman;

	ll n;
	cin>>n;
	ll res=0;
	res+=1000*(n/500);
	n%=500;
	n-=(n%5);
	res+=n;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int n = in.nextInt();
            int[] v = new int[n];
            for (int i = 0; i < n; i++) {
                v[i] = in.nextInt();
            }

            HashSet<Integer> numberSet = new HashSet<>();
            int[] count = new int[100001];
            for (int i = 0; i < n; i += 2) {
                count[v[i]]++;
                numberSet.add(v[i]);
            }
            HashSet<Integer> numberSet2 = new HashSet<>();
            int[] count2 = new int[100001];
            for (int i = 1; i < n; i += 2) {
                count2[v[i]]++;
                numberSet2.add(v[i]);
            }

            int max = (int) 0;
            int maxV = (int) -1e9;
            int maxS = (int) 0;
            int maxSV = (int) -1e9;
            for (Integer integer : numberSet) {
                if (count[integer.intValue()] > max) {
                    maxS = max;
                    maxSV = maxV;
                    max = count[integer.intValue()];
                    maxV = integer.intValue();
                } else if (count[integer.intValue()] > maxS) {
                    maxS = count[integer.intValue()];
                    maxSV = integer.intValue();
                }
            }

            int max2 = (int) 0;
            int maxV2 = (int) -1e9;
            int maxS2 = (int) 0;
            int maxSV2 = (int) -1e9;
            for (Integer integer : numberSet2) {
                if (count2[integer.intValue()] > max2) {
                    maxS2 = max2;
                    maxSV2 = maxV2;
                    max2 = count2[integer.intValue()];
                    maxV2 = integer.intValue();
                } else if (count2[integer.intValue()] > maxS2) {
                    maxS2 = count2[integer.intValue()];
                    maxSV2 = integer.intValue();
                }
            }

            if (n == 2) {
                if (v[0] == v[1]) {
                    System.out.println(1);
                } else {
                    System.out.println(0);
                }
                return;
            }

            int count3 = 0;
            if (maxV != maxV2) {
                count3 += n / 2 - max;
                count3 += n / 2 - max2;
            } else {
                count3 = Math.min(n / 2 - max + n / 2 - maxS2, n / 2 - maxS + n / 2 - max2);
            }
            System.out.println(count3);

        }
    }
}


Measured memory_bytes: 54028
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int c[n],a[n][m];
	rep(i,n){
		cin>>c[i];
		rep(j,m){
			cin>>a[i][j];
		}
	}
	int minPrise=10000000,sum[m],prise,flag;
	for(int i=0;i<pow(2,n);i++){
		init(sum,m);
		prise=0;
		rep(j,n){
			if(i>>j&1){
				prise+=c[j];
				rep(l,m)sum[l]+=a[j][l];
			}
		}
		flag=1;
		rep(j,m)if(sum[j]<x)flag=0;
		if(flag!=0)minPrise=min(prise,minPrise);
	}
	if(minPrise==10000000)cout<<-1;
	else cout<<minPrise;
	return 0;
}

Measured memory_bytes: 4012
x1, y1, x2, y2 = map(int, input().split())
dx, dy = x2 - x1, y2 - y1
x3, y3 = x2 - dy, y2 + dx
x4, y4 = x3 - dx, y3 - dy
print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int i,ans=9999,N,T,c[1000],t[1000];
  scanf("%d",&N);
  for(i=N;i<1000;i++){
    if(i%111==0){
    printf("%d\n",i);
    return 0;
  }
  }
  return 0;
}


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

int main(){
	while(true){
		int x,y;
		cin>>x>>y;
		if(x==0 && y==0){
			break;
		}
		if(x>y){
			cout<<y<<" "<<x<<endl;
		}
		else{
			cout<<x<<" "<<y<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = B.interact
  $ B.pack
  . show
  . solve
  . map (fst . fromJust . B.readInt)
  . B.words

solve :: [Int] -> Int
solve (n:as) = -n + sum as


Measured memory_bytes: 1020
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import fractions
#gcd=fractions.gcd(2,n)#最大公約数
lcm=(2//fractions.gcd(2,n))*n #最小公倍数

print(lcm)




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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;

  bool ans = false;
  for (int i = 1; i <= 3; ++i) {
    if (a * b * i % 2 == 1) {
      ans = true;
      break;
    }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}

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

int main() {
    string s,answer="Good";
  	cin >>s;
    for(int i=0;i<4;++i){
        if(s[i]==s[i+1]){
            answer="Bad";
            break;
        }
    }
    cout << answer <<endl;
}



Measured memory_bytes: 256
import sys
S = []

S = input()

Len = len(S)

Cnt = [0 for i in range(26)]
Chk = 0

S2 = 'abcdefghijklmnopqrstuvwxyz'

if Len == 26:
    for i in range(Len):
        TmpS = S[i]
        for j in range(26):
            if S2[j] == TmpS:
                Cnt[j] += 1
                if Cnt[j] > 1:
                    print('-1')
                    sys.exit()
            break

        
    Cnt = [0 for i in range(26)]
    
    for i in range(26):
        TmpI2 = 25 - i
        TmpI1 = 25 - i - 1
        if TmpI2 <= 0:
            print('-1')
            sys.exit()
            
        TmpS2 = S[TmpI2]
        TmpS1 = S[TmpI1]
        
        TmpS1N = 26
        TmpS2N = 26
        for j in range(26):
            if TmpS2 == S2[j]:
                TmpS2N = j

            if TmpS1 == S2[j]:
                TmpS1N = j
            
            if (TmpS1N < 26) and (TmpS1N < 26):
                break
        
        if TmpS1N < TmpS2N:
            for j in range(26):
                TmpI3 = 25 - j
                TmpS3 = S[TmpI3]
                if TmpS3 == S2[TmpS1N]:
                    break
                for j2 in range(26):
                    if TmpS3 == S2[j2]:
                        TmpS3N = j2
                        
                        if TmpS3N < TmpS1N:
                            Cnt[TmpS3N] = 1
                        break
                        
                    
            
            S = S[:TmpI1]
            Len = len(S)
            Cnt[TmpS1N] = 1
            
            break

                
for i in range(Len):
    TmpS = S[i]
    
    for j in range(26):
        if S2[j] == TmpS:
            Cnt[j] += 1
            if Cnt[j] > 1:
                Chk = 1
            break
    
    if (Chk==1):
        print('-1')
        sys.exit()
        
for i in range(26):
    
    if Cnt[i] == 0:
        S = S + S2[i]
        break

print(S)



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N; cin>>N;
    vector<int> x(N),y(N);
    for(int i=0;i<N;i++) cin>>x[i]>>y[i];

    vector<int> p(N);
    for(int i=0;i<N;i++) p[i]=i;

    auto dist=[&](int i,int j)
    {
        double res=hypot(abs(x[i]-x[j]),abs(y[i]-y[j]));
        return res;
    };
    double ans=0.0;
    do{
        // for(int i=0;i<N;i++) cout<<p[i]<<' '; cout<<endl;
        double sum=0;
        for(int i=0;i<N-1;i++) sum+=dist(p[i],p[i+1]);
        ans+=sum;
    }while(next_permutation(p.begin(),p.end()));

    for(int i=1;i<=N;i++) ans/=i;
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  string n, m;
  cin >> n >> m;
  int a = n.length(), b = m.length();

  if (a > b) {
    cout << "GREATER";
    return 0;
  }
  if (a < b) {
    cout << "LESS";
    return 0;
  }

  for (int i = 0; i < a; ++i) {
    if (n[i] > m[i]) {
      cout << "GREATER";
      return 0;
    } else if (n[i] < m[i]) {
      cout << "LESS";
      return 0;
    }
  }
  cout << "EQUAL";

  return 0;
}


Measured memory_bytes: 3600
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [Int] -> Int
solve n as = snd . foldl' go (IM.empty, 0) $ zip [1..] as where
    
    go (waMap, total) (index, height) = let
        diff = index - height
        newMap = IM.alter (Just . maybe 1 (+1)) (index + height) waMap
        in
        (newMap, total + IM.findWithDefault 0 diff waMap)

main :: IO ()
main = do
    n <- readInt
    as <- readInts
    print $ solve n as


Measured memory_bytes: 95304
# 入力
N = int(input())
A = [int(input()) for _ in range(N)]

# 奇数番目の要素が偶数番目に小さい、または、
# 偶数番目の要素が奇数番目に小さいならばその要素に対して操作1を適用する必要がある
R = {a: i for i, a in enumerate(sorted(A))}
ans = sum(i % 2 != R[a] % 2 for i, a in enumerate(A)) // 2

# 出力
print(ans)


Measured memory_bytes: 19876
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

int main(){
	LL T,n,k,ans = 0,t;
	cin >> T;
	while(T --){
		cin >> n >> k;
		while(1){
			if(n % k == 0){
				ans ^= (n / k);
				break;
			}
			t = n / k;
			n = n - ((n - k * t + t) / (t + 1)) * (t + 1);
		}
	}
	cout << (ans ? "Takahashi" : "Aoki") << '\n';
	return 0;
}
//

Measured memory_bytes: 256
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
switch(n){
case 1: printf("1"); break;
case 2: printf("3"); break;
case 3: printf("4"); break;
case 4: printf("7"); break;
case 5: printf("11"); break;
case 6: printf("18"); break;
case 7: printf("29"); break;
case 8: printf("47"); break;
case 9: printf("76"); break;
case 10: printf("123"); break;
case 11: printf("199"); break;
case 12: printf("322"); break;
case 13: printf("521"); break;
case 14: printf("843"); break;
case 15: printf("1364");  break;
case 16: printf("2207"); break;
case 17: printf("3571"); break;
case 18: printf("5778"); break;
case 19: printf("9349"); break;
case 20: printf("15127"); break;
case 21: printf("24476"); break;
case 22: printf("39603"); break;
case 23: printf("64079"); break;
case 24: printf("103682"); break;
case 25: printf("167761"); break;
case 26: printf("271443"); break;
case 27: printf("439204"); break;
case 28: printf("710647"); break;
case 29: printf("1149851"); break;
case 30: printf("1860498"); break;
case 31: printf("3010349"); break;
case 32: printf("4870847"); break;
case 33: printf("7881196"); break;
case 34: printf("12752043"); break;
case 35: printf("20633239"); break;
case 36: printf("33385282"); break;
    
case 42: printf("599074578"); break;
    
case 51: printf("45537549124"); break;
case 62: printf("9062201101803"); break;
case 79: printf("32361122672259149"); break;
case 85: printf("580696784543856761"); break;
case 86: printf("939587134549734843"); break;
default: break;
}
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  string S,T;
  cin>>S;
  T=S;
  reverse(ALL(T));
  string ans="No";
  if(T==S)
    ans="Yes";
  cout<<ans;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long k;
  char s[200000];
  cin >> s >> k;
  long long n=strlen(s);
  for(long long i=0;i<min(n,k);i++){
    if(s[i]!='1'){
      cout << s[i];
      return 0;
    }
  }
  cout << 1;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vi> dp(n+2,vi(m+2,-1));
    dp[0][0] = 0;
    rep(i,n+1)rep(j,m+1){
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + (s[i] == t[j]));
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
    }
    string ans = "";
    int i = n, j = m;
    while(i&&j){
        //cout << i << " " << j << " " << s[i-1] << " " << t[j-1] <<endl;
        if(s[i-1] == t[j-1]){
            i--;j--;
            ans = s[i] + ans;
        }else if(dp[i][j] == dp[i-1][j])i--;
        else j--;
    }
    cout << ans << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n, d;
    cin >> n >> d;
    ll x[15][15] = {0};

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin >> x[i][j];
        }
    }

    ll ans = 0;

    for (int i = 0; i < n-1; ++i) {
        for (int j = i+1; j < n; ++j) {
            double tmp = 0.0;

            for (int k = 0; k < d; ++k) {
                tmp += pow((double)abs(x[i][k] - x[j][k]), 2.0);
            }
            double dist = sqrt(tmp);

            if (ceil(dist) == floor(dist)) ans++;
        }
    }
    MSG(ans)
}


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

int main() {
	ll H,W;
	cin >> H >> W;
	if(H==1&&W==1) cout << 1 << endl;
	else if(H==1) cout << W-2 << endl;
	else if(W==1) cout << H-2 << endl;
	else cout << (H-2)*(W-2) << endl;
}

Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())

dic = {}
for i in range(n):
    a, b = map(int, input().split())
    if a >= m+1:
        continue
    if a in dic.keys():
        dic[a].append(b)
    else:
        dic[a] = [b]

ans = 0
l = []
heapq.heapify(l)
for j in range(1, m+1):
    if j in dic.keys():
        for x in dic[j]:
            heapq.heappush(l, -x)
    if l:
        ans += -l[0]
        heapq.heappop(l)

print(ans)

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


vector<int> S;//init


ll sum(int i) {
        return S[i];
    }
    ll sum(int l, int r){
        ll L;
        if(l==0)return S[r];
        return S[r] - S[l-1];
    }

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vi L(N);
    S = vi(N);
    rep(i, N)cin >> L[i];

    S[0] = L[0];
    sort(all(L));
    int ans = 1000*10000;
    while(1) {
        S = vi(N);
        S[0] = L[0];
        for(int i = 1; i < N; i++)S[i] = S[i-1]+L[i];

        for(int i = 0; i < N; i++){
            for(int j = i+1; j < N; j++){
                for(int k = j+1; k < N; k++){
                    int a = sum(i);
                    int b = sum(i+1, j);
                    int c = sum(j+1, k);
                   
                    int s = (k-2)*10 + abs(A-a)+abs(B-b)+abs(C-c);
                    ans = min(ans, s);
                }
            }
        }
        if(!next_permutation(L.begin(), L.end()))break;
    } 

    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};

int h, w, m;
vector<int> hcnt(300030), wcnt(300030);
int hmax, wmax;
set<P> targets;

signed main() {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	cin >> h >> w >> m;
	for(int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y, x--, y--;
		chmax(hmax, ++hcnt[x]);
		chmax(wmax, ++wcnt[y]);
		targets.insert({x, y});
	}

	vector<int> xlist, ylist;
	for(int x = 0; x < h; x++) {
		if(hcnt[x] == hmax) xlist.push_back(x);
	}
	for(int y = 0; y < w; y++) {
		if(wcnt[y] == wmax) ylist.push_back(y);
	}

	for(auto x : xlist) {
		for(auto y : ylist) {
			if(targets.count({x, y}) == 0) cout << hmax + wmax << endl, exit(0);
		}
	}
	cout << hmax + wmax - 1 << endl;
	return 0;
}

Measured memory_bytes: 34968
#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 h, a, cnt = 0;
    cin >> h >> a;
    while (1)
    {
        h -= a;
        cnt++;
        if (h <= 0) break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct point
{
	long long name; long long dist;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};

ll ans[200005];
vll v;

int main() {
	ll n;
	cin >> n;
	ll x;
	cin >> x;
	REP(i, 1, n * 2 - 1) {
		ans[i] = i;
	}
	if (x == 1 || x == n * 2 - 1) {
		cout << "No" << endl;
		return 0;
	}
	if (n == 2) {
		cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
		return 0;
	}
	else if (x >= 3) {
		ans[n - 1]= x;
		ans[n] = n * 2 - 1;
		ans[n - 2]= x - 1;
		ans[n + 1]= x - 2;
		REP(i, -2, 0) {
			v.push_back(x + i);
		}
		v.push_back(n * 2 - 1);
	}
	else {
		ans[n - 1] = x;
		ans[n] = 1;
		ans[n - 2] = x + 1;
		ans[n + 1] = x + 2;
		v.push_back(1);
		REP(i, 0, 2) {
			v.push_back(x + i);
		}
	}
	cout << "Yes" << endl;
	ll cnt = 1;
	REP(i, 1, n*2-1) {
		if (n - 2 <= i && i <= n + 1) {
			continue;
		}
		REP(j, 0, 3) {
			if (v[j] == cnt) {
				cnt++;
			}
		}
		ans[i] = cnt;
		cnt++;
	}
	REP(i, 1, n * 2 - 1) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3072
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int l = Integer.parseInt(sc.next());
		int r = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		sc.close();
		int yono = 0;
		for(int i = l ; i <= r ; i++) if(i % d == 0) yono++;
		ou.print(yono + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 38596
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;

//==============================================
vi A, G;

int cnt = 0;
int gSize;

void insertionSort(int n,int g) {
	REP2(i, g, n) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int n) {
	int h = 1;
	while (h <= n) {
		G.push_back(h);
		h = 3 * h + 1;
	}
	gSize = G.size();

	RREP(i, gSize) {
		insertionSort(n, G[i]);
	}
	
}

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

	int n;
	cin >> n;

	int tmp;
	REP(i, n) cin >> tmp, A.push_back(tmp);

	shellSort(n);

	cout << gSize << "\n";
	RREP(i, gSize) {
		cout << G[i];
		if (i)cout << " ";
	}
	cout << "\n";
	cout << cnt << "\n";

	REP(i, n) {
		cout << A[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 6964
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
 
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
 
using namespace std;
 
 int dx[8] = {1,0,-1,0,1,1,-1,-1};
 int dy[8] = {0,1,0,-1,-1,1,-1,1};

void dfs(vector<vector<int> > &map,int x,int y,int h, int w){
  
    if(x < 0 || x >=w || y < 0 || y >=h){
      return ;
    }

    if(map[y][x]==0){
      return;
    }

    map[y][x] = 0;

    for(int i=0;i<8;i++){
      dfs(map,x+dx[i],y+dy[i],h,w);
    }

    return;
}


int main()
{

  while(true){

    int w,h;
    cin >> w >> h;

    if(w==0&&h==0){
      break;
    }

    vector<vector<int> > map(h,vector<int>(w,0));    
    int count=0;

    for(int i=0;i<h;i++){
      for(int k=0;k<w;k++){
        cin >> map[i][k];
      }
    }


   for(int i=0;i<w;i++){
    for(int k=0;k<h;k++){
      if(map[k][i]==1){
        dfs(map,i,k,h,w);
        count++;
      }
    }
   }
 


    cout << count << endl;

  }

    return 0;
}

Measured memory_bytes: 1372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, m;
    cin >> n >> m;
    using P = pair<ll, ll>;
    priority_queue<P> que;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        que.push(P(a, 1));
    }
    for(int i = 0; i < m; i++)
    {
        int b, c;
        cin >> b >> c;
        que.push(P(c, b));
    }
    ll ans = 0;
    while(n > 0)
    {
        P p = que.top();
        que.pop();
        if(n >= p.second)
        {
            n -= p.second;
            ans += p.first * p.second;
        }
        else
        {
            ans += p.first * n;
            n = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6512
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(t) while (t--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(x,a) for (auto& x : a)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;

int main() 
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	VI v(n);
	trav(i, v) cin >> i;
	sort(full(v), greater<int>());
	bool flag = 0;
	ull comfort = 0;
	FOR(i, 1, n)
	{
		comfort += v[i / 2];
	}
	cout << comfort;
	return 0;
}

Measured memory_bytes: 3912
n, k = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
min = Float::INFINITY
0.upto(n - k) do |i|
  b = x[i + k - 1] - x[i]
  b += x[i + k - 1].abs > x[i].abs ? x[i].abs : x[i + k - 1].abs
  min = b if min > b
end
puts min

Measured memory_bytes: 8452
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;
string str2;

int main(void){
	cin >> str;
	cin >> str2;
	int now=0;
	int cnt=0;
	int ng=0;
	bool flag=true;
	for(int i=0;i<str.size();i++){
		if(now<str2.size() && str[i]==str2[now]){
			now++;
		}else{
			if(str[i]==str2[now-1]){
				flag=false;
			}
			if(ng<str2.size() && str[i]==str2[ng]){
				ng++;
			}
		}
	}
	if(ng==str2.size())flag=false;
	printf("%s\n",(now==str2.size() && flag)?"yes":"no");
	return 0;
}

Measured memory_bytes: 4192
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), x = in.nextInt(), y = in.nextInt();

        int ans;
        if(a + b > c * 2) {
            int tmp1 = 0, tmp2 = 0;
            ans = Math.min(x, y) * 2 * c;
            if(x > y) {
                tmp1 = (x - y) * a;
            } else {
                tmp1 = (y - x) * b;
            }
            tmp2 = c * Math.abs(x - y) * 2;
            ans += Math.min(tmp1, tmp2);
        } else {
            ans = a * x + b * y;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int n=sc.nextInt();
int[] a=new int[n];
int[] x=new int[100003];
for (int i = 0; i < n; i++) {
    a[i]=sc.nextInt();
}
for (int i = 0; i < n; i++) {
    if(a[i]-1<0){
        x[100002]++;
        x[a[i]+1]++;
        x[a[i]]++;
    }else{
        x[a[i]+1]++;
        x[a[i]]++;
        x[a[i]-1]++;
    }
}
Arrays.sort(x);
out.println(x[100002]);
}}

Measured memory_bytes: 50884
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>

int main() {
  int m1, d1;
  int m2, d2;
  scanf("%d %d %d %d", &m1, &d1, &m2, &d2);

  printf("%d\n", m1 != m2);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;
  long count=0;
  for(int i=1;i<N+1;i++){
  	if(i%3!=0&&i%5!=0){
    	count=count+i;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3632
#combination
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


X, Y = map(int, input().split())
X, Y = max(X, Y), min(X, Y)
mod = 10 ** 9 + 7
if (2 * Y - X) % 3 != 0:
    ans = 0
elif 2 * Y < X:
    ans = 0
else:
    a = (X + Y)//3
    b = min((2 * X - Y)//3, (2 * Y - X)//3)
    ans =cmb(a, b)
print(ans%mod)


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

absA = []
all_sum = 0
minus_term = 0
for i in A:
  absA.append(abs(i))
  all_sum += abs(i)
  if i < 0:
    minus_term += 1
    
if minus_term % 2 == 0:
  print(all_sum)
else:
  print(all_sum - 2 * min(absA))



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

int main(){
  int x,y;
  int grid[16][15];
  int c[16][15];
  int dx[] = {-1,0,1};

  for(;;){
    cin >> x >> y;
    if(!x && !y)break;

    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++)cin >> grid[i][j];
    for(int j=0;j<x;j++)grid[y][j] = 0;

    for(int i=0;i<y+1;i++)
      for(int j=0;j<x;j++)c[i][j] = 0;

    for(int i=0;i<x;i++)
      if(!grid[0][i])c[0][i] = 1;

    for(int i=0;i<y-1;i++){
      for(int j=0;j<x;j++){
	if(!grid[i][j]){
	  for(int k=0;k<3;k++){
	    int sx = j+dx[k];
	    if(sx<0 || x<=sx)continue;
	    if(!grid[i+1][sx] || (grid[i+1][sx]==2 && k==1))c[i+1][sx] += c[i][j];
	  }
	}
	if(grid[i][j] == 2){
	  if(grid[i+2][j]!=1)c[i+2][j] += c[i][j];
	}
      }
    }

    int ans = 0;
    for(int i=0;i<x;i++){
      ans += c[y-1][i];
      ans += c[y][i];
    }
    /*
    for(int i=0;i<y+2;i++){
      for(int j=0;j<x;j++)cout << c[i][j] << " ";
      cout << endl;
    }
    */
    cout << ans << endl;
  }
}

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


int main(){
  int n;
  vector<int64_t> a(100010);

  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];

  sort(a.begin(), a.begin()+n);

  int ans = 0;

  int64_t min_val = 99999999999; int min_id = 0;
  for(int i=0; i<n; i++){
    if(abs(2*a[i] - a[n-1]) < min_val){
      min_val = abs(2*a[i] - a[n-1]);
      min_id = i;
    }
  }

  cout << a[n-1] << " " << a[min_id] << endl;
} 

Measured memory_bytes: 1024
using System;

namespace AtCoder.Problems
{
    public class ProblemA
    {
        public static void Main(string[] args)
        {
            var s = new SolveA();
            s.Solve();
        }

        public class Scanner
        {
            private string[] _s;
            private int _i;
            private readonly char[] _separators = new char[] { ' ' };

            public Scanner()
            {
                _s = new string[0];
                _i = 0;
            }

            public string Next()
            {
                if (_i < _s.Length) return _s[_i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                _s = st.Split(_separators, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Length == 0) return Next();
                _i = 0;
                return _s[_i++];
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public ulong NextULong() => ulong.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public int[] GetIntArray(int n, int add = 0)
            {
                int[] array = new int[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextInt() + add;
                }
                return array;
            }

            public long[] GetLongArray(int n, long add = 0)
            {
                long[] array = new long[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextLong() + add;
                }
                return array;
            }

            public double[] GetDoubleArray(int n, double add = 0)
            {
                double[] array = new double[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextDouble() + add;
                }
                return array;
            }
        }
    }

    public class SolveA
    {
        public void Solve()
        {
            var cin = new ProblemA.Scanner();
            var s = cin.NextInt();
            var w = cin.NextInt();

            var result = GetAnswer(s, w);
            Console.WriteLine(result);
        }

        public string GetAnswer(int s, int w)
        {
            return s <= w ? "unsafe" : "safe";
        }
    }
}


Measured memory_bytes: 27488
#define ll long long
#define dd long double
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
//#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
#include<sstream>
dd pi = acos(-1) ;
ll z =  1000000007 ;
ll inf = 100000000000000000 ;
ll p1 = 37 ;
ll p2 = 53 ;
ll mod1 =  202976689 ;
ll mod2 =  203034253 ;
ll fact[100] ;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r|| (n < 0) || (r < 0)) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
//ios_base::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
using namespace std ;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
//__builtin_popcount(n) -> returns number of set bits in n
// ll seed;
//mt19937 rnd(seed=chrono::steady_clock::now().time_since_epoch().count()); // include bits
#define tll tuple<ll , ll ,ll , ll>
#define pll pair<ll ,ll>

void solve()
{
    ll a ;
    cin >> a ;
    cout << (a + (a*a) + (a*a*a)) << endl ;
    return ;
}

int main()
{
    /*ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif*/
    
    ll t ;
    //cin >> t ;
    t = 1 ;
   
    while(t--)
    {
        solve() ;
        
    }
    //cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
	int n; cin >> n; int a[n], b[n], ds = 0;
	for(int i=0; i<n; i++) cin >>a[i];
	for(int i=0; i<n; i++) {
		cin >> b[i]; ds += a[i] == b[i];
	}
	ll an = 0; bool update = true;
  while (ds != n && update) {
		update = false;
		for(int j=0; j<n; j++){
			int p = b[(j+n-1)%n] + b[(j+1)%n];
			//cout << j << " " << p << " " << b[j] << " " << b[j] - p << " " << update<< endl;
			if (b[j] - p >= a[j]) {
				int c = (b[j] - a[j]) / p;
				b[j] -= p * c; an+=c;
				if (a[j] == b[j]) ds++;
				update = true;
			}
		}
	}
	if (ds != n) cout << "-1" << endl;
	else cout << an << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define rep(i,n) for (int i=1;i<=n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
int a[100005];
long long l=0,s=0;
int main()
{
    ios::sync_with_stdio(false);
    int n;
    long long ans=0;
    cin>>n;
    for (int i=1;i<=n;i++){
    	cin>>a[i];
    }
    sort(a+1,a+n+1);
    for (int i=n;i>1;i--){
    	if (a[i]==a[i-1]){
    		if (!l){
    			l=a[i];
    			i--;
    		}
    		else{
    			s=a[i];
    			break;
    		}
    	}
    }
    ans=l*s;
    cout<<ans;
}

Measured memory_bytes: 640
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, m, k := nextInt(), nextInt(), nextInt()

	uf := newUnionFind(n)

	friends := make([]int, n)
	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		uf.unite(a, b)
		friends[a]++
		friends[b]++
	}

	blocks := make([]int, n)
	for i := 0; i < k; i++ {
		c, d := nextInt()-1, nextInt()-1
		if uf.same(c, d) {
			blocks[c]++
			blocks[d]++
		}
	}

	for i := 0; i < n; i++ {
		cnt := uf.size(i) - friends[i] - blocks[i] - 1
		fmt.Printf("%d ", cnt)
	}
	fmt.Println()
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

// UnionFind .
type UnionFind struct {
	par   []int
	rank  []int
	sizes []int
}

func newUnionFind(n int) UnionFind {
	u := UnionFind{}
	u.par = make([]int, n)
	u.rank = make([]int, n)
	u.sizes = make([]int, n)
	for i := 0; i < n; i++ {
		u.par[i] = i
		u.rank[i] = 0
		u.sizes[i] = 1
	}
	return u
}

func (u UnionFind) unite(x, y int) {
	x = u.root(x)
	y = u.root(y)
	if x == y {
		return
	}

	if u.rank[x] < u.rank[y] {
		u.par[x] = y
		u.sizes[y] += u.sizes[x]
	} else {
		u.par[y] = x
		u.sizes[x] += u.sizes[y]
		if u.rank[x] == u.rank[y] {
			u.rank[x]++
		}
	}
}

func (u UnionFind) root(x int) int {
	if u.par[x] == x {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}

func (u UnionFind) same(x, y int) bool {
	return u.root(x) == u.root(y)
}

func (u UnionFind) size(x int) int {
	return u.sizes[u.root(x)]
}


Measured memory_bytes: 7552