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

        long long n,i,p=0;
        string s;
        cin>>s;
        for(i=0;i<3;i++){
            if(s[i]=='R')
            p++;
        }if(p<=1)
        cout<<p<<endl;
        else{
        if(s[0]=='R'&&s[2]=='R'&&s[1]=='R')
        cout<<3;
        if(s[0]=='R'&&s[2]=='R'&&s[1]!='R')
        cout<<1;
        if(s[0]!='R'&&s[2]=='R'&&s[1]=='R')
        cout<<2;
        if(s[0]=='R'&&s[2]!='R'&&s[1]=='R')
        cout<<2;

        }
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int n,a[200001],b[200001];
bool cmp(int x,int y){
	return x>y;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(a[i]==b[1]){
			printf("%d\n",b[2]);
		}else{
			printf("%d\n",b[1]);
		}
	}
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	cout << N*800 - (N / 15) * 200 << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
a = list(map(int, input().split())) 
a = np.array(a)

i = 2
cnt = 0
mn = a.max()

while i < mn+1:
    tmp = a[a%i == 0]
    cnt += len(tmp)
    i = i*2

print(cnt)

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

int main(){
	
	int n,a[101],cnt=0;
	cin>>n;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=1;i<n;i++){
		if(a[i-1] == a[i]) cnt++;
		if(a[i-1] == a[i] && a[i] == a[i+1]){
		i++;
		}
	}
	cout<<cnt<<endl;
	
	return 0;
}

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

int main() {
  int N;
  string S;
  
  cin >> N;
  
  for (int i = 0; i < N; i ++) {
    cin >> S;
    
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    
    else if (i+1 == N) {
      cout << "Three" << endl;
      break;
    }
  }
}

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

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    N, M = map(int, input().split())

    print((N-1)*(M-1))

if __name__ == "__main__": main()


Measured memory_bytes: 4468
N, M = map(int, input().split())

e = [0]*N
for _ in range(M):
    a, b = map(int, input().split())
    e[a-1] += 1
    e[b-1] += 1

if all(x % 2 == 0 for x in e):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n % 2 == 0) {
        	System.out.println(0.5);
        }else {
        	System.out.println(Math.ceil((double)n/2)/n);
        }

        return;
    }
}

Measured memory_bytes: 24148
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);

    long answer = (long)Math.Pow(3,n);
    long oddNum = 1;

    for(long i = 0; i < n; i++)
    {
      if(nums[i] % 2 == 0) oddNum *= 2;
    }

    answer -= oddNum;
    
		Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#define eps 0.0000000001
#define maxn 3000009
#define inf 0x3f3f3f3f
#define mod 1000000009
#define ll long long
using namespace std;

int n,sum[maxn],pre[maxn];
vector<int>v[maxn],road;

void dfs(int x,int f)
{
    sum[x]=1,pre[x]=f;
    for(int i=0; i<v[x].size(); i++)
    {
        if(v[x][i]==f)
            continue;

        dfs(v[x][i],x);
        sum[x]+=sum[v[x][i]];
    }
}

int main()
{
    //freopen("d:\\in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=1; i<n; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1,0);
    for(int i=n; i; i=pre[i])
        road.push_back(i);
    reverse(road.begin(),road.end());
    int tb,ta;
    int tmp=road[(road.size()+1)/2];
    tb=sum[tmp];
    ta=n-tb;
    if(ta>tb)
        printf("Fennec\n");
    else
        printf("Snuke\n");
    return 0;
}

Measured memory_bytes: 83964
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[2500005];
pair<int,int> p[505];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        p[i]=mp(x,i);
    }
    sort(p+1,p+n+1);
    for(int i=1;i<=n;++i){
        int k=0;
        for(int j=1;j<p[i].second;++j){
            ++k;
            while(a[k])++k;
            if(k>=p[i].first){
                puts("No");
                return 0;
            }
            a[k]=p[i].second;
        }
        a[p[i].first]=p[i].second;
    }
    for(int i=1;i<=n;++i){
        int k=p[i].first;
        for(int j=p[i].second+1;j<=n;++j){
            ++k;
            while(a[k])++k;
            if(k>n*n){
                puts("No");
                return 0;
            }
            a[k]=p[i].second;
        }
    }
    printf("Yes\n");
    for(int i=1;i<n*n;++i)printf("%d ",a[i]);
    printf("%d\n",a[n*n]);
    //system("pause");
    return 0;
}


Measured memory_bytes: 2176
#define tst(a, b) for (int i = 1; i <= (b); i++) {cout << (a)[i] << " ";} cout << endl;
#define ll long long
#define lf long double
#define ch char
#define F(a) for (int i = 1; i <= (a); i++)
#define For(a, b) for (int (a) = 1; (a) <= (b); (a)++)
#define Rep(a, b, c) for (int (a) = (b); (a) <= (c); (a)++)
#define FD(a) for (int i = (a); i >= 1; i--)
#define ForD(a, b) for (int (a) = (b); (a) >= 1; (a)--)
#define RepD(a, b, c) for (int (a) = (b); (a) >= (c); (a)--)
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define fi first
#define se second
#define il inline
#define reg register
#define ret return
#define opt operator
#define Mem0(a) memset((a), 0, sizeof(a))
#define MemInf(a) memset((a), 115, sizeof(a))
#define Mem(a, n) memset((a), (n), sizeof(a))
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
inline ll Rd() {
	ll C = getchar();
	ll V = 0;
	ll Sign = 0;
	while (C > '9' || C < '0') {
		Sign |= (C == '-');
		C = getchar();
	}

	while (C <= '9' && C >= '0') {
		V = (V << 1) + (V << 3) + (C ^ '0');
		C = getchar();
	}
	Sign && (V = -V);
	return V;
}


ll A, B, C;
int Table[1000010];

int main()
{
	cin >> A >> B >> C;
	Table[A]++; Table[B]++; Table[C]++;
	if (Table[5] == 2 && Table[7] == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 3640
from operator import mul
from functools import reduce
import collections

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())
M = input().split()

c = collections.Counter(M)

A = 0

for i in c.values():
    if i >= 2:
        A += cmb(i, 2)
    
for j in M:
    print(A - (c[j]-1))

Measured memory_bytes: 26904
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scanf("%d %d %d", &n, &a, &b)
	set := n / (a + b)
	rem := n - (a+b)*set
	if a >= rem {
		fmt.Printf("%d\n", a*set+rem)
	} else {
		fmt.Printf("%d\n", a*set+a)
	}
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int finded = 0;
		int lineSamount = scan.nextInt();
		int[] lineSnum = new int[lineSamount];
		for(int i=0; i<lineSamount; i++){
			lineSnum[i] = scan.nextInt();
		}
		int lineTamount = scan.nextInt();
		int[] lineTnum = new int[lineTamount+1];
		for(int i=0; i<lineTamount; i++){
			lineTnum[i] = scan.nextInt();
		}

		for(int i=0; i<lineSamount; i++){
			int j = 0;
			//???T??????????°????????´¢????????°????????\?????????
			lineTnum[lineTamount] = lineSnum[i];
			//?????´??????????´¢??°???????????????????????????????????´??????????°??????°???????????\???????????§??¶??????????????????
			while(lineTnum[j] != lineSnum[i]){
				j++;
			}
			//???????????£????????°??????????°??????£?????????????????£??????????????¨???????????¨???
			if(j == lineTnum.length-1 ){
//				????????????????????£??????
			}
			else {
				finded++;
				lineTnum[j] = -1;
			}
		}
		System.out.println(finded);
	}
}

Measured memory_bytes: 40216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    ll x = min(a, k);
    k -= x;
    a -= x;
    ll y = min(k, b);
    k -= y;
    b-= y;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
    int N;
    cin >> N;
    static int A[100002] = {};

    REP(i,N){
        cin >> A[i];
    }

    int ans = gcd(A[0],A[1]);
    REP(i,N){
        ans = gcd(ans,A[i]);
    }
    PRINTD(ans);
}

Measured memory_bytes: 640
import math

x = int(input())
a = []
b = []
for i in range(-1000,1000,1):
    a.append([i,i**5])
    b.append([i,i**5])

for ai,a5 in a:
    for bi,b5 in b:
        if a5 - b5 == x:
            print(ai,bi)
            exit()



Measured memory_bytes: 9396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >>b;
    cin >>u;
    if(s == u){
        print(a-1);println(b);
    }else{
        print(a);println(b-1);
    }
    return 0;
}

Measured memory_bytes: 256
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
			


a=input1()
s=str(input())

if a>=3200:
	print(s)
else:
	print("red")

Measured memory_bytes: 12488
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;

    struct Edge {
        ll to, id;
    };

    vector<vector<Edge>> connect(N);
    for (ll i = 0; i < M; i++) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        connect[A].push_back({ B, i });
        connect[B].push_back({ A, i });
    }

    if (M % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }

    struct Element {
        ll dim, node;
        bool operator<(const Element& rhs) const {
            return dim > rhs.dim;
        }
    };
    priority_queue<Element> pq;
    vector<ll> remainder(N);
    vector<ll> dim(N, 0);
    vector<bool> used_node(N, false);
    vector<bool> used_edge(M, false);
    for (ll i = 0; i < N; i++) {
        pq.push({ (ll)connect[i].size(), i });
        remainder[i] = connect[i].size();
    }

    vector<pair<ll, ll>> ans;

    while (!pq.empty()) {
        auto t = pq.top();
        pq.pop();

        if (remainder[t.node] % 2 != dim[t.node] % 2) {
            for (const auto& e : connect[t.node]) {
                if (used_edge[e.id]) {
                    continue;
                }
                ans.push_back({ e.to, t.node });
                used_edge[e.id] = true;
                remainder[e.to]--;
                remainder[t.node]--;
                dim[e.to]++;
                pq.push({ remainder[e.to], e.to });
                break;
            }
        }

        for (const auto& e : connect[t.node]) {
            if (remainder[t.node] == 0) {
                break;
            }

            if (used_edge[e.id]) {
                continue;
            }
            ans.push_back({ t.node, e.to });
            used_edge[e.id] = true;
            remainder[e.to]--;
            remainder[t.node]--;
            pq.push({ remainder[e.to], e.to });
        }
    }

    for (const auto& p : ans) {
        cout << p.first + 1 << " " << p.second + 1 << endl;
    }
}

Measured memory_bytes: 14064
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = 10 ** 18
dp = [INF] * N

dp[0] = 0

for i in range(1, N):
    left = max(0, i - K)
    for j in range(left, i):
        dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]))

print(dp[N - 1])


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

using namespace std;

#define ll long long 
int main(){
  
  
  ll n;
  cin>>n;
  ll k;
  cin>>k;
  
  ll temp = n*500;
  if(temp < k  ){
    cout<<"No";
  }
  else
    cout<<"Yes";
  
  return 0 ;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define arr array

using namespace std;

const int e = 2e6 + 69;
const ll mod = 1e9 + 7;

ll dp[e];

//beginner 1999 127

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int l, r;
        cin >> l >> r;
        dp[l] ++;
        dp[r+1] --;
    }
    for(int i=1; i<=n; i++){
        dp[i] += dp[i-1];
    }
    int dem =0;
    for(int i=1; i<=n; i++){
        if(dp[i] >= m){
            dem ++;
        }
    }
    cout << dem;
}


Measured memory_bytes: 4348
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<=(b);++(i))
#define rep(i, n)  FOR(i,0,n-1)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;


int main() {
	
	string s;cin>>s;
	int w;cin>>w;

	for(int i=0;i<s.size();i+=w)cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	r := scanInt()
	fmt.Println(r*r)
}


Measured memory_bytes: 640
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	sort.Ints(A)
	p := make([]int, N)
	p[0] = A[0]
	for i := 1; i < N; i++ {
		p[i] = A[i] + p[i-1]
	}

	count := 1

	for i := N - 2; i >= 0; i-- {
		k := 0
		if i > 0 {
			k = p[i-1]
		}
		if 2*(A[i]+k) < A[i+1] {
			break
		}
		count++
	}

	fmt.Println(count)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 7296
#include <cstdio>
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;

signed main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   int a[3];
   rep(i,3)cin >> a[i];
   sort( a, a+3 );
   cout << 0[a] << ' ' << 1[a] << ' ' << 2[a] << endl;
}




Measured memory_bytes: 3128
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
  std.range, std.container, std.bigint, std.ascii, std.typecons, std.format, std.bitmanip;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int x, y, z;
  cin.scan(x, y, z);
  swap(x, y);
  swap(x, z);
  writefln("%s %s %s", x, y, z);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] R = new int[n];
		for (int i = 0; i < n; i++) {
			R[i] = sc.nextInt();
		}
		int maxProfit = -2000000000;
		int minProfit = R[0];
		for (int i = 1; i < n; i++) {
			maxProfit = Math.max(maxProfit, R[i] - minProfit);
			minProfit = Math.min(minProfit, R[i]);
		}
		System.out.println(maxProfit);
		sc.close();
	}
}



Measured memory_bytes: 101196
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	
	int i, j;
	long long denom, tmp, sum = 0;
	for (denom = 1; denom < K; denom *= 2);
	for (i = 1; i <= N; i++) {
		for (tmp = 1; tmp * i < K; tmp *= 2);
		sum += denom / tmp;
	}
	
	printf("%.9llf\n", (long double)sum / (denom * N)); 
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

const int N = 1e6 + 7;
const int MOD = 1e9 + 7;

int mul(int a, int b) {
    return (a * b) % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

int pr[N];
vector<int> divs[N];

void init() {
    fill(pr, pr + N, 1);
    for (int i = 2; i < N; i++) {
        if (!pr[i]) continue;
        for (int j = i; j < N; j += i) {
            divs[j].push_back(i);
            pr[j] = 0;
        } 
    }
}

int lol[N];

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

    init();

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (auto x : divs[a[i]]) {
            int tmp = a[i];
            int cnt = 0;
            while (tmp % x == 0) {
                cnt++;
                tmp /= x;
            }
            lol[x] = max(lol[x], cnt);
        }
    }
    int c = 1;
    for (int i = 1; i < N; i++) {
        c = mul(c, binpow(i, lol[i]));
    }
    int ans =0;
    for (auto t : a) {
        int cur = mul(c, binpow(t, MOD - 2));
        ans += cur;
        ans %= MOD;
    }
    cout << ans << endl;

}   


Measured memory_bytes: 85632
#include <cassert>
#include <vector>

// instance: an undirected and not necessarily simple graph
class two_edge_connected_component
{
    using size_t = unsigned;
    static constexpr size_t nil = -1;
    bool made;
    std::vector<size_t> stack, low, comp;
    std::vector<std::vector<size_t>> graph, tree, memb;

    void make(size_t now, size_t pre)
    {
        size_t ord = low[now] = stack.size();
        stack.emplace_back(now);
        std::vector<size_t> brid;
        for(size_t to : graph[now])
        {
            if(to == pre) { pre = nil; continue; }
            if(low[to] == nil) make(to, now);
            if(low[to] > ord)
            {
                brid.emplace_back(to);
                graph[to].emplace_back(now);
            }
            else if(low[now] > low[to]) low[now] = low[to];
        }
        brid.swap(graph[now]);
        if(ord == low[now])
        {
            auto pos = stack.end();
            tree.resize(tree.size() + 1);
            auto &adjc = tree.back();
            do
            {
                --pos;
                comp[*pos] = memb.size();
                for(size_t u : graph[*pos]) adjc.emplace_back(comp[u]);
            } while(*pos != now);
            memb.emplace_back(pos, stack.end());
            stack.erase(pos, stack.end());
        }
    }

public:
    two_edge_connected_component(size_t n) : made(false), comp(n), graph(n)
    {
        stack.reserve(n); comp.reserve(n);
        tree.reserve(n); memb.reserve(n);
    }

    void add_edge(size_t u, size_t v)
    {
        assert(u < size()), assert(v < size());
        graph[u].emplace_back(v), graph[v].emplace_back(u);
        made = false;
    }

    void make()
    {
        if(made) return;
        made = true;
        low.assign(size(), nil);
        for(size_t v = 0; v != size(); ++v) if(low[v] == nil) make(v, nil);
    }

    size_t size() const { return graph.size(); }

    size_t size(size_t i) { make(); assert(i < count()); return memb[i].size(); }

    size_t count() { make(); return memb.size(); }

    size_t operator[](size_t v) { make(); assert(v < size()); return comp[v]; }

    const std::vector<size_t> &bridge(size_t v) { make(); assert(v < size()); return graph[v]; }

    const std::vector<size_t> &component(size_t i) { make(); assert(i < count()); return memb[i]; }

    const std::vector<std::vector<size_t>> &bridge_tree() { make(); return tree; }
}; // class two_edge_connected_component


#include <cstdio>
#include <algorithm>

main()
{
    int v,e;
    scanf("%d%d",&v,&e);
    two_edge_connected_component becc(v);
    for(int a,b; e--;)
    {
        scanf("%d%d",&a,&b);
        becc.add_edge(a,b);
    }
    becc.make();
    for(int i=0; i<v; i++)
    {
        std::vector<int> brid;
        for(int u: becc.bridge(i))
        {
            if(i<u) brid.emplace_back(u);
        }
        std::sort(brid.begin(),brid.end());
        for(int u: brid)
        {
            printf("%d %d\n",i,u);
        }
    }
}



Measured memory_bytes: 4564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    printf("%d %d\n", min(x,y), max(x+y-n,0));
}


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

int main(){
  ll Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;

  ll L = min({Q*4,H*2,S});
  ll d = min(2*L,D);

  ll ans = 0,tea = 0;
  ans += N/2*d;
  tea += (N/2)*2;

  ans += (N-tea)*L;

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

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

using namespace std;

using ll = long long;

int main(){
    ll n, lastx = 0, lasty = 0, lastn = 0; cin >> n;
    for(ll i = 0; i < n; ++i){
        ll tmp, x, y;
        cin >> tmp >> x >> y;
        if((tmp - lastn)% 2 == (abs(x - lastx) + abs(y - lasty)) % 2 && (tmp - lastn) >= abs(x - lastx) + abs(y - lasty)){

        }else{
            cout << "No";
            return 0;
        }
        lastx = x;
        lasty = y;
        lastn = tmp;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MOD 1000000007
#define MAX 510000

long int FAC[MAX],FINV[MAX],INVE[MAX];
long int SUM(long int a,long int b){return (a%MOD+b%MOD+MOD)%MOD;}//a+b
long int PROD(long int a,long int b){return a%MOD*(b%MOD)%MOD;}//a*b
long int POW(long int a,long int b){//a^b
  long int c=1;
  for(a%=MOD;b;a=PROD(a,a),b>>=1)if(b&1)c=PROD(a,c);
  return c;
}
long int INV(long int a){return a<MAX?INVE[a]:POW(a,MOD-2);}//a^-1
long int QUOT(long int a,long int b){return PROD(a,INV(b));}//a/b
void init_inv(long int a){//make inv list
  INVE[1]=1;
  for(long int i=2;i<=a;i++)INVE[i]=SUM(0,-PROD(INVE[MOD%i],MOD/i));
}
void init_com(long int a){//make fac and facinv list
  FAC[0]=FAC[1]=1;
  FINV[0]=FINV[1]=1;
  init_inv(a);
  for(long int i=2;i<=a;i++){
    FAC[i]=PROD(FAC[i-1],i);
    FINV[i]=PROD(FINV[i-1],INV(i));
  }
}
long int COM(long int a,long int b){return PROD(PROD(FAC[a],FINV[a-b]),FINV[b]);}

int main(){
  int n,a[100001],i,x,y;
  scanf("%d",&n);
  init_com(n+1);
  for(i=1;i<=n;i++)a[i]=-1;
  for(i=0;i<=n;i++){scanf("%d",&y);if(a[y]==-1)a[y]=i;else {x=a[y];y=i;break;}}
  printf("%d\n",n);
  for(i=2;i<n+2;i++){if(n-y+x>i-2)printf("%ld\n",SUM(COM(n+1,i),-COM(n-y+x,i-1)));else printf("%ld\n",COM(n+1,i));}
}


Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define inf 1000000099
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back


 set<int> primeFactors(int n) 
{ 
     set<int>us;
    // Print the number of 2s that divide n 
    while (n%2 == 0) 
    { 
        us.insert(2);
        n = n/2; 
    } 
  
    // n must be odd at this point.  So we can skip  
    // one element (Note i = i +2) 
    for (int i = 3; i <= sqrt(n); i = i+2) 
    { 
        // While i divides n, print i and divide n 
        while (n%i == 0) 
        { 
            us.insert(i);
            n = n/i; 
        } 
    } 
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2 
    if (n > 2) 
        us.insert(n); 

    return us;
}


int32_t main()
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
  #endif
      int n;
      cin>>n;
     set<int>us=primeFactors(n);
     unordered_map<int,vector<int>>um;
     for(auto x:us)
     {
        for(int i=1;i<=10;i++)
        {
            um[x].push_back(pow(x,i));
        }
     }
     int count=0;
      for(auto x:us)
      {
        int val=pow(x,1);
        int i=1;
        while(val <= n)
        {
            i++;
            if(n%val==0)
            {
                n/=val;
                count++;
                val=pow(x,i);
                //watch(val);
            }
            else
              break;
            
        }
        //cout<<x<<" ";
      }
      cout<<count<<endl;
      
}

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

int main() {
  string s;
  cin >> s;
  for(int i = 97; i <= 122; i++){
    char x = i;
    bool flag = true;
    rep(j,s.size()){
      if(x == s.at(j)) flag = false;
    }
    if(flag){
      cout << x << endl;
      return 0;
    }
  }
  cout << "None" << endl;
 }


Measured memory_bytes: 3704
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;

const long long MAX = 1000100;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2;i < MAX;i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

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

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

  ll ans = 0;
  for(int i = 0;i < n;i++){
    ans += a[i] * (COM(i,k-1) - COM(n-1-i,k-1));
    ans %= MOD;
  }

  cout << ans << endl;
}

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


int main(){
    ll h,w; cin>>h>>w;
    vector<string> s(h);
    vector<string> t(h);
    rep(i,h) cin>>s[i];
    t=s;
    vector<ll> dx={-1,0,1,-1,0,1,-1,0,1}, dy={-1,-1,-1,0,0,0,1,1,1};
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') continue;
            ll res=0;
            rep(k,9){
                ll x=i+dx[k], y=j+dy[k];
                if(x>=0 && x<h && y>=0 && y<w){
                    if(s[x][y]=='#') res++;
                }
            }
            t[i][j]='0'+res;
        }
    }
    rep(i,h) cout<<t[i]<<endl;
    return 0;
}

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

signed main() {
	string s; cin >> s;
	rep(i, s.size()) {
		if (s[i] == '1')s[i] = '9';
		else if (s[i] == '9')s[i] = '1';
	}
	cout << s << endl;
}

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

int main() {
	string s;
	cin >> s;
	bool flag = false;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'C'){
			flag = true;
		}
		if(flag == true && s[i] == 'F'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    double N;
    cin >> N;

    int n = N;
    if (n % 2 == 0)
        printf("0.50000000");
    else {
        n = N / 2 + 1;
        printf("%.10f", double(n) / N);
    }
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8
class Tree(object):
    def __init__(self, N):
        self.tree   = [[] for _ in range(N)]
        self.colors = [0  for _ in range(N)]

    def add_node(self, a, b):
        self.tree[a].append(b)
    # 二部グラフか判定する関数
    def is_bipartite_graph(self, v, color):
        self.colors[v] = color
        for to in self.tree[v]:
            if self.colors[to] == color:
                return False
            if self.colors[to] == 0 and not self.is_bipartite_graph(to, -color):
                return False
        return True
    
    def count_node(self, color):
        return self.colors.count(color)
    
if __name__ == "__main__":

    import sys
    sys.setrecursionlimit(200000)
    # input data
    N, M = map(int, input().split())
    tree = Tree(N)
    for _ in range(M):
        a, b = map(int, input().split())
        tree.add_node(a-1, b-1)
        tree.add_node(b-1, a-1)
    
    # tree dp
    is_bpr = tree.is_bipartite_graph(0, 1)
    if is_bpr:
        bla = tree.count_node(1)
        whi = N - bla
        print(bla*whi-M)
    else:
        print(int(N*(N-1)/2-M))



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

void printArray(int* array, int size)
{
        int n;
        for(int i=1; i<size; i++){
                cout << array[i] << " ";
        }
        
        cout << array[size] << endl;
}

template<class T>        
void insertSort(T* array, int size)
{
        int tmp, j;
        for(int i=1; i<=size; i++){
                tmp = array[i];
                array[0] = tmp; // array[0] is used for sentinel
                for(j=i-1; array[j] > tmp; j--){
                        array[j+1] = array[j];
                }
                array[j+1] = tmp;
                printArray(array, size);
        }
}
        

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

        int elem[n+1]; // n[0]は番兵として使う
        for(int i=1; i<=n; i++){
                cin >> elem[i];
        }

        insertSort(elem, n);

        return 0;
}
        

Measured memory_bytes: 1160
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using LD = long double;

void Main(){
    int n; ll w; cin >> n >> w;
    vector<vector<ll>> bag(4);
    ll w0;
    rep(i, n) {
        ll a, b; cin >> a >> b;
        if(i == 0) w0 = a;
        bag[a - w0].pb(b);
    }
    
    vector<ll> sz(4);
    rep(i, 4) {
        bag[i].pb(0);
        sort(rall(bag[i]));
        sz[i] = bag[i].size();
    }      
    
    vector<vector<ll>> wa(4);
    rep(i, 4){
        wa[i].resize(sz[i]+1);
        wa[i][0] = 0;
        rep3(j, 1, sz[i]) wa[i][j] = wa[i][j-1] + bag[i][j-1];
    }
    
    /*
    rep(i, 4){
        rep(j, sz[i]+1) cout << wa[i][j] << " ";
        cout << endl;
    }
    //*/
    
    ll ans = 0;
    //*
    // w0 * a0 + (w0+1) * a1 + (w0+2) * a2 + (w0+3) * a3 <= w
    
    for(ll a0 = 0; w0 * a0 <= w && a0 < sz[0]; a0++){
        ll s0 = w0 * a0;
        for(ll a1 = 0; s0 + (w0+1) * a1 <= w && a1 < sz[1]; a1++){
            ll s1 = s0 + (w0+1) * a1;
            for(ll a2 = 0; s1 + (w0+2) * a2 <= w && a2 < sz[2]; a2++){
                ll s2 = s1 + (w0+2) * a2;
                for(ll a3 = 0; s2 + (w0+3) * a3 <= w && a3 < sz[3]; a3++){
                    ll tot = wa[0][a0] + wa[1][a1] + wa[2][a2] + wa[3][a3];
                    ans = max(ans, tot);
                    // cout << a0 << " " << a1 << " " << a2 << " " << a3 << " " << tot << endl;
                }
            }
        }
    }
    
    //*/
    cout << ans << endl;    
    return;
}

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

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int k;

  
  cin >> n >>k;
  
    vector<int> fruit(n);
  for(int i=0;i<n;i++){
    cin >> fruit.at(i);
    }
  
  
  sort(fruit.begin(), fruit.end());
  
  int goukei=0;
  for(int j=0;j<k;j++){
    goukei += fruit.at(j);
    if(j==k-1){
      cout << goukei << endl;
    }
    }
  }
    
  


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
ll a[maxn];
ll pow2[50];
void init()
{
    pow2[0] = 1;
    for(ll i = 1; i <= 32; ++i)
        pow2[i] = pow2[i-1]*2LL;
}
map<ll,int>res;
int main()
{
     int n;init();
     while(~scanf("%d",&n))
     {
         for(int i = 0; i < n; ++i)
            {
                scanf("%lld",a+i);
                res[a[i]]++;
            }
         sort(a,a+n);
         int pos = 32;
         int ans = 0;
         for(int i = n-1; i >= 0; --i)
         {
             if(res[a[i]] == 0)continue;
             while(pow2[pos-1] > a[i])pos--;
             ll nd = pow2[pos] - a[i];
             if(nd == a[i])
             {
                 ans += res[a[i]]/2;
                 res[a[i]] = 0;
             }
             else
             {
                 if(res[nd])
                    ans++,res[nd]--,res[a[i]]--;
             }
         }
         printf("%d\n",ans);
     }
}












Measured memory_bytes: 26752
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		//String t= sc.next();
		String[] buff= {"","","",""};
		//int n = sc.nextInt();
		//int m = sc.nextInt();
		//int k = sc.nextInt();
		long count=0,flag=0;
		long count1=0,count2=0;
		int count3=0;
		int[] array = new int[3];
		/*array[0]=n-m;
		array[1]=n*m;
		array[2]=n+m;*/
		Arrays.sort(array);

		for(int i=0;i<4;i++) {
			buff[i]=s.substring(i,i+1);
		}

		if(buff[0].equals(buff[1])&&!buff[1].equals(buff[2])&&buff[2].equals(buff[3])) {
			System.out.println("Yes");
		}else if(buff[0].equals(buff[3])&&buff[1].equals(buff[2])&&!buff[0].equals(buff[1])){
			System.out.println("Yes");
		}else if(!buff[0].equals(buff[1])&&!buff[2].equals(buff[3])&&buff[0].equals(buff[2])&&buff[1].equals(buff[3])){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

		//System.out.println(n*n);
	}
}




Measured memory_bytes: 21844
n = gets.to_i
print "#{n}: "

factors = []
while true
    n2 = n
    2.upto(Math.sqrt(n2).to_i){|x|
        if n2 % x == 0
            factors << x
            n2 /= x
            break
        end
    }
    if n2 == n
        factors << n
        break
    end
    n = n2
end
puts factors.join(" ")


Measured memory_bytes: 6884
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
int main(){
    int n,w;
    scii(n,w);
    vll dp(w+1,0);
    vi wgt(n+1),val(n+1);
    rep(i,1,n){
        scii(wgt[i],val[i]);
    }
    rep(i,1,n){
        rrep(j,w,1){
            if(j < wgt[i]) break;
            dp[j] = max(dp[j],dp[j-wgt[i]] + val[i]);
        }
    }
    cout << dp[w] << endl;
}

Measured memory_bytes: 4060
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    c = 0
    for i in range(1, n - 1):
        if sorted(a[i - 1:i + 2])[1] == a[i]:
            c += 1
    return c


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3060
a,b,n,x,y,DP[17];
main(){
	for(;scanf("%d%d%d",&a,&b,&n),a;){
		int m[17][17]={0};
		for(;n--;){
			scanf("%d%d",&x,&y);
			m[x][y]=1;
		}
		for(x=1;x<=a;x++){
			for(y=1;y<=b;y++){
				if(m[x][y])
					DP[y]=0;
				else if(x*y==1)
					DP[y]=1;
				else
					DP[y]=(x>1?DP[y]:0)+(y>1?DP[y-1]:0);
			}
		}
		printf("%d\n",DP[b]);
	}
	exit(0);
}

Measured memory_bytes: 0