akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(void) {
    int a, b, c, d, e, k;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;

    cout << ((e - a) <= k? "Yay!" : ":(") << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] arr = new int[n];
		int beforeNum = 0;
		boolean isAllEqual = true;
		int targetNum = 0;

		for(int i = 0; i < n; i++){
			arr[i] = Integer.parseInt(sc.next());
			if(isAllEqual){
				isAllEqual = (beforeNum == arr[i]) ? true : false;
			}
		}

		if(isAllEqual){
			System.out.println(0);
		}else{
			targetNum = calcAve(arr);
			System.out.println(calcCost(arr, targetNum));
		}

	}

	public static int calcAve(int[] arr){
		return (int)Math.round((double)calcSum(arr) / (double)arr.length);
	}

	public static int calcSum(int[] arr){
		int sum = 0;
		for(int i = 0; i < arr.length; i++){
			sum += arr[i];
		}
		return sum;
	}

	public static int calcCost(int[] arr, int target){
		int cost = 0;
		for(int i = 0; i < arr.length; i++){
			cost += Math.pow((arr[i] - target), 2);
		}
		return cost;
	}
}

Measured memory_bytes: 9428
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int x, a, b;
  cin >> x >> a >> b;
  int r = (x - a) - b * ((x - a) / b);

  cout << r << endl;

  return 0;
}


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

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int k;string en;
	cin>>k;
	cin>>en;
	if(en.length()<=k)cout<<en<<endl;
	else{
		for(int i=0;i<k;i++)cout<<en[i];
		cout<<"...\n";
	}
	
	return 0;
}

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

int main(){
    int K,S;
    cin >> K >> S;
    int cnt=0;

    int A[K+1];
    for(int i=0;i<=K;i++){
        A[i]=i;
    }

    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            int k=S-i-j;
            if(k>=0&&k<=K){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import * as fs from 'fs'
const reader = (s: string) => s.split(' ').map(t => parseInt(t, 10))

function Main(input: string) {
  const N = reader(input)
  const fil = N.filter((x, i, a) => a.indexOf(x) === i)

  console.log(fil.length)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main() {
	ll n, x, mod;
	cin >> n >> x >> mod;
	unordered_map<ll, ll> mp;
	ll c=1, curr=x, len=-1, total=0, magic=-1;
	while (1) {
		if (mp.find(curr)!=mp.end()) {
			len=c-mp[curr];
			magic=curr;
			break;
		}
		total+=curr;
		mp[curr]=c++;
		curr*=curr;
		curr%=mod;
	}
	curr=x;
	ll rest=0;
	c=0;
	while (1) {
		if (magic==curr) break;
		total-=curr;
		rest+=curr;
		curr*=curr;
		curr%=mod;
		c++;
	}
	ll times=(n-c)/len;
	ll ans=times*total+rest;
	c=n-times*len-c;
	while (c-->0) {
		ans+=magic;
		magic*=magic;
		magic%=mod;
	}
	cout << ans;
	
	return 0;
}

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



int main(){

  priority_queue<long long> v;

int n,m;
cin>>n>>m;
long long a;
  for(int i=0;i<n;i++){
    cin>>a;
    v.push(a);
  }

  long long b;
  for(int i=0;i<m;i++){
    b = v.top()/2;
    v.pop();
    v.push(b);
  }

long long sum;
  for(int i=0;i<n;i++){
    sum += v.top();
    v.pop();
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 1400
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <random>
using namespace std;

void show(vector<int> v) {
	for (int s = 0; s < v.size(); s++)
	{
		cout << v[s];
		cout << " ";
	}
	cout << endl;
}

int main() {
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		v.push_back(t);
	}

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

	//show(v);

	for (int i = 0; i < v.size();)
	{
		bool t = true;
		if (i+1<v.size() && v[i] == v[i + 1]) {
			int tmp = i+1;
			for (int s = i+2; s < v.size(); s++)
			{
				if (s + 1 < v.size() && v[s] == v[s + 1]) { tmp = s;  break; }
			}
			v.erase(v.begin() + i);
			v.erase(v.begin() + (tmp-1));
			i = 0;
			t = false;
			//show(v);
		}
		if (t) { i++; }
	}



	cout << v.size() << endl;

	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, K;
cin>>N>>K;
vector<int> n(N);
int a=0;

for(int i=0;i<N;i++)
{
 cin>>n.at(i);
}
stable_sort(n.begin(),n.end());
for(int i=0;i<K;i++)
{
 a=a+n.at(i);
}
cout<<a<<endl;
}


Measured memory_bytes: 3572
#ifdef __GNU_C__
#include <bits/stdc++.h>
#else
#include <sstream>
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <deque>
#include <memory.h>
#endif // __GNU_C__

using namespace std;

#define REP(i, max)	for(int i = 0, iMax = max; i < iMax; i ++)
#define RREP(i, min, max)	for(int i = min, iMax = max; i < iMax; i ++)
#define EREP(i, min, max)	for(int i = min, iMax = max; i <= iMax; i ++)
#define REV(i, max)	for(int i = max - 1; i >= 0; i --)
#define RREV(i, min, max)	for(int i = max, iMin = min; i > iMin; i --)
#define EREV(i, min, max)	for(int i = max - 1, iMin = min; i >= iMin; i --)
	
typedef	unsigned long long	u64;

struct Quaternion
{
	int	q[4];

	void	Print()
	{
		::printf("%d %d %d %d\n", q[0], q[1], q[2], q[3]);
	}
	Quaternion operator *(Quaternion &o)
	{
/*		static int	eddingtonEpsilon[][][]	=
		{
			{{0, 0, 0}, {0, 0, 1}, {-1, 0, 0} },
			{{0, 0, -1}, {0, 0, 0}, {1, 0, 0} },
			{{0, 1, 0}, {-1, 0, 0}, {0, 0, 0} },
		};
*/
		return Quaternion(
			q[0] * o.q[0] - q[1] * o.q[1] - q[2] * o.q[2] - q[3] * o.q[3],
			q[2] * o.q[3] - q[3] * o.q[2] + q[0] * o.q[1] + q[1] * o.q[0],
			q[3] * o.q[1] - q[1] * o.q[3] + q[0] * o.q[2] + q[2] * o.q[0],
			q[1] * o.q[2] - q[2] * o.q[1] + q[0] * o.q[3] + q[3] * o.q[0]
		);
	}
	
	Quaternion()	{}
	Quaternion(int ct, int x, int y, int z)
	{q[0] = ct, q[1] = x, q[2] = y, q[3] = z; }
};

int main(int args, char *psArgs[])
{
	int	numQuaternions;
	vector<Quaternion>	quaternions;
	
	while(::scanf("%d", &numQuaternions), numQuaternions)
	{
		while(numQuaternions --)
		{
			Quaternion	a, b;
			
			::scanf("%d %d %d %d", &a.q[0], &a.q[1], &a.q[2], &a.q[3]);
			::scanf("%d %d %d %d", &b.q[0], &b.q[1], &b.q[2], &b.q[3]);
			(a * b).Print();
		}
	}
}

Measured memory_bytes: 3104
import heapq

N, M = map(int, input().split())
income = [[] for _ in range(M+1)]  # income[i]はi日後に報酬が得られる全ての仕事についての報酬のリスト
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        income[a].append(-b)

# 後ろから考える。残りi日のときに終了までに報酬が得られる仕事のうち報酬最大のものを選ぶ
ans = 0
tmp = []
heapq.heapify(tmp)

for rest_days in range(1, M+1):
    for x in income[rest_days]:
        heapq.heappush(tmp, x)
    if tmp:
        ans += heapq.heappop(tmp)

print(-ans)

Measured memory_bytes: 17604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char str[50];
char pat[16][10]={
"KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA",
"AKIHABR","AKIHBAR","AKIHBRA","AKIHABAR","AKIHABRA","AKIHBARA",
"AKIHABARA","KIHABAR","KIHABRA","KIHBARA","KIHABARA"
};
int main(void)
{
	int i;
	scanf("%s",str);
	FOR(i,0,16){
		if(strcmp(pat[i],str)==0){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}
    
    


Measured memory_bytes: 128
#include<iostream>
int main(){
  int n = 0;
  std::cin >> n;
  int a = 0;
  bool flag = true;
  for(int i = 1; i <= 9 && flag; i++){
  	if (n % i == 0){
      a = n / i;
      if(a <= 9){
        flag = false;
      }
    }
  }
  if(flag) std::cout << "No";
  else std::cout << "Yes";
  std::cout << std::endl;
      
  }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    #ifdef LOCAL_DEBUG
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
    #endif // LOCAL_DEBUG
    int n,f=1;
    string s[105];
    int a[105];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string ss;
        cin>>ss;
        a[i]=ss.length()-1;
        s[i]=ss;
        if(i!=0 && f!=0)
        {
            for(int j=0;j<i;j++)
                if(s[j]==s[i])
                    f=0;
            if(s[i-1][a[i-1]]!=s[i][0])
                f=0;
        }
    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad (replicateM)

main :: IO ()
main = do
  [n,x] <- map read . words <$> getLine 
  ms    <- replicateM n readLn 
  print $ f n x ms

f :: Int -> Int -> [Int] -> Int
f n x ms = n + (x - sum ms) `div` (minimum ms)

Measured memory_bytes: 1020
#include <iostream>
 
int main()
{
  char a;
  
  std::cin >> a;
  
  if (a == 'A') {
    std::cout << "T" << std::endl;
  }
  
  if (a == 'T') {
    std::cout << "A" << std::endl;
  }
  
  if (a == 'G') {
    std::cout << "C" <<std::endl;
  }
  
  if (a == 'C') {
    std::cout << "G" << std::endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i, j, k, n, m, l;
        while(true) {
            String d = sc.next();
            char[] a = d.toCharArray();
            if(d.equals("-"))break;
            n = a.length;
            char[] c = new char[n];
            m = sc.nextInt();

            for(i = 0; i < m; i++) {
                k = 0;
                l = sc.nextInt();
                char[] b = new char[l];
                for(j = 0; j < l; j++) {
                    b[j] = a[j];
                }
                for(j = l; j < n; j++) {
                    c[k] = a[j];
                    k++;
                }
                for(j = 0; j < l; j++) {
                    c[k] = b[j];
                    k++;
                }
                for(j = 0; j < n; j++) {
                    a[j] = c[j];
                }
            }
            for(i = 0; i < n; i++) {
                System.out.print(a[i]);
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 26372
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    if(isprime(n)==true)
    {
    	cout<<1<<endl;
    	return 0;
	}
	if(n==1)
	{
		cout<<0<<endl;
		return 0;
	}
vector<ll>vi;
for(ll i=2;i*i<=n;i++)
{
	if(n%i==0)
	{
		int cnt=0;
		while(n%i==0)
		{
			cnt++;
			n=n/i;
		}
		vi.pb(cnt);
	}
}
if(n>1)
{
	vi.pb(1);
}
int ans=0;
for(ll i=0;i<vi.size();i++)
{
	int p=vi[i];
	for(ll j=1;j<=50;j++)
	{
		if(p<j)
		{
			break;
		}
		else
		{
			ans++;
			p=p-j;
		}
	}
}
cout<<ans<<endl;
}
 


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

int f[20][11],n,m;

inline int read(){
	char cc=getchar();
	int f=1,num=0;
	while (cc<'0'||cc>'9'){
		if (cc=='-') f=-1;
		cc=getchar();
	}
	while (cc>='0'&&cc<='9'){
		num=(num<<1)+(num<<3)+(cc^48);
		cc=getchar();
	}
	return f*num;
}

void write(int k,int x){
    for (int i=1;i<=k;i++){
    	cout<<min(x,9);
    	x++;
	}
	exit(0);
}

void go(int k,int x,int cnt){
	cout<<x;
	if (x){
		if (f[k-1][x-1]>cnt) go(k-1,x-1,cnt);
		else cnt-=f[k-1][x-1];
	    if (!cnt) write(k-1,x-1);
	}
	if (f[k-1][x]>cnt) go(k-1,x,cnt);
	else cnt-=f[k-1][x];
	if (!cnt) write(k-1,x);
	if (x!=9){
		if (f[k-1][x+1]>cnt) go(k-1,x+1,cnt);
		else cnt-=f[k-1][x+1];
	    if (!cnt) write(k-1,x+1);
	}
}

int main(){
	cin>>n;
	if (n<10){
		cout<<n;
		exit(0);
	}
	for (int i=0;i<=9;i++) f[1][i]=1;
	m=9;
	for (int i=2;i<=10;i++){
		f[i][0]=f[i-1][0]+f[i-1][1];
		f[i][9]=f[i-1][9]+f[i-1][8];
		for (int j=1;j<=8;j++) 
		 f[i][j]=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1];
		for (int j=1;j<=9;j++){
		    if (m+f[i][j]>n) go(i,j,n-m);
		    else if (m+f[i][j]==n) write(i,j);
		    else m+=f[i][j];
	    }
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s;
	cin >> s;
	int q;
	cin >> q;
	int r = 0;
	string a = "";
	string b = "";
	while(q--) {
		int t;
		cin >> t;
		if(t == 1) {
			r ^= 1;
		}
		if(t == 2) {
			int f;
			char c;
			cin >> f >> c;
			if(f == 1) {
				if(r == 0) {
					a = a + c; 
				} else {
					b = b + c;
				}
			}
			if(f == 2) {
				if(r == 0) {
					b = b + c;
				} else {
					a = a + c;
				}
			}
		}
	}
	if(r == 1) {
		reverse(s.begin(), s.end());
		reverse(b.begin(), b.end());
		cout << b << s << a << '\n';
	} else {
		reverse(a.begin(), a.end());
		cout << a << s << b << '\n';
	}
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string S; cin >> S;
    REP(i, 3) cout << S[i];
    cout << endl;

    return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const int INF = 1999999999;

template<typename T>
T vec_max(V<T> v){return *max_element(ALL(v));}

int main(){
    LL X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    Vll p(A),q(B),r(C);
    REP(i,A) cin>>p[i];
    REP(i,B) cin>>q[i];
    REP(i,C) cin>>r[i];

    sort(ALL(p),greater<int>());
    sort(ALL(q),greater<int>());

    REP(i,X) r.pb(p[i]);
    REP(i,Y) r.pb(q[i]);

    sort(ALL(r),greater<int>());

    LL sum_apple = 0;
    REP(i,X+Y) sum_apple += r[i];

    cout<<sum_apple<<endl;
    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;

int main() {
	int n, a, b, c, d[10000];
	cin >> n;
	cin >> a >> b;
	cin >> c;
	for(int i = 0; i < n; i++)
		cin >> d[i];
		
	int pizza = c;
	int best = c / a;
	sort(d, d + n, greater<int>());
	for(int i = 0; i < n; i++){
		pizza += d[i];
		best = max(best, pizza / (a + (i + 1) * b));
	}
	
	cout << best << endl;
	
	return 0;
}

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

int bubbleSort(int A[], int N)
{
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++)
	{
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--)
		{
			if (A[j] < A[j - 1])
			{
				swap(A[j], A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main()
{
	int A[100], N, sw;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	sw = bubbleSort(A, N);
	for (int i = 0; i < N; i++)
	{
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N(111111);
int a[N];
LL cnt[N];
int main() {
	int n;
	cin >> n;
	LL tot(0);
	for(int i(0); i < n; i++) 
		cin >> a[i], tot += a[i];
	if(tot % (n * (n + 1ll) / 2) != 0) {
		cout << "NO" << endl;
		return 0;
	}
	LL k(tot / (n * (n + 1ll) / 2));
	LL cur(0);
	for(int i(0); i < n; i++) {
		//delta = (a[i] - a[(i + n - 1) % n])
		//-n * cnt[i] = delta - k
		LL delta(a[i] - a[(i + n - 1) % n]);
		if((k - delta) % n || (k - delta) / n < 0) {
			cout << "NO" << endl;
			return 0;
		}
		cnt[i] = (k - delta) / n;
		cur += cnt[i] * (1 + (n - i) % n);
	}
	for(int i(0); i < n; i++) {
		if(cur != a[i]) {
			cout << "NO" << endl;
			return 0;
		}
		cur = cur + k - cnt[i + 1] * n;
	}
	cout << "YES" << endl;
}


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

typedef long long ll;
ll balls[100005];

ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}

int main() {
	ll n, k;
	cin >> n >> k;
	ll n_max = 0;
	for (int i = 1; i <= n; i++) {
		cin >> balls[i];
		n_max = max(balls[i], n_max);
	}
	if (n_max < k) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		int g = -1;
		for (int i = 2; i <= n; i++) {
			if (g == -1) g = gcd(balls[i], balls[i - 1]);
			else g = gcd(g, balls[i]);
		}
		if (k % g != 0) {
			cout << "IMPOSSIBLE" << endl;
		}
		else {
			cout << "POSSIBLE" << endl;
		}
	}
}

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

int main()
{
    string st;
    cin>>st;
    vector<char> s(st.size());
    int count=0;
    int www=0;
    for (int i = 0; i < st.size(); i++)
    {
        s.at(i)=st.at(i);
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < st.size()-1; i++)
    {
        if (s.at(i) == s.at(i + 1))
        {
            count++;
        }

    }
   // cout << count << endl;
    if (count > 0)
    {
        cout << "no" << endl;
    }
    else
    {
        cout << "yes" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
        int N,C[500],S[500],F[500];
        int  main()
        {
        scanf ("%d",&N);
        for(int i=0;i<N-1;i++) scanf ("%d%d%d",&C[i],&S[i],&F[i]);
        for(int i=0;i<N;i++)
        {
        int t=0;
        for(int j=i;j<N-1;j++)
        {
        if(t<S[j])t=S[j];
        else if(t%F[j]==0);
        else t=t+F[j]-t%F[j];
        t+=C[j];
        }
    printf ("%d\n",t);
    }
    }

Measured memory_bytes: 256
N,M,X,Y = gets.split.map(&:to_i)
x = gets.strip.split.map(&:to_i)
y = gets.strip.split.map(&:to_i)
a = 0
for Z in X+1..Y
    if x.all?{|w| w < Z} && y.all?{|w| w >= Z}
    a += 1
end
end

if a == 0
    puts 'War'
else
    puts 'No War'
end

Measured memory_bytes: 1788
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define vll(A) vector<long lonh> A;
#define ivt(A,n,p) vector<long long> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair

const long long inf=(long long)1e18;
const long long mod=(long long)(1e9+7);

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; 
    x = x % p;  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll a,ll p)
{
   return power(a,p-2,p);
}

int main()
{
    // #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
    fio;
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        ll n;
        i(n);
        ll a[n];
        ll x=0;
        forin(i,0,n-1)
        {
            i(a[i]);
            x=x^a[i];
        }
        forin(i,0,n-1)
        {
            ll y=x^a[i];
            cout<<y<<" ";
        }
        line;
    }
    return 0;
}

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

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

int gcd(int $a, int $b) {
    if ($b == 0) return $a;

    return gcd($b, $a % $b);
}

int main() {
    int K; cin >> K;
    
    ll ans = 0;
    rep1(i,K+1){
        rep1(j,K+1){
            rep1(k,K+1){
                int tmp = gcd(i,j);
                ans += gcd(tmp,k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;

int n, l, r, ans; 

int main()
{
	cin>>n;
	while(n--)
	{
		cin>>l>>r;
		ans += r - l + 1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(){ 
    int n; cin >> n;
    vector<int> A(n); rep(i, n) cin >> A[i];

    ll res = 0, sum = 0; int right = 0;
    for(int left = 0; left < n; left++){
        while(right < n){
            int XOR = sum ^ A[right];
            if(sum + A[right] != XOR) break;
            sum += A[right];
            right++;
        }
        res += right - left;

        sum -= A[left];
    }
    cout << res << ln;
}

Measured memory_bytes: 1024
from collections import deque
s = deque(input())
q = int(input())
isRight = True
for i in range(q):
    query = input()
    if query[0] == '1':
        isRight = not(isRight)
    else:
        _, f, c = query.split()
        if f == '1':
            if isRight:
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if isRight:
                s.append(c)
            else:
                s.appendleft(c)
t = ''.join(list(s))
if not isRight:
    reversed(t)
print(t if isRight else t[::-1])

Measured memory_bytes: 8436
#include <cmath>
#include <limits>
#include <iostream>
using namespace std;


int main(){
int n,m;
int point=0;
cin >> n >> m;
const long MOD=1000000007;
int a[100010];
long long int dp[100000]={};
for(int i=0;i<m;i++){
  cin >>a[i];
}
a[m]=-1;
dp[0]=1;
dp[1]=1;
dp[2]=2;
for (int i = 0; i <= n; i++)
{
  if(i==a[point]){
    dp[i]=0;
    point++;
  }else if(i!=0 and i!=1){
    dp[i]=dp[i-1]+dp[i-2];
    dp[i]%=MOD;
  }


}
cout <<dp[n]<<endl;
}

Measured memory_bytes: 1408
//aea ctmr
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
//v.erase(unique(v.begin(),v.end()),v.end());
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define PI 3.14159265358979323846
 
typedef long double ld;
typedef long long ll;
const ll N = 100500;
const ll mod = 1e9 + 7;
using namespace std;
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif


int n;
int fact[9];
vector <int> xd;

int tmr(set <int> s, int x){
    int u = 1;
    for(auto _x: s){
        if(_x == x) return u;
        u++;
    }
}

int posi(){
    int ans = 1;
    set <int> s; s.clear();
    for(int i = 1; i <= n; i++) s.insert(i);

    for(int i = 0; i < n; i++){
        int pos = tmr(s, xd[i]);
        s.erase(xd[i]);
        s.erase(xd[i]);
        ans += (pos - 1) * fact[n - i - 1];

    }

    return ans;
}

int main(){
    fastio;
    int resp = 0;
    cin >> n;
    fact[0] = 1; 
    for(int i = 1; i < 9; i++) fact[i] = fact[i - 1] * i; 
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        xd.push_back(a);
    }
    resp += posi();
    xd.clear();
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        xd.push_back(a);
    }
    resp -= posi();
    if(resp < 0) resp *= -1;
    cout << resp << endl;

    return 0;


}


Measured memory_bytes: 256
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

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

	N := nextInt()
	M := nextInt()

	for i := 0; i < M; i++ {
		N -= nextInt()
	}

	if N >= 0 {
		fmt.Println(N)
	} else {
		fmt.Println(-1)
	}
}


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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int n,i;
    cin >> n >> i;
    cout << n+1-i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    long N,M;
    cin>>N>>M;
    long aN=1,aM=1;
    
    for(int i=1;i<=N;i++) aN=(aN*i)%MOD;
    for(int i=1;i<=M;i++) aM=(aM*i)%MOD;
    
    cout<<((abs(N-M)<2)+(N==M))*aN*aM%MOD<<endl;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()

P = []
S = []
for i in range(m):
    tmp = input().split()
    P.append(int(tmp[0]))
    S.append(tmp[1])

AC = [0]*100001
WA = [0]*100001

for i in range(m):
    if S[i] == 'AC':
        AC[P[i]] = 1
    elif S[i] == 'WA' and AC[P[i]] != 1:
        WA[P[i]] += 1

cnt_ac = 0
cnt_wa = 0
for i in range(1,n+1):
    if AC[i] == 1:
        cnt_ac += 1
        cnt_wa += WA[i]

print(cnt_ac,cnt_wa)

Measured memory_bytes: 43436
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class rec_lambda {
  F f;

public:
  rec_lambda(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};
template <class F> auto make_rec(F &&f) { return rec_lambda<F>(std::move(f)); }
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize h = scan<usize>();
  const usize w = scan<usize>();
  auto s = md_vec(h, w, char());
  for (const usize i : rep(0, h)) {
    for (const usize j : rep(0, w)) {
      std::cin >> s[i][j];
    }
  }
  auto dp = md_vec(h, w, usize(h * w + 1));
  dp[0][0] = s[0][0] == '#';
  for (const usize i : rep(0, h)) {
    for (const usize j : rep(0, w)) {
      if (i != 0) {
        chmin(dp[i][j], dp[i - 1][j] + (s[i][j] != s[i - 1][j]));
      }
      if (j != 0) {
        chmin(dp[i][j], dp[i][j - 1] + (s[i][j] != s[i][j - 1]));
      }
    }
  }
  usize ans = dp[h - 1][w - 1] + (s[h - 1][w - 1] == '#');
  std::cout << ans / 2 << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

struct AB{
    int a;
    int b;
};
bool operator<(const AB& left, const AB& right) {
    return left.a < right.a;
}


int main(){
    unsigned long N, K;
    cin >> N >> K;
    AB ab[N];
    for (unsigned long i = 0; i < N; i++) {
        cin >> ab[i].a >> ab[i].b;
    }
    sort(ab, ab + N);

    unsigned long sum = 0;
    for (unsigned long i = 0; i < N; i++) {
        sum += ab[i].b;
        if (sum >= K) {
            cout << ab[i].a << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long a[200005], b[200005], suma[200005], sumb[200005];
int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    suma[0] = 0;
    for (int i = 1; i  <= n; i++)
    {
        scanf("%lld", &a[i]);
        suma[i] = a[i] + suma[i - 1];
    }
    sumb[0] = 0;
    for (int i = 1; i <= m; i++)
    {
        scanf("%lld", &b[i]);
        sumb[i] = b[i] + sumb[i - 1];
    }
    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        if (k - suma[i] < 0)
        {
            break;
        }
        int j = upper_bound(sumb, sumb + m + 1, k - suma[i]) - sumb;
        ans = max(ans, i + j - 1);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 10076
#coding:utf-8
import numpy as np
n = int(input())
a = list(map(int, input().split()))
a = np.array(a)
mod = 10**9 + 7
ans = 0
for i in range(60):
    # i桁目の1の数を数える
    cnt_zero = np.count_nonzero(a >> i & 1)
    cnt_one = n - cnt_zero
    # すべての１と０をそれぞれ掛けあわせた総数を、桁ごとに計算
    ans += 2**i * cnt_zero * cnt_one
    ans %= mod
print(ans)

Measured memory_bytes: 48836
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
 ll n,m,d,p;
 cin>>n>>m>>d>>p;
 V<ll> v(n),cp(n);
 multiset<ll> s;
 for(int i=0;i<n;i++){
     cin>>v[i];
     cp[i]=v[i];
     s.insert(v[i]);
 }
 sort(all(cp));
 sort(all(v));
 v.erase(unique(all(v)),v.end());
 V<ll> sum(v.size()+1,0);
 ll memo;
 for(int i=0;i<v.size();i++){
     sum[i+1]=sum[i]+v[i]*s.count(v[i]);
     if(v[i]==cp[n-p])memo=i;
 }
 ll now,ans=0;
 int vs=v.size();
 ll need=0;
 ll nuse=(n-d)*m,cnt=s.count(v[memo]);
for(int i=v.size()-1;i>=0;i--){
    int ite=upper_bound(all(cp),v[i]+m)-cp.begin();
    ite=n-ite;
    if(ite>=p)break;
    if(v[memo]>v[i]){
        need=sum[memo+1]-sum[i+1]-cnt*v[i];
        cnt+=s.count(v[i]);
    }
    if(v[memo]>v[i]&&need>nuse)break;
    ans+=s.count(v[i]);
}
cout<<ans<<endl;
}

Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var N = cin.ReadInt;
            var W = cin.ReadInt;
            var dp = new int[W + 1];   //weight to value
            dp[0] = 0;
            for(int i = 0; i < N; i++) {
                var item = cin.ReadIntArray(2);
                var v = item[0];
                var w = item[1];
                for(int j = W - w; j >= 0; j--) {
                    dp[j + w] = Max(dp[j + w], dp[j] + v);
                }
            }
            Console.WriteLine(dp.Last());
        }
    }

    static class ExtendClass {
        public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }

}



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

#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;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 3001;
const i64 P = 998244353;
i64 dp[maxn][maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[a][b] = 1;
    fore(x, a, c) fore(y, b, d) {
        i64 val = 0;
        if (x == a && y == b) continue;
        val = dp[x][y - 1] * x + dp[x - 1][y] * y;
        val -= dp[x - 1][y - 1] * (x - 1) * (y - 1) % P;
        val %= P;
        if (val < 0) val += P;
        dp[x][y] = val;
    }
    i64 ans = dp[c][d];
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 73860
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int size, x, y, coord[20][20] = {0}, noink = 0, max =0;

	while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
		x += 5;
		y += 5;
		coord[x][y]++;
		coord[x - 1][y]++;
		coord[x + 1][y]++;
		coord[x][y - 1]++;
		coord[x][y + 1]++;
		if (size >= 2){
			coord[x - 1][y - 1]++;
			coord[x - 1][y + 1]++;
			coord[x + 1][y - 1]++;
			coord[x + 1][y + 1]++;
			if (size == 3){
				coord[x - 2][y]++;
				coord[x + 2][y]++;
				coord[x][y - 2]++;
				coord[x][y + 2]++;
			}
		}
	}
	
	for (int i = 5; i < 15; i++){
		for (int j = 5; j < 15; j++){
			if (coord[i][j] == 0) noink++;
			if (coord[i][j] > max) max = coord[i][j];
		}		
	}
	cout << noink << endl;
	cout << max << endl;
	return (0);
}

Measured memory_bytes: 1208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.BitSet;

class Main{
    public static void main(String[] args) throws IOException{
        final PrintWriter out = new PrintWriter(System.out);
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final BitSet dict = new BitSet(33554432);
        final char[] key = new char[128];
        key['A'] = 0;
        key['C'] = 1;
        key['G'] = 2;
        key['T'] = 3;
        final int n = Integer.parseInt(br.readLine());
        for(int i = 0; i<n; i++){
            final String line = br.readLine();
            if(line.charAt(0)=='i'){
                int hash = 1;
                for(int j = 7; j<line.length(); j++){
                    hash <<= 2;
                    hash += key[line.charAt(j)];
                }
                dict.set(hash);
            }else{
                int hash = 1;
                for(int j = 5; j<line.length(); j++){
                    hash <<= 2;
                    hash += key[line.charAt(j)];
                }
                out.println(dict.get(hash) ? "yes" : "no");
            }
        }
        out.flush();
    }
}

Measured memory_bytes: 70776
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cs(n);
    vector<vector<int>> v(n, vector<int>(m, 0));
    for (int i = 0; i < n; ++i) {
        cin >> cs[i];
        for (int j = 0; j < m; ++j) {
            cin >> v[i][j];
        }
    }
    int ans = INF<int>;
    for (int i = 0; i < (1 << n); ++i) {
        vector<int> cnt(m);
        int val = 0;
        for (int j = 0; j < n; ++j) {
            if(i & (1 << j)){
                for (int k = 0; k < m; ++k) {
                    cnt[k] += v[j][k];
                }
                val += cs[j];
            }
        }
        int ok = 1;
        for (int j = 0; j < m; ++j) {
            if(cnt[j] < x) ok = 0;
        }
        if(ok) ans = min(ans, val);
    }
    if(ans == INF<int>){
        puts("-1");
        return 0;
    }
    cout << ans << "\n";
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 1000000007;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, x;
	cin>>n;
	map<int, int> mp;
	for(int i = 0; i < n; i++){
		cin>>x; mp[x]++;
	}
	if(n%2 == 0){
		ll ans = 1;
		for(int i = 1; i <= n; i += 2){
			if(mp[i] != 2){
				cout<<0<<endl;
				exit(0);
			}
			ans <<= 1;
			if(ans >= mod)ans -= mod;
		}
		cout<<ans<<endl;
	}else{
		ll ans = 1;
		if(mp[0] != 1){
			cout<<0<<endl;
			exit(0);
		}
		for(int i = 2; i <= n; i += 2){
			if(mp[i] != 2){
				cout<<0<<endl;
				exit(0);
			}
			ans <<= 1;
			if(ans >= mod)ans -= mod;
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 3200
n = int(input())
lunlun = [[1,2,3,4,5,6,7,8,9]]

for _ in range(9):
    tmp = []
    for i in lunlun[-1]:
        if i % 10 == 0 :
            tmp.append(10 * i + i % 10)
            tmp.append(10 * i + i % 10 + 1)
        elif i % 10 == 9:
            tmp.append(10 * i + i % 10 - 1)
            tmp.append(10 * i + i % 10)
        else:
            tmp.append(10 * i + i % 10 - 1)
            tmp.append(10 * i + i % 10)
            tmp.append(10 * i + i % 10 + 1)
    lunlun.append(tmp)
ans = []
for i in lunlun:
    for j in i:
        ans.append(j)
print(ans[n-1])

Measured memory_bytes: 13280
require 'pp'
n = gets.to_i
ab = []
n.times do
  a, b = gets.split.map(&:to_i) # 必要時間、締切時間
  ab << [a,b]
end

ab = ab.sort_by{|x|x[1]}

flag = true
first_day = 0
ab.each do |x|
  first_day += x[0]
  flag &&= first_day <= x[1]
end
puts flag ? 'Yes' : 'No'
# Yes, No, Yes


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

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

    int n;
    cin >> n;
    vector<int> A(n);
    map<int, int> M;
    rep(i, n) {
        cin >> A[i];
        ++M[A[i]];
    }

    sort(all(A));

    int maxA = A[n - 1] + 100;
    vector<bool> check_table(maxA + 1, false);
    int k;
    rep(i, n) {
        k = 2;
        while (A[i]*k <= maxA) {
            check_table[A[i]*k] = true;
            ++k;
        }
    }

    A.erase(unique(all(A)), A.end());
    int ans = 0;
    rep(i, (int)A.size()) {
        if (! check_table[A[i]] && M[A[i]] == 1) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13636