akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<string, string> P;
typedef pair<string, P> PP;

bool check(vector<PP> &v, string &s, string &d){
  REP(i, v.size()){
    bool f = true;
    REP(j, s.length()) if(v[i].second.first[j] != '?' && v[i].second.first[j] != s[j]) f = false;
    REP(j, d.length()) if(v[i].second.second[j] != '?' && v[i].second.second[j] != d[j]) f = false;
    if(f) return (v[i].first == "permit" ? true : false);
  }
  return false;
}

int main() {
  int N, M;
  while(cin >>N >>M && !(N == 0 && M == 0)){
    vector<PP> v(N);
    REP(i, N) cin >>v[i].first >>v[i].second.first >>v[i].second.second;
    REVERSE(v);
    vector<PP> ans;
    REP(i, M){
      string s, d, m; cin >>s >>d >>m;
      if(check(v, s, d)) ans.push_back(PP(s, P(d, m)));
    }
    cout <<ans.size() <<endl;
    REP(i, ans.size()) cout <<ans[i].first <<" " <<ans[i].second.first <<" " <<ans[i].second.second <<endl;
  }
  return 0;
}

Measured memory_bytes: 1452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
struct UnionFind
{
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) {}
  bool unionSet(ll x, ll y)
  {
    x = root(x);
    y = root(y);
    if (x != y)
    {
      if (data[y] < data[x])
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y)
  {
    return root(x) == root(y);
  }
  ll root(ll x)
  {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x)
  {
    return -data[root(x)];
  }
};
int main()
{
ll n , m , k ;
cin >> n >> m >> k ;
set<ll> s[n];
UnionFind arr(n);
vector<ll> cnt(n);
vector<ll> br(n);

rep(i,m){
  ll a , b ;
  cin >> a >> b ;
  arr.unionSet(a-1,b-1);
  cnt[a-1]++;
  cnt[b-1]++;
}
rep(i,k){
  ll a , b ;
  cin >> a >> b ;
  if(arr.findSet(a-1, b-1)){
    br[a-1]++;
    br[b-1]++;
  }
}
rep(i,n){
  cout << arr.size(i)-cnt[i]-br[i]-1 <<" ";
}
cout << endl;
return 0;
}

Measured memory_bytes: 7808
n, m, l = map(int, input().split())

A = []
B = []

for _ in range(n):
    A.append(list(map(int, input().split())))

for _ in range(m):
    B.append(list(map(int, input().split())))

C = [[sum([A[i][k] * B[k][j] for k in range(m)]) for j in range(l)] for i in range(n)]

for row in C:
    print(' '.join(map(str, row)))

Measured memory_bytes: 8864
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,a[1000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=n-1;i>=0;i--){
		printf("%d",a[i]);
		if(i!=0) printf(" ");
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3300
s = input()
n = len(s)
ss = int(s)
i = ss//(10**(n-1))
def cal(k):
    res = int(k)*(10**(n-1))+ int(k)*(10**(n-2))+int(k)*(n-2)
    return res

if cal(i)<ss:
    print(cal(i+1))
else:
    print(cal(i))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,d;
  cin >> n >> d;
  int b = 2*d+1;
  int v = b;
  int a = 0;
  while (1) {
    a += 1;
    if (b >= n) {
      break;
    }
    b += v;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,g,s,X;
    scanf("%d",&X);
    if(X>=500){
    a=X/500;
    g=a*1000;
    b=X%500;
    c=b/5;
    d=5*c;
    s=g+d;
    printf("%d\n",s);
    }
    else if(X<500){
        e=X/5;
        f=5*e;
        printf("%d\n",f);
    }


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007

template <typename T>
inline T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}

template <typename T>
map<T, T> prime_factorization(T n){
    map<T,T> ret;
    for(T i=2;i*i<n;i ++){
        while(n%i==0){
            ret[i] ++;
            n /= i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll A, B;
    cin >> A >> B;
    ll div = gcd(A,B);
    auto divs = prime_factorization(div);
    cout << divs.size()+1 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
a,b=gets.split.map &:to_i

if a<0 then
  if b<0 then
    if (b-a)%2==1 then
      puts 'Positive'
    else
      puts 'Negative'
    end
  else
    puts 'Zero'
  end
elsif a==0 then
  puts 'Zero'
else
  puts 'Positive'
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<climits> //INT_MIN/MAX
using namespace std;

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
typedef long long ll;

/* 2017/01/21 問題 ----- ABC044 C /Link http://abc043.contest.atcoder.jp/tasks/arc059_a */
/* -----解説等-----
問題: N 個の整数 a1,a2,..,aN が与えられます。えび君はこれらを書き換えて全て同じ整数にしようとしています。
各ai(1≦i≦N)は高々一回しか書き換えられません(書き換えなくても良い)。
整数xを整数yに書き換えるとき、コストが(x−y)^2かかります。
仮にai=aj(i≠j)だとしても、ひとつ分のコストで同時に書き換えることは出来ません(入出力例2 を参照)。
えび君が目的を達成するのに必要なコストの総和の最小値を求めてください。

制約
1≦N≦100
−100≦ai≦100

平均値から出せるかなと思ったがこれはデータの散らばり方によるので厳しいかなあということで全探索した。
全探索。

*/

int N;
int a[100];
ll ans = INT_MAX;

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

    cin >> N;
    FOR(i, 0, N) {
        cin >> a[i];
    }

    FOR(i, -100, 101) {
        ll minn = 0;
        FOR(j, 0, N) {
            minn += (a[j] - i)*(a[j] - i);
        }
        ans = min(minn, ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define N 3
using namespace std;
int formula();
int p,P,Q,R;
string str;
int main(){
  int r,cnt;
  while(1){
    cin >> str;
    if(str==".") break;
    cnt=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	for(int k=0;k<N;k++){
	  p=0,P=i,Q=j,R=k;
	  r=formula();
	  if(r==2) cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
int formula(){
  int val,val1;
  while(1){
    if(str[p]=='0'||str[p]=='1'||str[p]=='2'){
      p++;
      return str[p-1]-'0';
    }
    else if(str[p]=='P'){
      p++;
      return P;
    }
    else if(str[p]=='Q'){
      p++;
      return Q;
    }
    else if(str[p]=='R'){
      p++;
      return R;
    }
    else if(str[p]=='-'){
      p++;
      val=formula();
      return 2-val;
    }
    else if(str[p]=='('){
      p++;
      val=formula();
    }
    else if(str[p]=='*'){
      p++;
      val1=formula();
      return min(val,val1);
    }
    else if(str[p]=='+'){
      p++;
      val1=formula();
      return max(val,val1);
    }
    else if(str[p]==')') p++;
  }
  return val;
}

Measured memory_bytes: 1188
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		
			int[] ABC = new int[3];
			int counter1 = 0;
			int counter2 = 0;
			for (int i = 0; i < 3; i++) 
			{
				ABC[i] = scan.nextInt();
			}
			for (int a: ABC)
			{
				if (a == 5)
				{
					counter1++;
				}
				if (a == 7)
				{
					counter2++;
				}
			}
			if (counter1 == 2 && counter2 == 1)
				System.out.println("YES");
			else
				System.out.println("NO");
		
	}
}

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

int main()
{
    int n;
    cin>>n;
    string s;
    map<string,int> map;
    int mx=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        map[s]++;
        if(map[s]> mx)
            mx=map[s];
    }
    for(auto x : map)
    if(mx==x.second)
        cout << x.first <<  endl;
    return 0;
}


Measured memory_bytes: 18668
#include <iostream>
using namespace std;
static const int MAX = 100;

void trace(int data[], int n) {
  cout << data[0];
  for (int i = 1; i < n; i++) {
    cout << " " << data[i];
  }
  cout << endl;
}


void bubbleSort(int A[], int len) {
    int count = 0;
    for (int i=0; i<len; i++) {
        for (int j=len-1; j >= i+1; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                count++;
            }
        }
    }
    trace(A, len);
    cout << count << endl;
}


int main() {
  int data[MAX + 1];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> data[i];

  bubbleSort(data, n);
}

Measured memory_bytes: 3088
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
x = list(map(int,input().split()))
for i in range(5):
    if x[i] == 0:
        print(i+1)


Measured memory_bytes: 10520
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, h[maxn];
int main() {
    n = read();
    for (reg int i = 1; i <= n; i++) h[i] = read();
    reg int Ans = 0, res = 1;
    for (reg int i = 2; i <= n; i++) {
        if (h[i] <= h[i - 1]) res++;
        else Ans = max(Ans, res), res = 1;
    }
    Ans = max(Ans, res);
    cout << Ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}

struct TT{
	LL a,b;
}tt,ss;
LL t,n,m,ans;
LL MOD=1e9+7;
LL ff[111];

LL get(LL x){
	return x*x;
}

int main()
{
//	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,res;res=MOD;
	cin>>n;
	for(i=0;i<n;i++)cin>>ff[i];
	sort(ff,ff+n);
	for(i=ff[0];i<=ff[n-1];i++){
		m=0;
		for(j=0;j<n;j++){
			m+=get(ff[j]-i);
		}
		res=min(res,m);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

N = int(sys.stdin.readline().strip())

a = int(N / 1000)
b = int(N / 100) - a * 10
c = int(N / 10) - b * 10 - a * 100
d = N % 10

if (a+b+c+d) == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif (a+b+c-d) == 7:
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif (a+b-c+d) == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif (a+b-c-d) == 7:
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif (a-b+c+d) == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif (a-b+c-d) == 7:
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif (a-b-c+d) == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif (a-b-c-d) == 7:
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")



Measured memory_bytes: 3064
package main

import (
  "fmt"
)

func main() {
  var (
    a, b, c, x, count int
  )
  fmt.Scan(&a, &b, &c, &x)
  for i := 0; i < a+1; i++ {
    for j := 0; j < b+1; j++ {
      for k := 0; k < c+1; k++ {
        if i*500+j*100+k*50 == x {
          count++
        }
      }
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int x;
int main(){
	int ans=0;
	for(int i=1;i<=5;++i){
		cin>>x;
		if(x==0){
			ans=i;
		}
	}
	cout<<ans<<'\n';
	return 0;
} 

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner scanner = new Scanner(System.in);
		//读取数据
		int N = scanner.nextInt();
		int X = scanner.nextInt();
		int [] L = new int[N];
		int ans = N + 1;
		int i = 0;
		do {
			L[i] = scanner.nextInt();
			i ++;
		}while(i < N);
		int [] arr = new int[N + 1];
		arr[0] = 0;
		for(int j = 1; j <= N; j++) {
			arr[j] = arr[j-1] + L[j-1];
			if(arr[j] > X) {
				ans = j;
				break;
			}
		}
		System.out.println(ans);
		
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e6;
bool notPrime[maxN + 1];
vector<int> primes;
vector<pair<lli, int>> primeFactors[maxN + 1];

vector<pair<lli, int>> getPrimeFactors(lli num)
{
  if (num <= maxN) return primeFactors[num];
  vector<pair<lli, int>> pf;
  for (lli i: primes)
  {
    if (i > num) break;
    if (num % i == 0)
    {
      int p = 0;
      while (num % i == 0) num /= i, p ++;
      pf.push_back({i, p});
    }
  }
  if (num != 1)
    pf.push_back({num, 1});
  return pf;
}

int main()
{
  notPrime[0] = notPrime[1] = true;
  for (int i = 2; i <= maxN; i ++)
  {
    if (!notPrime[i]) primes.push_back(i), primeFactors[i].push_back({i, 1});
    for (int j = 0; i*primes[j] <= maxN; j ++)
    {
      notPrime[i*primes[j]] = true;
      int p = 0, num = i * primes[j];
      while (num % primes[j] == 0) num /= primes[j], p ++;
      primeFactors[i * primes[j]].push_back({primes[j], p});
      primeFactors[i * primes[j]].insert(primeFactors[i * primes[j]].end(), primeFactors[num].begin(), primeFactors[num].end());
      if (i % primes[j] == 0) break;
    }
  }

  lli n;
  while (scanf("%lld", &n) != EOF)
  {
    vector<pair<lli, int>> pf = getPrimeFactors(n);
    lli ans = 0;
    bool had;
    set<lli> done;
    do
    {
      had = false;
      lli curr;
      for (auto &p: pf)
      {
        for (int j = 1; j <= p.second; j++)
        {
          curr = pow(p.first, j);
          if (!done.count(curr) && n % curr == 0)
          {
            had = true;
            break;
          }
        }
        if (had) break;
      }
      // printf("\t%lld - %lld\n", n, curr);
      if (had) done.insert(curr), ans++, n /= curr;
    }
    while (had);
    printf("%lld\n", ans);
  }

  return 0;
}

Measured memory_bytes: 88896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)

int main()
{
  int N;
  cin >> N;
  set<int> ss;
  rep(i, N)
  {
    int a;
    cin >> a;
    ss.insert(a);
  }
  if (ss.size() == N)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;


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

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

	if (n[0] == n[1]) ans = n[2];
	else if (n[1] == n[2]) ans = n[0];
	else if (n[2] == n[0]) ans = n[1];

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            var w = int.Parse(s[0]);
            var h = int.Parse(s[1]);
            var x = int.Parse(s[2]);
            var y = int.Parse(s[3]);
            bool isyesorno = false;
            bool yes = false;
            if (!isyesorno)
            {
                

                Console.WriteLine(((double)w * h / 2) + ((x * 2 == w) && (y * 2 == h) ? " 1" : " 0"));
            }
            else
            {
                if (yes)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }

            #if DEBUG
                Console.WriteLine("続行するには何かキーを押してください．．．");
                Console.ReadKey();
            #endif
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    
 
    string ans = "None";
    for (char i = 'a'; i <= 'z'; i++){
 
        if(S.find(i) == string::npos){
            ans = i;
            break ;
        }
            
 
        
    }
 
    cout << ans << endl;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll dp[2005][2005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vpll v(n);
  rep(i,n){
    cin>>v[i].first;
    v[i].second=i;
  }
  vsort(v);
  for(ll l=0; l<=n; l++){
    for(ll r=n; r>=l; r--){
      ll idx=r-l;
      if(l>0){
        ll tmp=dp[l-1][r];
        tmp+=abs((l-1)-v[idx].second)*v[idx].first;
        chmax(dp[l][r],tmp);
      }
      if(r<n){
        ll tmp=dp[l][r+1];
        tmp+=abs(r-v[idx].second)*v[idx].first;
        chmax(dp[l][r],tmp);
      }
    }
  }
  ll ans=0;
  for(ll i=0; i<=n; i++){
    chmax(ans,dp[i][i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 26320
cnt=1
while True:
    n=input()
    if n==0:break
    data=[map(int,raw_input().split()) for i in range(n)]
    data.append(data[0])
    print cnt,sum((data[i][0]-data[i+1][0])*(data[i][1]+data[i+1][1]) for i in \
range(n))/(-2.0)
    cnt+=1
    skip=raw_input()

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

int main() {
    int n;
    ll x,zb=1;
    cin >> n;
    vector<ll> V;
    for (int i=0;i<n;i++) {
        cin >> x;
        V.push_back(x);
        if (x==0) {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i=0;i<n;i++) {
        x=V[i];
        if (1000000000000000000/zb<x) {
            cout << -1;
            return 0;
        }
        zb*=x;
    }
    cout << zb;
    return 0;
}


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

const int N = 1e5 + 10;
int n, L, q;
int a[N];
int f[N][33];

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

int main() {
	n = read();
	for(int i = 1; i <= n; ++i) a[i] = read();
	L = read(), q = read();
	for(int i = 1; i <= n; ++i) {
		int x = upper_bound(a + 1, a + n + 1, a[i] + L) - a - 1;
		if(a[i] + L >= a[n])	f[i][0] = n;
		else	f[i][0] = x;
	}
	for(int j = 1; j <= 30; ++j)
		for(int i = 1; i <= n; ++i)
			f[i][j] = f[f[i][j - 1]][j - 1];
	while(q--) {
		int l = read(), r = read();
		if(l > r)	swap(l, r);
		int cnt = l, ans = 0;
		for(int i = 30; i >= 0; --i) {
			if(f[cnt][i] < r) {
				ans += (1 << i);
				cnt = f[cnt][i];
			}
		}
		printf("%d\n", ans + 1);
	}
	return 0;
}

Measured memory_bytes: 14080
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(string[] args) {
    string s = readln.chomp;

    char[] st;
    foreach(c; s){
        if(c == 'T' && !st.empty && st.back == 'S'){
            st.popBack();
        }else{
            st ~= c;
        }
    }

    writeln(st.length);
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int 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; }

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,k,l; cin>>n>>k>>l;
    UnionFind road(n+1);
    UnionFind train(n+1);
    rep(i,k){
        int p,q; cin>>p>>q;
        road.unite(p,q);
    }
    rep(i,l){
        int r,s; cin>>r>>s;
        train.unite(r,s);
    }
    map<pair<int,int>,int> ans;
    for(int i=1;i<n+1;i++){
        ans[{road.root(i),train.root(i)}]++;
    }
    for(int i=1;i<n+1;i++) cout<<ans[{road.root(i),train.root(i)}]<<' ';
}

Measured memory_bytes: 13568
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll a[200000];
ll sum[200001];
int main() {
	int n; cin >> n; ll x; cin >> x;
	rep(i, n) {
		cin >> a[i];
	}
	sum[0] = 0;
	rep(i, n) {
		sum[i + 1] = sum[i] + a[i];
	}
	ll out = INF;
	rep1(k, n) {
		ll csum = 5*(sum[n]-sum[n-k]);
		for (int j = k; j < n; j += k) {
			if (out < csum)continue;
			csum += (2 * (j / k + 1) + 1)*(sum[n - j] - sum[max(0, n - j - k)]);
		}
		csum += n * x + k * x;
		out = min(out, csum);
	}
	cout << out << endl;
	return 0;
}

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

int main(){
  long long int a,b,c;
  cin>>a>>b>>c;
  long long int ans=min(b*c,min(a*c,a*b));
  if(a%2==0||b%2==0||c%2==0)ans=0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)

#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int inputs[3];
    rep(i, 0, 3) {
        cin >> inputs[i];
    }
    sort(inputs, inputs+3, greater<int>());

    if (inputs[0] == inputs[1] + inputs[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int N;
  cin >> N;
  vector<int> d(N);
  for (auto& v : d)cin >> v;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}


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

int main()
{
  vector<int> a(4), b(4);
  while (cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    int hit = 0, blow = 0;

    for (int i = 0; i < a.size(); ++i) {
      for (int j = 0; j < b.size(); ++j) {
	if (a[i] == b[j]) {
	  if (i == j)
	    ++hit;
	  else
	    ++blow;
	}
      }
    }

    cout << hit << " " << blow << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;

int main(){
    int d;
    cin >> d;
    if(d==25){
        cout << "Christmas" <<endl;
    }else if(d==24){
        cout << "Christmas Eve" << endl;
    }else if(d==23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
    }
}


Measured memory_bytes: 256
using System;

public class ABC152A {
  public static void Main(string[] args) {
    var str = Console.ReadLine().Split();
    var a = int.Parse(str[0]);
    var b = int.Parse(str[1]);
    var max = Math.Max(a, b);
    var num = 0;
    if (max == a) {
      num = 1;
    }
    string ans = str[num];
    for (var i = 1; i < max; i++) {
      ans += str[num];
    }
    
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			string c1 = Console.ReadLine();
			string c2 = Console.ReadLine();
			string c3 = Console.ReadLine();

			Console.WriteLine($"{c1[0]}{c2[1]}{c3[2]}");
			Console.Out.Flush();
			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using Int = long long;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,t;
  cin>>n>>t;
  vector<Int> h(n);
  for(Int i=0;i<n;i++) cin>>h[i];
  Int s=0,m=0;
  auto calc=[t](Int x,Int y,Int z){
    Int l=0,r=2e9;
    while(l+1<r){
      Int m=(l+r)>>1;
      if((__int128_t)x+y*m+z>(__int128_t)t) r=m;
      else l=m;
    }
    if(0){
      cout<<x<<" "<<y<<":"<<endl;
      cout<<x+y*l<<endl;
      cout<<x+y*r<<endl;
    }
    if((__int128_t)x+y*l+z>(__int128_t)t) r=l;
    return r+1;
  };
  for(Int i=0;i<n;i++){
    m=max(m,h[i]);
    cout<<calc(s,m,h[i])<<endl;
    s+=h[i];
  }
  return 0;
}



Measured memory_bytes: 3620
function main(N, S) {
  const S_array = S.split('');

  let r = 0,
    g = 0,
    b = 0;
  for (s of S_array) {
    if (s === 'R') ++r;
    if (s === 'G') ++g;
    if (s === 'B') ++b;
  }

  const total = r * g * b;

  let res = 0;

  for (let i = 0; i < N; i++) {
    for (let j = i + 1; j < N; j++) {
      if (S_array[i] === S_array[j]) continue;

      let k = 2 * j - i;

      if (k >= N || S_array[k] === S_array[i] || S_array[k] === S_array[j]) continue;

      ++res;
    }
  }
  console.log(total - res);
}
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');

main(input[0], input[1]);

Measured memory_bytes: 32748
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int k, n;
	cin >> n >> k;
	if (k == 1) {
		put(0);
	}
	else {
		put(n-k);
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <utility>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
	int a[3], n, m, sum = 0;
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	n = a[2] - a[1];
	m = a[2] - a[0];
	sum += n;
	if ((m - n) % 2 == 0) {
		sum += (m - n) / 2;
	}
	else{
		sum += (m - n) / 2 + 2;
	}
	cout << sum;
	return 0;
}



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

using namespace std;
int main() {
	int N;
	cin >> N;
	int cnt_AC = 0;
	int cnt_WA = 0;
	int cnt_TLE = 0;
	int cnt_RE = 0;
	
	
	for(int i = 0;i<N;i++){
		std::string S;
		cin >> S;
		if(S == "AC"){
			cnt_AC++;
		}
		else if(S == "WA"){
			cnt_WA++;
		}
		else if(S == "TLE"){
			cnt_TLE++;
		}
		else if(S == "RE"){
			cnt_RE++;
		}
		
	}
	
	std::cout << "AC x " << cnt_AC << endl; 
	std::cout << "WA x " << cnt_WA << endl; 
	std::cout << "TLE x " << cnt_TLE << endl; 
	std::cout << "RE x " << cnt_RE << endl; 
	
	return 0;
}


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


int main()
{
	ll N;
	cin>>N;
	int ans=1;
	while(ans*(ans+1)/2<N)
	{
		ans++;
	}
	int not_val=ans*(ans+1)/2-N;
	for(int i=1;i<=ans;i++)
	{
		if(not_val!=i) cout<<i<<endl;
	}
	return 0;
}


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

int main() {
  int R,G,B,N; cin>>R>>G>>B>>N;
  int ans = 0;
  for (int i=0; i<=3000; i++)
    for (int j=0; j<=3000; j++) {
      int x = i*R + j*G;
      if (N>=x && (N-x)%B==0) ans++;
    }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>


int partition(int A[],int p,int r)
{
  int x,i,j,tmp;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}

int main()
{
  int n,i,p,A[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  p=partition(A,0,n-1);
  for(i=0;i<p;i++){
    printf("%d ",A[i]);
  }
  printf("[%d]",A[p]);
  for(i=p+1;i<n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2132
#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    cin >> str;
    int fst = stoi(str.substr(0,2));
    int scd = stoi(str.substr(2,2));
    
    if(1 <= fst && fst <= 12){
        if(1 <= scd && scd <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1 <= scd && scd <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

    int n,d;
    cin>>n>>d;
    cout<<n/(2*d+1)+(n%(2*d+1)!=0)<<endl;
    return 0;
}


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

int main() {
	int N;
	std::cin >> N;
	
	std::vector<int> h(N);
	for(auto &hh : h) {
		std::cin >> hh;
	}

	const auto hMax = *std::max_element(h.begin(), h.end());

	int result = 0;
	for(int v = hMax; v >= 1; v--) {
		// XXX: meimei
		bool watering = false;
		for(auto &hh : h) {
			if(hh == v) {
				hh--;
				if(!watering) {
					watering = true;
					result++;
				}
			} else {
				if(watering) {
					watering = false;
				}
			}
		}
	}

	std::cout << result << std::endl;

	return 0;
}

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

int n;
vector<int> edge[101];
int d[101],LF[101];
int color=100000000,leaf;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

void f(int a){
  memset(d,0,sizeof(d));
  memset(LF,0,sizeof(LF));
  int L=0,D=0;
  map<int,int> m;
  for(int p:edge[a]){
    d[p]=1;
    queue<int> que;
    que.push(p);LF[p]=1;
    while(que.size()){
      int q=que.front();que.pop();
      for(int r:edge[q]){
        if(d[r])continue;
        if(r==a)continue;
        d[r]=d[q]+1;
        chmax(m[d[r]],(int)(edge[q].size()-1));
        LF[r]=LF[q]*(edge[q].size()-1);
        que.push(r);
      }
    }
  }
  L=1;for(auto q:m)L*=q.second;
  L*=edge[a].size();
  for(int i=0;i<n;i++)chmax(D,d[i]);
  if(color>D){color=D,leaf=L;}
  else if(color==D)chmin(leaf,L);
}
void g(int a,int b){
  memset(d,0,sizeof(d));
  memset(LF,0,sizeof(LF));
  int L=0,D=0;map<int,int> m;
  for(int p:edge[a]){
    if(p==b)continue;
    d[p]=1;
    queue<int> que;
    que.push(p);LF[p]=1;
    while(que.size()){
      int q=que.front();que.pop();
      for(int r:edge[q]){
        if(d[r])continue;
        if(r==a)continue;if(r==b)continue;
        d[r]=d[q]+1;
        chmax(m[d[r]],(int)(edge[q].size()-1));
        LF[r]=LF[q]*(edge[q].size()-1);
        que.push(r);
      }
    }
  }
  for(int p:edge[b]){
    if(p==a)continue;
    d[p]=1;int le=0;
    queue<int> que;
    que.push(p);LF[p]=1;
    while(que.size()){
      int q=que.front();que.pop();if(edge[q].size()==1)le++;
      for(int r:edge[q]){
        if(d[r])continue;
        if(r==a)continue;if(r==b)continue;
        d[r]=d[q]+1;
        chmax(m[d[r]],(int)(edge[q].size()-1));
        LF[r]=LF[q]*(edge[q].size()-1);
        que.push(r);
      }
    }
  }
  L=1;for(auto q:m)L*=q.second;
  L*=max(edge[a].size()-1,edge[b].size()-1)*2;
  for(int i=0;i<n;i++)chmax(D,d[i]);
  if(color>D){color=D,leaf=L;}
  else if(color==D)chmin(leaf,L);
}


signed main(){
  cin>>n;
  for(int i=1;i<n;i++){
    int a,b;cin>>a>>b;a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  if(n==2){
    cout<<1<<" "<<2<<endl;
    return 0;
  }
  for(int core=0;core<n;core++)f(core);
  for(int core1=0;core1<n;core1++) for(int core2:edge[core1]) if(core1<core2) g(core1,core2);
  cout<<color+1<<" "<<leaf<<endl;
}


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

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

	int ans = 0;
	for (auto x : a) {
		if (x.second < x.first)ans += x.second;
		else ans += x.second - x.first;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>

int main(void){
	int n, i, j, team[100], score[100], a, b, c, d;
	scanf("%d", &n);
	for (i = 0; i<n; i++){
		team[i] = 0;
	}
	for (i = 0; i<n*(n - 1) / 2; i++){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		if (c>d){
			team[a - 1] += 3;
		}
		else if (c<d){
			team[b - 1] += 3;
		}
		else{
			team[a - 1]++;
			team[b - 1]++;
		}
	}
	for (i = 0; i<n; i++){
		score[i] = 1;
		for (j = 0; j<n; j++){
			if (team[i]<team[j]){
				score[i]++;
			}
		}
	}
	for (i = 0; i<n; i++){
		printf("%d\n", score[i]);
	}
	return 0;
}

Measured memory_bytes: 2664
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    map<string,int> mp;
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    vector<pair<string,int>> arr(all(mp));
    stable_sort(all(arr),[&](pair<string,int> a,pair<string,int> b){
        return a.second>b.second;
    });
    int i=1;
    cout<<arr[0].first<<endl;
    while(i<n && arr[i].second==arr[i-1].second)
    cout<<arr[i++].first<<endl;
    return 0;
}

Measured memory_bytes: 28416
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;


#include <iostream>

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr std::ostream& operator << (std::ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

void printFixedDouble(double d, int fix) {
    cout << std::fixed;
    cout << std::setprecision(fix) << d << endl;
}

int main() {
    int m, n;
    cin >> m >> n;
    Fp<1000000007> number(m);
    cout << modpow(number, n) << endl;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int n;
string bin(int x) {
    string ans = "";
    for (int i = 0;i < n;++i)
        ans += '0' + ((x >> i) & 1);
    return ans; 
}
vector < string > f(string a,string b) {
    if (a.length() == 1)
        return vector < string > {a,b};
    int cnt = -1;
    const int sz = a.length();
    for (int i = 0;i < sz;++i)
        if (a[i] != b[i])
            cnt = i;
    string a0 = a.substr(0,cnt) + a.substr(cnt + 1,sz - cnt - 1);
    string b0 = b.substr(0,cnt) + b.substr(cnt + 1,sz - cnt - 1);
    string b1 = b0;
    b1[0] = '1' + '0' - b1[0];
    auto A = f(a0,b1);
    auto B = f(b1,b0);
    vector < string > answer;
    for (auto it : A)
        answer.pb(it);
    for (auto it : B)
        answer.pb(it);
    for (int i = 0;i < (1 << sz);++i) {
        answer[i] = answer[i].substr(0,cnt) + (i < (1 << (sz - 1)) ? a[cnt] : b[cnt]) + answer[i].substr(cnt,sz - 1 - cnt);
    }
    return answer;
}
int main(void) {
    int a,b;
    cin>>n>>a>>b;
    if (!(__builtin_popcount(a ^ b) & 1)) {
        puts("NO");
        return 0;
    }
    auto answer = f(bin(a),bin(b));
    cout << "YES\n";
    for (auto it : answer) {
        int ans = 0;
        for (int i = 0;i < n;++i)
            ans += (1 << i) * (it[i] - '0');
        cout << ans << ' ';
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 20724
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

// 二分累乗法
template <typename T>
T modpow(T a, T n, T mod) {
    T ret = 1;

    if (mod == 1) {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a;
            }
            a = a * a;
            n >>= 1;
        }
    } else {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
    }

    return ret;
}

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

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

    int ans;
    if (m.size() % 2 == 0) {
        ans = m.size() - 1;
    } else {
        ans = m.size();
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int n, p;
ll dp[60][2];

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

  dp[0][0] = 1;

  rep (i, n) {
    int a;
    cin >> a;
    dp[i + 1][0] = dp[i][0];
    dp[i + 1][1] = dp[i][1];
    rep (j, 2) {
      if (dp[i][j] > 0) {
        dp[i + 1][(a + j) % 2] += dp[i][j];
      }
    }
  }

  cout << dp[n][p % 2] << endl;
}


Measured memory_bytes: 256