akhauriyash/Code-Regression huggingface dataset:
A = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
B = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
C = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
D = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

x = int(input())
for i in range(x):
  b,f,r,v = map(int, input().split())
  if b == 1:
    A[f-1][r-1] += v
  elif b == 2:
    B[f-1][r-1] += v
  elif b == 3:
    C[f-1][r-1] += v
  else:
    D[f-1][r-1] += v

for i in range(3):
  text = " "
  temp = " ".join(map(str, A[i]))
  text += temp
  print(text)
print("####################")
for i in range(3):
  text = " "
  temp = " ".join(map(str, B[i]))
  text += temp
  print(text)
print("####################")
for i in range(3):
  text = " "
  temp = " ".join(map(str, C[i]))
  text += temp
  print(text)
print("####################")
for i in range(3):
  text = " "
  temp = " ".join(map(str, D[i]))
  text += temp
  print(text)


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

/*
2 8
5 2
8 3
*/

int H, N;
vector<pair<int, int>> goods(1001);
vector<vector<int>> memo(1001, vector<int>(10001, -1));

int rec(int i, int j){//i番目以降でh以下の重さで最大値
  if(i == N + 1){
    return 999999999;
  }
  if(j <= 0){
    return 0;
  }
  if(memo.at(i).at(j) > 0){
    return memo.at(i).at(j);
  }
  int a = 999999999;
  int b = 999999999;

  a = rec(i, j - goods.at(i).first) + goods.at(i).second;
  b = rec(i + 1, j);

  return memo.at(i).at(j) = min(a, b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  
  cin >> H >> N;
  for(int i = 1; i < N + 1; i++){
    int a, b;
    cin >> a >> b;
    pair<int, int> p = make_pair(a, b);
    goods.at(i) = p;
  }

  cout << rec(1, H) <<endl;
}

Measured memory_bytes: 40320
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  double sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  double ave = sum / n;
  // cout << ave << endl;
  if (ave >= 0) {
    if ((0 <= (ave - (int)(ave))) && ((ave - (int)(ave)) <= 0.5)) {
      ave = (int)(ave);
    } else {
      ave = (int)(ave) + 1;
    }
  } else {
    if ((-0.5 <= (ave - (int)(ave))) && ((ave - (int)(ave)) <= 0)) {
      ave = (int)(ave);
    } else {
      ave = (int)(ave)-1;
    }
  }
  int cost = 0;
  for (int i = 0; i < n; i++) {
    cost += (a[i] - ave) * (a[i] - ave);
  }

  // cout << ave << endl;
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main (){
	int n,flag=1;
	scanf ("%d",&n);
	char s[n+1];
	scanf ("%s",s);
	
	int len = strlen(s);
	
		if (n%2 != 0){
			printf ("No");
		}
	else {
	for (int i=0; i<len/2; i++){
		if (s[i] != s[(n/2)+i]){
			flag=0;
		}
	}
	if (flag==1){
		printf ("Yes");
	}
	else {
		printf ("No");
	}
}
	
	return 0;
}

Measured memory_bytes: 3224
n=int(input())
a=list(map(int,input().split()))

no2=0
bai4=0
bai2=0
for i in range(len(a)):
  if a[i]%4==0:
    bai4+=1
  elif a[i]%2==1:
    no2+=1
  else:
    bai2+=1
if bai2==0:
  print(("No","Yes")[no2<=bai4+1])
else:
  print(("No","Yes")[no2<=bai4])


Measured memory_bytes: 15020
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

using bit = std::bitset<50>;

int main()
{
    using namespace std;

    ll a, b;
    cin >> a >> b;

    auto bit1toN = [](ll n)
    {
        if (n <= 0)
            return 0ll;

        ll ret{};
        for (ll i = 0; (1ll << (i - 1)) <= n; ++i)
        {
            auto b = 1ll << (i + 1);
            auto halfB = 1ll << i;
            auto d = n / b;
            auto mod = n % b;
            
            auto bit = d * halfB + max({0ll, mod - halfB + 1});
            ret |= ((bit % 2) << i);
        }

        return ret;
    };

    auto rangeBit = [](ll a, ll b)
    {
        ll ret{};

        
    };

    auto ans = bit1toN(a - 1) ^ bit1toN(b);
    cout << ans << endl;
    // cout << bit1toN(a - 1) << endl;
    // cout << bit1toN(a) << endl <<  bit1toN(b) << endl;

    // cout << bit(bit1toN(a)).to_string() << endl; 

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

struct node {
  int id;
  int weight;
  struct node *next;
};

struct node **list;
int *dis;

void Insert(int, int, int);
void Bfs(int, int);
int main(void)
{
  int i, n, s, t, w, point = 0, maxdis = 0;
  scanf("%d", &n);
  list = (struct node**)malloc(sizeof(struct node*) * n);
  dis = (int*)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) list[i] = NULL;
  for (i = 0; i < n- 1; i++) {
    scanf("%d %d %d", &s, &t, &w);
    Insert(s, t, w);
  }
  Bfs(0, n);
  for (i = 1; i < n; i++) {
    if (dis[i] == INT_MAX) continue;
    if (maxdis < dis[i]) {
      maxdis = dis[i];
      point = i;
    }
  }
  Bfs(point, n);
  for (i = 0; i < n; i++) {
    free(list[i]);
    if (dis[i] == INT_MAX) continue;
    if (maxdis < dis[i]) maxdis = dis[i];
  }
  printf("%d\n", maxdis);
  free(list);
  free(dis);
}
void Insert(int a, int b, int w)
{
  struct node *p = (struct node*)malloc(sizeof(struct node));
  p->id = b;
  p->weight = w;
  p->next = list[a];
  list[a] = p;
  p = (struct node*)malloc(sizeof(struct node));
  p->id = a;
  p->weight = w;
  p->next = list[b];
  list[b] = p;
}
void Bfs(int point, int size)
{
  int i, ptr_front = 0, ptr_back = 0, *queue = (int*)malloc(sizeof(int) * size);
  struct node *n;
  for (i = 0; i < size; i++) dis[i] = INT_MAX;
  queue[ptr_back++] = point;
  dis[point] = 0;
  while (ptr_front != ptr_back) {
    int u = queue[ptr_front++];
    for (n = list[u]; n != NULL; n = n->next) {
      int edge = n->weight;
      if (dis[n->id] == INT_MAX) {
        dis[n->id] = dis[u] + edge;
        queue[ptr_back++] = n->id;
      }
    }
  }
  free(queue);
}


Measured memory_bytes: 9192
parseInt(x) = parse(Int, x)

function main()
  N = readline() |> parseInt
  s = Array{String}(N)
  for i=1:N
    s[i]=readline()|>strip
  end

  # w=count(b->b,map(ss->contains(ss,"AB"),s))
  w=sum(map(ss->(split(ss,"AB")|>length)-1,s))
  x=count(b->b,map(ss->ss[1]!='B'&&ss[end]=='A',s))
  y=count(b->b,map(ss->ss[1]=='B'&&ss[end]!='A',s))
  z=count(b->b,map(ss->ss[1]=='B'&&ss[end]=='A',s))
  # println([x,y,z,w])
  # result=z-1+(x>=1?1:0)+(y>=1?1:0)+((x>=1&&y>=1)?min(x-1,y-1):0)+w
  result=if z==0
    min(x,y)+w
  else
    z-1+(x>0?1:0)+(y>0?1:0)+((x>0&&y>0)?min(x-1,y-1):0)+w
  end

  println(result)
end

main()


Measured memory_bytes: 119816
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    int answer=0;
    cin >> s;
    REP(i,3)
        if(s[i] == '1')answer++;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, x; cin >> N >> x;
	vector<ll> a(N + 1, 0);
	vector<ll> b;
	ll ans = 0;
	for (int i = 1; i <= N;i++) cin >> a[i];
	b = a;
	if (a[1] > x) a[1] = x;
	for (int i = 1; i < N; i++) {
		if (a[i] + a[i + 1] > x) a[i + 1] -= a[i] + a[i + 1] - x;
	}
	for (int i = 1; i <= N; i++) {
		ans += b[i] - a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define grade(a) cout << a << endl
using namespace std;

int main(){
    int n, x;
    int i, j, k;
    while(1){
        cin >> n >> x;
        if(x==0 && n==0)break;
        int count=0;
        for(i=1;i<=n;i++){
            for(j=i+1;j<=n;j++){
                for(k=j+1;k<=n;k++) if(i+j+k==x)count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}


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

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

    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    string ans;

    int sum=0;
    rep(i,n) sum += a.at(i);
    if (sum >= h) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}


Measured memory_bytes: 640
S=input()
T=input()

if len(T)-1 == len(S):
  isSame = True
  for i in range(len(S)):
    if S[i]!=T[i]:
      isSame = False
      break
  if isSame == True:
    print('Yes')
  else:
    print('No')
else:
  print('No')


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

class Stack{
private:
int m[1000];
int tp;
public:
    Stack(){
    tp=0;
    }
    void push(int x){
        tp++;
        m[tp]=x;
    }
    int pop(){
        tp--;
        return m[tp+1];
    }
}; 
int main(){
    string str;
    int num;
    int a,b;
    Stack stack1;
    while(cin>>str){
        if(str=="+"){
        stack1.push(stack1.pop()+stack1.pop());
        }else if(str=="-"){
        a=stack1.pop();
        b=stack1.pop();
        stack1.push(b-a);  
        }else if(str=="*"){
        stack1.push(stack1.pop()*stack1.pop());
        }else {
        stack1.push(stoi(str));
        }
    }
    cout<<stack1.pop()<<endl;
    }


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[4],b[4],c[4];
    for(int i=1;i<=3;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<a[1]<<b[2]<<c[3];
    return 0;
}

Measured memory_bytes: 256
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let Arr = (input.trim()).split("\n");
let N1 = Number(Arr[0]);
let arr1 = Arr[1].split(" ").map(Number);
let arr2 = Arr[3].split(" ").map(Number);

const binarySearch = (key) => {
  let mid;
  let left = 0;
  let right = N1;
  if (key < arr1[0] || arr1[N1-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr1[mid]) right = mid;
    else if (key > arr1[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}

const summing = (a, b) => a + b;
console.log(arr2.map(binarySearch).reduce(summing));




Measured memory_bytes: 34936
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int x[n],y[n];
  
  for(int i=0;i<n;i++){
    scanf("%d %d", &x[i], &y[i]);
  }

  for(int i=0;i<n-2;i++){
    if((x[i] == y[i]) && (x[i+1] == y[i+1]) &&(x[i+2] == y[i+2])){
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");

  return 0;
}

Measured memory_bytes: 1636
{-# LANGUAGE BangPatterns #-}

import Data.Functor
import Control.Applicative
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import Data.Bits

main :: IO ()
main = do
  [n,k] <- map read . words <$> getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (<'!')) <$> BS.getLine
  print $ query n k as

query :: Int -> Int -> VU.Vector Int -> Int
query !n !k !as = VU.sum $ VU.map (`xor` x) as
  where
    bitLength = finiteBitSize k - countLeadingZeros k
    bitAccum = VU.generate bitLength
                (\ !i -> VU.length $ VU.filter (`testBit` i) as)
    x = VU.ifoldr' (\ !i !lev !acc ->
                     let setAcc = setBit acc i
                     in if lev `shiftL` 1 >= n || setAcc > k
                         then acc
                         else setAcc) 0 bitAccum


Measured memory_bytes: 6396
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int num(int n){
	int ret = 0;
	while(n){
		n /= 10;
		ret++;
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(num(i)%2) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

struct sina{
    int m;
    stack<int> st;
};

int main() {
    int n; cin >> n;
    vector<int> ar(n);
    rep(i,n) cin >> ar[i];
    vector<int> ky(n);
    ky[n-1] = 0;
    rep(i,n-1){
        if (ar[n-1-i] > ar[n-2-i]) ky[n-2-i] = 0;
        else ky[n-2-i] = ky[n-1-i]+1;
    }
    int ans = 0;
    rep(i,n) ans = max(ans,ky[i]);
    cout << ans << endl;
}

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

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int K = scan.nextInt();
			int[]p = new int[N];
			for(int i = 0;i<N;i++)p[i] = scan.nextInt();
			
			Arrays.sort(p);
			
			long goukei = 0;
			
			for(int i = 0;i<K;i++) {
				goukei+=p[i];
			}
			
			System.out.println(goukei);
			
		}
		
		
	}
		

}


Measured memory_bytes: 38844
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll x,ll y){
  if(x<y)swap(x,y);
  if(y==0)return x;
  return gcd(y,x%y);
}

int main(){
  ll a,b;
  cin>>a>>b;
  ll g=gcd(a,b);
  ll ans=0;
  for(ll i=2;i*i<=g;i++){
    if(g%i==0){
      ans++;
      while(g%i==0){
	g/=i;
      }
    }
  }
  if(g!=1)ans++;
  cout<<ans+1<<endl;
  return(0);
}


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

#define rep(i,n) for(int i = 0;i<n;++i)
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

struct x{
	ll a;
	ll deadLine;
	static bool LessA(const x& rLeft, const x& rRight)
		{ return rLeft.deadLine  < rRight.deadLine; } 
};

int main() {
	cin.tie(0);
        ios::sync_with_stdio(false);	
	ll n;
	cin >> n;
	vector<x> task(n);
	rep(i,n){
		cin >> task[i].a >> task[i].deadLine;
	}
	sort(task.begin(),task.end(),x::LessA);
	bool ans = true;
	ll tim = 0;
	repi(itr, task){
		tim += itr->a;
		if(tim>itr->deadLine){
			ans = false;
			break;
		}
	}
	if(ans)cout << "Yes"<<endl;
	else cout << "No" <<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vl H(N);
  rep(i,N) {
    cin >> H[i];
  }
  sort(rng(H));
  ll ans = 0;
  rep(i,max(0,N-K)) {
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, x, t, ans = 0;
	cin >> n >> x >> t;
	int cnt = 0;
	while(ans < n)
	{
		ans += x;
		cnt+=t;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	const int mod = 1e9 + 7;
	int n; cin >> n;
	vector<vi> a(n, vi(n));
	rep(i, n) rep(j, n) cin >> a[i][j];
	vi dp(1 << n);
	
	dp[(1 << n) - 1] = 1;
	rep(k, n) rep(i, 1 << n) if(dp[i]) rep(j, n) if((i >> j & 1) && a[k][j]){
		dp[i ^ 1 << j] += dp[i];
		if(dp[i ^ 1 << j] >= mod) dp[i ^ 1 << j] -= mod;
	}
	cout << dp[0] << endl;
	
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define P pair<int, int>
#define prique priority_queue<P, vector<P>, greater<P>>
struct edge { int to, cost; };
using namespace std;
int n;
signed main() {
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			if (i != 1) {
				if (n / (i - 1) == n % (i - 1)) cnt += i - 1;
			}
			int a = n / i;
			if (a != 1) {
				if (n / (a - 1) == n % (a - 1)) cnt += a - 1;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;
struct data{
	int x,y,dir,t;
	data(){}
	data(int xx,int yy,int dd,int tt){
		x=xx;
		y=yy;
		dir=dd;
		t=tt;
	}
};

int res=6;
int fie[6][4][4];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void bubble(int c){
	queue<data> que;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(fie[c][i][j]>=5){
				fie[c][i][j]=0;
				for(int k=0;k<4;k++){
					que.push(data(j,i,k,0));
				}
			}
		}
	}
	int prev=0;
	while(que.size()){
		data q=que.front();
		if(prev!=q.t){
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if(fie[c][i][j]>=5){
						fie[c][i][j]=0;
						for(int k=0;k<4;k++){
							que.push(data(j,i,k,q.t+1));
						}
					}
				}
			}
		}
		prev=q.t;
		que.pop();
		int nx=q.x+dx[q.dir],ny=q.y+dy[q.dir];
		if(nx<0 || nx>=4 || ny<0 || ny>=4)continue;
		if(fie[c][ny][nx]>0){
			fie[c][ny][nx]++;
			if(fie[c][ny][nx]>=5)que.push(data(-5,-5,0,q.t+1));
		}else que.push(data(nx,ny,q.dir,q.t+1));
	}
}

void dfs(int cnt){
	if(res<=cnt)return;
	bool flag=true;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(fie[cnt][i][j]>0)flag=false;
		}
	}
	if(flag){
		res=cnt;
		return;
	}
	if(cnt==5)return;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			fie[cnt][i][j]++;
			for(int k=0;k<4;k++){
				for(int l=0;l<4;l++){
					fie[cnt+1][k][l]=fie[cnt][k][l];
				}
			}
			bubble(cnt+1);
			dfs(cnt+1);
			fie[cnt][i][j]--;
		}
	}
}

int main(void){
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			scanf("%d",&fie[0][i][j]);
		}
	}
	dfs(0);
	printf("%d\n",res==6?-1:res);
	return 0;
}

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

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

using namespace std;

#define MAX int(1e5 + 1)

int h[MAX];
vector<int> adj[MAX];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> h[i];
	}
	while (m--) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		bool is_good = true;
		for (auto val : adj[i]) {
			if (h[val] >= h[i]) {
				is_good = false;
			}
		}
		if (is_good) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 9128
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, A: "List[int]", B: "List[int]"):
    left = [A[i] for i in range(N)]
    right = [B[i] for i in range(N)]

    med_left = np.median(left)
    med_right = np.median(right)

    if N%2==0:
        print(int((med_right-med_left)*2+1))
    else:
        print(int((med_right-med_left)+1))



    return


# Generated by 1.1.7.1 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()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 49004
#include<stdio.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int main(void){
    while(1){
        int n,m,a;
        scanf("%d%d%d",&n,&m,&a);
        if(n+m+a==0) break;
        int map[1001][101]={0};
        for(int i=0;i<m;i++){
            int h,p,q;
            scanf("%d%d%d",&h,&p,&q);
            map[h][p]=1;
            map[h][q]=-1;
        }
        int pos=a;
        for(int i=1000;i>=0;i--){
            if(map[i][pos]==1)
                pos++;
            else if(map[i][pos]==-1)
                pos--;
        }
        printf("%d\n",pos);
    }
}



Measured memory_bytes: 2244
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
	int a,b; cin>>a>>b;
	cout<<max(0,a-2*b)<<endl;
}

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


ll mypow10(ll n){
	ll ret=1;
	for(ll i=0;i<n;i++){
		ret*=10;
	}
	return ret;
}

ll get_chs(ll n){
	ll digit=toString(n).size();
	ll chs=0;
	for(ll i=1;i<digit;i++){
		chs+=i*(mypow10(i)-mypow10(i-1));
	}
	assert(chs>=0);
	for(ll i=1;i<digit;i++){
		ll a=mypow10(i)-1;
		ll b=mypow10(i-1)-1;
		chs+=(a/3-b/3)*4+(a/5-b/5)*4;
		chs-=(a/3-b/3)*i+(a/5-b/5)*i-(a/15-b/15)*i;
	}
	assert(chs>=0);
	ll remain=n-(mypow10(digit-1)-1);
	ll n2=mypow10(digit-1)-1;
	assert(n2>=0);
	chs+=remain*digit;
	assert(chs>=0);
	chs+=(n/3-n2/3)*4+(n/5-n2/5)*4;
	assert(chs>=0);
	chs-=(n/3-n2/3)*(digit)+(n/5-n2/5)*(digit)-(n/15-n2/15)*digit;
	assert(chs>=0);
	return chs;
}

int main(){
	ll n;
	cin>>n;
	ll lb=0,ub=mypow10(17);
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		ll chs=get_chs(mid);
		if(chs>=n){
			ub=mid;
		}else{
			lb=mid;
		}
	}

	ll prev_chs=(ub==1?0:get_chs(ub-1));
	ll cur_chs=get_chs(ub);
	string s;
	ll cur=ub;
	while(s.size()<20+n-(prev_chs+1)){
		if(cur%3==0){
			if(cur%5==0){
				s+="FizzBuzz";
			}else{
				s+="Fizz";
			}
		}else{
			if(cur%5==0){
				s+="Buzz";
			}else{
				s+=toString(cur);
			}
		}
		cur++;
	}

	cout<<s.substr(n-(prev_chs+1),20)<<endl;
}

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

typedef long long ll;
typedef pair<int, int> P;

int MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    string s; cin>>s;
    ll k; cin>>k;

    if(s[0] != '1'){
        cout << s[0] << endl;
        return 0;
    }
    else{
        if(k <= 100){
            for(int i=0; i<s.size(); i++){
                if(s[i] != '1'){
                    if(k < i+1){
                        cout << 1 << endl;
                        return 0;
                    }
                    else{
                        cout << s[i] << endl;
                        return 0;
                    }
                }
            }
            cout << 1 << endl;
            return 0;
        }
        else{
            for(int i=0; i<s.size(); i++){
                if(s[i] != '1'){
                    cout << s[i] << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
struct inputoutputfaster{
    inputoutputfaster(){
        ios::sync_with_stdio(false);\
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
}inputoutputfaster_;
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T divup(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    INT(x, y, z);
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>

static const auto NMAX = 100000;

static int num[NMAX];
static bool red[NMAX];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	std::fill(num, num + n, 1);
	red[0] = 1;
	for(; m > 0; m--) {
		int a, b;
		scanf("%d%d", &a, &b); a--; b--;
		if(red[a]) red[b] = true;
		if(--num[a] == 0) red[a] = false;
		num[b]++;
	}
	auto c = 0;
	for(auto i = 0; i < n; i++) if(red[i]) c++;
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 640
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    double n;
    cin >> n;
    int p = (int)(((double)(n)-0.01) / 1.08);
    if (p == (int)(((double)(n)+0.99) / 1.08)){
        cout << ":("<< endl;
    }else{
        cout << p+1<<endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    // variable

    // input
    cout << fixed << setprecision(10);
    int N; cin >> N;
    map<string, int> p;
    int ma = 0;
    rep(i, N) {
        string str;
        cin >> str;
        p[str] += 1;
        ma = max(ma, p[str]);
    }
    vector<string> ans;
    for(auto x : p){
        if(ma == x.second){
            ans.push_back(x.first);
        }
    }
    sort(ALL(ans));
    for(string x : ans){
        cout << x << endl;
    }

    // solve

    
    return 0;
}


Measured memory_bytes: 28656
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-13 17:16:45
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

LL gcd(LL k, LL l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

int bin_pow(int n)
{
    if (n % 2 == 0) return 1 + bin_pow(n/2);
    else return 0;
}

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

    int ok = 1;
    vector<int> bi(n);
    bi[0] = bin_pow(a[0]);
    LL lcm = a[0]/2;
    for (int i = 1; i < n; i++) {
        bi[i] = bin_pow(a[i]);
        lcm *= ((LL)a[i]/2)/(gcd(lcm, a[i]/2));

        if (lcm <= 0 || lcm > m) ok = 0;
    }

    for (int i = 1; i < n; i++)
        if (bi[i] != bi[i-1]) ok = 0;

    int ans = 0;
    for (int t = 1; lcm*t <= m; t += 2) {
        ans += ok;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};



int main(){

    map<ll, ll>flg;
    for(ll i = 0; i < 5000; i++){
        flg[i * i] = 1;
    }

    ll N, D;
    cin >> N >> D;
    ll X[15][15];
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = i + 1; j < N; j++){
            ll sum = 0;
            for(ll k = 0; k < D; k++){
                sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            if(flg[sum])ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
d=dict()
n=int(input())
for i in range(n):
    s=input()
    if s in d:
        # 入力した（s,1）にする
        d[s]+=1
    else:
        d[s]=1
d=list(d.items())
# 0はキー辞書順だからそのまま
d.sort(key=lambda x:x[0])
# 1は数値　昇順にしたいからリバースで
d.sort(key=lambda x:x[1],reverse=True)
m=len(d)
for i in range(m):
    # 先頭のものを先頭を出力
    if d[i][1]==d[0][1]:
        print(d[i][0])
    else:
        break

Measured memory_bytes: 41564
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

int cnt = 0 ;
int Q(int x){
    if(cnt >= 64) assert(false);
    cout << "? " << x << endl;
    char s ;
    cin >> s;
    return (s == 'Y');
}

bool f = false; 
int get_length(){
    int d = 1 , cur = 10;
    while(cur < inf && Q(cur)) cur = cur * 10LL , d++ ;
    if(cur == inf){
        f = true ;
        cur = 1 , d = 0 ;
        while( !Q(cur + 1) ) cur = cur * 10LL , d++ ;
    }
    return d;
}   

void solve()
{
    int k = get_length();
    int ans = 0;
    if(f){
        cout << "! " <<  po(10 , k);
        cout << endl ;
        return ;
    }
    rep(i , k){
        if(i == k - 1){
            int l = (i == 0) - 1 , r = 9 ;
            while(r - l > 1){
                int m = (l + r) >> 1 ;
                if(Q(ans * 100LL + 10LL * m))
                    r = m;
                else
                    l = m;
            }
            ans = ans * 10 + r ;
            continue ;
        }
        int l = (i == 0) , r = 10 ;
        while(r - l > 1){
            int m = (l + r) >> 1;
            if(Q(ans* 10 + m))
                l = m;
            else
                r = m;
        }
        ans = ans * 10 + l ; 
    }
    cout << "! " << ans << endl ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
//typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e5+4;

int main()
{
	ll cur=1;

	int n; scn(n);

	ll lim=1LL*(1e18);

	ll val[n];

	rep(i,0,n)	
	{
		lscn(val[i]);

		if(val[i]==0)
		{
			pri(0); return 0;
		}
	}


	rep(i,0,n)
	{
		if(cur>lim/val[i])
		{
			pri(-1); return 0;
		}

		cur*=val[i];

		// if(cur>lim)
		// {
		// 	pri(-1); return 0;
		// }
	}

	cout<<cur;

    return 0;
}

Measured memory_bytes: 4544
x, y, a, b, c = map(int, input().split())
apples = []
apples += sorted(list(map(int, input().split())), reverse=True)[:x]
apples += sorted(list(map(int, input().split())), reverse=True)[:y]
apples += list(map(int, input().split()))
print(sum(sorted(apples, reverse=True)[: x + y]))

Measured memory_bytes: 22456
#include <iostream>
#include <map>
#include <string>

int main() {
	std::string word, longest, freqest;
	std::map<std::string, int> table;
	//入力
	while (std::cin >> word) ++table[word];
	//演算
	longest = table.begin()->first;
	freqest = table.begin()->first;
	for (std::map<std::string, int>::iterator it = table.begin(); it != table.end(); ++it) {
		if (longest.length() < it->first.length()) longest = it->first;
		if (table[freqest] < it->second) freqest = it->first;
	}
	//出力
	std::cout << freqest << " " << longest << std::endl;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, s;
    cin >> n >> k >> s;
    vll sum(n + 1);
    for (int i = 1; i <= n; i++) {
        if (i <= k) {
            sum[i] = sum[i - 1] + s;
        } else {
            if (s < 1000000000) {
                sum[i] = sum[i - 1] + s + 1;
            } else {
                sum[i] = sum[i - 1] + 1;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << sum[i] - sum[i - 1];
        if (i < n) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
	char s[3];
	scanf(" %s",s);
	ll a=0,b=0;
	for(ll i=0;i<3;i++)
	{
		if(s[i]=='A')
		{
			a++;
		}
		else
		{
			b++;
		}
	}
	if(a*b==0)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
 }

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

const int INF = 1e9 + 7;
int tb[3][30];

int main() {
  int n, c;
  cin >> n >> c;
  int d[c][c];
  for ( int i = 0; i < c; i++ ) {
    for ( int j = 0; j < c; j++ ) {
      cin >> d[i][j];
    }
  }
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      int now_color;
      cin >> now_color; now_color--;
      tb[(i+j)%3][now_color]++;
    }
  }

  int ans = INF;
  for ( int i = 0; i < c; i++ ) {
    for ( int j = 0; j < c; j++ ) {
      for ( int k = 0; k < c; k++ ) {
        if ( i == j || j == k || k == i ) { continue; }
        int conf = 0;
        //-- switch (x+y)%3
        // case 0: 全部 color i にする
        for ( int l = 0; l < c; l++ ) { conf += tb[0][l] * d[l][i]; }
        // case 1: 全部 color j にする
        for ( int l = 0; l < c; l++ ) { conf += tb[1][l] * d[l][j]; }
        // case 2: 全部 color k にする
        for ( int l = 0; l < c; l++ ) { conf += tb[2][l] * d[l][k]; }
        ans = min(ans, conf);
      }
    }
  }

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


Measured memory_bytes: 3624
#include <stdio.h>
#include <algorithm>
#include <vector>

#define MAX_I 1000000007
using namespace std;

int n;
bool hh[1020];
//int sosu[1001];

int main(){
  int maxn=1000,i,j,k;
  scanf("%d",&n);
  vector <int>sosu;
  for (i=2;i<=maxn;i++){
    if (!hh[i]){
      sosu.push_back(i);
      //printf("%d\n",i);
      for(k=2;k*i<=maxn;k++){
        hh[i*k]=true;
      }
    }
  }
  vector <int> b(sosu.size());
 
  for (i=1;i<=n;i++){
    j=i;
    k=0;
    while(j!=1){
    //printf("%d %d\n",j,sosu[k]);
      while (j%sosu[k]==0){
        b[k]+=1;
        j/=sosu[k];
      }
        k++;
    }
  }
  long long int ans=1;
  for (i=0;i<(int)b.size();i++){
    ans=ans*(b[i]+1);
    ans=ans%1000000007ll;
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 256