akhauriyash/Code-Regression huggingface dataset:
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

using ll = long long;
using ld = long double;
struct line{
    ll m, c;
    line(ll slope, ll inter) : m(slope), c(inter){}
    ll val(ll x) { return m*x + c;}
    ld inter(ll m1, ll c1){
        ld m2 = (ld)m;
        ld c2 = (ld) c;
        return (c2-c1)/(m1-m2);
    }
};

ll square (ll a){
    return a*a;
}

int main(){
    #ifndef ONLINE_JUDGE
        //freopen("C:\\Users\\ACER\\Desktop\\Codes\\input.txt", "r", stdin);
    #endif
    deque<line> s;
    int N;
    ll C;
    cin>>N>>C;
    vector<ll> h(N); for(auto &v : h) cin>>v;
    vector<ll> dp(N);
    dp[0] = 0;
    s.push_back({-2*h[0], square(h[0])});
    for(int i = 1; i<N; i++){
        //remove redundant
        while(s.size()>=2 && (s[0].val(h[i])>=s[1].val(h[i])))
            {
                s.pop_front();
            }
        dp[i] = square(h[i]) + C + s[0].val(h[i]);
        //insert if worth
        while(s.size()>=2){
            int nn = s.size();
            ld a = s[nn-1].inter(-2*h[i], dp[i] + square(h[i]));
            ld b = s[nn-2].inter(s[nn-1].m, s[nn-1].c);
            if(a<b) s.pop_back();
            else break;
        }
        s.push_back({-2*h[i], dp[i] + square(h[i])});
    }
    cout<<dp[N-1];
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> num(k, 0);
    // num[x] = kで割ってxあまる数が1以上N以下に何個あるか
    for (int i = 1; i <= n; i++) num[i%k]++;
    long long res = 0;
    for (int a = 0; a < k; a++) {
        int b = (k - a) % k;
        int c = (k - a) % k;
        if ((b + c) % k != 0) continue;
        res += num[a] * num[b] * num[c];
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
/* ===================================*/
/* Author :   Moshiur Rahman Mohim    */
/* Email  :   mtmohim74@gmail.com     */
/* Institute: HSTU                    */
/* ===================================*/

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>

#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using  namespace  std;

const int INF = 0x7f7f7f7f;

#define pi              acos(-1.0)
#define mod             1000000007
#define MAX             10000
#define FOR(i, b, n)    for(LL i=b; i<=n; i++)
#define FORR(i, n, b)   for(LL i=n; i>=b; i--)
// Library.
#define mem(a,b)        memset(a,b,sizeof(a))
#define Sort(x)         sort(x.begin(),x.end())
#define Reverse(x)      reverse(x.begin(),x.end())
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a * (b / gcd(a,b)))
#define sq(x)           (x)*(x)
// File.
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
// i/o.
#define sf              scanf
#define pf              printf
#define pr1(x)          cout<<x<<"\n"
#define pr2(x,y)        cout<<x<<" "<<y<<"\n"
#define pr3(x,y,z)      cout<<x<<" "<<y<<" "<<z<<"\n"
// Test Case.
#define TEST(i,t)       LL i,t;scanf("%lld",&t);for(i=1;i<=t;i++)

typedef unsigned int            U;
typedef long int                L;
typedef unsigned long int       LU;
typedef long long int           LL;
typedef unsigned long long int  LLU;
typedef float                   F;
typedef double                  LF;
typedef char                    C;

//STL
typedef vector<LL>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<LL,LL>pll;
typedef pair<LF,LF>pdd;
typedef vector<pii> vpii;

/*.......Global Function.......*/
// Compute b^p%m
int BigMod(LL B,LL P,LL M)
{
    LL R=1;
    while(P>0)
    {
        if(P%2==1)
            R=(R*B)%M;
        P/=2;
        B=(B*B)%M;
    }
    return (int)R;
}
//Ugly Numbers
LL maxDivide(LL a,LL b)
{
    while(a%b==0)
        a=a/b;
    return a;
}
LL isUgly(LL no)
{
    no=maxDivide(no,2);
    no=maxDivide(no,3);
    no=maxDivide(no,5);
    return (no==1)?1:0;
}
//XOR of 2 Numbers
LL myXOR(LL x,LL y)
{
    LL res=0;
    FORR(i,31,0)
    {
        bool b1=x&(1<<i);
        bool b2=y&(1<<i);
        bool xoredBit=(b1&b2)?0:(b1|b2);
        res<<=1;
        res|=xoredBit;
    }
    return res;
}
/*............End............*/
/*.......Global Declaration.......*/
C st[1002];
int main()
{
    //READ("input.txt");
    //WRITE("output.txt");
    cin>>st;
    LL x=0;
    if(count(st,st+strlen(st),'W')!=0)
        x+=1;
    if(count(st,st+strlen(st),'E')!=0)
        x+=1;
    if(x==1)
    {
        pf("No\n");
        return 0;
    }
    else
        x=0;
    if(count(st,st+strlen(st),'S')!=0)
        x+=1;
    if(count(st,st+strlen(st),'N')!=0)
        x+=1;
    if(x==1)
    {
        pf("No\n");
        return 0;
    }
    else
        pf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool prime(int n){
    bool flag = true;
    for(int i=2; i*i<=n; i++){
        if(n%i==0){
            return false;
        }
    }
    return flag;
}
int main(){
    IOS;
    int n;
    cin >> n;
    for(int i=n; i<n+100; i++){
        if(prime(i)==true){
            cout << i <<endl;
            break;
        }
    }
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//main
//------------------------------------------
signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c>21){
        cout << "bust";
    }
    else{
        cout << "win";
    }
}

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

int main()
{
    int a , b , c , d , e , k , q , w ;
    cin >> a >> b >> c >> d >> e >> k ;
    q = max(a , b );
    w = min(a , b );
    q = max( q , c );
    q = max( q , d );
    q = max( q , e );
    w = min(w , c );
    w = min(w , d );
    w = min(w , e );
    if ( ( q - w ) <= k )
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
std::string s;

long cnt = 0;

int main(){
    scanf("%ld", &n);
    std::cin >> s;
    for(long i = 0; i < 1000; i++){
        long t[3];
        //printf("%ld\n", i);
        long ii = i;
        for(long j = 0; j < 3; j++){
            t[j] = ii%10;
            ii /= 10;
            //printf("%ld ",t[j]);
        }
        //printf("\n");
        long vis =  0;
        for(long j = 0; j < n; j++){
            if(s[j] == t[vis] +  '0'){
                vis++;
            }
            if(vis == 3){
                cnt++;
                break;
            }
        }
    }
    printf("%ld\n", cnt);
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B,K;
    scanf("%d%d%d",&A,&B,&K);
    int mini=A+K-1;
    int maxi=B-K+1;
    if(maxi<=mini) {
        while(A<=B) {
            cout<<A<<endl;
            A++;
        }
    }
    else {
        while(A<=mini) {
            cout<<A<<endl;
            A++;
        }
        while(maxi<=B) {
            cout<<maxi<<endl;
            maxi++;
        }
    }
}

Measured memory_bytes: 256
N,*as=$<.read.split.map(&:to_i)

count = 0
3.upto(9) do |i|
    %w(3 5 7).repeated_permutation(i) do |a|
        s = a.join
        next unless s.include?('3') && s.include?('5') && s.include?('7')
        next if N < s.to_i
        count += 1
    end
end

puts count 

Measured memory_bytes: 14352
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>



using namespace std;


int main() {
	int n;
	cin >> n;
	
	priority_queue<double, vector<double>,greater<double>> pq;

	for (int i = 0; i < n; i++) {
		double v;
		cin >> v;
		pq.push(v);
	}

	for (int i = 0; i < n - 1; i++) {
		double v1 = pq.top();
		pq.pop();
		double v2 = pq.top();
		pq.pop();
		pq.push((v1 + v2) / 2);
	}

	double ans = pq.top();

	printf("%0.6lf", ans);

}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int v[60];
int main(){
	int n;cin>>n;
	double A=0;
	rep(i,n){
		double B;cin>>B;
		A+=1./B;
	}
	printf("%.12lf\n",1./A);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int m,I,J,p[10000][100],s[10000],P;
pair<int,int> pos[101];

void destroy(int pI,int ppI,pair<int,int> *pos){
	p[pI][ppI]=0;
	for(int i=ppI+1;i<s[pI];i++){
		p[P][0]=p[pI][i];
		s[P]=1;
		pos[p[P][0]]=make_pair(P++,0);
		p[pI][i]=0;
	}
	s[pI]=ppI;
}

int main(){
	while(cin>>m&&m){
		rep(i,10000)fill(p[i],p[i]+100,0);
		fill(s,s+10000,0);
		rep(i,m){p[i][0]=i+1;s[i]=1;pos[i+1]=make_pair(i,0);}
		P=m;
		while(cin>>I>>J&&I){
			if(I==J)continue;
			int pI=pos[I].first,ppI=pos[I].second,pJ=pos[J].first,ppJ=pos[J].second;
			if(!J){
				if(ppI){
					destroy(pI,ppI,pos);
					p[P][0]=I;
					s[P]=1;
					pos[I]=make_pair(P++,0);
				}
			}
			else if(pI==pJ){
				if(ppI>ppJ)continue;
				else{
					int pppJ=P+ppJ-ppI-1;
					destroy(pI,ppI,pos);
					p[pppJ][1]=I;
					s[pppJ]++;
					pos[I]=make_pair(pppJ,1);
				}
			}
			else{
				destroy(pI,ppI,pos);
				p[pJ][s[pJ]]=I;
				pos[I]=make_pair(pJ,s[pJ]++);
			}
			//cout<<I<<"->"<<J<<endl;
			//rep(i,m)cout<<i+1<<":"<<pos[i+1].first<<","<<pos[i+1].second<<(i<m-1?" ":"\n");
			//int sum=0;rep(i,P)sum+=s[i];cout<<sum<<endl;
			//rep(i,P){if(s[i])cout<<i<<":";rep(j,s[i]){cout<<p[i][j]<<(j<s[i]-1?" ":"");}if(s[i])cout<<endl;}cout<<endl;
		}
		sort(s,s+10000);
		rep(i,10000)if(s[i])cout<<s[i]<<(i<9999?"\n":"\nend\n");
	}
}

Measured memory_bytes: 0
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
k=int(input())
a=list(map(int,input().split()))
ml=mr=2
l=r=2
for i in range(k):
    ai=a[k-1-i]
    mr=(r//ai)*ai
    ml=(1+(l//ai))*ai if l%ai!=0 else l
    if ml>mr:
      print(-1)
      exit()
    if mr==0:
        print(-1)
        exit()
    elif ml==0:
        ml=mr
    l=ml
    r=mr+ai-1
print(l,r)

Measured memory_bytes: 91264
module piyo
      implicit none
      
      type rest
        character(10) :: s
        integer :: p,num
      end type
      
      contains
      subroutine sortS( r )
        implicit none
        type(rest),intent(inout) :: r(:)
        type(rest) :: buffer
        integer :: i,k,len
        
        len = size(r)
        
        do i = 1,len-1
          do k = i+1,len
            if( r(i)%s(:)>r(k)%s(:) )then
              buffer = r(i)
              r(i) = r(k)
              r(k) = buffer
            end if
          end do
        end do
      end subroutine
      
      function sortP( r ) result( res )
        implicit none
        type(rest) :: r(:)
        type(rest) :: buffer
        type(rest),allocatable :: res(:)
        integer :: i,k,len
        
        len = size(r)
        
        do i = 1,len-1
          do k = i+1,len
            if( r(i)%p<r(k)%p )then
              buffer = r(i)
              r(i) = r(k)
              r(k) = buffer
            end if
          end do
        end do
        res = r
      end
      end module piyo
      
      
      PROGRAM GuideBook
      use piyo
      IMPLICIT NONE
      integer :: n
      type(rest),allocatable :: restaurant(:)
      integer :: i,len,k
      character(10) :: buffer
      
      read*,n
      allocate( restaurant(n) )
      do i = 1,n
        read*,restaurant(i)%s,restaurant(i)%p
        restaurant(i)%num = i
      end do
      
      call sortS( restaurant )
      
      
      i = 1
      do while(.true.)
        len = 0
        do k = 1,n
          if( restaurant(k)%s(1:10)==restaurant(i)%s(1:10) )then
            len = len + 1
          end if
        end do
        restaurant(i:i+len-1) = sortP( restaurant(i:i+len-1) )
        i = i+len
        
        if( i>=n )then
          exit
        end if
      end do
      
      
      
   !   print *,n
   !   do i = 1,n
   !     print*,restaurant(i)
   !   end do
      
      do i = 1,n
        print*,restaurant(i)%num
      end do
      
      END PROGRAM

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

typedef struct {
	int value;
	char *str;
} CONV_TABLE;

CONV_TABLE table[] = {
{  18, "XVIII"},
{  13, "XIII"},
{  80, "LXXX"},
{   8, "VIII"},
{  17, "XVII"},
{  30, "XXX"},
{  12, "XII"},
{  14, "XIV"},
{   3, "III"},
{  70, "LXX"},
{  16, "XVI"},
{   7, "VII"},
{  19, "XIX"},
{   2, "II"},
{  11, "XI"},
{  40, "XL"},
{  90, "XC"},
{  60, "LX"},
{  20, "XX"},
{  15, "XV"},
{   9, "IX"},
{   6, "VI"},
{   4, "IV"},
{ 500, "D"},
{ 100, "C"},
{  10, "X"},
{1000, "M"},
{  50, "L"},
{   1, "I"},
{   5, "V"},
{  -1, ""},
};

int main(void)
{
	char str[101];
	char *p;
	int value;
	CONV_TABLE *ct;
	int prev;
	
	while (scanf("%s", str) != EOF){
		value = 0;
		p = str;
		prev = 10000;
		while (*p != '\0'){
			ct = table;
			while (ct->value != -1){
				if (strncmp(p, ct->str, strlen(ct->str)) == 0){
					if (prev < ct->value){
						value = value - prev * 2 + ct->value;
					}
					else {
						value += ct->value;
					}
					prev = ct->value;
					p += strlen(ct->str);
					break;
				}
				ct++;
			}
		}
		printf("%d\n", value);
	}
	
	return (0);
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL n,q;
  cin >> n >> q;
  LL nowidx=0;
  LL k;
  int qn;
  for(int i=0;i<q;i++){
    cin >> qn >> k;
    if(qn==0){
      cout << (nowidx+k-1)%n+1 << endl;
    }else{
      nowidx=(nowidx+k)%n;
    }
  }
  return 0;
}



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

int main()
{
    string s, t;
    cin >> s >> t;
    int n=s.length();
    int ans=0;

    rep(i,n){
        if (s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

const long N = 16777216;
char str[N][13];
long n;

int getInt(char ch){
	switch (ch)
	{
	case 'A': return 1;
	case 'T': return 2;
	case 'G': return 3;
	case 'C': return 4;
	}
	return 0;
}
long long getKey(char* tmp){
	long long sum = 0, p=1;
	for (int i = 0; i < strlen(tmp); ++i){
		sum += p*getInt(tmp[i]);
		p *= 5;
	}
	return sum;
}

int main(){
	scanf("%ld",&n);
	while (n--){
		char ch[13]; scanf("%s", ch);
		if ( strcmp(ch,"insert")==0){
			scanf("%s", ch);
			long long tmp = getKey(ch);
			strcpy(str[tmp], ch);
		}
		else if ( strcmp(ch, "find")==0){
			scanf("%s", ch);
			long long tmp = getKey(ch);
			if (strcmp(str[tmp],ch)==0) cout << "yes\n";
			else cout << "no\n";
		}
	}
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod> struct modulo {
	int w;
	operator int&() { return w; }
	operator int() const { return w; }
	
	modulo() {}
	modulo(int w, bool f = 0) { this->w = w; if (f) fix(); }
	void inline fix() { if (w >= mod || w < -mod) w %= mod; if (w < 0) w += mod; }
	
	inline modulo  operator -  () { w = -w + mod; return *this; }
	inline modulo  operator +  (const modulo &b) { modulo r = *this; return r += b; }
	inline modulo  operator -  (const modulo &b) { modulo r = *this; return r -= b; }
	inline modulo  operator *  (const modulo &b) { return (num) w * b.w % mod; }
	inline modulo  operator /  (const modulo &b) { return *this * inv(b); }
	inline modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	inline modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	inline modulo& operator *= (const modulo &b) { return *this = *this * b; }
	inline modulo& operator /= (const modulo &b) { return *this /= inv(b); }
	
	friend inline modulo inv(const modulo &w) {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return modulo(u, 1);
	}
	
	friend inline modulo pow(const modulo &w, int p) {
		if (!w)  return 0;
		modulo a = w, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = int(1e9) + 7;
typedef modulo<mod> rem;

const int nsz = 5e5;//, asz = 10;//, asz = 1 << 21;
int n, dm, a[nsz + 5], pre[nsz + 5], c0[nsz + 5];
rem dp[nsz + 5][2], ans;
vector<int> p[nsz + 5]; //////////////////////???!!!!!!!!!!!!!!!!!!!!!!!!
map<int, int> to;

void inline init() {
	to[0] = 0;
	cont (i, n) pre[i] = pre[i - 1] ^ a[i], to[pre[i]] = 0;
	foreach (it, to) it->second = dm++;
	c0[0] = 1;
	cont (i, n) pre[i] = to[pre[i]];
	cont (i, n) p[pre[i]].push_back(i);
	cont (i, n) {
		c0[i] = c0[i - 1] + (pre[i] == 0);
	}
}

int main() {
	scanf("%d", &n);
	cont (i, n) scanf("%d", &a[i]);
	init();
	
	if (pre[n] == 0) {
		cont (w, dm) {
			rem f0 = 1, f1 = 0;
			int p, pp = 0;
			loop (k, ::p[w].size()) {
				int p = ::p[w][k];
				f0 += f1 * rem(c0[p] - c0[pp]);
				f1 += f0;
				pp = p;
			}
			ans += f1;
		}
		ans += pow(rem(2), int(p[0].size()) - 1);
	} else {
		int w = pre[n];
		rem f0 = 1, f1 = 0;
		cont (i, n) {
			if (pre[i] == 0) f0 += f1;
			else if (pre[i] == w) f1 += f0;
		}
		ans = f0;
	}
	printf("%d\n", ans.w);
	return 0;
}

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

double a,b,c,n,d;

int t;

main (){
  int ans=0;
  cin>>t>>n;
  
  while(t--){
    
    cin>>a>>b;
    
   double  r=sqrt(a*a+b*b);
    if(r<=n) ans++;
  }
cout<<ans;
}

Measured memory_bytes: 3868
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k= sc.nextInt();
    int s = sc.nextInt();
    int cnt=0,z;
    for(int x=0;x<=k;x++){
      for(int y=0;y<=k;y++){
        z=s-(x+y);
        if(k>=z&&z>=0) cnt++;
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 23892
main :: IO ()
main = do
    line <- getLine
    let nums = map (\n -> read n :: Int) $ words line
    putStrLn . unwords $ map show $ qsort nums

qsort :: Ord a => [a] -> [a]
qsort []     = []
qsort (x:xs) = qsort [l | l <- xs, l < x] ++ [x] ++ qsort [r | r <- xs, x <= r]


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int n;
int a[3010];
ll dp[3010][3010][2];

ll f(int l, int r, bool First)
{
  if (r - l == 1)
    return (First ? a[l] : -a[l]);

  if (dp[l][r][First] != -1)
    return dp[l][r][First];

  if (First)
  {
    ll res = max(a[l] + f(l + 1, r, !First), a[r - 1] + f(l, r - 1, !First));
    return dp[l][r][First] = res;
  }
  else
  {
    ll res = min(-a[l] + f(l + 1, r, !First), -a[r - 1] + f(l, r - 1, !First));
    return dp[l][r][First] = res;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, 3010) rep(j, 3010) rep(k, 2) dp[i][j][k] = -1;
  cout << f(0, n, true) << endl;
  return 0;
}


Measured memory_bytes: 141952
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static void main(String[] argv) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");

        int w = Integer.parseInt(str[0]);
        int h = Integer.parseInt(str[1]);
        int n = Integer.parseInt(str[2]);

        int[][] map = new int[h][w];
        for(int i=0; i<h; i++) Arrays.fill(map[i], 0);

        for(int i=0; i<n; i++){
            str = br.readLine().split(" ");
            int x = Integer.parseInt(str[0]);
            int y = Integer.parseInt(str[1]);
            int a = Integer.parseInt(str[2]);
            switch (a){
                case 1:
                    map[h-1][0]++;
                    if(x==w) break;
                    map[h-1][x]--;
                    break;
                case 2:
                    if(x==w) break;
                    map[h-1][x]++;
                    break;
                case 3:
                    if(y==0) break;
                    map[y-1][0]++;
                    break;
                case 4:
                    map[h-1][0]++;
                    if(y==0) break;
                    map[y-1][0]--;
                    break;
            }
        }

        for(int i=0; i<h; i++){
            for(int j=1; j<w; j++){
                map[i][j] += map[i][j-1];
            }
        }

        for(int i=h-2; i>=0; i--){
            for(int j=0; j<w; j++){
                map[i][j] += map[i+1][j];
            }
        }

        int cnt = 0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(map[i][j] <= 0) cnt++;
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 21332
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	double l; cin>>l; double p=l/3;
	double ans=p*p*p;
	printf("%.8lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =  998244353;
int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
     signed main(){
  int n,m,k;
  cin>>n>>m;
  bitset<300> a[n];
  for(int i=0;i<n;i++)for(int j=0;j<m;j++){
      cin>>k;
      if(k)a[i].set(j);
      else a[i].reset(j);
  }
  int j0=0;
  for(int i=0;i<m;i++){
      for(int j=j0;j<n;j++){
          if(a[j][i]){
              swap(a[j],a[j0]);
              break;
          }
      }
      if(a[j0][i]){
          for(int j=j0+1;j<n;j++){
              if(a[j][i])a[j]^=a[j0];
          }
          j0++;
      }
  }

  cout<<(MOD+modpow(2,n,MOD)-modpow(2,n-j0,MOD))%MOD*modpow(2,m-1,MOD)%MOD<<endl;



     }


 


 






    





      

        


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

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

    for (int i=1; i<=n; i++) {
        int z = (i*108)/100;
        if (z == n) {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);

typedef std::pair<long, long> P;

long ans;

long n, m;
std::vector<long> a;
std::vector<P> op;//first:C_j second:B_j
std::vector<long> b;

int main(){
	scanf("%ld%ld", &n, &m);
	for(int i = 0; i < n; i++){
		long x;
		scanf("%ld", &x);
		a.push_back(x);
	}
	for(int i = 0; i < m; i++){
		long b, c;
		scanf("%ld%ld", &b, &c);
		op.push_back(P(c, b));
	}
	std::sort(a.begin(), a.end());
	std::sort(op.begin(), op.end());
	
	/*
	for(int i = 0; i < n; i++){
		printf("%ld ", a[i]);
	}
	printf("\n");
	for(int i = 0; i < m; i++){
		printf("(%ld %ld) ", op[i].first, op[i].second);
	}
	printf("\n"); 
	//*/
	
	long vis = m-1;
	for(int i = 0; i < n; i++){
		if(vis < 0){
			break;
		}
		b.push_back(op[vis].first);
		op[vis].second--;
		if(op[vis].second == 0){
			vis--;
		}
	}
	/*
	for(int i = 0; i < n; i++){
		printf("%ld ", a[i]);
	}
	printf("\n");
	for(int i = 0; i < n; i++){
		printf("%ld ", b[i]);
	}
	printf("\n");
	* 
	//*/
	for(int i = 0; i < n; i++){
		if(i < b.size()){
			ans += std::max(a[i], b[i]);
		}else{
			ans += a[i];
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 4464
import numpy as np

IN = input().split()

dp = np.zeros((4,3001))
dp[0][0] = 1

for i in range(3):
    for j in range(3001):
        dp[i+1][j] += dp[i][j]
    for j in range(3001):
        if(j - int(IN[i]) >= 0):
            dp[i+1][j] += dp[i+1][j - int(IN[i])]

print(int(dp[3][int(IN[3])]))

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

int main()
{
  int co=0,res=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++)
  {
    if(s[i]=='S')
    {
      if(co>res)
      {
          res=co;
      }
      co=0;
    }
    else
    {
        co++;
        if(co>res)
        {
            res=co;
        }
    }
  }
  cout<<res;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int aScore = 0;
		int bScore = 0;
		for(int i = 0; i < n; i++){
			String aCard = sc.next();
			String bCard = sc.next();
			int conp = aCard.compareTo(bCard);
			if(conp == 0){
				aScore += 1;
				bScore += 1;
			}else {
				if(conp > 0){
					aScore += 3;
				}else{
					bScore += 3;
				}
			}
		}
		System.out.println(aScore + " " + bScore);
	}
}



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

int main() {
  int n;
  string s;
  cin >> n >> s;
  rep(i, s.size()) {
    s[i] = (s[i]-'A'+n)%26 + 'A';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
unordered_map<int,int>freq1, freq2;

typedef pair<int,int>pii;

void init(){
	freq1.clear();
	freq2.clear();
}

int main() {
	// your code goes here
	int n,m, val;
	while(scanf("%d",&n)==1){
		init();
		for(int i=0;i<n;i++){
			scanf("%d",&val);
			freq1[val]++;
		}
		
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			scanf("%d",&val);
			freq2[val]++;
		}
		
		bool can = true;
		for(pii p : freq2){
			int val = p.first, cnt2 = p.second;
			int cnt1 = freq1[val];
			if(cnt1 < cnt2){
				can = false; break;
			}
		}
		
		printf("%s\n", can ? "YES" : "NO");
	}
	
	return 0;
}

Measured memory_bytes: 19848
#include <iostream>

int main() {
    int a, b, c, output;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    if (b != a && b != c) {
        output = 3;
        if(a==c){
            output = 2;
        }
    } else if (b == a && b == c) {
        output = 1;
    } else {
        output = 2;
    }
    std::cout << output << std::endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	getline(cin,s);
	for(auto&& e:s){
		if('a'<=e && e<='z') e-=32;
		else if('A'<=e && e<='Z') e+=32;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 + c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 998244353;
int N,M;
int a[MAXN],b[MAXN],c[MAXN],dp[MAXN][2];
int d[MAXN][4][4];
map<pii,int> zz;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
        if(c & 1) res = mul(res,t);
        t = mul(t,t);
        c >>= 1;
    }
    return res;
}
void Init() {
    read(N);read(M);
    for(int i = 1 ; i <= N ; ++i) memset(d[i],-1,sizeof(d[i]));
    for(int i = 1 ; i <= M ; ++i) {
        read(a[i]);read(b[i]);read(c[i]);
        zz[mp(a[i],b[i])] = c[i];
        if(abs(a[i] - b[i]) <= 2) {
            int s = a[i],t = b[i];
            if(s > t) swap(s,t);
            for(int k = s - 1 ; k <= t + 1 ; ++k) {
                if(k < 0 || k > N) continue;
                if(abs(a[i] - k) <= 1 && abs(b[i] - k) <= 1) {
                    d[k][2 - (k - a[i])][2 - (k - b[i])] = c[i];
                }
            }
        }
    }

}
void Solve() {
    int64 cnt = 1LL * N * N;
    if(N == 2) cnt = 0;
    else cnt -= (N - 3) * 5 + 9;
    cnt /= 2;
    for(int i = 1 ; i <= M ; ++i) {
        if(abs(b[i] - a[i]) <= 2) continue;
        if(zz.count(mp(b[i],a[i]))) {
            if((zz[mp(b[i],a[i])] + c[i]) & 1) {puts("0");return;}
            if(a[i] < b[i]) --cnt;
        }
        else --cnt;
    }
    int ans = fpow(2,cnt % (MOD - 1));
    if(zz.count(mp(1,1))) dp[1][zz[mp(1,1)]] = 1;
    else dp[1][0] = dp[1][1] = 1;
    for(int i = 2 ; i <= N ; ++i) {
        int t = 1;
        if(d[i][1][2] == -1 && d[i][2][1] == -1) t = mul(t,2);
        if(d[i][1][3] == -1 && d[i][3][1] == -1 && i != N) t = mul(t,2);
        for(int k = 0 ; k <= 1 ; ++k) {
            if(d[i][2][2] != -1 && d[i][2][2] != k) continue;
            if(d[i][1][3] != -1 && d[i][3][1] != -1 && (d[i][1][3] ^ d[i][3][1]) != k) continue;
            for(int h = 0 ; h <= 1 ; ++h) {
                if(!dp[i - 1][h]) continue;
                if(d[i][1][2] != -1 && d[i][2][1] != -1 && (d[i][2][1] ^ d[i][1][2]) != (k ^ h)) continue;
                dp[i][k] = inc(dp[i][k],mul(t,dp[i - 1][h]));
            }
        }
    }
    ans = mul(ans,inc(dp[N][0],dp[N][1]));
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Init();
    Solve();
    return 0;
}


Measured memory_bytes: 11520
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
int inf = 1000000007;
using namespace std;

int n;

int main()
{
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++)cin >> p[i];
	sort(p.begin(), p.end());
	cout << p[n / 2] - p[(n / 2) - 1] << endl;
	return 0;
}

Measured memory_bytes: 768
n = int(input())

points = [list(map(int, input().split(" "))) for _ in range(n)]
X = 0
Y = 1
ans = 10 ** 14
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        p = x1 - x2
        q = y1 - y2
        cost = n
        for point1 in points:  # そのpointからcost0で遷移できる先があるかどうか
            fromx, fromy = point1
            for point2 in points:
                tox, toy = point2
                if fromx - tox == p and fromy - toy == q:
                    cost -= 1
                    break
        if ans > cost:
            ans = cost
if n == 1:
    print(1)
else:
    print(ans)


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

int main(){

	int a1,a2,a3;

	cin >> a1 >> a2 >> a3;

	if(a1+a2+a3 >= 22){
      cout << "bust" << endl;
    }
  
    if(a1+a2+a3 < 22){
      cout << "win" << endl;
    }
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	int ans = 0;
	bool flag = true;
	while (flag) {
		for (auto&& vv : v) {
			if (vv % 2) {
				flag = false;
				break;
			}
			vv /= 2;
		}
		if (flag) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
-module('Main').
-export([main/1]).

check(A, B, C, N) ->
    case 10000 * A + 5000 * B + 1000 * C =:= N of
        true -> throw({A, B, C});
        false -> ok
    end.

solve() ->
    [N, Y] = input("~d~d"),
    {A, B, C} = try
        lists:foreach(fun (I) ->
            lists:foreach(fun (J) -> check(I, J, N - I - J, Y) end, lists:seq(0, N - I)) end,
            lists:seq(0, N)),
        {-1, -1, -1}
    catch
        throw:E -> E
    end,
    io:format("~B ~B ~B~n", [A, B, C]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, r;
	scanf("%d%d", &n, &r);
	if (n < 10) r += 100 * (10 - n);
	printf("%d\n", r);
}


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

int main(void){
    long long a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    
    long long diff = abs(b-a), speed = (v-w);
    
    if(diff <= speed*t) cout << "YES" << endl;
    else cout << "NO" << endl;
 
}


Measured memory_bytes: 3592
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=2e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

bool prime(ll x){
  if(x==2)return true;

for(ll i=2;i*i<=x;i++){
  if(x%i==0)return false;
}

  return true;
}

ll dp[6000];

int main()
{ 

IOS;

ll n,m;
cin>>n>>m;

vl allow(6000);

vl a(m),d(m);


FOR(i,m){
cin>>a[i];
ll b;cin>>b;
while(b--){
  ll x;cin>>x;
  x--;
  d[i]+=(1<<x);
}
}

//cout<<d[0]<<endl;


for(int i=1;i<(1<<n);i++){
  dp[i]=1e18;
}

allow[0]=1;


for(int i=0;i<m;i++){
  for(int j=0;j<1<<n;j++){
    if(allow[j]){
      chmin(dp[j|d[i]],dp[j]+a[i]);
      allow[j|d[i]]=1;
      
    }
  }
}

//cout<<allow[(1<<n)-1]<<endl;

if(dp[(1<<n)-1]==1e18)dp[(1<<n)-1]=-1;

cout<<dp[(1<<n)-1]<<endl;





return 0;
 
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{


    int n;
    cin>>n;
    int a[n][3];
    rep(i,0,n)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    
    int dp[n][3];
    dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
    
    rep(i,1,n)
    {
    	dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
    	dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
    	dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0])
		;
	}

cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 2560
// E - Roadwork

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

// クエリタイプ（ソートに影響するので順番に注意）
const int REMOVE = 1;
const int INSERT = 2;
const int JUDGE = 3;

using Type = int;
using Coordinate = int;
using Time = int;
using Event = pair<Type, Coordinate>;
using Query = pair<Time, Event>;

vector<Query> queries;
multiset<Coordinate> blocking;

int main() {
	int N, Q;
	cin >> N >> Q;

	int S, T, X;
	for (int i=0; i<N; i++) {
		cin >> S >> T >> X;
		Event e1 = make_pair(INSERT, X);
		Event e2 = make_pair(REMOVE, X);
		queries.push_back(make_pair(S - X, e1));
		queries.push_back(make_pair(T - X, e2));
	}

	int D;
	for (int i=0; i<Q; i++) {
		cin >> D;
		Event e = make_pair(JUDGE, -1);
		queries.push_back(make_pair(D, e));
	}

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

	for (auto q : queries) {
		Event e = q.second;
		Type t = e.first;
		if (t == INSERT) {
			blocking.insert(e.second);
		} else if (t == REMOVE) {
			blocking.erase(e.second);
		} else {
			if (blocking.empty()) {
				cout << -1 << endl;
			} else {
				cout << *blocking.begin() << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 18792
#include <iostream>
using namespace std;
int main (){
    int a,b,c;
    cin>>a>>b>>c;
    
    int x,y,z;
    x = a + b;
    y = b + c;
    z = a + c;
    
    x = (x<y)?x:y;
    x = (x<z)?x:z;
    
    cout << x << endl;

    return 0;
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")

import math
import collections


def divisors_kai(n):
    ret = 1
    for i in range(1, int(n ** 0.5) + 1):
        d, m = divmod(n, i)
        if m == 0:
            ret = i
            # ret.add(d)
    return ret


def solve(N: int):
    a = divisors_kai(N)
    b = N/a
    print(int(a + b - 2))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


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





vector<string>finall;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
    string str;
    cin>>str;
    sort(str.begin(),str.end());
    finall.push_back(str);

}



long long int counter=1;
long long int res=0;
sort(finall.begin(),finall.end());
//for(auto x: finall)cout<<x<< " ";
string str2="";
for(int i=0;i<n;i++){

    if(str2==finall[i])counter++;
    else {
            res+=((counter*(counter-1))/2);
              counter=1 ;}

    str2=finall[i];

}
res+=((counter*(counter-1))/2);
cout<<res<<endl;






}

Measured memory_bytes: 5748
input = raw_input
n, x, y = map(int, input().split(" "))


nums = [None] + [0 for _ in range(n-1)]
## A
#numa = x-1
#if numa >= 2:
#    for i in range(1, numa):
#        nums[i] = numa - i
#
## B
#numb = n-y+1
#if numb >= 2:
#    for i in range(1, numb):
#        nums[i] = numb - i
#
## C
#numc = y - x + 1
#if numc % 2 == 0:
#    nums[numc//2] += (1 * numc) // 2
#
#for i in range(1, (numc+1)//2):
#    nums[i] += (2 * numc) // 2
#
## AB

# X
numx = n - (y-x-1)
if numx >= 2:
    for i in range(1, numx):
        nums[i] = numx - i

x1 = x + 1
y2 = y - 1
# c1+c2
for i in range(x1, y2+1):
    for j in range(i+1, y2+1):
        d = min(j-i, y-j + 1 + i-x)
        #print(i, j, d)
        nums[d] += 1

# x1+c1+c2
for i in range(1, x+1):
    for j in range(x1, y2+1):
        d = min(j-i,x-i+1+y-j)
        #print(i, j, d)
        nums[d] += 1

# x2+c1+c2
for i in range(y, n+1):
    for j in range(x1, y2+1):
        #print(i, j, i-j, i-y+1+j-x)
        d = min(i-j, i-y+1+j-x)
        #print(i, j, d)
        nums[d] += 1

nums = nums[1:]
for num in nums:
    print(num)

Measured memory_bytes: 33180
#include<bits/stdc++.h>
typedef long long ll;
//#define mod 1000000007

using namespace std;

bool cal(ll a, ll b) {
    cout<<a<<" "<<b<<endl;
	if (a << 1 > b) 
		return 1; 
	b >>= 1; 
	if (a << 1 > b) 
		return (b - a) & 1; 
	if (b & 1) 
		return (b - a) & 1; 
	return cal(a, b >> 1); 
}
  
 
main() {
    int n;
    cin>>n;
    if(n%1000==0)cout<<0<<endl;
    else cout<<1000*((n/1000)+1)-n<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = scan.nextLong();
        long n = 0;

        for (long z = a - 1; z != 0; z--) {
            n = a * z;
            a = n;
        }
        System.out.println(n);
    }
}



Measured memory_bytes: 25780