akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()

for i in range(K):
	B += A//2
	A //= 2

	A, B = B, A

if K%2 == 1:
	A, B = B, A
print(A, B)


Measured memory_bytes: 5516
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))

if len(list(filter(lambda v : v == 0, A))) > 0:
    print(0)
else:

    x = 1
    MAX = 10 ** 18
    for a in A:
        x *= a
        if x > MAX:
            x = -1
            break

    print(x)

Measured memory_bytes: 22800
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std ;
int main(){
    int N;
    cin >> N;
    if(N%1000==0){
        cout << 0 << "\n";
        return 0;
    }else{
        int a = N/1000 +1;
        int b = 1000*a - N;
        cout << b << "\n";
    }
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,k;
	cin>>n>>k;
	int a[101010]={};
	FOR(i,0,n)cin>>a[i];
	sort(a,a+n);
	int ans=mod;
	FORD(i,n,k-1){
		int j=i-k+1;
		ans=min(ans,a[i]-a[j]);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    result = sum([(a - max(A))**2 for a in A])
    for i in range(min(A), max(A)):
        tmp = sum([(i - a)**2 for a in A])
        if result > tmp:
            result = tmp

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        long num = rlong()-1;
        WriteLine((num*(num+1))/2);
    
    
    
    
    
    
    }
    static long CombinationMod(long m, long n, long mod) {
    Func<long, long, long> ModPow = (x1, x2) => {
        long ans = 1;
        while (x2 > 0) {
            if (x2 % 2 == 1) {
                ans = (ans * x1) % mod;
            }
            x1 = (x1 * x1) % mod;
            x2 /= 2;
        }
        return ans % mod;
    };
    Func<long, long> ModFact = (x1) => {
        long ans = 1;
        for (long i = x1; i > 0; i--)
            ans = (ans * i) % mod;
        return ans;
    };

    var a = ModFact(m);
    var b = (ModFact(n) * ModFact(m-n)) % mod;
    long bb = ModPow(b, mod - 2);
    return (a * bb) % mod;
}
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
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; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,c;
cin>>a>>b>>c;
if(a<b)cout<<a+min(b,c)<<endl;
else cout<<b+min(a,c)<<endl;
//system("pause");
return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

struct Pos { int x, y; };

int n, u, v, m, usaneko[2][1002];
unordered_map< int, Pos > usaneko_map[2];

int main() {
	cin >> n >> u >> v >> m;
	
	for_(un,0,2) {
		for_(i,0,n) for_(j,0,n) {
			int c;
			cin >> c;
			usaneko_map[un][c] = Pos{j, i};
		}
	}
	
	for_(un,0,2) for_(i,0,n+n+2) usaneko[un][i] = n;
	
	int cnt[2] = {0};
	
	for_(i,0,m) {
		int c;
		cin >> c;
		
		for_(un,0,2) {
			if (usaneko_map[un].count(c)) {
				Pos p = usaneko_map[un][c];
				if (--usaneko[un][p.y] == 0) ++cnt[un];
				if (n > 1 && --usaneko[un][n + p.x] == 0) ++cnt[un];
				if (n > 1 && p.x == p.y && --usaneko[un][n + n] == 0) ++cnt[un];
				if (n > 1 && p.x == n - p.y - 1 && --usaneko[un][n + n + 1] == 0) ++cnt[un];
			}
		}
						
		if (cnt[0] >= u && cnt[1] < v) {
			cout << "USAGI" << endl;
			return 0;
		}
		
		if (cnt[0] < u && cnt[1] >= v) {
			cout << "NEKO" << endl;
			return 0;
		}
	}
	
	cout << "DRAW" << endl;
}

Measured memory_bytes: 16168
#include <stdio.h>
int main(void) {
	int i, j, n, v, a[100];
	scanf("%d", &n); /*1 <= n <= 100*/
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (j = 0; j < n - 1; j++)
		printf("%d ", a[j]);
	printf("%d\n", a[n - 1]);
	for (i = 1; i < n; i++) {
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (j = 0; j < n - 1; j++)
			printf("%d ", a[j]);
		printf("%d\n", a[n - 1]);
	}
	return 0;
}

Measured memory_bytes: 600
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	fmt.Println(larger(intScanner()*intScanner(), intScanner()*intScanner()))
}


Measured memory_bytes: 1776
from itertools import accumulate
import sys
readlines = sys.stdin.readlines
input = sys.stdin.readline
S = tuple(accumulate(map(lambda x: 1 if x == 'A' else 2, input().rstrip())))
T = tuple(accumulate(map(lambda x: 1 if x == 'A' else 2, input().rstrip())))
input()
for line in readlines():
    a, b, c, d = map(lambda x: int(x)-1, line.split())
    s = S[b]-S[a-1] if a else S[b]
    t = T[d]-T[c-1] if c else T[d]
    print('YES' if s % 3 == t % 3 else 'NO')


Measured memory_bytes: 93392
#include <iostream>

using namespace std;

int main() {
    
    string s;
    cin >> s;
    
    if(s == "Sunny"){
        cout << "Cloudy";
    } else if(s == "Cloudy"){
        cout << "Rainy";
    } else {
        cout << "Sunny";
    }
    

    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back

using namespace std;

vector<vector<int>> g;
vector<bool> vs;
vector<int> dst[2];

void dfs(int v, int d){
	vs[v] = true;
	for(auto e : g[v]){
		if(!vs[e]){
			dst[d][e] = dst[d][v]+1;
			dfs(e,d);
		}
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,u,v,a,b;
	scanf("%d%d%d", &n, &u, &v);
	dst[0].resize(n+1);
	dst[1].resize(n+1);
	g.resize(n+1);
	vs.assign(n+1, false);
	for(int i = 0; i < n-1; ++i){
		scanf("%d%d", &a,&b);
		g[a].pb(b);
		g[b].pb(a);
	}
	dst[0][u] = 0;
	dst[1][v] = 0;
	dfs(u, 0);
	vs.assign(n+1, false);
	dfs(v,1);
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		if(dst[1][i] > dst[0][i]) {
			ans = max(ans,dst[1][i]);
		}
	}
	printf("%d\n", ans-1);
	return 0;
}


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

int z[200005];
int x[200005];
int main()
{
	int a;ll b,c;
	scanf("%d",&a);b=0;
	memset(z,0,sizeof(z));
	for(int i=0;i<a;i++)
	{
		scanf("%d",&x[i]);
		z[x[i]]++;
	}
	for(int i=0;i<200005;i++)
	{
		if(z[i]!=0)b+=1ll*z[i]*(z[i]-1)/2;
	}
	for(int i=0;i<a;i++)
	{
		c=b;
		c-=1ll*z[x[i]]*(z[x[i]]-1)/2;
		c+=1ll*(z[x[i]]-1)*(z[x[i]]-2)/2;
		printf("%lld\n",c);
	}
}


Measured memory_bytes: 4096
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

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

    int res = 0;
    for (int i = 1; i < n - 1; i++) {
        if (vec[i] > vec[i - 1] && vec[i] < vec[i + 1]) ++res;
        else if (vec[i] < vec[i - 1] && vec[i] > vec[i + 1]) ++res;
    }

    cout << res << endl;
}


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

int main(){
  int k;
  while(cin >> k,k){
    int ans = 0;
    for(int i=0;i<k*(k-1)/2;i++){
      int tmp;
      cin >> tmp;
      ans += tmp;
    }
    cout << ans/(k-1) << endl;
  }
}

Measured memory_bytes: 1160
def gcd(u, v):
    if (v == 0): return u
    return gcd(v, u % v)

def lcm(u, v):
    return (u * v) // gcd(u, v)

while 1:
    try:
        inp = input()
    except EOFError:
        break
    else:
        u, v = inp.split(' ')
        u = int(u)
        v = int(v)
        print(gcd(u, v), lcm(u, v))

Measured memory_bytes: 6720
from bisect import bisect_right


N, M, K = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))


B_time = []
time = 0
for B in B_list:
	time += B
	B_time.append(time)

i = bisect_right(B_time, K)
if i > 0:
	count = i
else:
	count = 0

time = 0
for i, A in enumerate(A_list):
	time += A
	if time <= K:
		j = bisect_right(B_time, K - time)
		if j > 0:
			c = i + 1 + j
		else:
			c = i + 1
		if c > count:
			count = c
print(count)


Measured memory_bytes: 40460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}


int main(){
    int N;
    cin >> N;
    string str = "";
    for(int i = 0; i < N; i++){
        char c;
        cin >> c;
        str.push_back(c);
    }
    ll count = 0;
    for(int i = 0; i < N - 2; i++){
        string test = {str[i], str[i + 1], str[i + 2]};
        if(test == "ABC")count++;
    }
    cout << count << endl;
}
    




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long asize=2e5+5;

int main(){
	long long n,h,a[asize],ans=0;
	unordered_map<long long,long long>hpi,hmi;
	cin>>n;
	for(long long i=1;i<=n;i++){
		cin>>a[i];
		hmi[i-a[i]]++;
		hpi[i+a[i]]++;
	}
/*	for(auto x:hmi){
		cout<<x.first<<" "<<x.second<<"\n";
	}
	cout<<"\n";
	for(auto x:hpi){
		cout<<x.first<<" "<<x.second<<"\n";
	}*/
	for(auto x:hmi){
		ans+=x.second*(hpi[x.first]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 27896
n = int(input())
a = list(map(int, input().split()))
b = a[::-1]

if n == 0 and a[0] == 1:
    print(1)
    exit()

if n == 0:
    print(-1)
    exit()
      
if a[0] >= 1:
    print(-1)
    exit()
    
ans = [0] * (n + 1)
for i in range(n):
    ans[i + 1] = ans[i] + b[i]

ans = ans[::-1]

ans = ans[1::]
a = a[1::]

res = 1
prev_cnt = 1

for i in range(n):
    cnt = min(prev_cnt * 2, ans[i] + a[i])
    if cnt < a[i]:
        print(-1)
        exit()
    res += cnt
    prev_cnt = cnt - a[i]
print(res)


Measured memory_bytes: 83404
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(ll N){
    vector<bool> a(N+1); //* false: female, true: male
    string s;
    cout << 0 << endl;
    cin >> s;
    if(s == "Vacant") 
        return;
    if(s == "Male")
        a[N]=a[0] = true;
    else
        a[N]=a[0] = false;
    ll lo = 0, hi = N;
    while(hi - lo > 1){
        ll mid = (lo + hi)/2;
        cout << mid << endl;
        cin >> s;
        if(s == "Vacant") 
            return;
        a[mid] = (s=="Male"? true: false);
        if((a[lo] == a[mid]) == ((mid-lo)&1)){
            hi = mid;
            continue;
        }
        if((a[mid] == a[hi]) == ((hi-mid)&1)){
            lo = mid;
            continue;
        }
    }
    
}

int main(){
    ll N;
    std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 852
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 600
int dirx[] = {1, -1,0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};



//=============================================ASIFAZAD==============================================//

bool cmp(int a, int b)
{
    return abs(a) > abs(b);
}

int32_t main()
{
    io;
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans= max(ans, b*d);
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main(){
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a[i];
  int q;
  cin >> q;
  REP(i,q){
    int b,e;
    cin >> b >> e;
    reverse(a.begin()+b,a.begin()+e);
  }
  REP(i,n-1) cout << a[i] << " ";
  cout << a[n-1] << endl;
}



Measured memory_bytes: 3124
from collections import deque
def main():
    h, w = map(int, raw_input().split())
    s = [raw_input().strip() for _ in xrange(h)]
    q = deque()
    po = q.popleft
    pu = q.append
    a = [100000] * (h * w)
    for i, r in enumerate(s):
        for j, c in enumerate(r):
            if c == '#':
                pu((i, j))
                a[i*w+j] = 0
    dd = ((0, -1), (0, 1), (1, 0), (-1, 0))
    while q:
        x, y = po()
        z = a[x*w+y] + 1
        for dx, dy in dd:
            nx, ny = x + dx, y + dy
            if 0 <= nx < h and 0 <= ny < w and a[nx*w+ny] > z:
                a[nx*w+ny] = z
                pu((nx, ny))
    print z - 1
main()


Measured memory_bytes: 74012
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void fc(const vector<int> &p, const vector<int> &c, ll &ans, int st, int k, int n){
  vector<int> chk(n, -1);
  ll add = 0;
  int now = st;
  int co = 0;
  vector<ll> pa;
  pa.push_back(0);
  while(1){
    now = p.at(now);
    if(chk.at(now) != -1){
      break;
    }
    k--;
    if(k < 0) break;
    add += c.at(now);
    ans = max(ans, add);
    pa.push_back(add);
    chk.at(now) = co++;
  }

  if(k <= 0) return ;
  if(add - pa.at(chk.at(now)) > 0){
    int sz = co - chk.at(now);
    ll up = add - pa.at(chk.at(now));
    int cs = k/sz;
    k %= sz;
    if(cs > 0){
      cs--;
      k += sz;
    }
    add += up*cs;
    ans = max(ans, add);
    while(k > 0){
      now = p.at(now);
      add += c.at(now);
      ans = max(ans, add);
      k--;
    }
  }else{
    int sz = co - chk.at(now);
    rep(i, min(k, sz)){
      now = p.at(now);
      add += c.at(now);
      ans = max(ans, add);
      k--;
    }
  }
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n){
    cin >> p.at(i);
    p.at(i)--;
  }
  vector<int> c(n);
  rep(i, n) cin >> c.at(i);
  
  ll ans = -1e18;
  rep(i, n){
    fc(p, c, ans, i, k, n);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3720
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int n;
	cin >> n;
	vvi matrix(n + 1, vi(n + 1, 0));
	FOR(i, 1, n) {
		FOR(j, 1, n) {
			cin >> matrix[i][j];
		}
	}

	if (n == 1) {
		cout << matrix[1][1] << endl;
		return 0;
	}

	FOR(i, 1, n) {
		FOR(j, 2, n) {
			matrix[i][j] += matrix[i][j - 1];
		}
	}
	FOR(i, 2, n) {
		FOR(j, 1, n) {
			matrix[i][j] += matrix[i - 1][j];
		}
	}

	int ans = INT_MIN;
	FOR(ye, 1, n) {
		FOR(xe, 1, n) {
			REP(ys, ye) {
				REP(xs, xe) {
					ans = max(ans, matrix[ye][xe] - matrix[ys][xe] - matrix[ye][xs] + matrix[ys][xs]);
				}
			}
		}
	}

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

Measured memory_bytes: 1256
import           Data.List


main :: IO ()
main = do
    _  <- read <$> getLine :: IO Int
    ns <- map read . words <$> getLine :: IO [Int]
    let sorted = sort ns
    let a   = sorted !! (length sorted `div` 2)
        b   = sorted !! ((length sorted `div` 2) - 1)
        ans = a - b
    print ans


Measured memory_bytes: 29052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,z,j;
  int64_t ans=-1e14;
  cin>>n;
  multiset<int> p,m;
  vector<int64_t> x(n),ps(n+1),ms(n+1);
  for(j=0;j<3*n;j++){
    cin>>z;
    if(j<n){
      p.insert(z);
      ps.at(0)+=z;
    }
    else if(j<2*n) x.at(j-n)=z;
    else if(j<3*n){
      m.insert(z);
      ms.at(0)+=z;
    }
  }
  for(j=0;j<n;j++){
    if(x.at(j)>*p.begin()){
      ps.at(j+1)=ps.at(j)+x.at(j)-*p.begin();
      p.erase(p.begin());
      p.insert(x.at(j));
    }
    else ps.at(j+1)=ps.at(j);
    if(x.at(n-1-j)<*prev(m.end(),1)){
      ms.at(j+1)=ms.at(j)+x.at(n-1-j)-*prev(m.end(),1);
      m.erase(prev(m.end(),1));
      m.insert(x.at(n-1-j));
    }
    else ms.at(j+1)=ms.at(j);
  }
  for(j=0;j<=n;j++) ans=max(ans,ps.at(j)-ms.at(n-j));
  cout<<ans<<endl;
}

Measured memory_bytes: 14876
#include <algorithm>
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
/**
 * 重み付き有向グラフの問題
 */
 
struct List {
  int v;    // 隣接リスト
  int dis;  // distance
  List(int node, int distance) {
    v = node;
    dis = distance;
  }
};
 
bool flag[100000];
int dist[100000] = {};
bool ans = true;
vector<unique_ptr<List>> str[1000000];
 
void dfs(int v) {
  if (flag[v]) {
    return;
  }
  flag[v] = true;
  for (auto&& i : str[v]) {
    if (!flag[i->v]) {
      dist[i->v] = dist[v] + i->dis;
      dfs(i->v);
    } else if (dist[i->v] != dist[v] + i->dis) {
      ans = false;
    }
  }
}
 
auto find(vector<unique_ptr<List>>& list, int v, int d) {
  if (list[v]->v == v) {
    return make_unique<List>(v, d);
  } else {
    list[v] = find(list, list[v]->v, list[v]->dis);
    return make_unique<List>(list[v]->v, list[v]->dis + d);
  }
}
 
bool unite(vector<unique_ptr<List>>& list, int xx, int yy, int d) {
  auto x = find(list, xx, 0);
  auto y = find(list, yy, 0);
  if (x->v == y->v) {
    if (x->dis + d == y->dis) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}
 
int main() {
  int n, m;
  cin >> n >> m;
  int l, r, d;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> d;
    str[l - 1].push_back(make_unique<List>(r - 1, d));
    str[r - 1].push_back(make_unique<List>(l - 1, -d));
  }
 
  // memset(flag, false, sizeof flag);
  fill_n(flag, 100000, false);
 
  for (int i = 0; i < n; ++i) {
    if (!flag[i]) {
      dfs(i);
    }
  }
 
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 44160
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>

#define EPS 1e-7

using namespace std;

typedef complex<double> P;

struct L : public vector<P> {
    L(const P &a, const P &b){
        push_back(a);
        push_back(b);
    }
};

struct C{
    P p;
    double r;
    C(const P &p, double r) : p(p), r(r) { }
};

double dot(const P &a, const P &b){
    return real(conj(a) * b);
}

bool intersectSP(const L &s, const P &p) {
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

int main(){
    int n,m;                                     
    double x,y,r;
    double a,b;

    while(cin >> n && n){
        vector<C> circles;
        bool isok = false;
        for(int i=0;i<n;i++){
            cin >> x >> y >> r;
            circles.push_back(C(P(x,y), r));
        }
        cin >> m;
        for(int i=0;i<m;i++){
            isok = false;
            cin >> x >> y;
            cin >> a >> b;
            L line = L(P(x,y), P(a,b));
            for(int j=0;j<n;j++){
                if((abs(line[0]-circles[j].p) < circles[j].r &&
                    abs(line[1]-circles[j].p) < circles[j].r) ||
                   distanceSP(line, circles[j].p) > circles[j].r){
                }else{
                    isok = true;
                }
            }
            if(isok){
                cout << "Safe" << endl;
            }else{
                cout << "Danger" << endl;
            }
        }
    }
}

Measured memory_bytes: 0
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	ll n,k;
	cin>>n>>k;
	ll x,i;
	priority_queue<ll>q;
	for(i=0;i<n;i++)
	{
		cin>>x;
		q.push(x);
	}
	while(k--&&q.size())
	{
		q.pop();
	}
	ll s=0;
	while(q.size())
	{
		s+=q.top();
		q.pop();
	}
	cout<<s;
 
	return 0;
}

Measured memory_bytes: 2420
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def prepare(n, MOD):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


def main():
    n, k = ns()

    if n > k:
        print(0)
    else:
        print(1)

    # 使い方
    # facts, invs = prepare(n + k, MOD)




if __name__ == '__main__':
    main()



Measured memory_bytes: 7304
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint N, K;
	cin >> N >> K;
	lint ans = 1000000000;
	lint now = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < i; j++) {
			now *= 2;
			//cout << now << ' ';
		}
		for (int j = i; j < N; j++) {
			now += K;
			//cout << now << ' ';
		}
		//cout << endl;
		ans = min(ans, now);
		now = 1;
	}
	for (int i = 0; i < N; i++) {
		now *= 2;
	}
	ans = min(ans, now);
	cout << ans << endl;
}

Measured memory_bytes: 256
import heapq as hq
X,Y,A,B,C = map(int,input().split())
heap = []
for p in map(int,input().split()):
    hq.heappush(heap,(-p, 0))
for p in map(int,input().split()):
    hq.heappush(heap,(-p, 1))
for p in map(int,input().split()):
    hq.heappush(heap,(-p, 2))
xs = 0
ys = 0
zs = 0
ans = 0
while xs+ys+zs < X+Y:
    p, i = hq.heappop(heap)
    p = -p
    if i == 0 and xs < X:
        xs += 1
        ans += p
    elif i == 1 and ys < Y:
        ys += 1
        ans += p
    elif i == 2:
        zs += 1
        ans += p
print(ans)

Measured memory_bytes: 123884
#include <stdio.h>
#include <string.h>
 
typedef struct{
    char name[6];
    long num;
    char f;
}product;
 
int main(void){
    long n=0, i, j, t, count=0;
    char str[6];
    product p[300000];
     
    scanf("%ld", &n);
    for(i=0; i<n; i++){
        int flag=0;
     
        scanf(" %s %ld", str, &t);
         
        for(j=0; j<count; j++){
            if(strcmp(p[j].name, str)==0){
                p[j].num+=t;
                flag=1;
                break;
            }
        }
         
        if(flag==0){
            strcpy(p[count].name, str);
            p[count].num = t;
            count++;
        }   
         
           }
     
    for(i=0; i<count; i++){
        for(j=0; j<count; j++){
            if(strcmp(p[i].name, p[j].name) < 0){
                product tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }
        }
    }   
     
    long r=0;
 
    while(r<6){

        for(i=0; i<count; i++){
            if(p[i].name[r]=='\0' && p[i].f != 'N'){
                printf("%s %ld\n", p[i].name, p[i].num);
                p[i].f='N';
            }
        }
        r++;
    }
 
    return 0;
}

Measured memory_bytes: 2732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] cards1 = new String[N];
		String[] cards2 = new String[N];
		String[] origin = new String[N];
		for(int i = 0; i < N; i++) {
			cards1[i] = sc.next();
		}
		System.arraycopy(cards1, 0, cards2, 0, N);  // cards1をcards2にコピー
		System.arraycopy(cards1, 0, origin, 0, N);

		bubbleSort(cards1, N);
		showArray(cards1);
		if(isStable(origin, cards1)) {
			System.out.println("Stable");
		}else {
			System.out.println("Not stable");
		}

		selectionSort(cards2, N);
		showArray(cards2);
		if(isStable(origin, cards2)) {
			System.out.println("Stable");
		}else {
			System.out.println("Not stable");
		}
		sc.close();
	}

	// ちなみにバブルソートは常に安定なソート
	public static void bubbleSort(String[] cards, int N) {
		for(int i = 0; i < N; i++) {
			for(int j = N - 1; j > i; j--) {
				if(getCardValue(cards[j]) < getCardValue(cards[j-1])) {
					String tmp = cards[j];
					cards[j] = cards[j-1];
					cards[j-1] = tmp;
				}
			}
		}
	}

	public static void selectionSort(String[] cards, int N) {
		for(int i = 0; i < N; i++) {
			int minj = i;
			for(int j = i+1; j < N; j++) {
				if(getCardValue(cards[j]) < getCardValue(cards[minj])) {
					minj = j;
				}
			}
			if(i != minj) {
				String tmp = cards[minj];
				cards[minj] = cards[i];
				cards[i] = tmp;
			}
		}
	}

	// 例："H9"という文字列から整数値9を取り出す
	public static int getCardValue(String s) {
		char c = s.charAt(1);
		String str = String.valueOf(c);
		return Integer.parseInt(str);
	}

	public static void showArray(String[] s) {
		System.out.print(s[0]);
		for(int i = 1; i < s.length; i++) {
			System.out.print(" " + s[i]);
		}
		System.out.println();
	}

	// ソート前後の配列を比べて、そのソートが安定かどうか判定(本課題のキモ)
	public static boolean isStable(String[] a, String[] b) {
		for(int i = 0; i < a.length; i++) {
			for(int j = i+1; j < a.length; j++) {
				for(int x = 0; x < a.length; x++) {
					for(int y = x+1; y < a.length; y++) {
						if(getCardValue(a[i]) == getCardValue(a[j]) && a[i].equals(b[y]) && a[j].equals(b[x])) {
							return false;
						}
					}
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 55536
n=int(input())
key=[]
value=[]
for i in range(1,n+1):
    a,b=input().split()
    b=100-int(b)
    key.append((a,b))
    value.append(i)
dic=dict(zip(key,value))

key.sort()
for j in key:
    print(dic[j])

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

const int MX = 2005;
bool d[3][3][MX];

int main() {
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    sort(s.begin(), s.end());
    int ans = MX * 3;
    do {
        rep(i, 3) rep(j, 3) rep(k, (int)s[i].size()) {
            if (i >= j) continue;
            bool ok = true;
            for (int ni = k; ni < (int)s[i].size(); ni++) {
                int nj = ni - k;
                if (nj >= (int)s[j].size()) break;
                if (s[i][ni] == '?' || s[j][nj] == '?') continue;
                if (s[i][ni] != s[j][nj]) ok = false;
            }
            d[i][j][k] = ok;
        }

        auto f = [&](int i, int j, int k) {
            if (k >= (int)s[i].size()) return true;
            return d[i][j][k];
        };

        rep(x, MX) rep(y, MX) {
            if (!f(0, 1, x)) continue;
            if (!f(1, 2, y)) continue;
            if (!f(0, 2, x + y)) continue;
            int now = 0;
            now = max<int>(now, (int)s[0].size());
            now = max<int>(now, x + (int)s[1].size());
            now = max<int>(now, x + y + (int)s[2].size());
            ans = min(ans, now);
        }
    } while (next_permutation(s.begin(), s.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S=input()[::-1]
List=[0]*2019
ans=0
a=1
d=0

for s in S:
  d=d+int(s)*a
  List[d%2019]+=1
  a=a*10
  a=a%2019
  #print(s[i:],int(s[i:])%2019)
  
#print(List)
ans=List[0]
for i in List:
  if (i>=2):
    ans+=(i*(i-1))//2
  
print(ans)

Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#define MAXN   1000001
int spf[MAXN]; 
int ct[MAXN];
int gcd(int a,int b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

void getFactorization(int x) 
{ 
    //vector<int> ret; 
    while (x != 1) 
    {
    	int y = spf[x];
    	ct[y]++;
    	while(spf[x]==y)
    	{
    		x = x / spf[x]; 
    	} 
    } 
    return; 
} 

signed main()
{
	int n;
	cin >> n;
	int a[n];
	rep(i,0,n) cin >> a[i];
	int x = a[0];
	rep(i,1,n)
	{
		x = gcd(x,a[i]);
	}
	rep(i,0,MAXN) ct[i] = 0;
	sieve();

	rep(i,0,n)
	{
		getFactorization(a[i]);

	}

	int flag=0;
	rep(i,0,MAXN)
	{
		if(ct[i]>1)
		{
			flag=1;
			break;
		}
	}

	if(flag==0)
	{
		cout << "pairwise coprime"<<endl;
		return 0;
	}
	else
	{
		if(x==1)
		{
			cout << "setwise coprime"<<endl;
			return 0;
		}
		else
		{
			cout << "not coprime" <<endl;
		}
	}
		
		
}
 
	
		



Measured memory_bytes: 26952
import java.util.*;
class Main{
  public static void main(String args[]){

    int max = -1000000000;
    int rt;
    int min;

    Scanner sc = new Scanner(System.in);
    // input
    int n = sc.nextInt();
    //first
    min = sc.nextInt();
    //Comparison
    for(int i = 1; i<n; i++){
      rt = sc.nextInt();
      if(rt-min>max)max = rt-min;
      if(min>rt)min = rt;

    }
    System.out.println(max);
  }
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c)
{
    int sum = a + b + c;
    if (sum - max(a, max(b, c)) == max(a, max(b, c)))
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long c;
    scanf("%lld", &c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
antenna = []
for i in range(5):
    antenna.append(int(input()))
k = int(input())

can = True

for i in antenna:
    for j in antenna:
        if i == j or i < j:
            continue
        else:
            if abs(i - j) > k:
                can = False
                break
            else:
                continue

print('Yay!') if can else print(':(')


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
/**********************************************/

int main(){
    int num = 0;
    cin >> n;
    int N = n;
    while(N){
        num += N % 10;
        N /= 10;
    }

    if(n % num == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
struct node{
	int s,t,v;
}stk[100];
int m;
int main(){
	int l;
	scanf("%d",&l);
	int n;
	for(n=1;n<=20;n++)
		if((1<<n)>l)
			break;
	for(int i=1;i<n;i++){
		stk[++m]=(node){i,i+1,1<<(i-1)};
		stk[++m]=(node){i,i+1,0};
	}
	l-=1<<(n-1);
	int sum=1<<(n-1);
	while(l>0){
		int pos=0;
		for(int i=1;i<=20;i++)
			if((1<<i)>l){
				stk[++m]=(node){i,n,sum};
				sum+=1<<(i-1);
				l-=1<<(i-1);
				break;
			}
	}
	printf("%d %d\n",n,m);
	for(int i=1;i<=m;i++)
		printf("%d %d %d\n",stk[i].s,stk[i].t,stk[i].v);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
set<string> a;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		a.insert(s);
	}
	cout << a.size() << endl;
	return 0;
}

Measured memory_bytes: 19188
//#pragma comment (linker,"/STACK:256000000")
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

#define INF 1000000000
#define LLINF 10000000000000000

typedef long long ll;

typedef struct queue
{
	int front;
	int rear;
	int *data;
}queue;

/*
void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

void print(char* str, int a, int b)
{
	int i;

	for (i = a; i <= b; i++)
		printf("%c", str[i]);
	printf("\n");
}
*/

void reverse(char* str, int a, int b)
{
	int i,j=0;
	char t;

	for (i = a; i <= (a + b) / 2; i++)
	{
		t = str[i];
		str[i] = str[b - j];
		str[b - j] = t;
		j++;
	}
}

void replace(char* str, int a, int b, char* temp)
{
	int i, j=0;

	for (i = a; i <= b; i++)
	{
		str[i] = temp[j];
		j++;
	}
}

double rad(int C)
{
	return M_PI * C / 180;
}

double distance(int* a, int* b, int n, int p)
{
	double sum = 0.0;

	int i, j;

	int max = 0;

	for (i = 0; i < n; i++)
	{
		sum += pow(ABS(a[i] - b[i]), p);

		if (ABS(a[i] - b[i]) > max)
			max = ABS(a[i] - b[i]);
	}

	if (p == INF)
		return max;

	return pow(sum, (double)1 / p);
}

/*
typedef struct Vector
{
	int data[10];
	int size;
	int max;
}Vector;

Vector *init()
{
	Vector* p;

	//p = malloc(sizeof(int)*(10+2));
	p = (Vector*)(sizeof(int) * 12);
	//p->data = (int*)malloc(sizeof(int) * 10);
	p->size = 0;
	p->max = 10;

	return p;
}

Vector* Extend(Vector* p)
{
	Vector* q;

	q = (Vector*)malloc(sizeof(int) * p->max * 2);

	memcpy(q, p, sizeof(int) * p->size);

	p->max *= 2;

	free(p);

	return q;
}

Vector *pushBack(Vector *p,int x)
{
	if (p->size == p->max)
		p = Extend(p);

	p->data[p->size++] = 1;

	return p;
}

int randomAccess(Vector* p,int x)
{
	return p->data[x];
}

Vector* popBack(Vector* p)
{
	//free(p->data[--(p->size)]);
	--p->size;
	return p;
}
*/

int max_array(int* p, int n, int a, int b)
{
	int i, max = -INF;

	for (i = a; i < b; i++)
	{
		if (p[i] > max)
			max = p[i];
	}
	return  max;
}

int min_array(int* p, int n, int a, int b)
{
	int i, min = INF;

	for (i = a; i < b; i++)
	{
		if (p[i] < min)
			min = p[i];
	}
	return  min;
}

int count(int* p, int n, int a, int b,int k)
{
	int count = 0, i;

	for (i = a; i < b; i++)
	{
		if (p[i] == k)
			count++;
	}
	return count;
}

int main()
{
	int a[1000];
	int n;
	int temp;
	int q, l, m;

	scanf("%d", &n);

	int i, j;

	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	scanf("%d", &q);

	for (i = 0; i < q; i++)
	{
		scanf("%d%d%d",&l,&m,&temp);
		printf("%d\n", count(a, n, l, m, temp));
	}
	return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if( 1 <= a  && a <= 9 &&  1 <= b  && b <= 9){
    cout << a*b << endl;
  }
  else{
    cout << -1 << endl;
  }
  
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

const lint MOD = 1000000007;

int main()
{


    lint n, k;
    cin >> n >> k;

    lint ans, tmp;
    lint Tcount=0, tcount=0;

    vector<lint> a(n);
    REP(i, n) { cin >> a[i]; }

    REP(i, n){
        REP(j,n){
            if(a[i] > a[j]){
                Tcount += 1;
                if(j > i){
                    tcount += 1;
                    //cout << i << j << "\n";
                }
            }
        }
    }


    //ans = Tcount *k%MOD * (k - 1) / 2 % MOD + (tcount * k) % MOD;
    if(k%2==0){
        ans = Tcount * (k / 2) % MOD * (k - 1) % MOD + (tcount * k) % MOD;
    }else{
        ans = Tcount * ((k-1) / 2) % MOD * (k) % MOD + (tcount * k) % MOD;
    }

    cout << ans % MOD << "\n";

    return 0;
}

Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));
$k = trim(fgets(STDIN));
$x = trim(fgets(STDIN));
$y = trim(fgets(STDIN));

$sum = 0;
if($n - $k > 0){
    $sum += $x * $k;
    $sum += $y * ($n - $k);
}else{
    $sum += $x * $n;
}

echo $sum;

Measured memory_bytes: 4728
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    let info: Vec<usize> = {
        handle.read_line(&mut buf).unwrap();
        let tmp = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp
    };
    let n: usize = info[0];
    let w: usize = info[1];
    let items: Vec<Vec<isize>> = {
        let mut tmp = Vec::with_capacity(n);
        for i in 0..n {
            handle.read_line(&mut buf).unwrap();
            let t = buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
            buf.clear();
            tmp.push(t);
        }
        tmp
    };
    let mut memo: Vec<Vec<isize>> = vec![vec![-1; w+1]; n];
    println!("{}", dp(n-1, w, w, &items, &mut memo));
}
fn dp(now_n: usize, now_w: usize, w: usize, items: &Vec<Vec<isize>>, memo: &mut Vec<Vec<isize>>) -> isize {
    if now_n == 0 {
        if now_w as isize - items[0][0] < 0 { return 0; }
        else { return items[0][1]; }
    }
    if memo[now_n][now_w] == -1 {
        if  now_w as isize - items[now_n][0] < 0 { // exclude
            memo[now_n][now_w] = dp(now_n-1, now_w, w, items, memo);
        } else {
            let included = dp(now_n - 1, now_w - items[now_n][0] as usize, w, items, memo) + items[now_n][1];
            let excluded = dp(now_n - 1, now_w, w, items, memo);
            memo[now_n][now_w] = max(included, excluded);
        }
    }
    memo[now_n][now_w]
}


Measured memory_bytes: 106748