akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 1010
	#define mod 1000000007ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,ll y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m;ll K;
char s[sz][sz];

struct Mat
{
	ll a[2][2];
	const Mat operator * (const Mat &m) const 
	{
		Mat ret;memset(ret.a,0,sizeof(ret.a));
		rep(i,0,1) rep(k,0,1) rep(j,0,1) (ret.a[i][j]+=a[i][k]*m.a[k][j]%mod)%=mod;
		return ret;
	}
}I,A,ret;

void KSM(ll y)
{
	I.a[0][0]=I.a[1][1]=1;ret=I;
	for (;y;y>>=1,A=A*A) if (y&1) ret=ret*A;
}

int main()
{
	file();
	read(n,m,K);
	rep(i,1,n) cin>>(s[i]+1);
	int flg=0;
	rep(i,1,m) if (s[1][i]=='#'&&s[n][i]=='#') flg=1;
	rep(i,1,n) if (s[i][1]=='#'&&s[i][m]=='#') flg|=2;
	if (flg&1) rep(i,1,max(n,m)) rep(j,1,i) swap(s[i][j],s[j][i]);
	if (flg&1) swap(n,m);
	int c1=0,c2=0,c3=0,c4=0;
	rep(i,1,n) c1+=(s[i][1]=='#'&&s[i][m]=='#');
	rep(i,1,n) rep(j,1,m) c2+=(s[i][j]=='#'&&s[i][j-1]!='#');
	rep(i,1,n) rep(j,1,m) c3+=(s[i][j]=='#');
	rep(i,1,n) rep(j,2,m) c4+=(s[i][j]=='#'&&s[i][j-1]=='#');
	if (flg==3||K<=1) return puts("1"),0;
	if (!flg) return printf("%lld\n",ksm(c3,K-1)),0;
	K-=2;
	A.a[0][0]=c1,A.a[1][0]=-c4,A.a[1][1]=c3;
	KSM(K);
	ll ans=(c1*ret.a[1][0]%mod+c2*ret.a[1][1]%mod+mod*2)%mod;
	cout<<ans;
	return 0;
}

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

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

int main(){
    int n,m=0; cin>>n;
    map<string,int> M;
    rep(i,n){
        string s; cin>>s;
        if(!(M.count(s))) M[s]=0;
        M[s]++; m=max(m,M[s]);
    }
    vector<string> ans;
    for(auto p:M){
        if(m==p.second) ans.push_back(p.first);
    }
    sort(al(ans));
    rep(i,ans.size()) cout<<ans[i]<<endl;
}

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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define siz(x) (int)x.size()

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// ---------------------------  TEMPLATE ENDS  -------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9+7;
const int inf = 2e9;
const ld eps = 1e-9;
const int NN = 5002;

/*void solve(){
	int i = 0, j = 0, k = 0, n = 0, m = 0;
	int A[3], B[3];
	cin >> n;
	fr(i, 0, 2) {
		fr(j, 0, 3) {
			if(i == 0) 
				cin >> A[j];
			else 
				cin >> B[j];
		}
	}

	vi a;
	a.assign(20, n);
	if(A[0] < B[0]) {
		a[0] = (a[0]%A[0]) + B[0]*(a[0]/A[0]);
		fr(j, 0, 3) {
			a[1+j] = (a[0]%B[j]) + (A[j])*(a[0]/B[j]);
		}
	}
	if(A[1] < B[1]) {
		a[4] = (n%A[1]) + B[1] * (n/A[1]);
		fr(j, 0, 3) {
			a[5+j] = (a[4]%B[j]) + (A[j])*(a[4]/B[j]);
		}
	}

	if(A[2] < B[2]) {
		a[8] = (n%A[2]) + (B[2]) * (n/A[2]);
		fr(j, 0, 3) {
			a[9+j] = (a[8]%B[j]) + A[j]*(a[8]/B[j]);
		}
	}

      // go to B with buying from A
	fr(j, 0, 3) {
		a[12 + j] = (n%B[j]) + A[j]*(n/B[j]);
	}

	int ans = 0;
	for(auto o : a) remax(ans, o);

		cout << ans;
}
*/

int dp[NN][3];
int fun(vi a, vi b, int n) {
	if(siz(a) == 0) return n;

	if(siz(a) == 1) {
		return n + (b[0] - a[0]) * (n/a[0]);
	}
	if(siz(a) == 3) { 
		// dp required
		assert(n <= 5000);
		for(int amt = 0; amt <= n; amt++) {
			dp[amt][0] = amt + (b[0]-a[0])*(amt/a[0]);
		}	
		for(int m = 1; m < 3; m++) {
			for(int amt = 0; amt <= n; amt++) {
				int &v = dp[amt][m];
				for(int x = 0; x <= amt; x++) {
					int h = dp[amt-x][m-1] + x + (b[m] - a[m])*(x/a[m]);
					remax(v, h);
				}
			}
		}
		return dp[n][2];
	}

	int ret = 0;
	for(int amt = 0; amt <= n; amt++) { // amount for metal 1
		int x = n - amt; 	// amount for metal 2
		int h = x + (b[1] - a[1])*(x/a[1]) + amt + (b[0] - a[0])*(amt/a[0]);
		remax(ret, h);
	}
	return ret;
}

int32_t main(){
#ifndef TRACE
	ios::sync_with_stdio(false); cin.tie(0); 
#endif
	// solve();
	int i, j, n;
	cin >> n;
	int A[3], B[3];
	fr(i, 0, 3) {
		cin>>A[i];
	}

	fr(i, 0, 3) {
		cin >> B[i];
	}

	vi d1, d2;
	fr(i, 0, 3) {
		if(B[i] - A[i] > 0) d1.pb(A[i]), d2.pb(B[i]);
	}

	n = fun(d1, d2, n);
	d1.clear();
	d2.clear();
	fr(i, 0, 3) {
		if(A[i] - B[i] > 0) d1.pb(B[i]), d2.pb(A[i]);
	}

	n = fun(d1, d2, n);
	cout << n << el;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long  long
using namespace std;
int a[300000];
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		
	}
	sort(a,a+n,cmp);
	ll sum=0;
	for(int i=k;i<n;i++)
	sum+=a[i];
	cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

typedef unsigned long long int ULLI;

int main()
{
	int n;
	ULLI sum = 0;

	scanf("%d", &n);

	for (int i = 1; i <= n; i++) {
		if (i % 15 != 0 && i % 5 != 0 && i % 3 != 0)
			sum += i;
	}

	printf("%llu\n", sum);

	return 0;
}

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

using namespace std;

typedef long long llint;

int main() {
  int n;
  cin >> n;
  vector<llint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  llint cur = 1000;
  for (int i = 0; i + 1 < n; i++) {
    llint cnt = 0;
    if (a[i] < a[i + 1]) cnt = cur / a[i];
    cur += (a[i + 1] - a[i]) * cnt;
  }
  cout << cur << endl;

  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <array>

/*This function is a counter for "hit" and "blow".*/
void counter(int* n_a, int* n_b, int* hit, int* blow) {

	*hit = 0;
	*blow = 0;

	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			//the case of factor and place are same
			if (n_a[i] == n_b[j] && i == j) {
				*hit = *hit + 1;
			}
			//the case of only factor is same
			else if (n_a[i] == n_b[j]) {
				*blow = *blow + 1;
			}
		}
	}
}

int main() {

	std::array<int, 4> n_a;//selection of "A"
	std::array<int, 4> n_b;//selection of "B"

	while (std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3] && std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3]) {
		//std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3];
		//std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3];

		int hit = 0;//factor and place are same
		int blow = 0;//only factor is same

		counter(n_a.data(),n_b.data(),&hit,&blow);

		std::cout << hit << " " << blow << std::endl;
	}

	return 0;

}

Measured memory_bytes: 3068
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	r := eGetInt(scanner)
	if n >= 10 {
		fmt.Println(r)
	} else {
		fmt.Println(r + (100 * (10 - n)))
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 640
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    string s; cin>>s;

    int n = sz(s);

    if(n%2 == 1){
        cout<<"No\n";
        return;
    }

    for(int i=0;i<n;i+=2){
        if(s[i] == 'h' && s[i+1] == 'i') continue;
        else {
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	ll a, b;
	cin >> a >> b;
	if (b < 0) {
		ll c = b - a;
		if (c % 2 == 0) {
			cout << "Negative" << endl;
		} else {
			cout << "Positive" << endl;
		}
	} else if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
	} else {
		cout << "Positive" << endl;
	}
	return 0;
}



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

t = B - A

if t % 2 == 0:
  print(t // 2)
else:
  print(min(B - 1, N - A, A + (t - 1) // 2, (N - B + 1) + (t - 1) // 2))
  

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
  #define PI 3.141592653589793
  int a,b,x;
  double ad,bd,xd;
  double dgr;
  scanf("%d %d %d",&a,&b,&x);
  ad = (double)a;
  bd = (double)b;
  xd = (double)x;
  if ( a*a*b > 2*x){
    dgr = atan(ad*bd*bd/(2*xd)) * 180 / PI;
  }else{
    dgr = atan(2*(ad*ad*bd - xd)/(ad*ad*ad)) * 180 / PI;
  }
  
  printf("%lf",dgr);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>

#define FORi(N) for(LL i=0;i<N;++i)
#define FABi(a,b) for(LL i=a;i<=b;++i)

using namespace std;
using LL = long long;
using LD = long long;
using LLV = vector<LL>;
using LDV = vector<LD>;
using LLVV = vector<vector<LL> >;
int main(){
  LL H,W,N;
  cin>>H>>W>>N;
  if(N==0){
    cout<<H<<endl;
    return 0;
  }
  LLVV XY;
  FORi(N){
    LL  x,y;
    cin>>x>>y;
    if(x+1<y)continue;
    LLV xy{x,y};
    XY.push_back(xy);
  }
  if(XY.size()==0){
    cout<<H<<endl;
    return 0;
  }
  sort(XY.begin(),XY.end(),[](LLV a,LLV b){
    if(a[0]<b[0]){
      return true;
    }else if(a[0]==b[0]){
      return a[1]<b[1];
    }else{return false;}
  });
  LL x=2,y=2;
  LL b;
  bool flag=false;
  bool yflag=true;
  LL id=0;
  b=0;
  while(true){
    while(XY[id][0]==x){
      if(XY[id][1]<y){
        flag=true;
        break;
      }
      ++id;
      if(id>=XY.size()){
        flag=true;
        x=H+1;
        break;
      }
    }
    if(flag)break;
    id=b;
    yflag=true;
    while(XY[id][0]==x){
      if(XY[id][1]==y)yflag=false;
      ++id;
      if(id>=XY.size()){
        --id;
        break;
      }
    }
    //e=id-1;
    ++x;
    if(x>H){
      x=H+1;
      break;
    }
    if(yflag)++y;
    b=id;
  }
  cout<<x-1<<endl;
  return 0;
}

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

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

int main(){
    int n;
    cin>>n;
    int ans=1;

    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        ans=lcm(ans,a);

    }

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

Measured memory_bytes: 1160
#include <cstdio>
#include <cctype>
#include <algorithm>
#define MAXN 1100005
using namespace std;
int a[MAXN];
int fst[MAXN]={0};
int sec[MAXN]={0};
int tmp[25];
int temp[5];
int f[MAXN];
int read(void);
void write(int x);
int main(void){
    int len,n;
    len=read();
    n=1<<len;
    for (int i=0;i<n;i++)
        fst[i]=read();
    for (int l=0;l<len;l++){
        int tpow=1<<l;
        for (int i=1;i<n;i++){
            if (i&tpow){
                //Use i^tpow;
                int tfore=i^tpow;
                temp[0]=fst[i],temp[1]=sec[i];
                temp[2]=fst[tfore],temp[3]=sec[tfore];
                sort(temp,temp+4);
                fst[i]=temp[3],sec[i]=temp[2];
            }
        }
    }
    f[0]=fst[0];
    for (int i=1;i<n;i++)
        f[i]=max(f[i-1],fst[i]+sec[i]);
    for (int i=1;i<n;i++)
        write(f[i]);
    return 0;
}

int read(void){
    int ans=0;
    char ch;
    do {
        ch=getchar();
    } while (!isdigit(ch));
    while (isdigit(ch)){
        ans=ans*10+(ch-'0');
        ch=getchar();
    }
    return ans;
}

void write(int x){
    int lg=0;
    if (!x){
        putchar('0');
        return;
    }
    while (x){
        tmp[lg++]=x%10;
        x/=10;
    }
    for (int i=lg-1;i>=0;i--)
        putchar(tmp[i]+'0');
    putchar('\n');
}

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

int main(){
    int N;
    cin>>N;
    
    vector<int> V(N);
    for(int i=0;i<N;i++) cin>>V[i];
    
    int ans = 0;
    for(int i=0;i<N;i++){
        while(V[i]%2==0){
            V[i] /= 2;
            ans++;
        }
    }cout<<ans<<endl;
}

Measured memory_bytes: 256
#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 >;

int a[200002], b[200002];
bool ok1[200002], ok2[200002];

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

    rep(i, m) {
        cin >> a[i] >> b[i];

        if (a[i] == 1) {
            ok1[b[i]] = 1;
        }
        if (b[i] == n) {
            ok2[a[i]] = 1;
        }
    }

    rep(i, n) {
        if (ok1[i] and ok1[i] == ok2[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[1100][1100];
inline void solve(int n)
{
	if(n==1){a[2][2]=1;return ;}
	else
	{
		solve(n-1);
		int ul=1<<(n-1),uf=1<<n;
		for(int i=1;i<=ul;i++)
		{
			for(int j=ul+1;j<=uf;j++)a[i][j]=a[i][j-ul];
		}
		for(int i=ul+1;i<=uf;i++)
		{
			for(int j=1;j<=ul;j++)a[i][j]=a[i-ul][j];
			for(int j=ul+1;j<=uf;j++)a[i][j]=a[i][j-ul]^1;
		}
	}
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read(),T=max(n,m);
    solve(T);
    n=1<<n,m=1<<m,T=1<<T;
    for(int i=T;i>=2;i--)
    {
    	for(int j=T;j>=2;j--)a[i][j]^=a[i-1][j]^a[i][j-1]^a[i-1][j-1];
    }
    for(int i=2;i<=n;i++)
    {
    	for(int j=2;j<=m;j++)write(a[i][j]);
    	puts("");
    }
    return 0;
}

Measured memory_bytes: 5632
#include <cstdio>
using namespace std;

int main(){
    int a,b,c,x,count=0;

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);

    int tmp;
    for(int i=0;i<=a;i++){
        if( x < 500 * i ) break;
        for(int j=0;j<=b;j++){
            tmp=x - i*500 - j*100;
            if(tmp < 0) break;
            if(tmp%50 == 0 & tmp/50 <= c) count+=1;
        }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

const int len = 1000010;
int a,b,c;

int main() {
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	cin >> a >> b >> c;
	int n = min(min(a,b),c);
	int m = max(max(a,b),c);
	cout << a+b+c-m << endl;
    return 0;
}

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

int N,W;
const int SIZE = 100005;
long long mem [105][SIZE];
long long arr [105][2];

long long dp (int i, int w) {
  
  if (i == N ) return 0;
  if (mem[i][w] != -1) return mem[i][w];  

  long  long ret = -1;
  if (w+arr[i][1] <= W) 
  ret = max (ret, arr[i][0] + dp (i+1 , w+arr[i][1]));
  ret = max (ret,  dp (i+1, w));
  return  mem[i][w] = ret;
}

int main (){ 

  cin  >> N  >> W;
  for (int i =0; i< N; i++) {
    cin >> arr[i][1] >> arr [i][0];
  }

  memset(mem, -1, sizeof mem);

  cout << dp(0,0);

}

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

int main()
{
    int A[3];

    for (int i = 0; i != 3; ++i)
    {
        cin >> A[i];
    }

    sort(A, A+3);

    for (int i = 0; i != 3; ++i)
    {
        if (i) cout << " ";
        cout << A[i];
    }

    cout << endl;
    
    return 0;
}



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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL n;cin >> n;
    LL ans = 1;
    for(LL i=1LL;i<=n;i++){
        ans *= i;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
vector<ll> A[2020];
ll G[2020],T[2020];

void dodo(vector<ll>& V) {
	int i;
	for(i=1;i<V.size();i++) V[i]+=V[i-1];
}

ll hoge(vector<ll> A,vector<ll> B,bool eq_ok) {
	if(A[0]<B[0]) {
		cout<<-1<<endl;
		exit(0);
	}
	if(A[0]>B[0]) return 0;
	
	ll t=(B[1]-A[1]+A[0]-1)/A[0];
	if(A[0]*t+A[1]>B[1]) return t;
	
	int mapos=B.size();
	ll ov=1LL<<30;
	int i,x,y;
	FOR(i,t) {
		if(mapos==2) {
			A[1]+=A[0]*(t-i);
			break;
		}
		for(x=1;x<mapos;x++) {
			A[x]+=A[x-1];
			if(A[x]>=ov) {
				mapos=x;
				break;
			}
		}
	}
	
	if(eq_ok && A>=B) return t;
	if(!eq_ok && A>B) return t;
	return t+1;
}
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) FOR(x,W) cin>>i, A[y].push_back(i);
	
	if(W==1) {
		FOR(y,H-1) if(A[y][0]>=A[y+1][0]) return _P("-1\n");
		return _P("0\n");
	}
	
	FOR(y,H-1) {
		if(A[y][0]>A[y+1][0]) return _P("-1\n");
		if(A[y][0]<A[y+1][0]) {
			G[y+1]=-1LL<<30;
			continue;
		}
		
		if(A[y]<A[y+1]) {
			G[y+1]=-hoge(A[y],A[y+1],true)+1;
		}
		else {
			G[y+1]=hoge(A[y+1],A[y],false);
		}
	}
	
	ll ret=0;
	for(i=1;i<H;i++) {
		T[i]=max(0LL,T[i-1]+G[i]);
		ret+=T[i];
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 8320
def inputOneLine():
	global S
	S=input()

def inputMaltiLine1():
	global S,N,lines
	N=int(input())
	for i in range(N):
		lines.append(input())

def inputMaltiLine2Numbers():
	global S,N,lines
	N=int(input())
	for i in range(N):
		lines.append(input())


##main#######################################

S=''
N=''
lines=[]

inputOneLine()
n=int(S)
line2=input()
line2s=line2.split(' ')
min=int(line2s[0])
max=int(line2s[1])

#get min
if not((min % n)==0):
	min= min + (n-(min % n))

#get max
if not((max % n)==0):
	max = max - (max % n)

#print(min)
#print(max)
if min <=max :
	print ('OK')
else:
	print ('NG')


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

using namespace std;


#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int 
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))


int solve(){

    int k,a,b;

    cin >> k >> a >> b;

    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout <<"OK"<<endl;
            return 0;
        }
    } 
    
        cout << "NG" << endl;
    
    
    return 0;
}

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


    time__("programm time"){
        solve();
	}
    return 0;

}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n, m, sum = 0;
  cin >> n >> m;

  vector<int> a(m);

  REP(i, m) {
    cin >> a[i];
    sum += a[i];
  }

  cout << (sum <= n ? n - sum : -1) << "\n";
}

Measured memory_bytes: 3672
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <functional>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int n; cin >> n;
  string s[n]; 
  ll m=0,a=0,r=0,c=0,h=0;
  rep(i,n){
    cin >> s[i];
    if (s[i][0] == 'M'){
      m++;
    }
    if (s[i][0] == 'A'){
      a++;
    }
    if (s[i][0] == 'R'){
      r++;
    }
    if (s[i][0] == 'C'){
      c++;
    }
    if (s[i][0] == 'H'){
      h++;
    }
  }
  cout << m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+r*c*h+a*c*h;
  
 
 return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s,w;
    cin>>s>>w;
    if(s>=1&&s<=100&&w>=1&&w<=100)
    {
        if(s<=w)
            cout<<"unsafe"<<endl;
        else
            cout<<"safe"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
	long long n , m , ans , b;
	cin >> n >> m;
	if (m > (2 * n))
	{
		m -= (2 * n);
		ans = (n + (m / 4));
	}
	else
		ans = (m / 2);
	cout << ans;
}

Measured memory_bytes: 256
n = gets.to_i
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
exp = [0]*15
2.upto(n) do |v|
  prime.each_with_index do |a,i|
    while (v % a == 0)
      exp[i] += 1
      v /= a
    end
  end
end
 
v,w,x,y,z = 0,0,0,0,0
exp.each do |e|
  if e >= 74
    v += 1
  end
 
  if e >= 24
    w += 1
  elsif e >= 14
    x += 1
  elsif e >= 4
    y += 1
  elsif e == 2 || e == 3
    z += 1
  end
end
 
ans = 0
if v > 0
  ans += v
end
if w > 0
  ans += w * (x+y+z) + w * (w-1)
end
if (w+x) > 0
  ans += (w+x) * y + (w+x) * ((w+x)-1)
end
y = w+x+y
if y >= 3
  ans += y * (y-1) * (y-2) /2
end
if y >= 2 && z > 0
  ans += y * (y-1) * z /2
end
p ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007

using namespace std;

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

  if (s == "SUN")
    cout << 7 << endl;
  if (s == "MON")
    cout << 6 << endl;
  if (s == "TUE")
    cout << 5 << endl;
  if (s == "WED")
    cout << 4 << endl;
  if (s == "THU")
    cout << 3 << endl;
  if (s == "FRI")
    cout << 2 << endl;
  if (s == "SAT")
    cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define N 1000102
const int p=998244353;
int n,m,f[N],finv[N],inv[N];
inline int C(int nn,int mm)
{
    if(nn<mm)return 0;
    return 1ll*f[nn]*finv[mm]%p*finv[nn-mm]%p;
}
inline int ksm(int d,int k){int ret=1;while(k){if(k&1)ret=1ll*ret*d%p;d=1ll*d*d%p;k>>=1;}return ret;}
int main()
{
    f[0]=finv[0]=f[1]=finv[1]=inv[1]=1;
    for(int i=2;i<=1000000;i++)
    {
        inv[i]=1ll*(p-p/i)*inv[p%i]%p;
        f[i]=1ll*f[i-1]*i%p;finv[i]=1ll*finv[i-1]*inv[i]%p;
    }
    scanf("%d%d",&n,&m);if(n>m)swap(n,m);
    int ans=0;
    for(int i=0;i<=n;i++)
    {
        int te=1ll*C(n,i)*C(m,i)%p*f[i]%p*ksm(m+1,n-i)%p*ksm(n+1,m-i)%p;
        if(i&1)ans=(ans-te+p)%p;
        else ans=(ans+te)%p;
    }
    printf("%d\n",ans);
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

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

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a[100000],b[100000],c,cmp,data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;
bool graph[50][50];
bool visited[50];
string s;

vector<int> z;


void dfs(int v){
    visited[v]=true;
    for(int v2=0;v2<n;v2++){
        if(graph[v][v2]==false){
            continue;
        }
        if(visited[v2]==true){
            continue;
        }
        dfs(v2);
    }
}


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

       cin >> n >> m;
       rep(i,m){
           cin >> a[i] >> b[i];
           a[i]--;
           b[i]--;
           graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
       }
       rep(i,m){
           graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
           rep(j,n){
               visited[j]=false;
           }
           dfs(0);
           
           bool bridge=false;
           rep(j,n){
               if(visited[j]==false){
                   bridge=true;
               }
           }
           if(bridge){
               ans+=1;
           }
           graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define INF 10000
typedef long long ll;
int main(){
	int h,w;
	int d_cnt=0;

	cin>>h>>w;
	int map[52][52]={};
	typedef pair<int,int> P;
	queue<P> Q;
	int x[4]={1,0,-1,0};
	int y[4]={0,1,0,-1};
	char sub;

	rep(i,h){
		rep(j,w){
			cin >> sub;
			if (sub=='.') {
				d_cnt++;
				map[i][j]=-1;
			}
			else {
				map[i][j]=INF;
			}
		}
	}

	Q.push(make_pair(0,0));
	map[0][0]=1;
	while(!Q.empty()){
		P a = Q.front(); Q.pop();

		rep(i,4){
			int x_sub = a.first + x[i];
			int y_sub = a.second + y[i];
			if (x_sub>=0 &&x_sub<h &&y_sub >=0&& y_sub<w){
			if (-1==map[x_sub][y_sub]){
				Q.push(P(x_sub,y_sub));
				map[x_sub][y_sub] = map[a.first][a.second]+1;
				if (x_sub == h-1 &&y_sub == w-1) break;
			}
			}
		}
	}
/*
	rep(i,h){
		rep(j,w){
			cout << map[i][j] << " ";
		}
		cout << endl;
	}
*/
	int mahi = map[h-1][w-1];
	cout << (mahi == -1 ? -1 : (d_cnt - mahi)) << endl;
	return 0;
}



Measured memory_bytes: 256
input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))

minus = 0
for v in map(lambda x: x[1] - x[0], zip(a, b)):
    if v < 0:
        minus += v
    else:
        minus += v // 2

print("Yes" if minus >= 0 else "No")


Measured memory_bytes: 4596
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;
    ld a[100];
int main()
{
    ll n;
    cin >> n;
    for (int i = 1; i <= n; i ++)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = 1; i < n; i ++)
    {
        a[i + 1] = (a[i] + a[i + 1]) / 2;
//      cout << a[i] << ' ';
    }
    cout << a[n];
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    int a,b,c,d,e,k;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&k);
    if(b-a>k||c-a>k||d-a>k||e-a>k||c-b>k||d-b>k||e-b>k||d-c>k||e-c>k||e-d>k){printf(":(");}
    else{printf("Yay!");}
}

Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split(" ")))
q = int(input())
m = list(map(int, input().split(" ")))

F = "{:0" + str(n) + "b}"
variations = set()
for i in range(2 ** n):
    b = F.format(i)
    s = 0
    for j, bj in enumerate(b):
        if bj == "1":
            s += A[j]
    variations.add(s)

for query in m:
    if query in variations:
        print("yes")
    else:
        print("no")


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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	int a[5][5];
	rep(i, 0, 3){
		rep(j, 0, 3){
			cin >> a[i][j];
		}
	}
	int n; cin >> n;
	int b[20];
	rep(i, 0, n) cin >> b[i];
	rep(i, 0, n){
		rep(j, 0, 3){
			rep(k, 0, 3){
				if(b[i]==a[j][k]){
					a[j][k] = -1;
				}
			}
		}
	}
	string ans = "No";
	if(a[0][0]==-1 && a[0][1]==-1 && a[0][2]==-1) ans = "Yes";
	if(a[1][0]==-1 && a[1][1]==-1 && a[1][2]==-1) ans = "Yes";
	if(a[2][0]==-1 && a[2][1]==-1 && a[2][2]==-1) ans = "Yes";
	if(a[0][0]==-1 && a[1][0]==-1 && a[2][0]==-1) ans = "Yes";
	if(a[0][1]==-1 && a[1][1]==-1 && a[2][1]==-1) ans = "Yes";
	if(a[0][2]==-1 && a[1][2]==-1 && a[2][2]==-1) ans = "Yes";
	if(a[0][0]==-1 && a[1][1]==-1 && a[2][2]==-1) ans = "Yes";
	if(a[0][2]==-1 && a[1][1]==-1 && a[2][0]==-1) ans = "Yes";
	cout << ans << endl;
	return 0;
}

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

const int MOD=3,MAXN=100050;
char str[MAXN];
int as[2][MAXN];

int getSum(int idx,int l,int r) {
	return as[idx][r]-as[idx][l-1];
}
inline int sub(int a,int b) {
	return ((a-b)%MOD+MOD)%MOD;
}
int main() {
	for(int i=0;i<2;i++) {
		scanf("%s",str+1);

		int n=strlen(str+1);
		for(int j=1;j<=n;j++) as[i][j] = as[i][j-1] + (str[j]=='A');
	}

	int query;
	scanf("%d",&query);
	while(query--) {
		int l1,r1,l2,r2;
		scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
		
		if(sub(2*getSum(0,l1,r1),(r1-l1+1))==sub(2*getSum(1,l2,r2),(r2-l2+1))) puts("YES");
		else puts("NO");
	}
	
	return 0;
}

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

int main() {
  int N;
  int64_t K;
  cin >> N >> K;
  vector<int> next(N);
  for (int i = 0; i < N; i++){
    cin >> next[i];
  }
  set<int> candidates;
  vector<int> loop(N);
  int pre, post, base, made;
  loop[0] = 1;
  candidates.insert(1);
  for (int i = 1; i < N; i++){
    loop[i] = next[loop[i - 1] - 1];
    pre = candidates.size();
    candidates.insert(next[loop[i - 1] - 1]);
    post = candidates.size();
    if (pre == post){
      for (int j = 0; j < pre; j++){
        if (loop[j] == loop[i]){
          base = pre - j;
          made = j;
        }
      }
      break;
    }
  }
  if (K < made){
    cout << loop[K] << endl;
  }
  else{
    int remainder = (K - made) % base;
    cout << loop[remainder + made] << endl;
  }
}


Measured memory_bytes: 14016
(defconstant +inf+ (ash 1 32))

(defun rep-helper (args body &optional (top nil))
  (if (null args)
      body
      (let ((arg (first args)))
        (rep-helper
         (rest args)
         (append `(loop for ,(first arg) from ,(second arg) below ,(third arg)
                        do) (if top body (list body)))))))

(defmacro rep (args &body body)
  (rep-helper (reverse args) body t))

(defun solve ()
  (let* ((n (read))
         (m (read))
         (d (make-array (list n n) :initial-element +inf+))
         (e (make-array (list n n) :initial-element +inf+)))
    (rep ((i 0 n))
      (setf (aref d i i) 0
            (aref e i i) 0))

    (loop repeat m
          do (let ((a (1- (read)))
                   (b (1- (read)))
                   (c (read)))
               (setf (aref d a b) c (aref d b a) c
                     (aref e a b) c (aref e b a) c)))

    (rep ((k 0 n) (i 0 n) (j 0 n))
      (setf (aref d i j) (min (aref d i j) (+ (aref d i k) (aref d k j)))))

    (let ((a 0))
      (rep ((i 0 n) (j (1+ i) n))
        (when (and (not (= (aref e i j) +inf+))
                   (< (aref d i j) (aref e i j)))
          (incf a)))
      (princ a) (terpri))))

(solve)


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,a[200000];
vector<int> v;

main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    int k=n-1,f=(n+1)/2;
    rep(i,f) {
        v.pb(k)
        if(!k) {k=1;break;}
        if(k==1) {k=0;break;}
        k-=2;
    }
    f=n/2;
    rep(i,f) {v.pb(k)k+=2;}
    rep(i,n) {
        if (i+1==n) ct(a[v[i]])
        else cts(a[v[i]])
    }
}

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

  
int main() {
    string n;
    cin>>n;
    string t;
    cin>>t;
    int cnt=0;
    int N=n.length();
    for(int i=0;i<N;i++){
        if(n.at(i)==t.at(i)){
            cnt++;
            
    }else{
    }
    }

    if(cnt==N){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  for(int i = 0; i < N; i++) {
    cin >> d[i];
  }

  sort(d.begin(), d.end());
  
  int count = 1;
  
  for (int i = 1; i < N; i++) {
    if (d[i - 1] < d[i]) {
      count ++;
    }
  }    
  
  cout << count << endl;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
	int S;cin>>S;
	int a=S/100;int b=S%100;
	if(0<a&&a<=12){
		if(0<b&&b<=12){
			cout<<"AMBIGUOUS"<<endl;
		}else{
			cout<<"MMYY"<<endl;
		}
	}else{
		if(0<b&&b<=12){
			cout<<"YYMM"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
}

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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<string,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int modpow(ll x, ll n){
    int res = 1;
    while(n){
        if(n % 2) res = (ll)res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }

    return res;
}

int choose(ll n, ll x){
    ll y = 1, z = 1;
    for (int i = n - x + 1; i <= n; ++i) {
        z *= i;
        z %= MOD;
    }
    for (int i = 1; i <= x; ++i) {
        y *= i;
        y %= MOD;
    }

    int res = modpow(y, MOD-2) % MOD;
    return z * res % MOD;
}

int main(void){

    int s;
    cin >> s;

    ll ans = 0;
    for(int i = 1; i <= s / 3; ++i){
        int tmp = s - i * 3;
        //cout << i << " " << tmp << "\n";
        ans += choose(tmp+i-1, tmp);
        ans %= MOD;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3576
import java.util.*;
class Main{
  static int freq[] = new int[100010];
  static long mod = (long)(1e9)+7;
  public static long solve(int n){
    long ans = 1;
  	if(n%2==1){
    	if(freq[0]!=1) return 0;
      	for(int i = 2; i < n ; i+=2){
          	//System.out.println(freq[i]);
        	if(freq[i]!=2)return 0;
          	ans = (ans*2)%mod;
        }
    }
    else{
    	for(int i = 1; i < n ; i+=2){
          	//System.out.println(freq[i]);
        	if(freq[i]!=2)return 0;
          	ans = (ans*2)%mod;
        }
    }
    return ans;
  }
	public static void main(String [] args){
    	Scanner in = new Scanner(System.in);
      	int n = in.nextInt();
      	for(int i = 0; i< n ; i++){
        	freq[in.nextInt()]++;
        }
      	long ans = solve(n);
      	System.out.println(ans);
    }
  	
}

Measured memory_bytes: 48828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		String A,B;
		long n = Long.MAX_VALUE;

		for(int i = 1; i <= Math.sqrt(N); i++) {
			if(N % i == 0) {
				A = String.valueOf(i);
				B = String.valueOf(N / i);
				n = B.length();
			}
		}
		System.out.println(n);
		sc.close();
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 100005
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 9223372036854775807
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


signed main() 
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    int n,k;
    cin>>n>>k;
    int A[n];
    fn(i,n) cin>>A[i];

    int dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-A[j]>=0 && dp[i-A[j]]==0)
            {
                dp[i]=1;
                break;
            }
        }
    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}   

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+5; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,x,d=0,l,cnt=1;
	bool finish=false;
	cin>>n>>x;
	forn(i,n){
		cin>>l;
		d += l;
		if(d>x)finish=true;
		if(!finish)cnt++;
	}
	cout<<cnt<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""

Measured memory_bytes: 256
n,a,b = gets.split.map(&:to_i)
s = gets.chomp.split('')
fo = 0
tot = 0
s.each do |x|
  case x
    when "a"
    if tot < a+b
      puts :Yes
      tot += 1
    else
      puts :No
    end
   
    when "b"
    if (fo < b) && (tot < a + b)
      puts :Yes
      tot += 1
      fo += 1
    else
      puts :No
    end
    
    when "c"
    puts :No
  end
end

Measured memory_bytes: 9852
#!/usr/bin/env python
# coding: utf-8
#

def main(n, k, a):
    t_n = n
    t_k = k
    t_a = a
    counter = 0
    while t_n > 0:
        if counter == 0:
            t_n -= t_k
        else:
            t_n -= (t_k - 1)
        counter += 1
    print(counter)


if __name__ == '__main__':
    try:
        n, k = list(map(float,input().strip().split(' ')))
        a = list(map(int,input().strip().split(' ')))
        main(n,k,a)
    except EOFError:
        pass


Measured memory_bytes: 13880
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int dp[40000];
int a[1000+1],b[1000+1]; 
int main(){
	fastio;
	int n,h;
	cin>>h>>n;
	rb(i,1,n){
		cin>>a[i]>>b[i];
	}
	memset(dp,0x3f,sizeof(dp));
	dp[h]=0;
	int res=INF;
	rb(i,1,n){
		rl(j,h,0){
			dp[max(j-a[i],0)]=min(dp[max(j-a[i],0)],dp[j]+b[i]);
		}
		res=min(res,dp[0]);
	}cout<<res;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  string s;
  ll n, k;
  cin >> n >> k;
  cin >> s;
  s[k-1] = s[k-1]+32;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define mod 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  ll n,k; cin>>n>>k;
  vl a(n+1,0);
  rep(i,k){
    ll x; cin>>x;
    rep(i,x){
      ll y; cin>>y;
      a[y]=1;
    }
  }
  ll ans=0;
  haha(i,1,n+1){
    if(a[i]==0) ans++;
  }
  cout<<ans;
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

Measured memory_bytes: 3636