akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        String  S = sc.next();
        String s = S.substring(2,S.length()-1);
        int cnt = 0;
        int tmp = 0;

        boolean jud = false;

        if(S.charAt(0) == 'A'){
            for(int i = 0;i < s.length();i++){
                if(s.charAt(i) == 'C'){
                    cnt++;
                    tmp = i+2;
                }
            }
            if(cnt == 1){
                for(int i = 1;i < S.length();i++){
                    if(i != tmp){
                        if(Character.isUpperCase(S.charAt(i))){
                            jud = false;
                            break;
                        }else{
                            jud = true;
                        }
                    }
            }
            
        }        
        }
        if(jud == true){
            System.out.println("AC");
        }else{
            System.out.println("WA");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int n;
P f[300001];
int k[300001];

bool C(int num){
	multiset<int> S;
	ll sum=0;
	for(int i=n-1;i>=0;i--){
		sum+=f[i].second;
		S.insert(f[i].second);
		if(S.size()<num)continue;
		if(S.size()>num){
			sum-=*S.rbegin();
			S.erase(--S.end());
		}
		if((ll)num*f[i].first>=sum)return true;
	}
	return false;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&f[i].second,&f[i].first);
	}
	sort(f,f+n);
	int lb=0,ub=n+1;
	while(ub-lb>1){
		int mid=(lb+ub)/2;
		if(C(mid))lb=mid;
		else ub=mid;
	}
	printf("%d\n",lb);
	return 0;
}

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

ll mod=998244353;
ll res;
const int MAX=1100000;
const int MOD=998244353;

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long long COM(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll solve(ll x,ll y,ll z){
  res=0;
  if(x<z){
    return 0;
  }
  if(x==z){
    if(y>x){
      return 0;
    }
    res=(COM(x+y,x)-COM(x+y,y-1))%mod+mod*100;
    res%=mod;
    return res;
  }
  if(x>z){
    if(y+z<=x){
      res=COM(x+y,x);
    }
    else if(y>x){
      res=0;
    }
    else{
      if(x!=y){
      res=COM(x+y,x);
      res-=COM(x+y,(x+x-z+1));
      }
      if(x==y){
        res=COM(x+y-1,x);
        res-=COM(x+y-1,x+x-z+1);
      }
      res+=mod*100;
    }
    res%=mod;
    return res;
  }
}
//red x,blue y,chameleon z

int main(){
  COMinit();
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  for(int i=0;i<=k;i++){
    ans+=solve(i,k-i,n);
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 29420
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;


const int mod = 1e9+7;


int add_self(int &a,int b)
{
  a +=b;
  if(a>=mod)
  {
    a-=mod;
  }
}

int sub_self(int &a,int b)
{
  a -=b;
  if(a<=0)
  {
    a+=mod;
  }
}


int main() 
{

int n,k;
cin>>n>>k;
vector<int> dp(k+1);
//dp[i] represents number of ways to get into state in which i candies are distributed.
dp[0] = 1;

for(int i=0;i<n;i++)
{
  int upto;
  cin>>upto;
  vector<int> diff(k+1);
  for(int j=k;j>=0;j--)
  {
    int tmp = dp[j];
    //for order(n*k^2) algorithm
    int L = j+1;
    int R = j+min(upto,k-j);
    if(L<=R)
    {
    add_self(diff[L],tmp);
    if(R+1<=k)
    {
    sub_self(diff[R+1],tmp);
    }
   }
  // for(int dat=L;dat<=R;dat++)
  // {
  //   if(dat<=k)
  //   {
  //   dp[dat] += tmp;
  //   } 
  // }
   }

  int prefix = 0;
for(int i=0;i<=k;i++)
{
  //cout<<"diff "<<i<<endl;
 add_self(prefix,diff[i]);
 //cout<<"prefix "<<prefix<<endl;
 add_self(dp[i],prefix);
}

}

cout<<dp[k]<<endl;

}


Measured memory_bytes: 1144
import Data.Array.IO
import Data.List
import Control.Monad


main = do
  (n:m:_) <- getLine >>= return . map read . words :: IO [Int]
  dat <- getContents >>= return . map ((\(x:y:z:_) -> (x,y,z)) . map read . words) . lines :: IO [(Integer,Integer,Integer)]

  print $ maximum $ map (solve m dat) [(1,1,1), (-1,1,1), (1,-1,1), (1,1,-1), (-1,-1,1), (-1,1,-1), (1,-1,-1), (-1,-1,-1)]
  
  where
    solve m xs (a,b,c) = sum . take m . reverse . sort $ map (\(x,y,z) -> a*x+b*y+c*z) xs
  


Measured memory_bytes: 2428
#!/usr/bin/env python3
import sys
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(a: int, b: int, c: int):
    if 4 * a * b < (c - b - a)**2:
        if 0 < (c - b - a):
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define FILEIO(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout);
#include <stdio.h>
#define N 405
#define CLZ 1000000007
typedef long long ll;
int n,c,a[N],b[N];
ll sum[N][N],f[N][N];
inline ll qpow(ll a,int b) {
	ll ans=1;
	for(;b;b>>=1) {
		if(b&1) ans=ans*a%CLZ;
		a=a*a%CLZ;
	}
	return ans;
}
int main() {
	//FILEIO("candies");
	int i,j,k;
	scanf("%d%d",&n,&c);
	for(i=1;i<=n;++i) scanf("%d",a+i);
	for(i=1;i<=n;++i) scanf("%d",b+i);
	for(i=0;i<=c;++i) for(j=1;j<=400;++j) sum[i][j]=(sum[i][j-1]+qpow(j,i))%CLZ;
	f[0][0]=1;
	for(i=1;i<=n;++i) {
		for(j=0;j<=c;++j) {
			for(k=0;k<=j;++k) {
				f[i][j]=(f[i][j]+f[i-1][j-k]*(sum[k][b[i]]-sum[k][a[i]?a[i]-1:0]+CLZ)%CLZ)%CLZ;
			}
		}
	}
	printf("%d",(int)f[n][c]);
	return 0;
}

Measured memory_bytes: 2816
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

D = I()
c = [0] + LI()
s = [0] + [[0] + LI() for i in range(D)]

last = [[0]*27 for i in range(D+1)]

for i in range(1,D+1):
    r = 0
    manzokudo = 0
    for j in range(1,27):
        m = s[i][j]
        for k in range(1,27):
            if k != j:
                m -= c[k]*(i-last[i][k])
            else:
                continue
        if j == 1:
            r = 1
            manzokudo = m
        else:
            if manzokudo < m:
                manzokudo = m
                r = j
    print(r)
    last[i][r] = i

Measured memory_bytes: 74944
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll x,y;
  cin>>x>>y;
  ll cnt=1;
  while(x*(ll)2<=y){
    x*=(ll)2;
    cnt++;
  }
  cout<<cnt<<endl;

  return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

template<class T>
class heap {
public:
    heap(int s) : xs {new T[s]}, max_size {s}, size {} {};
    heap(int* ys, int n, int s) : xs {new T[s]}, max_size {s}, size {} {
        for(int i = 0; i < n; ++i){
            xs[i] = ys[i];
        }
        size = n;
        for(int i = size/2; i >= 0; --i){
            heapify_down(i);
        }
    };
    void heapify_down(int t){
        int left = t*2 + 1;
        int right = left + 1;
        int max_i = t;
        if(left < size && xs[left] > xs[max_i]){
            max_i = left;
        }
        if(right < size && xs[right] > xs[max_i]){
            max_i = right;
        }
        if(max_i == t){
            return;
        }
        swap(xs[t], xs[max_i]);
        heapify_down(max_i);
    };
    void heapify_up(int t){
        if(!t){
            return;
        }
        int parent = (t-1)/2;
        if(xs[t] <= xs[parent]){
            return;
        }
        swap(xs[t], xs[parent]);
        heapify_up(parent);
    };
    void insert(int v){
        xs[size++] = v;
        heapify_up(size-1);
    };
    T pop(){
        T ret = xs[0];
        swap(xs[0], xs[--size]);
        heapify_down(0);
        return ret;
    };
    void print(){
        for(int i = 0; i < size; ++i){
            cout << ' ' << xs[i];
        }
        cout << endl;
    };
private:
    T* xs;
    int max_size;
    int size;
};

int main(){
    auto pque = heap<int>(2000010);
    char com[10];
    int v;
    while(1){
        scanf("%s", com);
        if(strcmp(com, "end") == 0){
            break;
        }
        if(com[0] == 'i'){
            scanf("%d", &v);
            pque.insert(v);
        } else {
            printf("%d\n", pque.pop());
        }
    }
}

Measured memory_bytes: 5932
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define LEN 1000
int LCSLength(char*,char*);
int max(int,int);
int main(void)
{
  int i;//counter
  int n;//the number of dataset
  char str[2][LEN+1];//2 input strings
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s %s",str[0],str[1]);
      printf("%d\n",LCSLength(str[0],str[1]));
    }
  return 0;
}
int LCSLength(char *str0,char *str1)
{
  int i,j;//counter
  int len[2];//length of each string
  len[0]=strlen(str0);
  len[1]=strlen(str1);
  int **arr;//array to calculate LCS length
  arr=(int**)malloc(sizeof(int*)*(len[0]+1));
  for(i=0;i<=len[0];i++) arr[i]=(int*)malloc(sizeof(int)*(len[1]+1));
  for(i=0;i<=len[0];i++)
    {
      for(j=0;j<=len[1];j++)
	{
	  if(i==0||j==0) arr[i][j]=0;
	  else if(str0[i-1]==str1[j-1]) arr[i][j]=arr[i-1][j-1]+1;
	  else arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
	}
    }
  return arr[len[0]][len[1]];
}
int max(int x,int y)
{
  return x>y?x:y;
}



Measured memory_bytes: 80408
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		String y = sc.next();
		if (y.length() <= x) {
			System.out.println(y);
		} else {
			System.out.println(y.substring(0, x) + "...");
		}
	}
}

Measured memory_bytes: 38564
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

const ll INF = 1e15;

ll dp[100001][3];
char op[100000];
int a[100000];

int main(void) {
    int i, n;
    scanf("%d",&n);
    op[0] = '+';
    REP (i,n-1) scanf("%d %c",&a[i],&op[i+1]);
    scanf("%d",&a[n-1]);

    dp[0][1] = dp[0][2] = -INF;
    REP (i,n) {
        if (op[i] == '+') {
            dp[i+1][0] = max({dp[i][0] + a[i],dp[i][1] - a[i],dp[i][2] + a[i]});
            dp[i+1][1] = max(dp[i][1] - a[i],dp[i][2] + a[i]);
            dp[i+1][2] = dp[i][2] + a[i];
        }
        else {
            dp[i+1][0] = max(dp[i][0] - a[i],dp[i][2] - a[i]);
            dp[i+1][1] = max({dp[i][0] - a[i],dp[i][1] + a[i],dp[i][2] - a[i]});
            dp[i+1][2] = dp[i][1] + a[i];
        }
    }
    ll ans = 0;
    REP (i,3) ans = max(ans,dp[n][i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3072
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

void solve()
{
	string s;
	cin >> s;
	for (char c : s)
	{
		if (c == '7')
		{
			cout << "Yes" << ln;
			return;
		}
	}
	cout << "No" << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 3624
from collections import deque
import sys
input = sys.stdin.readline

class Node:
    nodes = {}
    max_c = 0
    @classmethod
    def get_root_node(cls):
        n = Node.nodes[1]
        for _ in range(1000000):
            if n.parent is None:
                return n
            else:
                n = n.parent

    @classmethod
    def dump_all_nodes(cls):
        for key, node in Node.nodes.items():
            print(str(node))

    @classmethod
    def get_instance(cls, id, parent):
        if id in Node.nodes:
            if Node.nodes[id].parent is None:
                Node.nodes[id].parent = parent
            return Node.nodes[id]
        else:
            return Node(id, parent)

    @classmethod
    def color_childs(clf, start_node):
        c = 1
        list_to_visit = deque(start_node.childs)
        list_to_visit.append(-1)
        ap = list_to_visit.append

        while(len(list_to_visit)>0):
            if list_to_visit[0]==-1:
                c = 1
                list_to_visit.popleft()
                continue
            node = list_to_visit[0]
            list_to_visit.popleft()
            if c == node.parent.parent_edge_color:
                c += 1
            node.parent_edge_color = c
            if c > Node.max_c:
                Node.max_c = c
            list_to_visit += deque(node.childs)
            ap(-1)
            c += 1

    def __init__(self, id, parent):
        self.id = id
        self.parent = parent # None if root Node
        self.parent_edge_color = None
        self.childs = []
        Node.nodes[id] = self
        self.used_color = []

    def __str__(self):
        x = self.parent.id if self.parent else "None"
        #return f"id: {self.id}, parent: {x}, parent_edge_color: {self.parent_edge_color} ,num_child {len(self.childs)}, num_color {self.num_color}"
        return str(self.id)

    def append_child(self, node):
        self.childs.append(node)

    @property
    def num_color(self):
        if self.parent_edge_color is None:
            return len(self.childs)
        else:
            return len(self.childs) + 1

N = int(input())

Edges = []
Edges_color = []
ap = Edges.append
for i in range(N-1):
    edge = list(map(int, input().split()))
    ap(edge)
    pnode = Node.get_instance(edge[0], None)
    cnode = Node.get_instance(edge[1], pnode)
    pnode.append_child(cnode)

root = Node.get_root_node()

Node.color_childs(root)
#Node.dump_all_nodes()
K = Node.max_c
print(K)

for edge in Edges:
    print(Node.get_instance(edge[1], edge[0]).parent_edge_color)

Measured memory_bytes: 74344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		sc.close();

		if(s>=30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35612
cnt = [0 for i in range(26)]
while True:
      try:
            s = input()
      except:
            break
      for i in range(len(s)):
            m = ord(s[i])-ord('A')
            if(m >= 0 and m < 26):
                  cnt[m]+=1
            m = ord(s[i])-ord('a')
            if(m >= 0 and m < 26):
                  cnt[m]+=1
for i in range(26):
      print(chr(i+ord('a')),":",cnt[i])



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

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

#define ALL(a) a.begin(), a.end()

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
    int n, k;
    cin >> n >> k;
    unsigned long long ret = k;
    FOR_IN(i, 2, n) {
        ret *= (k - 1);
    }
    cout << ret << endl;
}


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

int main(){

	int N;
	cin >> N;

	for (int i = 0; i < N; i++){
		int a[3];
		for (int j = 0; j < 3; j++)
			cin >> a[j];
		sort(a, a + 3);

		if (pow(a[2], 2) == pow(a[1], 2) + pow(a[0], 2))
			cout << "YES";
		else
			cout << "NO";
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353;
char st[maxn];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
    {
        int ans = i;
        ans = ans * 10 + i;
        ans = ans * 10 + i;
        if(ans >= n)
        {
            printf("%d\n", ans);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        #define int long long
        //#define endl '\n'
        #define modulo 1000000007
        ///I am the backupguy!
        using namespace std;
        int DP[101][101][202];
        int arr[101],maxer,k;
        int Recursion(int L,int R,int Left){
        if(L>R)
        return 0;
        if(!Left){
        return DP[L][R][Left]=0;
        }
        else if(Left<0)
        return 0;
        if(DP[L][R][Left]+1)
        return DP[L][R][Left];
        return DP[L][R][Left]=max(max(Recursion(L+1,R,Left-1)+arr[L],Recursion(L+1,R,Left-2)),max(Recursion(L,R-1,Left-1)+arr[R],Recursion(L,R-1,Left-2)));
        }
        int32_t main()
        {
        iostream::sync_with_stdio(0);
        cin.tie(0);
        for(int i=0;i<101;i++)
        for(int l=0;l<101;l++)
        for(int x=0;x<202;x++)
        DP[i][l][x]=-1;
        cin>>maxer>>k;
        if(maxer>50||k>100)
        return -1;
        for(int i=0;i<maxer;i++){
        cin>>arr[i];
        if(arr[i]<-1e7||arr[i]>1e7)
        return -1;
        }
        cout<<max(Recursion(0,maxer-1,min(k,maxer*2)),(int)0);
        return 0;
    }


Measured memory_bytes: 16384
/*
 * atcoder/dp_3rd/o.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/* Mod */
#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

class Bits {
public:
  inline static bool included(ll S, ll v) {
    return ((S&(1<<v))>>v) == 1;
  }
  inline static ll add(ll S, ll v) {
    return S|(1<<v);
  }
  inline static ll remove(ll S, ll v) {
    return S&(~(1<<v));
  }
};

const int MAX = 25;
ll N;
bool G[MAX][MAX] = {0};
ll all = 0;

// dp[S] := 既にマッチした女性集合S
mint dp[1<<22] = {0};

void input() {
  cin >> N;
  loop(m,0,N) {
    loop(f,0,N) {
      cin >> G[m][f];
    }
    cout << endl;
  }
  loop(n,0,N) all = Bits::add(all, n);
}

void solve() {
  dp[0] = 1;
  for (ll S=1; S<=all; S++) {
    for (int f=0; f<N; f++) {
      if (!Bits::included(S, f)) continue;
      int m = __builtin_popcount(S)-1;
      if (!G[m][f]) continue;
      dp[S] += dp[Bits::remove(S,f)];
      // cout << m << " " << f << " " << dp[Bits::add(S,f)] << endl;
    }
  }
  cout << dp[all] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 33152
#include<iostream>
using namespace std;
int main(void)
{
  char num[3];
  for(int i=0;i<3;i++){
    cin >> num[i];
  }
  
  for(int i=0;i<3;i++){
    if(num[i]=='1'){
      num[i] = '9';
    }
    else{
      num[i] = '1';
    }
    cout << num[i];
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

string s[101];
int main(){
    int h,w;
    cin>>h>>w;
    rep(i,h) cin>>s[i];
    rep(i,h){
        cout<<s[i]<<endl;
        cout<<s[i]<<endl;
    }
    return 0;
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9

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

	string a, b;
	cin >> a >> b;
	b += b;
	int i, j;
	for (i = 0; b[i]; ++i) {
		for (j = 0; a[j]; ++j) {
			if (b[i+j] != a[j]) break;
		}
		if (a[j] == '\0') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
//No change above here

const ll maxi = 5*1e5;
ll mod = 5;

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here

int main()
{
	IOS;
	int l, r, d,an=0;
	cin >> l ;
	for (int i = 1; i <= l; ++i)
	{
		cin >> r;
		if (i % 2 && r%2)
			++an;
	}
	cout << an << endl;
	return 0;
}

Measured memory_bytes: 3636
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    set<int> x;
    forn(i,n)   {
        int y;
        cin>>y;
        x.insert(y);
    }
    if(x.size()==n) cout<<"YES\n";
    else            cout<<"NO\n";
    return 0;
}



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

const int MAX_N = 1e5 + 5;
int n, ind;
int Arr[MAX_N];

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

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

	if (n == 1) {
		if (Arr[0] % 2 == 1)
			cout << "Second\n";
		else
			cout << "First\n"; 
			
		return 0;
	}
	
	sort(Arr, Arr + n);
	reverse(Arr, Arr + n);
	
	if (Arr[0] == 1) {
		if (n % 2 == 1)
			cout << "Second\n";
		else
			cout << "First\n"; 
			
		return 0;
	}
	
	ind = n;
	int h = Arr[0];
	for (int i = 1; i < n; i++) {
		if (Arr[i - 1] >= i && Arr[i] <= i) {
			ind = i;
			break;
		}
	}
	
	ind--;
		
//	cout << ind << "\n";

	if ((Arr[ind] - ind) % 2 == 0) {
		cout << "First\n";
		return 0;
	}
	
	int cnt = 0;
	int tmp = ind + 1;
	while (tmp < n && Arr[tmp] == ind + 1) {
		tmp++;
		cnt++;
	}
	
	if (cnt % 2 == 1) {
		cout << "First\n";
		return 0;
	}
	
	cout << "Second\n";
	return 0;
}


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

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif
//#define int long long
#define ld1 long double
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define cint int t;cin>>t;while(t--)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 50011
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define MAXN (int)1e6 + 11
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'

const int mod=1000000007;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve(){
    int n,m;
    cin>>n>>m;

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

    vector<priority_queue<int>> vp(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        vp[x].push(h[y]);
        vp[y].push(h[x]);
    }

    int count=0;
    for(int i=0;i<n;i++){
        if(vp[i].empty()){
            count++;
            continue;
        }
        if(vp[i].top()<h[i]) count++;
    }
    cout<<count<<endl;
}

int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("inp.txt");
    WRITE("out.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

    while(t--){
        solve();
    }

#ifndef ONLINE_JUDGE
    double end=clock();
    cerr<<"*** Total time = "<<(end-beg)/CLOCKS_PER_SEC;
#endif
}


Measured memory_bytes: 9496
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N,M;
cin>>N>>M;
long long a[N]={};
long long d[N]={};
for(long long i=1;i<=N;i++){
d[i]=10;}
long long b,c,counter=0;
for(long long i=1;i<=N;i++){
cin>>a[i];}
for(long long i=0;i<M;i++){
cin>>b>>c;
if(a[b]>a[c])
{d[c]=0;}
else if(a[b]==a[c]){
d[b]=0;
d[c]=0;}
else
d[b]=0;}
for(long long i=1;i<=N;i++){
if(d[i]>0)
{counter++;}}
cout<<counter<<endl;}




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

void func(int d, vector<int>&v) {
	for (int i = 1; i*i <= d; i++) {
		if (d%i == 0)v.push_back(i);
	}
}
int main() {
	int a, b;
	while (scanf("%d%d", &a, &b), a) {
		vector<int>u, v;
		func(a, u); func(b, v);
		int Min = INT_MAX;
		for (int i : u)for (int j : v) {
			int k = a / i, l = b / j;
			int p[]{ i,j,k,l }; sort(p, p + 4);
			int sum = 0;
			rep(i, 3)sum += pow(p[i + 1] - p[i], 2);
			Min = min(Min, sum);
		}
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 3112
a, b, x = map(int, input().split(' '))
if a != 0 and b != 0:
    s = b // x
    t = (a-1) // x
elif a == 0 and b != 0:
    s = b // x + 1
    t = 0
elif a == 0 and b == 0:
    s = 1
    t = 0

print(s-t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

struct City {
  int i, p, y;
  char n[15];
};

bool sort_by_p_y(City a, City b) {
  if (a.p != b.p) {
    return a.p < b.p;
  } else {
    return a.y < b.y;
  }
}

bool sort_by_i(City a, City b) {
  return a.i < b.i;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<City> cities;
  rep(i, m) {
    int p, y;
    scanf("%d %d", &p, &y);
    cities.push_back({i, p, y});
  }
  sort(all(cities), sort_by_p_y);
  int prev = 0, idx = 0;
  for (auto &city: cities) {
    if (prev < city.p) {
      prev = city.p;
      idx = 1;
    }
    sprintf(city.n, "%06d%06d\0", prev, idx++);
  }
  sort(all(cities), sort_by_i);
  for (auto city: cities) {
    printf("%s\n", city.n);
  }
  return 0;
}


Measured memory_bytes: 5748
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    REP(i, n) cin >> l[i];
    vector<int> aa(1 << n), bb(1 << n), cc(1 << n);
    FOR(i, 1, 1 << n){
        int sum = -10;
        int h = 0;
        REP(j, n){
            if(i & (1 << j)){
                sum += 10;
                h += l[j];
            }
        }
        aa[i] = sum + abs(h - a);
        bb[i] = sum + abs(h - b);
        cc[i] = sum + abs(h - c);
    }

    int ans = INF;
    FOR(i, 1, 1 << n) FOR(j, 1, 1 << n) FOR(k, 1, 1 << n){
        if(i & j || i & k || j & k) continue;
        ans = min(ans, aa[i] + bb[j] + cc[k]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}


int main(){
    string str;
    cin >> str;
    N = str.size();
    vector<vector<ll>> dp(N + 1, vector<ll> (13, 0));
    dp[0][0] = 1;

    for(int i = 0; i < N; ++i){
        if(str[i] == '?'){
            for(int j = 0; j < 13; ++j){
                for(int k = 0; k < 10; ++k){
                    dp[i + 1][(10*j + k) % 13] += dp[i][j]%MOD;
                    dp[i + 1][(10*j + k) % 13] %= MOD;
                }
            }
        }
        else{
            int num = str[i] - '0';
            for(int j = 0; j < 13; ++j){
                dp[i + 1][(10*j + num) % 13] += dp[i][j]%MOD;
                dp[i + 1][(10*j + num) % 13] %= MOD;
            }
        }
    }
    cout << dp[N ][5];
    return 0;
}

Measured memory_bytes: 13696
#include "bits/stdc++.h"
using namespace std;
const int MAXN=1e5+1,OO=0x3f3f3f3f;
typedef  long long ll;
 vector<pair<int,int>>vc;
int main(){
    int n,x; cin>>n;
  for(int i=1;i<=n;i++)cin>>x,vc.push_back({x,i});
  sort(vc.begin(),vc.end());
  for(auto i:vc)cout<<i.second<<" ";
}

Measured memory_bytes: 1780
n = int(input())
mymap = {}
maxi = 0
for i in range(n):
	s = str(input())
	if (s in mymap):
		mymap[s] += 1
	else:
		mymap[s] = 1
	maxi = max(maxi, mymap[s])
	
ans = []

for key in mymap:
	if (mymap[key] == maxi):
		ans.append(key)
		
ans.sort()

for s in ans:
	print(s)
		


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

int main(){
    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    ll m = n*(n+1)/2;
    vector<ll> b;
    rep(i,n) b.push_back(a[(i+1)%n]-a[i]);
    sort(b.begin(),b.end(),greater<ll>());
    ll s = 0;
    rep(i,n){
        if((b[0]-b[i]) % n){
            cout << "NO" << endl;
            return 0;
        } else {
            s += (b[0]-b[i])/n;
        }
    }
    if(b[0] == s && sum >= s*m && ((sum-s*m)%(n*m)) == 0)  cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll h; cin >> n >> h;
  vector<ll> A(n), B(n);
  rep(i, n) cin >> A[i] >> B[i];
  priority_queue<pair<ll, int>> q;
  rep(i, n) {
    q.push({A[i], 1});
    q.push({B[i], 0});
  }
  ll ans = 0;
  while(!q.empty() && h>0) {
    if(q.top().second == 0) {
      ans++;
      h -= q.top().first;
      q.pop();
    } else {
      ans += (h+q.top().first-1)/q.top().first;
      h = 0;
    }
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 8972
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
  	cin>>k;
  int a,b;
  bool flag=true;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK"<<endl;
      flag=false;
      break;
    }
  }
  if(flag) cout<<"NG"<<endl;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int[] array = new int[n];
 		int temp = 0;
 		for(int i = 0;i<n;i++){
 			array[i] = Integer.parseInt(st.nextToken());
 			if (i >= 1){
 				temp = temp^array[i];
 			}
 			
 		}
 		int[] ans = new int[n];
 		ans[0] = temp;
 		for(int i = 1;i<n;i++){
 			ans[i] = array[0]^array[i]^ans[0];
 		}
 		for(int i = 0;i<n;i++){
 			out.print(ans[i] + " ");
 		}
 		out.println();
 		out.close();
 		
 		
 	}
}
 	

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

int main()
{
    int n;
    vector<int>vec;

    cin>> n;
    int input;

    for(int i = 0; i < n; i++)
    {
        cin>> input;
        vec.push_back(input);
    }

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

    long int sum, ans;
    //cout<< n;
    int l = 0;

    for(int i= vec[0]; i <= vec[n-1]; i++)
    {
        //cout<< 'x';
        long int temp = 0;
        for(int j = 0; j < n; j++)
        {
            temp =temp + pow((vec[j] - i),2);
        }
        //cout<< temp << "\n";

        if(l == 0)
            ans = temp;
        else
        {

        if(temp < ans)
           ans = temp;

        }

        l++;


    }

    cout<< ans;

}


Measured memory_bytes: 3584
#include<iostream>
#include<set>

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

int main(){
    int s,m,n;
    std::cin >> s;
    std::set<int> st;
    int x = s;
    while(st.count(x) == 0){
        st.insert(x);
        x = fanc(x);
    }
    std::cout << st.size() + 1 << std::endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
    char c;
    int x,y,sz,f[13][13],cnt = 0,max = 0; 
    for(int i = 0 ; i < 13 ; i++){
	for(int j = 0 ; j < 13 ; j++){
	    f[i][j] = 0;
	}
    }
    while(cin >> x >> c >> y >> c >> sz){
	x += 2; y += 2;
	switch(sz){
	case 3:
	    f[x][y-2]++; f[x][y+2]++;
	    f[x-2][y]++; f[x+2][y]++;
	case 2:
	    f[x-1][y-1]++; f[x+1][y+1]++;
	    f[x-1][y+1]++; f[x+1][y-1]++;
	case 1:
	    f[x][y]++; f[x-1][y]++; f[x][y-1]++; 
	    f[x+1][y]++; f[x][y+1]++;
	    break;
	}
    }
 
    for(int i = 2 ; i < 12 ; i++){
	for(int j = 2 ; j < 12 ; j++){
	    if(max < f[i][j]) max = f[i][j];
	    if(f[i][j] == 0) cnt++;
	}
    }
    cout << cnt << "\n" << max << endl; 
    return 0;
}

Measured memory_bytes: 1164
import sys
from functools import lru_cache

input = sys.stdin.readline


ans = 0
X = []
A = 0

@lru_cache(maxsize=None)
def solve(i, selected, total):
    global X, ans

    if i == len(X):
        if selected != 0 and total == (selected * A):
            return 1
        return 0

    ret = 0
    ret += solve(i + 1, selected + 1, total + X[i])
    ret += solve(i + 1, selected, total)
    return ret


def main():
    global X, ans, A
    N, A = [int(x) for x in input().split()]
    X = [int(x) for x in input().split()]

    print(solve(0, 0, 0))

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 132984
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<utility>
#include<tuple>
#include<cmath>

using namespace std;
typedef long long ll;

int main(){
    ll n;cin >> n;
    ll k;cin >> k;
    vector<ll>a(n);
    vector<ll>f(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> f[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    sort(f.begin(),f.end());

    ll ub = a[0] * f[n-1]+1;
    ll lb = -1;
    while(ub-lb>1){
        ll m = (ub+lb)/2;
        ll count = 0;
        for(int i=0;i<n;i++){
            if(a[i]*f[i] > m){
                count += (a[i]*f[i] - m + f[i] -1)/f[i];
            }
        }
        if(k < count){
            lb = m;
        }
        else{
            ub = m;
        }
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 3328
//Think simple yet elegant
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll maxn=5e6+5;
const ll mod=1e9+7;

int main(){
	fast;
	ll x,i,j;
	cin>>x;
	for(i=-120;i<=120;++i){
		for(j=-120;j<=120;++j){
			if((ll)(pow(i,5) - pow(j,5)) == x){
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 4060
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();

		long max = Math.max(a, b);
		max = Math.max(max, c);
		long oneSide;

		if(max == a){
			oneSide = b*c;
		}else if(max == b){
			oneSide = a*c;
		}else{
			oneSide = a*b;
		}

		long mid = max/2;
		System.out.println((max-mid-mid)*oneSide);
	}
}


Measured memory_bytes: 9808
#include <stdio.h>

int main( void ) {

	int prime[10000], i, j, n, sum, count;

	for ( i = 0; i < 10000; i++ ) { prime[i] = 1; }
	prime[0] = 0;
	
	for ( i = 0; i < 10000; i++ ) {
		
		if ( prime[i] == 1 ) {

			for ( j = i + 1; j < 10000; j++ ) {
			
				if ( ( j + 1 ) % ( i + 1 ) == 0 ) { prime[j] = 0; }
		
			}

		}

	}

	while ( scanf( "%d", &n ) && n > 0 ) {

		count = 0;

		for ( i = 0; i < n; i++ ) {

			sum = 0;

			if ( prime[i] == 1 ) {
				
				for ( j = i; j < n; j++ ) {

					if ( prime[j] == 1 ) {

						sum += j + 1;

						if ( sum == n ) { count++; }
						else if ( sum > n) { break; }

					}

				}

			}

		}

		printf( "%d\n", count );

	}

	return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	int pre = -INF, ans = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if(x < pre) {
			ans += pre - x;
			x = pre;
		}
		pre = x;
	}
	cout << ans << endl;
	
}





Measured memory_bytes: 3652
f :: String -> String -> Bool
f s t = maximum $ map (== s) $ h $ take (length s) $ repeat t
  where
    g (x:xs) = xs ++ [x]
    h [] = []
    h (y:ys) = y : map g (h ys)

main = do
  s <- getLine
  t <- getLine
  putStrLn $ if f s t then "Yes" else "No"


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

int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    int same = 0;
    if (W%2 == 0 and H%2 == 0 and x == W/2 and y == H/2) same = 1;
    printf("%.10lf %d\n", (W*H)/2.0, same);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF -1e18
#define INF 1e18
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef pair<int,pair<int,int>> PIPI;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    if(s[i]=='?')s[i]='D';
    cout<<s<<endl;
}


return 0;
}





Measured memory_bytes: 3768
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim A(N - 1), B(N - 1), ans As Long

        For i As Integer = 0 To N - 1
            A(i) = NextInt()
            B(i) = NextInt()
        Next

        For i As Integer = N - 1 To 0 Step -1
            A(i) += ans
            If A(i) Mod B(i) <> 0 Then
                ans += Math.Abs(A(i) Mod B(i) - B(i))
            End If
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 26072
# B - Judge Status Summary

N = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for _ in range(N):
    S = str(input())
    if S == 'AC':
        ac += 1
    elif S == 'WA':
        wa += 1
    elif S == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)

Measured memory_bytes: 9208
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>

using int64 = long long;

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

    int A, B, Q;
    std::cin >> A >> B >> Q;

    std::vector<int64> s(A + 2), t(B + 2);
    for (int i = 0; i < A; i++) {
        std::cin >> s[i + 1];
    }
    for (int i = 0; i < B; i++) {
        std::cin >> t[i + 1];
    }

    constexpr int64 inf = (1LL << 50);
    s[0] = t[0] = -inf;
    s[A + 1] = t[B + 1] = inf;

    for (int i = 0; i < Q; i++) {
        int64 x;
        std::cin >> x;

        int si = std::lower_bound(s.begin(), s.end(), x) - s.begin(),
            ti = std::lower_bound(t.begin(), t.end(), x) - t.begin();
        int64 ans = inf;
        for (int j : {-1, 0}) {
            for (int k : {-1, 0}) {
                if (j == k) {
                    // 片方向
                    ans = std::min(ans,
                                   std::max({x, s[si + j], t[ti + k]}) - std::min({x, s[si + j], t[ti + k]}));
                } else {
                    // 逆方向
                    int64 a = std::abs(std::max({x, s[si + j], t[ti + k]}) - x),
                          b = std::abs(std::min({x, s[si + j], t[ti + k]}) - x);
                    ans = std::min(ans, std::min(a, b) + a + b);
                }
            }
        }
        std::cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 2944