akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long MD=1e9+7;
long long n,fact[1000001],ans;
long long qpow(long long b,long long exp) {
    long long ret=1;
    while (exp!=0) {
        if (exp%2==1) {ret*=b; ret%=MD;}
        b*=b; b%=MD;
        exp/=2;
    }
    return ret;
}
long long xcy(int x,int y) {
    if (y==0 or y==x) return 1;
    long long nom=fact[x];
    long long de1=qpow(fact[x-y],MD-2),de2=qpow(fact[y],MD-2);
    return (((nom*de1)%MD)*de2)%MD;
}
int main() {
    cin>>n;
    fact[0]=1;
    for (int i=1; i<=n; i++) {fact[i]=fact[i-1]*i; fact[i]%=MD;}
    for (int i=2; i<=n; i++) {
        long long ch=xcy(n,i);
        long long arr=((((qpow(2,i)-2)+MD)%MD))%MD;
        long long oth=qpow(8,n-i);
        ans+=((((ch*arr)%MD)*oth)%MD); ans%=MD;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 11384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c[200001],d,n,m,x,y,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<int,int> > VP;


int main(){
    cin>>n>>k;
    VI v;
    rep(i,n){
        cin>>tmp;
        c[tmp]++;
    }
    rep(i,n+1){
        if(c[i]){
            sum++;
            v.pb(c[i]);
        }
    }
    sort(all(v));
    sum-=k;
    x=0;
    while(sum>0){
        ans+=v[itr];
        sum--;
        itr++;
    }
    p(ans);
    return 0;
}


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

int main(void) {
  int a, b, c, d;
  bool flag = false;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) {
    flag = true;
  } else if (abs(a - b) <= d && abs(b - c) <= d) {
    flag = true;
  }
  if (flag) {
    cout << "Yes" << endl;

  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int i,n,a;
  string asi[100];
  while(1){
    cin>>n;
    if(n==0) break;
    else {
      for(i=0;i<n;i++){
	cin>>asi[i];
      }
      a=0;
      for(i=0;i<n-1;i++){

	  if(asi[i]=="lu"){
	    if(asi[i+1]=="ru"){
	      a++;
	    
	    }
	  }
	  if(asi[i]=="ru"){
	    if(asi[i+1]=="lu"){
	      a++;
	     
	    }
	  }
	
	
	  if(asi[i]=="ld"){
	    if(asi[i+1]=="rd"){
	      a++;
	    }
	  }
	  if(asi[i]=="rd"){
	    if(asi[i+1]=="ld"){
	      a++;
	    }
	  }
	
      }
      cout<<a<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a[100],b[100],i,temp=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(i=0;i<=n;i++){
        if(a[i]==b[i])
            temp++;
        else
            temp=0;
        if(temp==3)
        break;
    }
    if(temp<3)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3612
<?php
# A - Fifty-fifty

$array = str_split((fgets(STDIN)));
if (($array[0] == $array[1] && $array[2] == $array[3]) && ($array[0] != $array[2])) {
    echo 'Yes' . PHP_EOL;
    exit;
}

if (($array[0] == $array[2] && $array[1] == $array[3]) && ($array[1] != $array[2])) {
    echo 'Yes' . PHP_EOL;
    exit;
}

if (($array[0] == $array[3] && $array[1] == $array[2]) && ($array[0] != $array[1])) {
    echo 'Yes' . PHP_EOL;
    exit;
}

echo 'No' . PHP_EOL;


Measured memory_bytes: 4604
#include<iostream>
#include<limits>

using namespace std;

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

	int c[N], t[N];
	for(int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
	}

	int minCost = numeric_limits<int>::max();
	for (int i = 0; i < N; i++) {
		if(t[i] <= T && c[i] < minCost) {
			minCost = c[i];
		}
	}

	if(minCost == numeric_limits<int>::max()) {
		cout << "TLE" << endl;
	}
	else {
		cout << minCost << endl;
	}

	return 0;
}


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

long long memo[51];

int main(){
	memo[1]=1;
	for(int i=2;i<51;i++)memo[i]=memo[i-1]*2;
	for(int i=1;i<51;i++)memo[i]+=memo[i-1];

	int L,N;	cin>>L>>N;
	string snake;	cin>>snake;

	long long cnt=0;
	for(int i=0; i+1<L; i++){
		if(snake[i]=='o'&&snake[i+1]=='o')cnt++;
	}

	cout<<L+3*cnt*memo[N]<<endl;
	return 0;
}



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

using namespace std;
//typedef long long ll;
typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


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

    ll ans = k;
    rep(i, n - 1) {
        ans *= (k - 1);
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,g[200001][65]; 
signed main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&g[i][0]);
	for(int l=1;l<=64;l++)
		for(int i=1;i<=n;i++)
			g[i][l]=g[g[i][l-1]][l-1];
	int now=1,cnt=0;
	while(k)
	{
		if(k&1)
			now=g[now][cnt];
		cnt++;
		k/=2;
	}
	cout<<now;
	return 0;
}

Measured memory_bytes: 105252
x,y = map(int,input().split())

l = [1,3,5,7,8,10,12]
k = [4,6,9,11]

#print(l.count(3))

a1 = l.count(x)
a2 = l.count(y)

b1 = k.count(x)
b2 = k.count(y)

if x == 2 or y == 2:
	print('No')
elif a1 == a2:
	print('Yes')
elif b1 == b2:
	print('Yes')
else:
	print('No')
	
	


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int H, W;
int CX, CY, GX, GY;
vector<vector<char>> S;
vector<vi> G;

vector<pair<int, int>> changed;

void dfs(int x, int y) {
    S[x][y] = 'X';

    vector<vi> pattern = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    rep(i, 4) {
        int nx = x + pattern[i][0];
        int ny = y + pattern[i][1];

        if (nx >= 0 && nx < H && ny >= 0 && ny < W && S[nx][ny] == '.') {
            G[nx][ny] = G[x][y];
            dfs(nx, ny);
        }
    }

    for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
            int nx = x + i;
            int ny = y + j;
            if (nx >= 0 && nx < H && ny >= 0 && ny < W && S[nx][ny] != '#') {
                if (G[nx][ny] > G[x][y] + 1) {
                    G[nx][ny] = min(G[nx][ny], G[x][y] + 1);
                    changed.push_back(make_pair(nx, ny));
                }
            }
        }
    }

    return;
}

int main() {
    cin >> H >> W;
    cin >> CX >> CY >> GX >> GY;
    CX--; CY--; GX--; GY--;
    S.resize(H, vc(W)); rep(i, H) { rep(j, W) cin >> S[i][j]; }
    G.resize(H, vi(W, INF - 100));
    G[CX][CY] = 0;

    dfs(CX, CY);
    while (changed.size() != 0) {
        for (int i = 0; i < changed.size(); i++) {
            int x = changed[i].first;
            int y = changed[i].second;
            if (S[x][y] == 'X') continue;
            dfs(x, y);
        }
        changed = {};
    }

    if (S[GX][GY] == 'X') {
        cout << G[GX][GY] << endl;
    } else {
        cout << -1 << endl;
    }

    // rep(i, H) {
    //     rep(j, W) {
    //         cout << S[i][j];
    //     }
    //     cout << endl;
    // }

    // rep(i, H) {
    //     rep(j, W) {
    //         cout << G[i][j] << " ";
    //     }
    //     cout << endl;
    // }

}


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

ll X;

ll gcd(ll a, ll b)
{
	if(!b) return a;
	else return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
	return a*gcd(a,b)/b;
}

int main()
{
	cin >> X;
	cout << lcm(X,360)/X << '\n';
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
int top=0,S[101];//topは要素を入れないで空白を入れておく,S[]はスタックで数字格納S[0]は何も入っていない
int isEmpty(void);//topが0かどうか確かめスタックが空かどうか確かめる
int isFull(void);//スタックが満杯かどうかを確かめる
void push(int);//スタックの先頭に要素xを追加する
int pop(void);//スタックのトップから要素を取り出す関数
int main(){//last in first out
  int x,i,a[2],score=0;
  char s[100];//式に

  while( scanf("%s", s) != EOF ){
	if ( s[0] == '+' ){
	  a[0]=pop();
	  a[1]=pop();
	  score=a[1]+a[0];
	  push(score);
	}else if ( s[0] == '-' ){
	  a[0]=pop();
	  a[1]=pop();
	  score=a[1]-a[0];
	  push(score);
	} else if ( s[0] == '*' ){
	  a[0]=pop();
	  a[1]=pop();
	  score=a[0]*a[1];
	  push(score);
	} else {
	  x = atoi(s);
	  push(x);
	}
  }
  printf("%d",S[1]);
  printf("\n");
  return 0;
}
int isEmpty(void){//topが0かどうか確かめスタックが空かどうか確かめる
  if(top==0)
	return 1;//空
  else return 0;
}

int isFull(void){//スタックが満杯かどうかを確かめる
  int MAX=101;
  if( top >=MAX-1)//満杯
	return 1;
  else return 0;//満杯じゃない
}

void push(int x){//スタックの先頭に要素xを追加する
  if (isFull()==0){
	top++;
	S[top] = x;
  }else printf("overflow!");
}
int pop(void){
  if (isEmpty()==1){
	printf("empty!");
	return 0;
  }
  top--;//頂点の要素を削除
  return S[top+1];
}



Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef int SegT;
const int defvalue=0;
class SegTree{
	private:
		vector<SegT>val;
		int n;
		SegT combine(SegT a,SegT b){return a+b;}
	public:
		SegTree(int size){
			n=1;
			while(n<size)n<<=1;
			val=vector<SegT>(2*n,defvalue);
		}
		SegTree(const vector<SegT> &in){
			n=1;
			while(n<in.size())n<<=1;
			val=vector<SegT>(2*n,defvalue);
			for(int i=n-1+in.size()-1;i>=0;i--){
				if(n-1<=i)val[i]=in[i-(n-1)];
				else val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		void update(int i,SegT a){
			i+=n-1;
			val[i]+=a;
			while(i>0){
				i=(i-1)/2;
				val[i]=combine(val[i*2+1],val[i*2+2]);
			}
		}
		SegT query(int a,int b,int k=0,int l=0,int r=-1){//[a,b)
			if(r==-1)r=n;
			if(r<=a||b<=l)return defvalue;
			if(a<=l&&r<=b)return val[k];
			else return combine(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
		}
		void tmp(){
			rep(i,val.size())cout<<" "<<val[i];cout<<endl;
		}
};

int main(){
	int n,q;
	cin>>n>>q;
	SegTree in(n);
	while(q--){
		int a,b,c;
		cin>>a>>b>>c;
		if(a==0)in.update(b-1,c);
		else cout<<in.query(b-1,c)<<endl;;
	}
}

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

using namespace std;
using p = pair<long long, int>;
#define INF 100000000

int main(){
    int n;
	cin >> n;
	vector<int> p(n),q(n);
	
	rep(i,n)  cin >> p[i];
	rep(i,n)  cin >> q[i];
	
	vector<int> order(n);
	rep(i,n) order[i] = i+1;
	int a = 0;
	int b = 0;
	int count = 0;
	do{
		count++;
		int count_a = 0;
		int count_b = 0;
		
		for(int i = 0; i < n; i++){
			if(p[i] == order[i]) count_a++;
			if(q[i] == order[i]) count_b++;
		}
		
		if(count_a == n) a = count;
		if(count_b == n) b = count;
		
	} while(next_permutation(order.begin(),order.end()));
	cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

int n;
int main()
{
	std::cin >> n;
	int m = 0, sum = 0;
	for (int i = 0; i < n; ++i) {
		int l;
		std::cin >> l;
		m = std::max(m, l);
		sum += l;
	}

	if (sum - m > m)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	return 0;
}


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

using namespace std;

int main(){
	long long int x,p;
	cin >> x;
	
	p = x/11 * 2;
	
	if(x % 11 == 1)
		p++;
	else if(x % 11 > 1 && x % 11 < 7){
		p++;
	}
	else if (x % 11 == 0){
	}
	else
		p += 2;
		
	cout << p << endl;
	
	return 0;
}

Measured memory_bytes: 256
s=input()
a=-1
at=-1
b=-1
bt=-1
for i in range(len(s)):
    if a==s[i]:
        print(at+1,i+1)
        quit()
    if b==s[i]:
        print(bt+1,i+1)
        quit()
    a=b
    at=bt
    b=s[i]
    bt=i
print(-1,-1)


Measured memory_bytes: 39664
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC109();
}

void ABC109(){
    int i,j,cou=0,n,ans=1;
    cin>>n;
    vector<string> str ;
    string s;
    char c;
    for(i=0;i<n;i++){
        cin>>s;
        if(i>=1&&c==s[0]){
            cou++;
        }
        c=s[s.length()-1];
        if(count(str.begin(),str.end(),s)>=1){
            ans=0;
            break;
        }
        str.push_back(s);
    }
    cerr<<cou<<endl;
    if(cou!=n-1)ans=0;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}

int main() {
    int N; cin >> N;
    vector<ll> C(N);
    REP(i,N) cin >> C[i];
    vector<ll> vec(200005,-1);
    vector<ll> dp(N,0);
    dp[0] = 1;
    vec[C[0]] = 0;
    FOR(i,1,N) {
        if(vec[C[i]]==i-1 || vec[C[i]]==-1) {
            dp[i] = dp[i-1];
            vec[C[i]] = i;
        }
        else {
            dp[i] = add(dp[i-1],dp[vec[C[i]]]);
            vec[C[i]] = i;
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include <iomanip>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/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;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int N,K;
  cin>>N>>K;
  if(K==1) cout<<0;
  else cout<<N-K;
return 0;}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    if(x > y){ swap(a, b); swap(x, y);}
    cout << min({a*x+b*y, b*(y-x)+2*c*x, 2*c*y}) << "\n";
    return 0;
}

Measured memory_bytes: 256
A=list(map(int,input().split()))
X=list(map(int,input().split()))
Y=list(map(int,input().split()))

x=max(X)
y=min(Y)

if x<y and A[2]<A[3] and A[2]<y and x<A[3]:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
n=int(input())
a=[0]*n
xy=[[] for _ in range(n)]
for i in range(n):
    aa = int(input())
    a[i]=aa
    for j in range(aa):
        xx,yy = map(int, input().split())
        xy[i].append([xx-1,yy])
ans=0
for i in range(2**n):
    str_bin = str(bin(i))[2:].zfill(n)
    f=True
    for j in range(n):
        if str_bin[j]=="1":
            for xxyy in xy[j]:
                if str_bin[ xxyy[0] ]!=str(xxyy[1]):
                    f=False
    if f:
        ans = max(ans,sum(int(i) for i in str_bin))
print(ans)        

Measured memory_bytes: 43612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
    char str[4]={};

    scanf("%s\n",str);
    
    if(strncmp(str,"SUN",3)==0){
        printf("7");
    }
    else if(strncmp(str,"MON",3)==0){
            printf("6");
    }
    else if(strncmp(str,"TUE",3)==0){
            printf("5");
    }
    else if(strncmp(str,"WED",3)==0){
            printf("4");
    }
    else if(strncmp(str,"THU",3)==0){
            printf("3");
    }
    else if(strncmp(str,"FRI",3)==0){
            printf("2");
    }
    else if(strncmp(str,"SAT",3)==0){
            printf("1");
    }
    
    return 0;
}

Measured memory_bytes: 128
m,d = map(int,input().split())
cnt = 0
if d <= 19:
    print(0)
    exit()
for i in range(1,m+1):
    for j in range(20,d+1):
        if (j%10)*(j//10) == i and j%10 != 1:
            #print(i,j)
            cnt += 1
print(cnt)

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

using namespace std;

typedef pair<int,int> p;

int main(){

  int n, t;
  int c, ti;
  //tipo de dato, vector de ese tipo de dato, comparador
  priority_queue<p,vector<p>,greater<p> > q;
  cin >> n >> t;

  for(int i = 0; i < n; i++){
    cin >> c >> ti;
    if(ti <= t){
      q.push(make_pair(c,ti));
    }
  }
 if(q.empty()){
   cout<< "TLE\n";
 }else cout << q.top().first << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a=0,b=0;
string s,w="CODEFESTIVAL2016";

int main(){
	cin >> s;
	REP(i,0,s.size()) if(s[i]!=w[i]) a++;
	cout << a << endl;
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int sum=0;
    for(int i=0;i<n-1;i++)sum+=arr[i];
    if(sum>arr[n-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

signed main(void)
{
	long long n, ans, maxi, max_e, max_o, sec_o, sec_e;
	cin >> n;
	map<long long, long long> odd;
	map<long long, long long> even;
	rep(i, n / 2)
	{
		long long e, o;
		cin >> e >> o;
		even[e]++;
		odd[o]++;
	}
	sec_o = sec_e = max_o = max_e = 0;
	maxi = 0;
	for(auto e : even)
	{
		auto k = e.first;
		auto v = e.second;
		if (maxi <= v)
		{
			maxi = v;
			sec_e = max_e;
			max_e = k;
		}
		else if (even[sec_e] <= v)
			sec_e = k;
	}
	maxi = 0;
	for(auto o : odd)
	{
		auto k = o.first;
		auto v = o.second;
		if (maxi <= v)
		{
			maxi = v;
			sec_o = max_o;
			max_o = k;
		}
		else if (odd[sec_o] <= v)
			sec_o = k;
	}
	if (max_e == max_o)
		ans = min(n - even[sec_e] - odd[max_o],\
				n - even[max_e] - odd[sec_o]);
	else
		ans = n - even[max_e] - odd[max_o];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = a + b;
			String d = String.valueOf(c);
			int len = d.length();
			System.out.println(len);
		}
	}
} 

Measured memory_bytes: 20592
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define int int64_t
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<ii>
#define vvii vector<vii>
#define F first
#define S second
#define pb push_back
#define FOR(i,l,r) for(int i=l; i<r; ++i)
#define ROF(i,r,l) for(int i=r; i>l; --i)
#define all(x) x.begin(), x.end()
#define amin(a,b) a = min(a,b)
#define amax(a,b) a = max(a,b)
#define test int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long ll;

const int MAXN = 2e5+73;
const int MAXINT = 2147483098;
const int MAXLL = 9223372036854775258LL;
const int MOD = 998244353;




void solve(){
    int n;
    cin >> n;
    vi a(n);
    FOR(i,0,n) cin >> a[i];
    int ans = 0;
    FOR(i,1,n){
    int temp=0;
    if (a[i-1]-a[i]>0) temp = a[i-1]-a[i];
    ans+=temp;
    a[i]+=temp;
    }
    cout << ans;

}





int32_t main()
{
    fast;
    //test;
    solve();
    //freopen("kotlin.in", "r", stdin);
    //freopen("kotlin.out","w", stdout);



    return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int ans=0;
  int x=0;
  rep(i,s.length()){
    if(s[i]=='I') x++;
    if(s[i]=='D') x--;
    ans=max(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
int N;
int sib[100001];
int deg[100001];
int par[100001];


int Depth(int);
int Height(int);

int main() {
  int j,i;
  
  scanf("%d", &N);

  for(i = 0; i < N; ++i) {
    par[i] = -1;
    sib[i] = -1;
    deg[i] = 0;
  }

  for(i = 0; i < N; i++) {
    int id, l, r;

    scanf("%d %d %d", &id, &l, &r);

    if(l != -1) {
      par[l] = id;
      sib[l] = r;
      deg[id]++;
    }

    if(r != -1) {
      par[r] = id;
      sib[r] = l;
      deg[id]++;
    }
  }
  
  for(i = 0; i < N; ++i) {
    int depth = Depth(i);

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
           i, par[i], sib[i], deg[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(deg[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}

int Depth(int i) {
  if(par[i] == -1) return 0;
  return Depth(par[i]) + 1;
}

int Height(int i) {
  int j, h=0;
  
  for(j = 0; j < N; ++j) {
    if(par[j] == i) {
      int tmp = Height(j) + 1;
      if(tmp > h) h = tmp;
    }
  }
  return h;
}





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

#define mod 1000000007
#define pi 2 * acos(0.0)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rloop(i, a, b) for (int i = a; i >= b; i--)
void fun()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

/* DON'T LIMIT YOUR CHALLENGES, CHALLENGE YOUR LIMITS */
void solve()
{
    int h, w;
    cin >> h >> w;

    vector<vector<char>> v(h, vector<char>(w));
    for (auto &i : v)
        for (auto &j : i)
            cin >> j;
    vector<vector<int>> dp(h + 1, vector<int>(w + 1, 0));
    for (int i = 0; i < w; i++)
    {
        if (v[0][i] == '#')
            break;
        dp[1][i + 1] = 1;
    }

    for (int i = 0; i < h; i++)
    {
        if (v[i][0] == '#')
            break;
        dp[i + 1][1] = 1;
    }

    for (int i = 2; i <= h; i++)
    {
        for (int j = 2; j <= w; j++)
        {
            if (v[i - 1][j - 1] == '#')
                continue;
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }

    // for (auto i : dp)
    // {
    //     for (auto j : i)
    //         cout << j << " ";
    //     cout << "\n";
    // }

    cout << dp[h][w];
}

signed main()
{
    fun();
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 12108
#include <bits/stdc++.h>
using namespace std;
 
#define fst() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
#define maxn ((int)1e7)
typedef long long ll;
typedef long double ld;
const int m=132000;

int main()
{ 
  fst();
  int h,w,i,j,f;
  string s[55];
  cin>>h>>w;
  f(i,0,h)
  {
  	cin>>s[i];
  }
  f(i,0,h)
  {
  	f(j,0,w)
  	{
  		if(s[i][j]=='#')
  		{
  			f=0;
  			if(i>0 && s[i-1][j]=='#') f=1;
  			if(i<h-1 && s[i+1][j]=='#') f=1;
  			if(j>0 && s[i][j-1]=='#') f=1;
  			if(j<w-1 && s[i][j+1]=='#') f=1;
  			if(!f)
  			{
  				cout<<"No"<<endl;
  				return 0;
  			}
  		}
  	}
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int A,B,C=9999,D=0;
  cin >> A;
  for(int i=1;i<101;i++){
    for(int j=2;j<10;j++){
      if(pow(i,j)>A)break;
      B=pow(i,j);
      C=min(A-B,C);
    }
  }
  cout << A-C << endl;
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))
lst=[0 for i in range(N)]
count=0
flag=0
while H!=lst:
    for i in range(N):
        if H[i]>lst[i]:
            lst[i]+=1
            flag=1
        else:
            if flag:
                flag=0
                count+=1
    if flag:
        count+=1
        flag=0
print(count)


Measured memory_bytes: 38896
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<vector>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main()
{
    int a;
    int b;
    cin >> a >>  b;
    vector<int> v(3);
    v[0] = a + a -1;
    v[1] = a + b;
    v[2] = b + b -1;
    cout << max({v[0],v[1],v[2]});
    

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define ll long long 
#define maxn 233333
inline ll read()
{
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    } 
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
string s;
ll len;
int a[maxn];
bool vis[maxn];
inline void debug()
{
	cout<<endl;
	for(rg int i=0;i<len;++i) cout<<a[i]<<" ";
	cout<<endl;
}
int main()
{
	cin>>s;
	len=s.length();
	for(rg int i=0;i<len;++i)//L向左   R向右走 
	{
	//	debug();
		if(s[i]=='R'&&s[i+1]=='L'&&i+1<=len-1)
		{
			vis[i]=vis[i+1]=1;
			a[i]++;
			a[i+1]++;
			for(rg int j=i-1;j>=0;--j)
			{
				if(vis[j]==1) break;
				if(s[j]=='R') 
				{
					if((i-j)%2==0) a[i]++,vis[j]=1;
					else a[i+1]++,vis[j]=1;
				}
				else break;
			}
			for(rg int j=i+2;j<len;++j)
			{
				if(vis[j]==1) break;
				if(s[j]=='L') 
				{
					if((j-(i+1))%2==0) a[i+1]++,vis[j]=1;
					else a[i]++,vis[j]=1;
				}
				else break;
			}
		}
	}
	for(rg int i=0;i<len;++i) cout<<a[i]<<" ";
}

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

int N,K;
char S[200020] = {0};
int a,b;

int main()
{
    scanf("%s",S);
    N = strlen(S);
    for(int i = 0; i < N; i++)if(S[i] == 'Z')a = i;
    reverse(S,S + N);
    for(int i = 0; i < N; i++)if(S[i] == 'A')b = i;
    printf("%d\n",a + b - N + 2);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, A, B; 
  cin >> N >> A >> B;

  vector<int> X(N);
  REP(i, N) cin >> X[i];

  int ans = 0;
  REP(i, N-1){
    ans += min(A*(X[i+1]-X[i]), B);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
    using namespace std;
    #define el "\n"
    #define ll long long
    #define ull unsigned long long long
    #define pb push_back
    #define mp make_pair
    #define X first
    #define Y second
    #define M 1000000007
    #define all(v) v.begin(), v.end()
    ll _lcm(ll a,ll b){
        return (a*b)/(__gcd(a,b));
    }
    int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      ll n;
      cin>>n;
      long double a[n]={0};
      priority_queue<long double,vector<long double> , greater<long double>>pq;
      for(int i=0;i<n;i++){
          cin>>a[i];
          pq.push(a[i]);
      }
      long double ans=0,tmp=0;
      for(int i=0;i<n-1;i++){
          tmp=0;
          tmp+=pq.top();
          pq.pop();
          tmp+=pq.top();
          pq.pop();
          pq.push(tmp/2);
         // cout<<tmp/2<<el;
      }
      cout<<setprecision(10)<<pq.top()<<el; 
      return 0;
    }


Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
  {
    var tmp=Read(2);
    var n=tmp[0]; var t=tmp[1];
    long m=1001;
    for(long i=0;i<n;i++){
      tmp=Read(2);
      m=(tmp[1]<=t&&tmp[0]<m)?tmp[0]:m;
    }
    if(m==1001){
      Write("TLE");
    }else{
      Write(m);
    }
  }

  static void Write(string s) { Console.WriteLine(s); return; }
  static void Write(long n) { Console.WriteLine(n.ToString()); return; }
  static string ReadStr() { return Console.ReadLine(); }
  static string[] ReadStrs() { return Console.ReadLine().Split(' '); }
  static long Read() { return long.Parse(Console.ReadLine()); }
  static long[] Read(long n) {
    long[] p = new long[n];
    string[] t = Console.ReadLine().Split(' ');
    for(long i = 0; i < n; i++) { p[i] = long.Parse(t[i]); }
    return p;
  }
  static long abs(long n) { return (n > 0) ? n : -n; }
  static long gcd(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
  static long gcd(long a, long b) { return (a==0)?b:gcd(b % a, a); }
  static long lcm(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
  static long lcm(long a, long b) { return a * b / gcd(a, b); }
  static long max(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p>n[i])?p:n[i]; } return p; }
  static long min(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p<n[i])?p:n[i]; } return p; }
  static void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
  static void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
  static void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
  static string clip(string s, int start, int count) {
    if (start + count < s.Length) { s = s.Remove(start + count); }
    if (start > 0) { s = s.Remove(0, start); }
    return s;
  }
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c || a == c && a != b || b == c && a != b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

const int CMax = 102;
const int CVMax = 31;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, k;
int A[CMax], B[CMax], C[CMax];
int res;

long long gcd(long long a, long long b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}



int main()
{
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    for (int i = 0; i < n; i++) { scanf("%d", &B[i]); res += B[i]; }
    for (int i = 0; i < n-1; i++) scanf("%d", &C[i]);

    for (int i = 1; i < n; i++) {
        if (A[i] - A[i-1] == 1) res += C[A[i-1]-1];
    }

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

    return 0;
}


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

int main() {
  double x1, y1, x2, y2, x3, y3;
  double a, b, c, z, s = 0.0;
  scanf("%lf,%lf\n", &x1, &y1);
  scanf("%lf,%lf\n", &x2, &y2);
  while (scanf("%lf,%lf\n", &x3, &y3) == 2) {
    a = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    b = sqrt((x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));
    c = sqrt((x3-x2)*(x3-x2) + (y3-y2)*(y3-y2));
    z = (a+b+c)*0.5;
    s += sqrt(z*(z-a)*(z-b)*(z-c));
    x2 = x3;
    y2 = y3;
  }
  printf("%.6lf\n", s);
  return 0;
}

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

using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N;
  cin >> N;
  int a, b, c;
  cin >> a >> b >> c;
  while(--N)
  {
    int ai, bi, ci;
    cin >> ai >> bi >> ci;
    int ai_ = ai + max(b, c);
    int bi_ = bi + max(a, c);
    int ci_ = ci + max(a, b);
    a = ai_;
    b = bi_;
    c = ci_;
  }
  
  cout << max({a, b, c}) << "\n";
  
  return 0;
}

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

for i in range(N):
  C=A[i]-B[i]
  D=A[i+1]+A[i]-B[i]
  E=A[i+1]+A[i]
  if C>=0:
    A[i]=C
    teki=teki+B[i]
  else:
    if D>0:
      A[i]=0
      A[i+1]=D
      teki=teki+B[i]
    else:
      A[i]=0
      A[i+1]=0
      teki=teki+E

print(teki)    


Measured memory_bytes: 18476
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

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

bool debug=false;
/*---------------------------------------------------*/

int main(){
  double r0,w0,c,r;
  while(cin>>r0>>w0>>c>>r){
    if(r0==0&&w0==0&&c==0&&r==0)break;
    cout<<max(0,int((c*w0-r0)/r+0.99999999))<<endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include <algorithm>
#include <array>
#include <cstdio>
#include <queue>
using namespace std;
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
vector<bool> seen;
vector<int> ans(3000, 0);
int d[3000][3000];
vector<vector<int>> G(3000);

void bfs(int s) {
  queue<int> q;
  q.push(s);
  seen[s] = true;

  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto next_v : G[v]) {
      if (seen[next_v]) continue;
      seen[next_v] = true;
      q.push(next_v);
      d[s][next_v] = d[s][v] + 1;
      if (s < next_v) ans[d[s][next_v]]++;
    }
  }
}

int main() {
  int N, X, Y;
  scanf("%d %d %d", &N, &X, &Y);
  X--;
  Y--;
  FOR(i, N - 1) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);
  FOR(i, N) FOR(j, N) d[i][j] = 0;

  FOR(i, N) {
    seen.assign(N, false);
    bfs(i);
  }

  for (int i = 1; i < N; i++) printf("%d\n", ans[i]);
  return 0;
}

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

int main(){
  int p, q, r;
  cin >> p >> q >> r;
  int max = 10000;
  if(max > p + q) max = p + q;
  if(max > q + r) max = q + r;
  if(max > r + p) max = r + p;
  cout << max << endl;
  return 0;
}

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

using namespace std;

#define ll long long

int main(){
    int N;
    ll power = 1;

    cin >> N;
    for(int i=0; i < N; ++i){
        power *= (i+1);
        power %= 1000000007;
    }

    cout << power << endl;

    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int r, g, b; cin >> r >> g >> b;
    
    int n = r * 100 + g * 10 + b;
    cout << ((n % 4 == 0) ? "YES" : "NO") << endl;
    return 0;
}


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int x, y, z, k;
ll a[1005], b[1005], c[1005];
ll sum1[10000005], sum2[10000005];
int num1, num2;
int main()
{
	std::cin >> x >> y >> z >> k;
	for (int i = 0; i < x; ++i)
		std::cin >> a[i];
	for (int i = 0; i < y; ++i)
		std::cin >> b[i];
	for (int i = 0; i < z; ++i)
		std::cin >> c[i];

	std::sort(a, a + x, std::greater<ll>());
	std::sort(b, b + y, std::greater<ll>());
	std::sort(c, c + z, std::greater<ll>());

	for (int i = 0; i < x; ++i)
		for (int j = 0; j < y; ++j)
			sum1[num1++] = a[i] + b[j];

	std::sort(sum1, sum1 + num1, std::greater<ll>());

	for (int i = 0; i < k; ++i)
		for (int j = 0; j < z; ++j)
			sum2[num2++] = sum1[i] + c[j];

	std::sort(sum2, sum2 + num2, std::greater<ll>());

	for (int i = 0; i < k; ++i)
		std::cout << sum2[i] << std::endl;
	return 0;
}


Measured memory_bytes: 33152
s = input()
c0 = 0
c1 = 0

for i in range(len(s)):
    if i % 2 == 0 and s[i] != '0':
        c0 += 1
    if i % 2 != 0 and s[i] != '1':
        c0 += 1

for i in range(len(s)):
    if i % 2 == 0 and s[i] != '1':
        c1 += 1
    if i % 2 != 0 and s[i] != '0':
        c1 += 1

print(min(c0, c1))


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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

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

int main(){
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    int result = s.compare(t);
    cout << ((result < 0) ? "Yes" : "No") << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll INF=(ll)1e18+1;

int main() {
  ll n,k,p=0,z=0,m=0,mid,s,ri;
  cin >> n >> k;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    (a[i]<0 ? m : (a[i]>0 ? p : z))++;
  }
  sort(a,a+n);
  ll ok=INF,ng=-INF;
  while(ok-ng>1){
    mid=ng+(ok-ng)/2; //mid未満の積はいくつあるか
    if(mid==0) s=m*p;
    if(mid>0){
      s=m*p + z*(m+p) + z*(z-1)/2;
      ri=n-1;
      for(int i=m+z;i<n;i++){
        while(a[i]*a[ri]>=mid) ri--;
        if(ri>i) s+=ri-i;
        else break;
      }
      ri=0;
      for(int i=m-1;i>=0;i--){
        while(a[i]*a[ri]>=mid) ri++;
        if(ri<i) s+=i-ri;
        else break;
      }
    }
    if(mid<0){
      s=0;
      ri=m+z;
      for(int i=0;i<m;i++){
        while(a[i]*a[ri]>=mid) ri++;
        if(ri<n) s+=n-ri;
        else break;
      }
    }
    if(s<k)ng=mid;
    else ok=mid;
  }
  cout << ng << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
double X1,X2,Y1,Y2;
double dis;
int main()
{
    scanf("%lf%lf%lf%lf",&X1,&Y1,&X2,&Y2);
    dis=sqrt((double)(X1-X2)*(X1-X2)+(double)(Y1-Y2)*(Y1-Y2));
    printf("%f",dis);
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

vector<int> tonari[100010];
void solve(int ca){
    int N,M; cin>>N>>M;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) {
        cin>>h[i];
    }
    for (int i = 0; i < M; ++i) {
        int a,b;
        cin>>a>>b; --a; --b;
        tonari[a].push_back(b);
        tonari[b].push_back(a);
    }

    int cnt=0;
    for (int i = 0; i < N; ++i) {
        bool high=true;
        for(auto j:tonari[i]){
            if(h[i]<=h[j]){
                high = false;
                break;
            }
        }
        if(high) cnt++;
    }

    cout<<cnt<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 8804
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  c=1
  n-=k

  while True:
    if n<=0:
      break

    n-=(k-1)
    c+=1

  return c

print(main())


Measured memory_bytes: 16296
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 3e5 + 5;
int n;
long long l;
long long x[maxn], t[maxn];

bool read() {
  if (scanf("%d%lld", &n, &l) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &x[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &t[i]);
  }
  return true;
}

vector<long long> ls, rs;
vector<long long> bad, good;
vector<int> used;

void solve() {
  ls.clear();
  rs.clear();
  bad.clear();
  good.clear();
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += t[i] / (2 * l);
    t[i] %= 2 * l;
    if (!t[i]) {
      bad.push_back(x[i]);
      continue;
    }
    if (t[i] <= 2 * x[i]) {
      if (t[i] <= 2 * (l - x[i])) {
        good.push_back(x[i]);
      } else {
        rs.push_back(x[i]);
      }
    } else {
      if (t[i] <= 2 * (l - x[i])) {
        ls.push_back(x[i]);
      } else {
        bad.push_back(x[i]);
        res++;
      }
    }
  }
  long long mx = 0;
  used.clear();
  used.resize(sz(good), false);
  int pos = 0;
  bool found = false;
  for (int i = 0; i < sz(ls); i++) {
    mx = max(mx, ls[i]);
    if (pos < sz(good) && good[pos] < ls[i]) {
      used[pos] = true;
      pos++;
      found = true;
    } else {
      found = false;
    }
    res++;
  }
  pos = sz(good) - 1;
  if (!rs.empty()) {
    if (pos >= 0 && !used[pos] && good[pos] > rs.back()) {
      mx = max(mx, good[pos]);
      used[pos] = true;
      pos--;
    } else {
      mx = l;
    }
    for (int i = sz(rs) - 1; i >= 0; i--) {
      if (pos >= 0 && !used[pos] && good[pos] > rs[i]) {
        mx = max(mx, good[pos]);
        used[pos] = true;
        pos--;
      } else {
        mx = l;
      }
      res++;
    }
    int cnt = 0;
    for (int i = 0; i < sz(good); i++) {
      cnt += !used[i];
    }
    res += 1 + (cnt + 1) / 2;
    if (cnt & 1) {
      mx = l;
    }
  } else {
    int cnt = 0;
    for (int i = 0; i < sz(good); i++) {
      cnt += !used[i];
    }
    if (found || cnt) {
      res += 1 + cnt / 2;
      if (!good.empty()) {
        mx = max(mx, good.back());
      }
      if (!(cnt & 1)) {
        mx = l;
      }
    }
  }
  if (!bad.empty() && bad.back() > mx) {
    res++;
  }
  printf("%lld\n", res * 2 * l);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 11120
#include <stdio.h>

int main()
{
  int N , i, j ,k, count = 0;
  scanf("%d", &N);
  
  int L[N];
  for (i = 0;i < N;i ++) {
    scanf("%d", &L[i]);
  }
  
  for (i = 0;i < N-2;i ++) {
    for (j = i;j < N-1;j ++) {
      for (k = j;k < N;k ++) {
        if ((L[i]==L[j]) || (L[j]==L[k]) || (L[k]==L[i])) {
          continue;
        }
        if ((L[i]<L[j]+L[k]) && (L[j]<L[k]+L[i]) && (L[k]<L[i]+L[j])) {
          count ++;
        }
      }
    }
  }
  
  printf("%d", count);
  return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	int n;
	cin >> n;

	vector<double> v(n);

	double ans = 0;
	REP(i, n)cin >> v[i];

	sort(ALL(v));

	REP(i, n - 1) {
		v[i + 1] = (v[i] + v[i + 1]) / 2;
	}


	cout << setprecision(15) << v[n-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int m[16][16] = {0};
int a, b;

int check(int x, int y) {
	if (x < 0 || x >= a || y < 0 || y >= b) return 0;
	if (m[y][x] == -1) return 0;
	return 1;
}

int main() {
	int n, x, y;
	while (cin >> a >> b, a || b) {
		cin >> n;
		for (y = 0; y < 16; ++y)
			for (x = 0; x < 16; ++x)
				m[y][x] = 0;

		m[0][0] = 1;

		for (int i = 0; i < n; ++i) {
			cin >> x >> y;
			m[y-1][x-1] = -1;
		}
		int l = a + b - 2;
		for (int i = 0; i < l; ++i) {
			for (int n = 0; n <= i; ++n) {
				x = n;
				y = i - x;
				if (!check(x, y)) continue;
				int nx = x + 1, ny = y + 1;
				if (check(nx, y )) m[y][nx] += m[y][x];
				if (check(x,  ny)) m[ny][x] += m[y][x];
			}
		}

		cout << m[b-1][a-1] << endl;
	}
}

Measured memory_bytes: 0