akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll x,y;
    cin >> x >> y;
    ll ans=MOD;
    ll cx=x*(-1);
    ll cy=y*(-1);
    if(x<=y){
        ans=min(ans,y-x);
    }
    if(cx<=y){
        ans=min(ans,y-cx+1);
    }
    if(x<=cy){
        ans=min(ans,cy-x+1);
    }
    if(cx<=cy){
        ans=min(cy-cx+2,ans);
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    
    int tmp;
    int n2;
    cin >> n2;
    for( int i = 0; i < n2; i++ ){
        int tmp;
        cin >> tmp;
        a[tmp - 1] = 1;
    }
    
    cin >> n2;
    for( int i = 0; i < n2; i++ ){
        int tmp;
        cin >> tmp;
        b[tmp - 1] = 1;
    }
    
    cin >> n2;
    for( int i = 0; i < n2; i++ ){
        int tmp;
        cin >> tmp;
        c[tmp - 1] = 1;
    }
    
    int count = 0;
    for( int i = 0; i < n; i++ ){
        if( ( !a[i] && c[i] ) || ( b[i] && c[i] )){
            count++;
        }
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N, B;
        cin >> N >> B;

        if (N > 8 || B > 8)
        {
                cout << ":(" << endl;
        }
        else
        {
                cout << "Yay!" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
n=int(input())
aa=[]
bb=[]
for i in range(n):
    a,b=map(int,input().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort()
if(n%2==0):
    print(bb[n//2-1]+bb[n//2]-aa[n//2]-aa[n//2-1]+1)
else:
    print(bb[n//2]-aa[n//2]+1)

Measured memory_bytes: 99044
x = int(input())


temp = x % 100
x = x - 105 * int(temp / 5)
temp = x % 100
x = x - 104 * int(temp / 4)
temp = x % 100
x = x - 103 * int(temp / 3)
temp = x % 100
x = x - 102 * int(temp / 2)
temp = x % 100
x = x - 101 * int(temp / 1)

if x >= 0:
    print('1')
else:
    print('0')

Measured memory_bytes: 3064
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin  = open("input.txt","r")
    sys.stdout = open("output.txt","w")
    sys.stderr = open("output.txt","w")

# for _testcases_ in range(int(input())):
import functools as fnc
print("Yes") if not fnc.reduce(lambda a, b: a^b, list(map(lambda x: ord(x) - ord('a') + 1, input()))) else print("No")


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 38384
#define B(a,x,b) ((a)<=(x)&&(x)<(b))

char T[400];
int x,y,cx,cy,i;

void R(a,b){
	if(B(0,a,x)&&B(0,b,y)&&!T[b*20+a]){
		T[b*20+a]=1;i++;R(a-1,b);R(a+1,b);R(a,b-1);R(a,b+1);
	}
}

main(){
	char c;
	for(;scanf("%d%d",&x,&y),x;){
		for(i=0;i<x*y;i++){
			int _x=i%x, _y=i/x;
			for(;(c=getchar())=='\n';);
			switch(c){
				case '@': cx=_x;cy=_y;
				case '.': T[_y*20+_x]=0; break;
				case '#': T[_y*20+_x]=1; break;
			}
		}
		i=0;
		R(cx,cy);
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
// Copyright (C) 2016 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>
#include <ctime>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <string>

#define x first
#define y second
#define MP std::make_pair
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long LL;
typedef std::pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
std::string procStatus()
{
    std::ifstream t("/proc/self/status");
    return std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 5e2 + 5;

int N, M;
int A[MAXN][MAXN];

void print(int a[][MAXN])
{
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= M; ++j) {
            putchar(a[i][j] & 1 ? '#' : '.');
        }
        putchar('\n');
    }
    putchar('\n');
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= M; ++j) {
            putchar(a[i][j] & 2 ? '#' : '.');
        }
        putchar('\n');
    }
}

void input()
{
    read(N); read(M);
    for (int i = 1; i <= N; ++i) {
        static char inp[MAXN];
        scanf("%s", inp);
        for (int j = 1; j <= M; ++j) {
            A[i][j] = inp[j - 1] == '#' ? 3 : 0;
        }
    }
}

void solve()
{
    for (int i = 1; i <= N; ++i) {
        A[i][1] = 1; A[i][M] = 2;
    }
    for (int i = 2; i < M; ++i) {
        A[1][i] = 1; A[N][i] = 2;
    }
    for (int i = 2; i < N; ++i) {
        for (int j = 2; j < M; ++j) {
            A[i][j] |= i & 1 ? 1 : 2;
        }
    }
    print(A);
}

int main()
{
#ifdef __DEBUG
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}


Measured memory_bytes: 1664
import math
import queue

n, m = map(int, input().split(" "))
aL = [int(input()) for _ in range(m)]

dp = [-1] * (n + 1)
dp[0] = 1

for a in aL:
    dp[a] = 0

for i in range(1, n + 1):
    if dp[i] == 0:
        continue
    if i == 1:
        dp[i] = dp[i - 1]
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % 1_000_000_007

print(dp[n] % 1_000_000_007)

# q = queue.Queue()
# q.put(0)

# cnt = 0
# while not q.empty():
#     c = q.get()
#     if dp[c] != -1:
#         cnt += dp[c]
#         continue
#     if c == n:
#         cnt += 1
#         continue
#     q.put(c + 1)
#     if c + 1 != n:
#         q.put(c + 2)
#     dp[c] = cnt

# def ppp(num):
#     cnt = 0
#     q = queue.Queue()
#     q.put(num)
#     while not q.empty():
#         c = q.get()
#         if dp[c] != -1:
#             cnt += dp[c]
#             continue
#         if c == num:
#             cnt += 1
#             continue
#         q.put(c + 1)
#         if c + 1 != num:
#             q.put(c + 2)
#         dp[c] = cnt
#     print(cnt)
#     return cnt

# cli = [aL[0] - 1]
# for i in range(1, m):
#     if abs(aL[i] - aL[i - 1]) == 1:
#         print(0)
#         exit()
#     cli.append(aL[i] - aL[i - 1] - 1)
# cli.append(n - aL[-1] - 1)

# ans = 1
# for c in cli:
#     ans = (ans * ppp(c)) % 1_000_000_007

# print(ans)

# dp = [-1] * (n + 1)
# def od(num):
#     if dp[num] != -1:
#         return dp[num]
#     q = queue.Queue()
#     q.put(num)
#     cnt = 0
#     while not q.empty():
#         c = q.get()
#         if c == 0:
#             cnt += 1
#             continue
#         if c != 1:
#             q.put(c - 2)
#         q.put(c - 1)
#     dp[num] = cnt
#     return cnt
# if m == 0:
#     print(od(n))
#     exit()
# cli = [aL[0] - 1]
# for i in range(1, m):
#     if abs(aL[i] - aL[i - 1]) == 1:
#         print(0)
#         exit()
#     cli.append(aL[i] - aL[i - 1] - 1)
# cli.append(n - aL[-1] - 1)
# print(cli)
# ans = 1
# for c in cli:
#     ans = (ans * od(c)) % 1_000_000_007
# print(ans % 1_000_000_007)

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

int main() {
	map<string, int>ans = {
		{"SUN",7},{"MON",6},{"TUE",5},{"WED",4},
	{"THU",3},{"FRI",2},{"SAT",1}
	};
	string s; cin >> s;
	cout << ans[s] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll s;
    cin >> s;
    ll r = ceil(sqrt(s));
    ll x = r * r - s;
    cout << "0 0" << " " << r << " " << 1 << " " << x << " " << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int max=0;
    if(k<=a){
        max+=k;
    }
    if(k>a&&k<=a+b){
        max+=a;
    }
    if(k>a+b){
        max+=a+a+b-k;
    }
    cout<<max;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b=num)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[60];
void power()
{
    powe[0]=1;
    REP(i,1,15)
    {
        powe[i]=2*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m=num) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool my(pll p1,pll p2)
{
    if(p1.f<p2.f) return true;
    if(p1.f==p2.f && p1.s<p2.s) return true;
    return false;
}
bool isprime(ll n)
{
    REP(i,2,sqrt(n))
    {
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n,k;
   cin>>n>>k;
   ll A[200005];
   REP(i,0,n)
   {
       cin>>A[i];
   }
   sort(A,A+n);
   ll sum=0;
   REP(i,0,n-k)
   {
       sum+=A[i];
   }
   cout<<sum<<"\n";
	return 0;
}


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

#define MOD 1e9+7
#define ll long long int

int main(void){
	ll n,h;
	cin>>n>>h;
	ll a=0;
	ll ak;
	ll b[100005];
	for(int i=0;i<n;i++){
		cin>>ak>>b[i];
		a=max(a,ak);
	}
	sort(b,b+n);
	reverse(b,b+n);
	ll ans=0;
	int i=0;
	while(h>0){
		if(i<n&&a<b[i]){
			h-=b[i];
			i++;
			ans++;
		}else{
			ans+=h/a;
			if(h%a!=0){
				ans++;
			}
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <cstring>

using namespace std;
const int INF = (1<<30);
typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離
int d[100][100];


//移動方向のベクトル
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

//汎用
ll ans = 0;
pair<int, int> red[101], blue[101];
ll BIG = 10000000000;

//累乗
ll POW(ll a, ll b) {
ll c = 1;
for (int i = 0; i < b; ++i) {
c *= a;
}
return c;
}

//階乗
int Kaijou(int a) {
if (a < 2) return 1;
return a * Kaijou(a - 1);
}


int A[200000];
int kinds[200001];


int main() 
{
	int n;
	cin >>n;
	int M = 0,id=-1;
	rep(i, n) {
		cin >> A[i];
		if (M <= abs(A[i])) {
			M = abs(A[i]);
			id = i;
		}
	}
	int x[100] = { 0 }, y[100] = { 0 };
	int s = 0;
	rep(i, n) {
		if (i != id) {
			A[i] += A[id];
			x[s] = id+1, y[s++] = i+1;
		}
	}
	if (A[id] > 0) {
		rep(i, n - 1) {
			A[i + 1] += A[i];
			x[s] = i + 1, y[s++] = i + 2;
		}
	}
	else {
		for(int i=n-2;i>=0;--i){
			A[i] += A[i+1];
			x[s] = i + 2, y[s++] = i + 1;
		}
	}
	cout << s << endl;
	rep(i, s) {
		cout << x[i] << " " << y[i] << endl;
	}
	cin >> qqq;
}


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

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

    int price;
    if (A >= 13)
    {
        price = B;
    }
    else if (A >= 6 && A <= 12)
    {
        price = B / 2;
    }
    else
    {
        price = 0;
    }
    cout << price << endl;
    return (0);
}

Measured memory_bytes: 384
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for i in range(N)]

a =set(S)
print(len(a))

Measured memory_bytes: 36532
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();

        if (a == 22) {
            System.out.println("Christmas Eve Eve Eve");
        } else if (a == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (a == 24) {
            System.out.println("Christmas Eve");
        } else if (a == 25) {
            System.out.println("Christmas");
        }
    }
}


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

for _ in range(n):
  b = int(input())
  for y in range(3):
    for x in range(3):
      if a[y][x] == b:
        a[y][x] = -1

for y in range(3):
  f = True
  for x in range(3):
    if a[y][x] != -1:
      f = False
  if f:
    print('Yes')
    exit()
    
for x in range(3):
  f = True
  for y in range(3):
    if a[y][x] != -1:
      f = False
  if f:
    print('Yes')
    exit()
    
f = True
for x in range(3):
  if a[x][x] != -1:
    f = False
if f:
  print('Yes')
  exit()
  
f = True
for x in range(3):
  if a[x][2-x] != -1:
    f = False
if f:
  print('Yes')
  exit()
  
print('No')

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    for (int i = 0; i < H; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i < H+2; ++i) {
        string out;
        if (i == 0 || i == H+1) {
            out = string(W+2,'#');
        } else {
            out = '#' + a[i-1] + '#';
        }
        cout << out << endl;
    }


    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
L = []
for i in range(n):
    L.append(sorted(list(input())))
set1 = set(L[0])
for i in range(2,n):
    set1 = set1&set(L[i])
li = []
al = "abcdefghijklmnopqrstuvwxyz"
for s in al:
    if s in set1:
        min1 = 10 **10
        for i in range(n):
            a = Counter(L[i])
            min1 = min(min1,a[s])
        li.append((s,min1))
ans = ""
for i in range(len(li)):
    ans += li[i][0]*li[i][1]
print(ans)

Measured memory_bytes: 3316
#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;
const int MAX_N = 305;
char S[MAX_N][MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		rep(j,N)
		{
			cin >> S[i][j];
		}
	}
	int ans = 0;
	for (int i = -N+1; i <= N-1; ++i)
	{
		bool flag = true;
		for (int a = 0; a < N; ++a)
		{
			for (int b = 0; b < N; ++b)
			{
				int c = (b + N - i) % N;
				int d = (a + N + i) % N;
				if (S[a][b] != S[c][d]) flag = false;
			}
		}
		//cout << i << " " <<  flag << endl;
		if (flag) ans += N - abs(i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3680
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll INF = 1LL << 40;
const ll LIM = 100 * 1000;

struct st
{
	st(ll n) :
		v(vector<vector<ll>>(n, vector<ll>(n))),
		row(n,0),
		column(n,0),
		cross(2,0)
	{
		
	}
	void in(ll n)
	{
		for(ll y = 0; y < n; y ++)
			for(ll x = 0; x < n; x++) {
				cin >> v[x][y];
				m[v[x][y]] = pll(x, y);
			}
	}
	bool find(ll x)
	{
		if(m.find(x) == m.end()) { return false; }
		return true;
	}
	void draw(ll w)
	{
		if(!find(w)) { return; }
		ll n = v.size();
		pll p = m[w];
		column[p.first] ++;
		row[p.second] ++;
		if (p.first == p.second) {
			cross[0] ++;
		}
		if (p.first == n - p.second - 1) {
			cross[1] ++;
		}
	}
	ll cnt(ll n)
	{
		ll ret = 0;
		for(auto c:column)
			if(c == n) ret ++;
		if (n == 1) { return ret; }
		for(auto r:row)
			if(r == n) ret ++;
		for(auto c:cross)
			if(c == n) ret ++;
		return ret;
	}
	vector<ll> row;
	vector<ll> column;
	vector<ll> cross;
	vector<vector<ll>> v;
	map<ll, pll> m;
};

int solve(void);

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

int solve(void)
{

	ll n, u, v, m;
	cin >> n >> u >> v >> m;

	st us(n), nk(n);

	us.in(n);
	nk.in(n);

	st s[] = {us, nk};
	ll w[] = {u, v};
	const char* ch[] = {"USAGI", "NEKO"};

	for (ll i = 0; i < m; i++)
	{
		ll d;
		cin >> d;

		for(ll j = 0; j < 2; j++) {
			s[j].draw(d);
		}

		for(ll j = 0; j < 2; j++)
			if (s[j].cnt(n) >= w[j])
			{
				if (s[0].cnt(n) >= w[0] && s[1].cnt(n) >= w[1]) {
					cout << "DRAW" << endl;
					return 0;
				}
				cout << ch[j] << endl;
				return 0;
			}

		if (i == m - 1)
		{
			cout << "DRAW" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 43160
let readCharArray _ = stdin.ReadLine().ToCharArray()
let uniq a = a |> Array.groupBy id |> Array.map fst

()
|> readCharArray
|> uniq
|> Array.sort
|> fun x ->
    if x.[0] <> 'a' then
        "a"
    elif x.Length = 26 then
        "None"
    else
        let y =
            Array.zip x.[0..x.Length - 2] x.[1..x.Length - 1]
            |> Array.filter (fun (a, b) -> (int b) - (int a) <> 1)

        if y.Length = 0
        then "z"
        else y.[0] |> fst |> int |> (+) 1 |> char |> string
|> printfn "%s"


Measured memory_bytes: 30984
#include<stdio.h>
typedef long long int ll;

int main(void){
    ll W,H,x,y;
    scanf("%lld%lld%lld%lld", &W,&H,&x,&y);

    double area;
    int ok;
    area = (double)W*H/2;
    if((x*2==W) && (y*2==H)){
        ok = 1;
    }else{
        ok = 0;
    }

    printf("%.9lf %d\n", area, ok);
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  int n, k;
  cin >> n >> k;
  map<int, int> m;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    m[a]++;
  }

  vector<int> v;
  for (auto x : m) {
    v.push_back(x.second);
  }

  sort(v.begin(), v.end());

  cout << ((v.size() <= k) ? 0 : accumulate(v.begin(), v.begin() + (v.size() - k), 0ll)) << endl;
}


Measured memory_bytes: 10748
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

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

modk = 7 % k
i = 1
for i in range(k):
    if modk == 0:
        print(i+1)
        exit()

    modk = (modk * 10 + 7) % k
else:
    print(-1)


Measured memory_bytes: 9180
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    int n;
    while(cin >> n){
        vi a(n);
        rep(i, n)cin >> a[i];
        ll ans = LLONG_MAX;
        for(int i = -100; i <= 100; ++i){
            ll val = 0;
            rep(j, n)val += (a[j] - i)*(a[j] - i);
            smin(ans, val);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 764
class UnionFind():
    def __init__(self, n):
        self.n = n
        # 親の名(いない場合はNone)
        self.parent = [None]*n
        # 子の数
        self.count = [0] * n

    def root(self, x):
        # xの根を返す
        if self.parent[x] == None:
            return x
        else:
            return self.root(self.parent[x])

    def union(self, x, y):
        # xとyをまとめる
        x0 = self.root(x)
        y0 = self.root(y)
        if x0 == y0:
            return
        if x0 > y0:
            x0, y0 = y0, x0
        self.parent[y0] = x0
        self.count[x0] += self.count[y0] + 1

    def size(self, x):
        # xの属する木の大きさ
        return self.count[self.root(x)] + 1

    def same(self, x, y):
        return self.root(x) == self.root(y)


n, m, k = map(int, input().split())
uf = UnionFind(n)
# F[i]=iの友達の数
F = [0]*n
# B[i]=iと同じグループでブロックしている数
B = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    F[a-1] += 1
    F[b-1] += 1
for j in range(k):
    a, b = map(int, input().split())
    if uf.same(a-1, b-1):
        B[a-1] += 1
        B[b-1] += 1
L = [uf.size(i)-1-F[i]-B[i] for i in range(n)]
print(*L)


Measured memory_bytes: 13852
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

int main(void){
  int N,M;
  cin >>N>>M;
  int B[M];
  for (int i=0;i<M;i++){
    B[i]=0;
  }
  int K[N];
  int A[N][M];
  for (int i=0;i<N;i++){
    cin >>K[i];
    for (int j=0;j<K[i];j++){
      cin >>A[i][j];
      B[A[i][j]-1]+=1;
    }
  }
  int res=0;
  for (int i=0;i<M;i++){
    if (B[i]==N){
      res+=1;
    }
  }
  cout << res<< endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		N int
	)
	fmt.Scan(&N)
	A := make([]int, N)
	B := make([]int, N)
	C := make([]int, N-1)
	for i := range A {
		fmt.Scan(&A[i])
	}
	for i := range B {
		fmt.Scan(&B[i])
	}
	for i := range C {
		fmt.Scan(&C[i])
	}
	res := 0
	pre := -1
	for i, a := range A {
		res += B[a-1]
		if i == 0 {
		} else {
			if pre == a-1 {
				res += C[pre-1]
			}
		}
		pre = a
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

# --------------------------------------------

dp = None

def main():
    N = int(input())

    L = [2, 1]

    for i in range(2, N+1):
        L.append(L[i-1] + L[i-2])

    print(L[N])

main()


Measured memory_bytes: 4928
def resolve_b():
    n, a, b = map(int, input().split())
    i = int(n / (a + b))
    j = n % (a + b)
    if n < (a + b):
        if n <= a:
            print(n)
        else:
            print(a)
    else:
        if j == 0:
            print(i * a)
        else:
            if j >= a:
                print(i * a + a)
            else:
                print(i * a + j)
resolve_b()

Measured memory_bytes: 3064
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <random>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

class timer {
    vector<timer> timers;
    int n = 0;
public:
    double limit = 9.8;
    double t = 0;
    timer() {}
    timer(int size) : timers(size) {}
    bool elapses() const {
        return time() - t > limit;
    }
    void measure() {
        t = time() - t;
        ++n;
    }
    void measure(char id) {
        timers[id].measure();
    }
    void print() {
        if (n % 2)
            measure();
        for (int i = 0; i < 128; ++i) {
            if (timers[i].n)
                cerr << (char)i << ' ' << timers[i].t << 's' << endl;
        }
        cerr << "  " << t << 's' << endl;
    }
    static double time() {
#ifdef LOCAL
        return __rdtsc() / 3.3e9;
#else
        unsigned long long a, d;
        __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
        return (d << 32 | a) / 2.8e9;
#endif
    }
} timer(128);

class {
    unsigned y = random_device()();
public:
    unsigned next() {
        return y ^= (y ^= (y ^= y << 13) >> 17) << 5;
    }
    int next(int b) {
        return next() % b;
    }
    int next(int a, int b) {
        return next(b - a) + a;
    }
    double nextDouble(double b = 1) {
        return b * next() / 4294967296.0;
    }
    double nextDouble(double a, double b) {
        return nextDouble(b - a) + a;
    }
    int operator() (int b) {
        return next(b);
    }
} rando;

vector<array<int, 3>> ad[100010];
long long fromS[100010];
long long fromT[100010];

void f(long long* a, int s, int type) {
    for (int i = 0; i < 100010; ++i)
        a[i] = 1ll << 62;
    a[s] = 0;
    priority_queue<pair<int, long long>> q;
    q.emplace(s, 0);
    while (q.size()) {
        auto p = q.top();
        q.pop();
        int i = p.first;
        long long c = p.second;
        if (a[i] != c) continue;
        for (auto& k : ad[i]) {
            if (a[k[0]] > c + k[type]) {
                a[k[0]] = c + k[type];
                q.emplace(k[0], c + k[type]);
            }
        }
    }
}

int main() {
    int n, m, s, t;
    while (cin >> n >> m >> s >> t) {
        --s;
        --t;
        for (auto& p : ad)
            p.clear();
        for (int i = 0; i < m; ++i) {
            int u, v, a, b;
            cin >> u >> v >> a >> b;
            --u;
            --v;
            ad[u].emplace_back(array<int, 3>{ v, a, b });
            ad[v].emplace_back(array<int, 3>{ u, a, b });
        }
        f(fromS, s, 1);
        f(fromT, t, 2);
        vector<long long> r{ 1ll << 62 };
        for (int i = n - 1; i >= 0; --i) {
            long long c = fromS[i] + fromT[i];
            r.emplace_back(min(r.back(), c));
        }
        reverse(r.begin(), r.end());
        r.pop_back();
        for (long long c : r)
            cout << 1000000000000000ll - c << endl;
    }
    return 0;
}


Measured memory_bytes: 16436
# reference -> https://atcoder.jp/contests/keyence2020/submissions/9649881
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

INF = 2**19

# dp[bit][s]
#   ビットに1が立っているカードはソートされて左から並んでいる
#   そのとき最後の値をsにするのに必要な最小操作回数
# 1 <= A,B <= 50, bitの立ち方が 0...0 ~ 1...1 の2**N
dp = [[INF for _ in range(50 + 1)] for _ in range((1<<N))]
# 0枚選んでいて右端が0は何もしてないのでコスト0
dp[0][0] = 0

for bit in range(1<<N):
  num_used = bin(bit).count("1") # 既に並んでいるカードの枚数
  idx = num_used
  remaining = [] # まだ並べていないカードがどれか
  for i in range(N):
    if not (bit & (1 << i)):
      # (初期位置, 現在位置)
      #   - 初期位置 : 最初の状態で左から何番目にあるか
      #   - 現在位置 : bitで1が立っているカードを並べたときに左から何番目にあるか
      remaining.append((i, idx))
      idx += 1
  for s in range(51):
    # bitの集合かつ、その右端にsの状態が作れないならスキップ
    if dp[bit][s] >= INF:
        continue
    for init_pos, current_pos in remaining:
      # 最後尾まで移動させる際の交換回数に応じてA, Bの適切な方を選ぶ
      number = [A[init_pos], B[init_pos]][abs(init_pos-num_used)%2]
      if number >= s: # 現段階の最後尾の値以上であればOK
        dp[bit | (1<<init_pos)][number] = min(
          dp[bit | (1<<init_pos)][number], dp[bit][s] + abs(num_used - current_pos)
        )


# 全てのbitに1が立っている（全て並べ切った）時の最小コストが答え
ans = min([dp[-1][s] for s in range(51)])

print(ans if ans < INF else -1)

Measured memory_bytes: 181148
#include <iostream>
#include <math.h>
using namespace std;

int getTop(int num){
  return num / pow(10, (int)log10(num));
}

int main(void){
  int num;
  cin >> num;
  
  int array[10][10];
  int i, j, n;
  for(i = 0; i < 10; i++){
    for(j = 0; j < 10; j++){
      array[i][j] = 0;
    }
  }
  
  int sum = 0;
  for(i = 0; i < 10; i++){
    for(j = 0; j < 10; j++){
      int count = 0;
      for(n = 1; n <= num; n++){
        if(j == n % 10 && getTop(n) == i){
          count++;
        }
      }
      array[i][j] = count;
    }
  }
  
  for(i = 0; i < 10; i++){
    for(j = 0; j < 10; j++){
      sum += array[i][j] * array[j][i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e6 + 9;

ll z[N], a[N], b[N];
vector<ll> va, vb;

vector<ll> vv;

void Z() {
	for(int it: vb)
		vv.push_back(it);
	vv.push_back(-1); // invalid number like $
	for(int it: va)
		vv.push_back(it);
	for (ll i = 1, l = 0, r = 0; i < (int)vv.size(); ++i) {
		if(i <= r)
			z[i] = min(r - i + 1, z[i - l]);
		while(i + z[i] < (int)vv.size() && vv[i + z[i]] == vv[z[i]])
			++z[i];
		if(i + z[i] - 1 > r) {
			r = i + z[i] - 1;
			l = i;
		}
	}
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 1; i < n + n; ++i) {
		if(i >= n)
			a[i] = a[i - n];
		va.push_back(a[i] ^ a[i - 1]);
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		if(i)
			vb.push_back(b[i] ^ b[i - 1]);
	}
	Z();
	for (int i = n; i < n + n; ++i) {
		if(z[i] == n - 1)
			cout << i - n << ' ' << (a[i - n] ^ b[0]) << '\n';
	}
	return 0;
}


Measured memory_bytes: 31208
#include<bits/stdc++.h>
using namespace std;
const int N=2010;
int n,m,len[N][N],l[N][N],r[N][N];
bool ok[N][N];char s[N][N];
int q[N],tail;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for (int i=1;i<=n;i++)
	for (int j=2;j<=m;j++)
		ok[i][j]=(s[i][j]!=s[i][j-1]);
	for (int i=1;i<=n;i++)
	for (int j=2;j<=m;j++)
		len[i][j]=(ok[i][j]==ok[i-1][j]?len[i-1][j]+1:1);
	for (int i=1;i<=n;i++){
		q[tail=1]=1;
		for (int j=2;j<=m;j++){
			while (len[i][q[tail]]>=len[i][j]) tail--;
			l[i][j]=q[tail]+1;
			q[++tail]=j;
		}
		q[tail=1]=m+1;
		for (int j=m;j>1;j--){
			while (len[i][q[tail]]>=len[i][j]) tail--;
			r[i][j]=q[tail]-1;
			q[++tail]=j;
		}
	}
	int ans=max(n,m);
	for (int i=1;i<=n;i++)
	for (int j=2;j<=m;j++)
		ans=max(ans,len[i][j]*(r[i][j]-l[i][j]+2));
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    string s;cin>>s;
    sort(all(s));
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
        puts("Yes");
    }
    else puts("No");
    return 0;
}



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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;
long long int c = 0;


void merge(int a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int l[n1+1], r[n2+1];
    REP(i, n1) l[i] = a[left + i];
    REP(i, n2) r[i] = a[mid + i];
    l[n1] = INF;
    r[n2] = INF;
    int i = 0;
    int j = 0;
    for(int k = left; k < right ; k++){
        if(l[i] <= r[j]){
            a[k] = l[i];
            i++;
        } else {
            c += n1-i;
            a[k] = r[j];
            j++;
        }
    }
    return;
}

void merge_sort(int a[], int left, int right){
    if (left+1 < right){
        int mid = (left + right) / 2;
        merge_sort(a, left, mid);
        merge_sort(a, mid, right);
        merge(a, left, mid, right);
    }
    return;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    merge_sort(a, 0, n);

    cout << c << endl;

    return 0;
}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; i + j <= N; j++) {
      int k = N - i - j;
      if (10000 * i + 5000 * j + 1000 * k == Y) {
        cout << i << "\n";
        cout << j << "\n";
        cout << k << "\n";
        return 0;
      }
    }
  }
  cout << -1 << "\n";
  cout << -1 << "\n";
  cout << -1 << "\n";
}

Measured memory_bytes: 3596
s = input()
answer = "Yes"
for n in range(int((len(s)-1)/2)):
    if s[n] != s[-(n+1)]:
        answer = "No"
if len(s) % 4 == 1:
    for n in range(int((len(s)-1)/4)):
        if s[n] != s[int((len(s)-1)/2-1-n)]:
            answer = "No"
if len(s) % 4 == 3:
    for n in range(int((len(s)-3)/4)):
        if s[n] != s[int((len(s)-1)/2-1-n)]:
            answer = "No"
print(answer)

Measured memory_bytes: 3064
// AOJ 0330: Halting Problem
// 2017.10.27 bal4u@uu

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

#define ADDV	1
#define ADDC	2
#define SUBV	3
#define SUBC	4
#define SETV	5
#define SETC	6
#define IFV		7
#define HALT	8

typedef struct { int lin, cmd, v1, v2, v3, con, to; } T;
T pgm[52]; int n;

int tr['z'+1];
char var[26]; int sz;
int lin[1002];
char tmp[110][26];
char mk[51][16][16][16][16][16];

void doprint()
{
	int i;
	for (i = 'a'; i <= 'z'; i++) if (tr[i] >= 0) printf("%c=%d\n", i, var[tr[i]]);
}

void calc(int id, int v)
{
	if (v < 0 || v >= 16) { doprint(); exit(0); }
	var[id] = v;
}

int varid(char x)
{
	int r;
	if (tr[x] < 0) r = sz++, tr[x] = r;
	else r = tr[x];
	return r;
}

int main()
{
	int i, pc, cnt;
	char cmd, b1[10], b2[10], b3[10];
	T *tp;

	memset(tr, -1, sizeof(tr)), memset(lin, -1, sizeof(lin)), sz = 0;
	scanf("%d", &n);
	for (tp = pgm, i = 0; i < n; i++, tp++) {
		scanf("%d%s", &tp->lin, b1); lin[tp->lin] = i, cmd = *(b1+1);
		if (cmd == 'A') tp->cmd = HALT;
		else if (cmd == 'D' || cmd == 'U') {
			scanf("%s%s%s", b1, b2, b3);
			tp->v1 = varid(*b1), tp->v2 = varid(*b2);
			if (*b3 >= 'a') {
				tp->cmd = (cmd == 'D') ? ADDV : SUBV;
				tp->v3 = varid(*b3);
			} else {
				tp->cmd = (cmd == 'D') ? ADDC : SUBC;
				tp->con = atoi(b3);
			}
		} else if (cmd == 'E') {
			scanf("%s%s", b1, b2);
			tp->v1 = varid(*b1);
			if (*b2 >= 'a') {
				tp->cmd = SETV;
				tp->v2 = varid(*b2);
			} else {
				tp->cmd = SETC;
				tp->con = atoi(b2);
			}
		} else {		// IF
			scanf("%s%d", b1, &tp->to);
			tp->cmd = IFV, tp->v1 = varid(*b1);
		}
	}
	pc = 0, cnt = 0;
	while (1) {
		if (mk[pc][var[0]][var[1]][var[2]][var[3]][var[4]]) { puts("inf"); return 0; }
		mk[pc][var[0]][var[1]][var[2]][var[3]][var[4]] = 1;
		tp = pgm+pc;
		if      (tp->cmd == ADDV) calc(tp->v1, var[tp->v2] + var[tp->v3]);
		else if (tp->cmd == ADDC) calc(tp->v1, var[tp->v2] + tp->con);
		else if (tp->cmd == SUBV) calc(tp->v1, var[tp->v2] - var[tp->v3]);
		else if (tp->cmd == SUBC) calc(tp->v1, var[tp->v2] - tp->con);
		else if (tp->cmd == SETV) calc(tp->v1, var[tp->v2]);
		else if (tp->cmd == SETC) calc(tp->v1, tp->con);
		else if (tp->cmd == HALT) break;

		if (tp->cmd == IFV && var[tp->v1] != 0) {
			if (lin[tp->to] < 0) break;
			pc = lin[tp->to];
		} else {
			pc++;
			if (pc == n) break;
		}
	}
	doprint();
	return 0;
}

Measured memory_bytes: 45904
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    int d[N];
    int sum=0;
    for(int i=1;i<=N;i++){
        cin>>d[i];
    }
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            sum=sum+d[i]*d[j];
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=21;
int h,w;
vs a;
int dp[M][M][M][M];

int Rec(int lx,int rx,int ly,int ry){
	if(lx==rx||ly==ry) return 0;
	if(dp[lx][rx][ly][ry]>=0) return dp[lx][rx][ly][ry];
	set<int> st;
	for(int i=lx;i<rx;i++) for(int j=ly;j<ry;j++) if(a[i][j]=='.'){
		st.insert(Rec(lx,i,ly,j)^Rec(lx,i,j+1,ry)^Rec(i+1,rx,ly,j)^Rec(i+1,rx,j+1,ry));
	}
	for(int i=0;;i++) if(st.find(i)==st.end()){
		dp[lx][rx][ly][ry]=i;
		break;
	}
	return dp[lx][rx][ly][ry];
}

int main(){
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) for(int k=0;k<M;k++) fill(dp[i][j][k],dp[i][j][k]+M,-1);
	cin>>h>>w;
	a=vs(h);
	for(int i=0;i<h;i++) cin>>a[i];
	cout<<(Rec(0,h,0,w)?"First":"Second")<<endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n){
        cin >> p[i];
    }
    q = p;
    sort(q.begin(), q.end());
    int cnt = 0;
    rep(i, n){
        if(q[i]!=p[i]){
            cnt++;
        }
    }
    if(cnt==0 || cnt == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m, val;
    unordered_map<int, int> prob;
    unordered_map<int, int> real;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> val;
        prob[val] += 1;
    }
    cin >> m;
    for(int i = 0; i < m; i++) {
        cin >> val;
        real[val] += 1;
    }
    for(auto [level, cnt]: real) {
        if (prob[level] < cnt) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 19820
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    long long int n,k,sum=0,max=0;
    cin>>k>>n;
    vector<long long int>a(1000000);
    vector<long long int>b(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        b[i]=a[i+1]-a[i];
        if(max<b[i]){
            max=b[i];
        }
    }
    b[n-1]=k-a[n-1]+a[0];
    if(max<b[n-1]){
            max=b[n-1];
        }
    for(int i=0;i<n;i++){
        sum+=b[i];
    }
    cout<<sum-max<<endl;

   return 0;
}

Measured memory_bytes: 15872
def main():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())

    dist = abs(a - b)
    if dist - (v - w) * t <= 0:
        print('YES')
    else:
        print('NO')    

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    for(int i = 0; i < 3; i++) {
      a[i] = sc.nextInt();
    }
    int f = a[0];
    int ans = 0;
    int c = 0;
    for(int i = 0; i < 3; i++) {
      if(a[i] != f) {
        c++;
        ans = a[i];
      }
    }
    if(c == 2) ans = f;
    System.out.println(ans);
  }
}

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

int main()
{
    int n, a[200], ans = 0;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n)
    {
        if (i % 2 == 1 && a[i] % 2 == 1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  string S;
  cin >> S;
  
  int num1 = atoi(S.substr(0,2).c_str());
  int num2 = atoi(S.substr(2,2).c_str());
  
  bool flag1 = false;
  bool flag2 = false;
  if(1<=num1 && num1<=12) flag1 = true;
  if(1<=num2 && num2<=12) flag2 = true;
  
  if(!flag1 && !flag2){
    cout << "NA" << endl;
  }else if(flag1 && flag2)
  {
    cout << "AMBIGUOUS" << endl;
  }else if(flag1){
    cout << "MMYY" << endl;
  }else{
    cout << "YYMM" << endl;
  }
  
//  cout << num1 << num2 << endl;
  
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    edge=[[] for _ in range(N)]
    for i in range(M):
        a,b=map(int1,input().split())
        edge[a].append(b)
        edge[b].append(a)
    for i in range(N):
        print(len(edge[i]))

if __name__ == '__main__':
    main()


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

using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define fi first
#define se second
 
template<class T> bool ckmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<class T> bool ckmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n;
string s;

bool moze(int x)
{
    for(int i = 0; i+2*x-1 < n; ++i)
    {
        string pat = s.substr(i, x);
        string ost = s.substr(i+x);
        //cout << pat << " " << ost << "\n";
        if(ost.find(pat) != string::npos)
        {
            //cout << "alo nasao sam xxxxd\n";
            return 1;
        }
    }

    return 0;
}

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

    cin >> n;
    cin >> s;

    int l = 1, r = n / 2;
    int ans = 0;

    while(l <= r)
    {
        int mid = l + (r - l) / 2;

        if(moze(mid))
        {
            ans = mid;
            l = mid + 1;
        }
        else
            r = mid - 1;
    }

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


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

using namespace std;


int main()
{
    
    int n,k;
    cin>>n>>k;
    int d[k];
     int i,a;
     set<int >s;
     int j;
     for(i=0;i<k;++i)
       {
           cin>>d[i];
           for(j=0;j<d[i];++j)
             {
                 cin>>a;
                 s.insert(a);
             }
       }
       
      cout<<n-s.size(); 
   
       
       
    
     
     return 0;   
    
}

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

using namespace std;

void printVector(const vector<int> &A) {
    for(int i = 0; i < A.size(); i++) {
        cout << A[i];
        if(i+1 < A.size()) cout << ' ';
    }
    cout << endl;
}

int main() {
    int n, count = 0;
    auto swap = [](int &a, int &b) {
        int tmp = a;
        a = b;
        b = tmp;
    };

    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    
    for(int i = 0; i < n-1; i++) {
        for(int j = n-2; j >= i; j--) {
            if(A[j] > A[j+1]) {
                swap(A[j], A[j+1]);
                count++;
            }
        }
    }
    printVector(A);
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3076