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

#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'

typedef long long int ll ;

void solve()
{
	 string s;
	 cin >> s ;
	 if ( s[s.length() - 1] == 's' ) { cout << s << "es" << endl ; }
	 else { cout << s << 's' << endl ; }
}

int main()
{
	 ios ;
	 
	 solve() ;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll m = -1;
    rep(i,1,n+1){
        if(i*(i+1)/2 >= n){
            m = i;
            break;
        }
    }
    rep(i,1,m+1){
        if((m+1)*m/2-n == i) continue;
        cout << i << ednl;
    }
}




Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: usize = read();
	let mut v: Vec<usize> = vec![0; n+1];
	let mut temp: usize;
	for _ in 1..n {
		temp = read();
		v[temp] += 1;
	}
	for i in 1..n+1 {
		println!("{}", v[i]);
	}
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 3512
import sys
import math
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]
MOD = 1000000007

def main():
	N = INT()
	A = input().rstrip()
	B = input().rstrip()

	C = []
	cur = 0
	while cur < N:
		if A[cur] == B[cur]:
			C.append(1)
			cur += 1
		else:
			C.append(2)
			cur += 2
	
	if C[0] == 1: ans = 3
	else:	ans = 6
	for i in range(1, len(C)):
		if C[i] == 1 and C[i-1] == 1:
			ans *= 2
			ans %= MOD
		elif C[i] == 1 and C[i-1] == 2:
			ans *= 1
			ans %= MOD
		elif C[i] == 2 and C[i-1] == 1:
			ans *= 2
			ans %= MOD
		elif C[i] == 2 and C[i-1] == 2:
			ans *= 3
			ans %= MOD

	print(ans%MOD)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#define ll long long
#define N 200005
using namespace std;
int n,x,y;
struct pi{
	ll a,b;
	pi(){};
	pi(ll _a,ll _b){
		a=_a;b=_b;
	}
}tmp[N];
vector<pi>h[N];
struct pl{int l,r,lv,rv;}s[N];
void add(int a,int b,int c){
	if(s[a].l==0) s[a].l=b,s[a].lv=c;
	else s[a].r=b,s[a].rv=c;
}
bool cmp(const pi &A,const pi &B){return A.a<B.a||A.a==B.a&&A.b<B.b;} 
void dfs(int a,int fa,ll v,int w){
	if(s[a].l==0){h[a].push_back(pi(w,w));return;}
	else dfs(s[a].l,a,v,s[a].lv),dfs(s[a].r,a,v,s[a].rv);
	if(h[s[a].l].size()>h[s[a].r].size()) swap(s[a].l,s[a].r),swap(s[a].lv,s[a].rv);
	int l=0,top=0;
	for(int i=0;i<h[s[a].l].size();i++){
		while(l<h[s[a].r].size()&&h[s[a].r][l].a+h[s[a].l][i].b<=v) l++;
		if(l!=0) top++,tmp[top]=pi(h[s[a].l][i].a+w,h[s[a].r][l-1].b+w);
	}
	int tip=top;
	for(int i=1;i<=tip;i++)
		if(tmp[i].a!=tmp[i].b) top++,tmp[top]=pi(tmp[i].b,tmp[i].a);
	sort(tmp+1,tmp+1+top,cmp);
	if(top!=0) h[a].push_back(tmp[1]);
	for(int i=2;i<=top;i++)
		if(tmp[i].b<h[a][h[a].size()-1].b) h[a].push_back(tmp[i]);
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++) scanf("%d%d",&x,&y),add(x,i,y);
	ll l=0,r=1e15;
	while(l+1<r){
		ll mid=(l+r)/2;
		for(int i=1;i<=n;i++) h[i].clear();
		dfs(1,0,mid,0);
		if(h[1].size()!=0) r=mid;else l=mid;
	}
	for(int i=1;i<=n;i++) h[i].clear();
	dfs(1,0,l,0);if(h[1].size()!=0) r--;else l++;
	printf("%lld\n",l);
	return 0;
}

Measured memory_bytes: 32936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
			
			System.out.println(n*n*n);
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll n; cin >> n;
	vector<ll> a(n), b(n), c(n);
	rep(i, n)
		cin >> a[i];
	rep(i, n)
		cin >> b[i];
	rep(i, n)
		cin >> c[i];

	vector<ll> ab(n, 0), bc(n, 0);
	sort(all(a));
	sort(all(b));
	sort(all(c));

	rep(i, n)
	{
		ll left = -1, right = n;
		ll mid = (left + right) / 2;
		while (right-left>1)
		{
			if (a[mid]<b[i])
			{
				left= mid;
			}
			else
			{
				right = mid;
			}
			mid = (left + right) / 2;
		}
		ab[i] = left + 1;
	}

	rep(i, n)
	{
		ll left = -1, right = n;
		ll mid = (left + right) / 2;
		while (right - left > 1)
		{
			if (b[i] < c[mid])
			{
				right = mid;
			}
			else
			{
				left = mid;
			}
			mid = (left + right) / 2;
		}
		bc[i] = n - right;
	}

	ll ans = 0;
	rep(i, n)
	{
		ans += ab[i] * bc[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		if(s[0]==s[1]){
			Console.WriteLine(0);
			return;
		}
		var a=sc.La2;
		var dp=new long[s[0]+1][][];
		long ans=0,p=0;
		for(int i = 1;i<=s[0];i++) {ans+=Max(a[i]-a[i-1],0);}
		dp[0]=new long[s[1]+1][];
		for(int j = 0;j<=s[1];j++) {dp[0][j]=new long[1];}
		for(int i = 1;i<=s[0];i++) {
			dp[i]=new long[s[1]+1][];
			dp[i][0]=new long[i+1];
			for(int j = 1;j<=Min(s[1],i-1);j++) {
				dp[i][j]=new long[i+1];
				for(int k = Max(i-j,0);k<=i;k++) {
					if(i==k){
						for(int l = 0;l<i;l++) {
							dp[i][j][k]=Max(dp[i][j][k],dp[i-1][j][l]);
						}
					}
					else{
						dp[i][j][k]=dp[i-1][j-1][k]+Max(0,Max(a[i+1]-a[i],0)+Max(a[i]-a[k],0)-Max(a[i+1]-a[k],0));
					}
					p=Max(p,dp[i][j][k]);
				}
			}
			if(i<=s[1]){
				dp[i][i]=new long[i+1];
				dp[i][i][0]=dp[i-1][i-1][0]+Max(0,Max(a[i+1]-a[i],0)+a[i]-a[i+1]);
				p=Max(p,dp[i][i][0]);
			}
		}
		Console.WriteLine("{0}",ans-p);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

#define ll long long
#define ld long louble
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll a[n+1];
    for (ll i = 1; i <= n; i++){
        cin >> a[i];
    }
    ll dp[3][n+1];
    map<ll,ll> ma;
    for (ll i = 1; i <= n; i++){
        dp[1][i] = a[i];
        dp[2][i] = a[i]+1;
        dp[3][i] = a[i]-1;
        ma[dp[1][i]]++;
        ma[dp[2][i]]++;
        ma[dp[3][i]]++;
    }
//    ll answ = (ma.end())->first;
    ll answ = 0;
    for (auto i : ma){
        answ = max(answ,i.second);
    }
//    for (auto i : ma){
//        ll cura = 0;
//        for (ll j = 1; j <= n; j++){
//            if (dp[1][j] == i.first || dp[2][j] == i.first || dp[3][j] == i.first)
//                cura++;
//        }
//        answ = max(answ,cura);
//    }
    cout << answ << endl;
    return 0;
}

Measured memory_bytes: 8576
S = input()
Slength = len(S)
current = S[0] # 初期値&現在値
i = 1
ans = 1
while i < Slength:
    judge = True
    j = 0
    while judge:
#         print("current:{}".format(current))
#         print("target:{}".format(S[i:i+j+1]))
        if current == S[i:i+j+1]:
            # 無限ループ回避-------------------
            if i+j+1>=Slength:
                ans -= 1 # breakだと外側のwhileまで抜けられない。
                break
            else:
                pass
            # -------------------------------
            j += 1
        else:
            current = S[i:i+j+1]
            judge = False
    i += j + 1
    ans += 1
#     print("owe")

print(ans)

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=b&&b<=c){
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	else if(a<=c&&c<=b){
		cout<<a<<" "<<c<<" "<<b<<endl;
	}
	else if(b<=a&&a<=c){
		cout<<b<<" "<<a<<" "<<c<<endl;
	}
	else if(b<=c&&c<=a){
		cout<<b<<" "<<c<<" "<<a<<endl;
	}
	else if(c<=a&&a<=b){
		cout<<c<<" "<<a<<" "<<b<<endl;
	}
	else {
		cout<<c<<" "<<b<<" "<<a<<endl;
	}
}



Measured memory_bytes: 3112
//
// Created by Wangzhe on 2019/10/19.
//

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 300 + 10, INF = 0x3f3f;

int d1[maxn][maxn];

int mp[maxn][maxn];

int main() {
    int n,m,l; cin >> n >> m >>l;
//    for (int i = 0; i < maxn; i++) {
//        for (int j = 0; j < maxn; j++) {
//            mp[i][j] =  INF;
//            d1[i][j] =  INF;
//        }
//    }
    memset(mp, INF, sizeof mp);
    memset(d1, INF, sizeof d1);
    for (int i = 0; i < m; i++) {
        int x, y, z; cin >> x >> y >> z;
        x--; y--;
        mp[x][y] = mp[y][x] = min(mp[x][y],z);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                mp[j][k] = min(mp[j][k], mp[j][i] + mp[i][k]);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++){
            if (mp[i][j] <= l) {
                d1[i][j] = 1;
            }
        }
        d1[i][i] = 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                d1[j][k] = min(d1[j][k], d1[j][i] + d1[i][k]);
            }
        }
    }

    int q; cin >> q;
    while (q--) {
        int s, t; cin >> s >>t;
        s--; t--;
        cout << ((d1[s][t] > 500) ? -1 : (d1[s][t] - 1)) << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
n,k = map(int,input().split())
s = list(input())
ans = ''

if s[k-1] == 'A':
  s[k-1] = 'a'
elif s[k-1] == 'B':
  s[k-1] = 'b'
else:
  s[k-1] = 'c'
  
for i in s:
  ans += i
  
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int solve( const int n, const int p )
{
	int cup = p;
	VI have( n, 0 );
	for ( int i = 0; ; i++, i %= n )
	{
		if ( cup )
		{
			have[i]++;
			cup--;
		}
		else
		{
			cup = have[i];
			have[i] = 0;
		}

		if ( have[i] == p )
		{
			return i;
		}
	}

	return -1;
}

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

	while ( true )
	{
		int n, p;;
		cin >> n >> p;

		if ( !( n | p ) )
		{
			break;
		}

		cout << solve( n, p ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
n,k=map(int,input().split())
s=input()
t=s[0]
c=[-1,1][s[0]=="R"]
d=[]

for i in s[1:]:
    if t!=i:
        d.append(c)
        c=0
    t=i
    c+=[-1,1][i=="R"]
d.append(c)
c=len(d)
for i in range(k):
    if i*2+1>=c: break
    d[i*2+1]*=-1
chk=0
ans=0
for i in d:
    if (i>0 and chk>0) or (i<0 and chk<0):
        chk+=i
    else:
        if chk!=0: ans+=abs(chk)-1
        chk=i
print(ans+(abs(chk)-1))

Measured memory_bytes: 45936
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(m+1);
    for(int i=1;i<=m;i++){
        cin >>a[i];
    }
    int left=0,right=0;
    int now=1;
    while(a[now]<x){
        left++;
        now++;
    }
    while(now<=m){
        right++;
        now++;
    }
    cout << min(left,right) <<endl;
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split())) # 入力配列
B = [0 for i in range(n)] # 出力配列
C = [0 for i in range(10001)] # カウンタ配列

for a in A:
    C[a] += 1

for i in range(1, len(C)):
    C[i] = C[i] + C[i - 1]

for a in reversed(A):
    B[C[a] - 1] = a
    C[a] -= 1

print(' '.join(map(str, B)))



Measured memory_bytes: 242180
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    int res = max( llong(0), c - (a- b) );
    cout <<res <<  endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1e9;
const int E = numeric_limits<int>::min();

int main(void)
{
    string N;
    cin >> N;

    int nnum = 0;
    while(!N.empty()){
        nnum += atoi(N.substr(0, 1).c_str());
        nnum %= 9;
        N = N.substr(1);
    }

    if (nnum == 0){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 3856
#include <stdio.h>

char map[6][6]={"abcde","fghij","klmno","pqrst","uvwxy","z.?! "};

int main(void){
    int n,i,sign,t;
    char line[201],ans[101];
    for(;i=0,t=0,sign=0,~scanf("%s",line);){
        while(line[i]){
            if(line[i]-48<1 || line[i]-48>6 || line[i+1]-48<1 || line[i+1]-48 >5){
                sign=1;break;
            }
            else if(line[i+1]==0){
                sign=1;break;
            }
            ans[t++]=map[line[i]-1-48][line[i+1]-1-48];
            i+=2;
        }
        ans[t]=0;
        if(sign)
            puts("NA");
        else
            puts(ans);
    }
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

signed main(){

#ifndef ONLINE_JUDGE
   // freopen("input.txt","r", stdin);
#endif

    fastIO

    int n;
    cin >> n;
    int a[n], b[n], c[n];
    int dp[n][3];
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
//    cout << dp[0][0] << " " << dp[0][1] << ' ' << dp[0][2] << endl;
    for(int i=1;i<n;i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
//        cout << dp[i][0] << " " << dp[i][1] << ' ' << dp[i][2] << endl;
    }
    cout << max({dp[n-1][0], dp[n-1][2], dp[n-1][1]});

    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int main() {
    unsigned long long N;
    cin >> N;
    unsigned long long ans = 0;
    xrep(i,1, N+1) {
        if(!(i%3==0||i%5==0)) ans+=i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3684
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
int n,k;cin>>n>>k;
int ans=0;
while(n>0){
    n/=k;
    ans++;
}
cout<<ans<<endl;
}

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

const int N = 200000;

vector<bool> isp(N+1, true);

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}

int main() {
  // N以下の整数に対して素数判定をしてくれます。
  // nが素数ならば isp(n)=true、そうでなければ isp(n)=false
  int n;cin >>n;
  sieve();
  // ex. 51から80までの素数を出力
  for (int i=n; i<=200000; i++){
    if(isp[i]){cout << i << endl;break;}
  }
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  string s,t;cin>>s>>t;
  rep(i,n+1){
    string ss = s+t.substr(n-i, i);
//cout<<ss<<' '<<ss.substr(ss.size()-n, n)<<endl;
    if(ss.substr(ss.size()-n, n)==t){
      cout<<ss.size();
      break;
    }
  }


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define Int long long




int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    Int n;
    cin>>n;
    Int cv=(n*(n+1))/2;
  	cv*=n;
  	cv=0;
  	for(int i = 1;i<=n;i++)
    {
        //Int j = (n*(n+1))/2;
      	cv+=(i)*(n-i+1);
        //cv-=j;
    }
    for(int i = 1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
      	cv-=(min(x,y)*(n-max(x,y)+1));
    }
    cout<<cv<<endl;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

ll n, d, ans = 0;

void solve(ll p, ll q) {
    if(p * p + q * q <= d * d) ans++;
}

int main() {
    cin >> n >> d;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        solve(x, y);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string A, B, C;
  cin >> A >> B >> C;
  int ans = 0;
  FOR(i,0,N) {
    int mn = 1e9;
    FOR(s,0,26) {
      int count = 0;
      if(A[i] != char('a' + s)) count++;
      if(B[i] != char('a' + s)) count++;
      if(C[i] != char('a' + s)) count++;
      mn = min(mn, count);
    }
    ans += mn;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))

if N>=M:
  print(0)
else:
  distance = [0]*(M-1)
  for i in range(M-1):
    distance[i] = X[i+1]-X[i]
  r_sorted_distance = list(reversed(sorted(distance)))
  print(X[M-1]-X[0]-sum(r_sorted_distance[:N-1]))



Measured memory_bytes: 13960
// AOJ 0218
#include<iostream>

int main()
{
	int n, pm, pe, pj;
	while( std::cin >> n, n )
	{
		int rank;
		for( int i = 0; i != n; ++i )
		{
			std::cin >> pm >> pe >> pj;
			int ave = ( pm + pe + pj ) / 3;

			if( pm == 100 || pe == 100 || pj == 100 )
				rank = 0;
			else if( ( pm + pe ) / 2 >= 90 )
				rank = 0;
			else if( ave >= 80 )
				rank = 0;
			else if( ave >= 70 )
				rank = 1;
			else if( ave >= 50 && ( pm >= 80 || pe >= 80 ) )
				rank = 1;
			else
				rank = 2;

			std::cout << (char)('A' + rank) << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200001
#define LIMIT2 500001
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ffor(i, a, b, c) for(i=(int)(a);i<=(int)(b);i+=(int)c)
#define rep(i, n) for(i=0;i<(int)n;i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define bit(n) (1LL<<(n))
#define median(a, b) (a+b)/2.0
ll swap(ll *a,ll *b){ll tmp;tmp=*a;*a=*b;*b=tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll sum(ll *a,ll n){if(n<=0){return 0;}else{return sum(a,n-1)+a[n-1];}}
ld avg(ll *a,ll n){if(n<=0){return 0;}else return (ld)sum(a,n)/n;};
ld ABS(ld a){if(a>=0){return a;}else{return -a;}}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int stack[LIMIT2];//stack[0]=count;
int queue[LIMIT2];//stack[0]=start,stack[1]=length;
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
//qsort(s,n,sizeof(s[0]),upchar);
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
//qsort(s,n,sizeof(s[0]),downchar);
int push(int n){
    if(stack[0]>=LIMIT2) return -1;
    stack[0]++;
    stack[stack[0]] = n;
    return 1;
}
int pop(){
    if(stack[0]<=0) return -1;
    stack[0]--;
    return stack[stack[0]+1];
}
int enqueue(int n){
    if(queue[0]+queue[1]>=LIMIT2) return -1;
    queue[queue[0]+queue[1]] = n;
    queue[1]++;
    return 1;
}
int dequeue(){
    int result;
    if(queue[1]<=0) return -1;
    result = queue[queue[0]];
    queue[0]++;
    queue[1]--;
    if(queue[1]==0){
        queue[0] = 2;//queue reset
    }else if(queue[1]==1){
        queue[2] = queue[queue[0]];//only oneth
        queue[0] = 2;
    }
    return result;
}
void initialize(){
    stack[0] = 0;//stack size
    queue[0] = 2;//queue start
    queue[1] = 0;//queue length
}

int main(void){
    initialize();
    int n,m,p,i,j,result=0;
    char s[LIMIT1][10];
    ll a[LIMIT1],b[LIMIT1];
    scanf("%d %d", &n, &m);
  
  printf("%d", n*(n-1)/2+m*(m-1)/2);
    
    return 0;
}



Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(S: str):
    N = len(S)
    count = 0
    if N == 1:
        pass
    else:
        for i in range(N//2):
            if S[i] != S[-1-i]:
                count += 1
    print(count)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) {
        println("Yes")
    } else {
        println("No")
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:
/*
const int limit = 10;
int win[3*limit+1][3*limit+1];

int rec(int x,int y){
	int &ret = win[x][y];
	if(ret >= 0) return ret;

	ret = 0;
	
	for(int i = 1; 2*i <= x; i++){
		if(rec(x-2*i,y+i)==0){
			ret = 1;
		}
	}

	for(int i = 1; 2*i <= y; i++){
		if(rec(x+i,y-2*i)==0){
			ret = 1;
		}
	}

	return ret;
}
*/

int main(void){
	/*
	rep(x,3*limit+1)rep(y,3*limit+1) win[x][y]=-1;

	rep(x,limit){
		rep(y,limit) cout << (y?" ":"") << (rec(x,y) == 1 ?"o":"x");
		cout << endl;
	}
	*/

	ll x,y;
	cin >> x >> y;
	if(abs(x-y)<=1)
		puts("Brown");
	else
		puts("Alice");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

constexpr int MOD = 1e9 + 7;

struct modint {
	int n;
	modint(int n = 0) : n(n) {}
};

modint operator+(modint a, modint b) { return modint((a.n += b.n) >= MOD ? a.n - MOD : a.n); }
modint operator-(modint a, modint b) { return modint((a.n -= b.n) < 0 ? a.n + MOD : a.n); }
modint operator*(modint a, modint b) { return modint(1LL * a.n * b.n % MOD); }
modint &operator+=(modint &a, modint b) { return a = a + b; }
modint &operator-=(modint &a, modint b) { return a = a - b; }
modint &operator*=(modint &a, modint b) { return a = a * b; }

int main() {
	// dp[i][i][j]

	int n, m;
	std::cin >> n >> m;

	static modint dp[310][310][310];

	std::vector<std::vector<int>> query(n + 1);
	std::vector<int> l(m), r(m), x(m);
	for (int i = 0; i < m; i++) {
		std::cin >> l[i] >> r[i] >> x[i];
		query[r[i]].push_back(i);
	}

	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int u = 0; u < n; u++) {
			for (int v = 0; v < n; v++) {
				int us[3] = { u, v, u };
				int vs[3] = { v, i - 1, i - 1 };
				int ws[3] = { i, i ,i };
				bool ok[3] = { true, true, true };

				for (int id : query[i]) {
					for (int j = 0; j < 3; j++) {
						int cnt[3] = {};
						if (us[j] >= l[id]) cnt[j]++;
						if (vs[j] >= l[id]) cnt[j]++;
						if (ws[j] >= l[id]) cnt[j]++;
						if (x[id] != cnt[j]) {
							ok[j] = false;
						}
					}
				}

				for (int j = 0; j < 3; j++) {
					if (ok[j]) {
						dp[i][us[j]][vs[j]] += dp[i - 1][u][v];
					}
				}
			}
		}
	}

	modint ans = 0;
	for (int i = 0; i < n + 1; i++) {
		for (int j = 0; j < n + 1; j++) {
			ans += dp[n][i][j];
		}
	}
	std::cout << ans.n << std::endl;
}


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

int main(void) {

    int N; // ぬすけ君
    int K; // お菓子の種類

    int nusuke[100];
    int temp_num;
    int okashi_ari;

    for(int i = 0;i < 100;i++){
        nusuke[i] = 0;
    }

    scanf("%d %d",&N,&K);

    for(int i = 0;i < K;i++){
        
        scanf("%d",&temp_num);
        //printf("%d num:%d\n",i,temp_num);
        for(int j = 0;j < temp_num;j++){
            scanf("%d",&okashi_ari);
            nusuke[okashi_ari - 1] = 1;
            //printf("ari:%d\n",okashi_ari);
        }
    }

    int count = 0;
    for(int i = 0;i < N;i++){
        if(nusuke[i] == 0)count++;
    }
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 2128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();

        StringBuilder sb = new StringBuilder();
        for (int i = 0 ; i < ty - sy ; i++) {
            sb.append("U");
        }
        for (int i = 0 ; i < tx - sx ; i++) {
            sb.append("R");
        }
        for (int i = 0 ; i < ty - sy ; i++) {
            sb.append("D");
        }
        for (int i = 0 ; i < tx - sx ; i++) {
            sb.append("L");
        }

        sb.append("L");
        for (int i = 0 ; i < ty - sy + 1 ; i++) {
            sb.append("U");
        }
        for (int i = 0 ; i < tx - sx + 1 ; i++) {
            sb.append("R");
        }
        sb.append("D");
        sb.append("R");
        for (int i = 0 ; i < ty - sy + 1 ; i++) {
            sb.append("D");
        }
        for (int i = 0 ; i < tx - sx + 1 ; i++) {
            sb.append("L");
        }
        sb.append("U");

        System.out.println(sb.toString());

    }

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long

bool solve(){
  int n;
  cin>>n;
  vector<vector<int> > vec(n, vector<int>());
  vector<int> num(n);
  rep(i,n) scanf("%d",&num[i]);
  rep(i,n-1){
    int a,b;
    scanf("%d %d", &a, &b);
    a--;b--;
    vec[a].pb(b);
    vec[b].pb(a);
  }
  if(n==2) return num[0]==num[1];

  // n>=3
  // だめじゃん
  function<long(int,int)> dfs = [&](int from, int d){
    if(vec[d].size()==1) return (long)num[d];
    long c=0;
    long mx=0;
    for(auto to : vec[d]) if(to!=from){
      long tmp = dfs(d, to);
      if(tmp==-1) return -1LL;
      c += tmp;
      mx = max(tmp, mx);
    }
    if(c >= num[d]){
      // c-num[d]を中で
      if(c-num[d]>min(c/2,c-mx)) return -1LL;
      else return c-2*(c-num[d]);
    }
    return -1LL;
  };

  int s=0;
  while(vec[s].size()==1) s++;

  return dfs(-1, s)==0;
}

int main(){
  if(solve()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;


  return 0;
}


Measured memory_bytes: 14080
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

const ll INFTY = 1e+16;

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N + 1), b(N + 1);
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];
        b[i] = a[i];
        if (i != 0)
        {
            a[i] += a[i - 1];
            b[i] += b[i - 1];
        }
    }

    ll ans = INFTY;
    bool sign;
    for (int j = 0; j < 2; ++j)
    {
        sign = j;
        if (j == 1)
        {
            for (int i = 0; i < N + 1; ++i)
            {
                a[i] = b[i];
            }
        }
        ll v = 0, count = 0;
        for (int i = 0; i < N; ++i)
        {
            if (sign)
            {
                if (a[i] >= 0)
                {
                    count += abs(-a[i] - 1);
                    v -= abs(-a[i] - 1);
                }
            }
            else
            {
                if (a[i] <= 0)
                {
                    count += abs(-a[i] + 1);
                    v += abs(-a[i] + 1);
                }
            }
            a[i + 1] += v;
            sign = !(sign);
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a, b;

int main() {
    scanf("%lld%lld", &a, &b);
    if(a > b) swap(a, b);
    puts(b-a <= 1 ? "Brown" : "Alice");
    return 0;
}

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

int main(){

  string A, B, C;

  cin>>A>>B>>C;

  if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  N =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int n,k;
ll a[N];
ll mp[N];
 
bool cmp(ll x,ll y){
	return abs(x)<abs(y);
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
  	cin>>n>>k;
  	for(int i=1;i<=n;++i){
  		cin>>a[i];
  		if(a[i]>=0) mp[1]++;
  		else mp[2]++; 
  	}
  	int l=1,r=n;
  	ll ans=1;
  	if(mp[1]==0 && k%2==1){
  		sort(a+1,a+1+n,cmp);
  		for(int i=1;i<=k;++i){
  			ans=a[i]*ans%mod;
  		}
  	}
  	else{
  		sort(a+1,a+1+n,greater<int>());
  		while(k>0){
  			if(k%2==1) ans=ans*a[l++]%mod,k--;
  			else if(k>=2){
  				if(a[l]*a[l+1]>=a[r]*a[r-1]){
  					ans=ans*a[l]%mod*a[l+1]%mod;
  					l+=2;
  					k-=2;
  				}
  				else{
  					ans=ans*a[r-1]%mod*a[r]%mod;
  					r-=2;
  					k-=2;
  				}
  			} 
  		}
  	}

  	cout<<(ans%mod+mod)%mod<<endl;

    return 0;
}

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

D={}
for x in A:
    if x in D:
        D[x]+=1
    else:
        D[x]=1

S=sum(A)

Q=int(input())
for _ in range(Q):
    B,C=map(int,input().split())

    if B in D:
        S+=(C-B)*D[B]
        if C in D:
            D[C]+=D[B]
        else:
            D[C]=D[B]

        D[B]=0

    print(S)


Measured memory_bytes: 85364
import java.lang.*;
import java.util.*;

public class Main
{
    static Scanner sc = new Scanner(System.in);

    public static void main(String args[])
    {
        
        while( sc.hasNext() ){
            int N = sc.nextInt();
            int M = sc.nextInt();

            int[][] p = new int[301][4];
            for(int i=0; i<N;i++){
                sc.nextLine(); sc.nextLine();
                for(int j=0; j<4; j++){   
                    p[i][j] = sc.nextInt();
                }
            }

            
            int[][] dp = new int[M+1][4];
                for(int i=0; i<N; i++){
                    for(int j=1; j<4;j++){
                        for(int k=0; k<=M; k++){
                            if(k+p[i][0] <= M) dp[ k+p[i][0] ][j] = Math.max(dp[ k+p[i][0] ][j], p[i][j] + dp[k][j]);
                        }
                    }
                }

                int max = 0;
                for(int[] d: dp) for(int s: d) max = Math.max(s, max);
                
                System.out.println(max);
        }
        
    }
}

	    
	    

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

const int INF = 1e+8;
int n, a[110][110] = {0};

// [x1, x2] && [y1, y2] の領域の和を返す
int sum(int x1, int y1, int x2, int y2){
	return a[y1][x1] - a[y1][x2 + 1] - a[y2 + 1][x1] + a[y2 + 1][x2 + 1];
}

// 累積和化
void init(){
	for(int y = 0; y < n; y++){
		for(int x = n - 1; x >= 0; x--){
			a[y][x] += a[y][x+1];
		}
	}
	for(int y = n - 1; y >= 0; y--){
		for(int x = 0; x < n; x++){
			a[y][x] += a[y+1][x];
		}
	}
}

int main(){
	cin >> n;
	for(int y = 0; y < n; y++){
		for(int x = 0; x < n; x++){
			cin >> a[y][x];
		}
	}
	init();
	int ans = -INF;
	for(int y1 = 0; y1 < n; y1++){
		for(int x1 = 0; x1 < n; x1++){
			for(int y2 = y1; y2 < n; y2++){
				for(int x2 = x1; x2 < n; x2++){
					ans = max(ans, sum(x1, y1, x2, y2));
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    lg n;
    cin>>n;
    vector<lg>a(n,0);
    lg ans=0;
    for(lg i=0;i<n;i++)
    {
        cin>>a[i];
    }

    sort(a.begin(),a.end());
    ans+=a[n-1];
    lg k=n-2;
    lg i=n-2;
    while(k>0)
    {
        ans+=a[i];
        k--;
        if(k==0) break;
        ans+=a[i];
        k--;
        if(k==0) break;
        i--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cerr << #x << " = " << (x) << "\n"
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int a, b, c, d, p;

void input() {
  scanf( "%d %d %d %d %d", &a, &b, &c, &d, &p );
}

void solve() {
  printf( "%d\n", min( a * p, b + max( 0, p - c ) * d ) );
}

int main() {
  input();
#ifdef WIN32
  clock_t stime = clock();
#endif
  solve();
#ifdef WIN32
  clock_t etime = clock();
  fprintf(stderr,"TIME : %f\n", ( double ) ( etime - stime ) / CLOCKS_PER_SEC);
#endif
  return 0;
}

Measured memory_bytes: 1188
n = int(input())
a = list(map(int,input().split()))
import collections
b = collections.Counter(a).most_common()
li4 = []
li2 = []
ansli = []
for k in b:
    if k[1]>=4:
        li4 +=[k[0]]
        ansli += [k[0]**2]
    if k[1]>=2:
        li2 +=[k[0]]

if len(li2)>=2:
    li22 = sorted(li2)
    ansli += [li22[-1]*li22[-2]]
if ansli:
    print(max(ansli))
else:
    print(0)

Measured memory_bytes: 25968
#include <cstdint>
#include <cstdio>
#include <algorithm>

const int N = 1e5 + 10;
int n, l[N], r[N], ans, acnt, pre[N], suf[N];
std::pair<int, int> min, max;
std::pair<int, int> a[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", l + i, r + i);
    min.first = INT32_MAX, max.first = INT32_MIN;
    for (int i = 1; i <= n; i++)
        min = std::min(min, std::make_pair(r[i], i)), max = std::max(max, std::make_pair(l[i], i));
    for (int i = 1; i <= n; i++)
        if (i != min.second && i != max.second)
            ans = std::max(ans, std::max(min.first - max.first + 1, 0) + r[i] - l[i] + 1);
    if (min.second != max.second) {
        for (int i = 1; i <= n; i++)
            if (i != min.second && i != max.second)
                a[++acnt] = std::make_pair(l[i], r[i]);
        n -= 2;
        std::sort(a + 1, a + n + 1, [](const auto &a, const auto &b) {
            return a.first == b.first ? a.second > b.second : a.first < b.first;
        });
        pre[0] = l[min.second], suf[n + 1] = r[max.second];
        for (int i = 1; i <= n; i++) pre[i] = std::max(pre[i - 1], a[i].first);
        for (int i = n; i; i--) suf[i] = std::min(suf[i + 1], a[i].second);
        for (int i = 0; i <= n; i++)
            ans = std::max(ans, std::max(min.first - pre[i] + 1, 0) + std::max(suf[i + 1] - max.first + 1, 0));
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    double n, m, d;
    cin >> n >> m >> d;

    if (d) {
        cout << fixed << setprecision(10) << (m-1)*2*(n-d)/(n*n) << endl;
    } else {
        cout << fixed << setprecision(10) << (m-1)/n << 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 PI 3.14159265

int main( void ) {
    int a, b;
    while( 1 ) {
        cin >> a >> b;
        for( int i = 1; i <=a; i++ ) {
            for( int j = 1; j <= b; j++) {
                if( (i + j) % 2 == 0 ) cout << '#';
                else
                    cout << '.';
            }
            cout << endl;
        }
        if( a == 0 ) break;
        cout << endl;
    }
}



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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int T[n];
    for (int i=0;i<n;i++)
        cin>>T[i];
    sort(T,T+n);
    int test;
    test=0;
    for (int i=1;i<n;i++)
    {
        if (T[i-1]==T[i])
        {
            test=1;
            break;
        }
    }
    if (test==1)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if (a>b) {
    printf("a > b\n");
  } else if (a<b) {
    printf("a < b\n"); 
  } else {
    printf("a == b\n");
  } 
  return 0;
}


Measured memory_bytes: 2100