akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n,m;cin>>n>>m;
    vll a(n);
    REP(i,n) cin>>a[i];
    vll rui(n+1,0);
    ll sum=0;
    REP(i,n){
        sum += a[i];
        rui[i+1] = sum % m; 
    }
    map<ll,ll> mp;
    REP(i,n+1) mp[rui[i]]++;
    ll ans=0;
    for(auto p:mp){
        // cout<<p.second<<endl;
        ans += p.second * (p.second-1) /2;
    } 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	// cout << std::fixed << std::setprecision(15);

	long long N, Y;
	cin >> N >> Y;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N - i; j++){
			if (10000 * i + 5000 * j + (N - i - j) * 1000 == Y) {
				cout << i << " " << j << " " << N - i - j << endl;
				exit(0);
			}
		}
	}

	cout << "-1 -1 -1" << endl;
}


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

using namespace std;


/// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER true
#define TIME false
#define DEBUG true
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second


const double pi = acos(-1);
const int inf = 2147483647;
const int _inf = -2147483648;
const int mod = 1e9+7;


void delay(int sec); // DEBUG



void solution(void)
{
    int n;

    cin >> n;
    int ara[n], dp[n];

    for(int i = 0; i < n; ++i) {
        cin >> ara[i];
        dp[i] = mod;
    }
    dp[0] = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j <= i+2; ++j) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i]+abs(ara[i]-ara[j]));
            }
        }
    }


    cout << dp[n-1] __;




    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif


    unsigned short int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}

Measured memory_bytes: 1024
/*input
keyence
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	string a,b="keyence";
	cin>>a;

	int i=0,j=SZ(a)-1;

	for(i=0;i<SZ(a)&&i<SZ(b);i++){
		if(a[i]!=b[i]) break;
	}
	for(j=0;j<SZ(a)&&j<SZ(b);j++){
		if(a[SZ(a)-1-j]!=b[SZ(b)-1-j]) break;
	}

	if(i+j>=SZ(b)) cout<<"YES\n";
	else cout<<"NO\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2000005;
using lint = long long;
const int mod = 1e9 + 7;

int n, m;

int main(){
	cin >> n >> m;
	if(n > m) swap(n, m);
	lint ret = 0;
	if(n + 1 == m) ret = 1;
	if(n == m) ret = 2;
	for(int i=1; i<=n; i++) ret = ret * i % mod;
	for(int i=1; i<=m; i++) ret = ret * i % mod;
	cout << ret << endl;
}


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

int main(){
	int A, B, K, i;
	scanf("%d%d%d", &A, &B, &K);
	for(i = 0; i < K; i++){
		if(A + i <= B){
			printf("%d\n", A + i);
		}
	}
	for(i = K - 1; i >= 0; i--){
		if(B - i >= A + K){
			printf("%d\n", B - i);
		}
	}
	return 0;
}

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

using namespace std;

struct Trie {
	char value;
	bool finished;
	Trie *next[2];
	Trie() {
		value = 0;
		finished = false;
		next[0] = next[1] = NULL;
	}
};
void add(Trie *r, const char *t, char v)
{
	for (int i = 0; t[i]; i++){
		int c = t[i] - '0';
		if (!r->next[c]) r->next[c] = new Trie();
		r = r->next[c];
	}
	r->value = v;
	r->finished = true;
}

int main(void)
{
	Trie *tree = new Trie();
	char fr[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

	add(tree,"101",' ');
	add(tree,"000000",'\'');
	add(tree,"000011",',');
	add(tree,"10010001",'-');
	add(tree,"010001",'.');
	add(tree,"000001",'?');
	add(tree,"100101",'A');
	add(tree,"10011010",'B');
	add(tree,"0101",'C');
	add(tree,"0001",'D');
	add(tree,"110",'E');
	add(tree,"01001",'F');
	add(tree,"10011011",'G');
	add(tree,"010000",'H');
	add(tree,"0111",'I');
	add(tree,"10011000",'J');
	add(tree,"0110",'K');
	add(tree,"00100",'L');
	add(tree,"10011001",'M');
	add(tree,"10011110",'N');
	add(tree,"00101",'O');
	add(tree,"111",'P');
	add(tree,"10011111",'Q');
	add(tree,"1000",'R');
	add(tree,"00110",'S');
	add(tree,"00111",'T');
	add(tree,"10011100",'U');
	add(tree,"10011101",'V');
	add(tree,"000010",'W');
	add(tree,"10010010",'X');
	add(tree,"10010011",'Y');
	add(tree,"10010000",'Z');

	string str;
	while (getline(cin, str)){
		Trie *now = tree;
		for (int i = 0; i < str.length(); i++){
			for (int idx = 0; ; idx++){
				if (fr[idx] == str[i]){
					for (int j = 4; 0 <= j; j--){
						now = now->next[(idx >> j) & 1];
						if (now->finished){
							cout << now->value;
							now = tree;
						}
					}
					break;
				}
			}
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
  int at,bt,xt;
  cin >> at >> bt >> xt;
  vector<int> A(at);
  vector<int> B(bt);
  rep(i,at) cin >> A[i];
  rep(i,bt) cin >> B[i];
  int X[xt][3];
  rep(i,xt)rep(j,3) cin >> X[i][j];
  
  int rs=0;
  rs = *min_element(ALL(A)) + *min_element(ALL(B));
  rep(i,xt){
    int y=A[(X[i][0]-1)]+B[(X[i][1]-1)]-X[i][2];
    rs=min(y,rs);
  }
  cout << rs;
  return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void)
{
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if (op == '?')break;
    else if (op == '+')
      printf("%d\n",a+b);
    else if (op == '-')
      printf("%d\n",a-b);
    else if (op == '*')
      printf("%d\n",a*b);
    else  if(op == '/')
      printf("%d\n",a/b);
  }
  return 0;
}
  

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;
    int t=0;
    while(a>=b) b*=2,t++;
    while(b>=c) c*=2,t++;
    cout<<(t<=k?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 3636
x,y=map(int,input().split())
p=0
if x==1:
  p+=300000
elif x==2:
  p+=200000
elif x==3:
  p+=100000
if y==1:
  p+=300000
elif y==2:
  p+=200000
elif y==3:
  p+=100000
if x==1 and y==1:
  p+=400000
print(p)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    ll ans = 0;
    while(0 < n){
        ans += n%10;
        n /= 10;
    }
    if(ans == 1)ans = 10;
    cout << ans << endl;
}

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

int main()
{
  string s;
  cin >> s;
  
  int n = s.size(), maxlen = 0;;
  for(int i = n-1; i > 0; i--){
    string ans = s.substr(0,i);
    int len = ans.size();
    if(len % 2 == 1){
        continue;
    }
      
    int flag = 0;
    for(int i = 0; i < len/2; i++){
      if(ans[i] != ans[len/2+i]){
        flag = 1;
        break;
      }
    }
    if(flag == 0 && len > maxlen){
      maxlen = len;
    }
    
  }//for
  
  cout << maxlen << endl;
      
}


Measured memory_bytes: 3616
N=int(input())
A=list(map(int,input().split()))
S=sum(A)
NOW=A[0]
ANS=abs(NOW-(S-NOW))
for i in range(1,N-1):
    NOW+=A[i]
    if abs(NOW-(S-NOW))<ANS:
        ANS=abs(NOW-(S-NOW))

print(ANS)

Measured memory_bytes: 24808
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>
#include <chrono>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back


using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const int MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };


void solve() {

    ll n;
    cin >> n;
    vll v(n);
    for (auto& x : v) cin >> x;
    srt(v);
    ll curr = 1, rem = 1;
    ll const lim = 1e18;
    rem = lim;
    for (int i = 0; i < n; i++) {
        rem = lim / curr;
        if (v[i] > rem) {
            cout << -1 << endl;
            return;
        }
        curr *= v[i];
        if (curr == 0) {
            cout << 0 << endl;
            return;
        }
    }
    cout << curr << endl;
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

        
        solve();


    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll cnt[26];
int main() {
    init();
    string s, p;
    ll N;
    cin >> s >> p;
    N = s.size();
    s += s;

    bool isok = false;
    rep(i,N){
        if (s.substr(i, p.size())==p) isok = true;
    }

    cout << (isok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3216
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	int k;
	cin >> k;
		string x;
		cin >> x;
	if (x.size() <= k) {
		cout << x << endl;
	} else {
		cout << x.substr(0, k) << "..." << endl;
	}
}

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


int main(){
while(1){
int H,W;
cin>>H>>W;
if(H == 0 && W == 0) break;


for(int i=0;i<H;i++){
 for(int j=0;j<W;j++){
  if((i+j) %2 ==0) cout<<"#";
   else cout<<".";
   }
   cout<<endl;
  }
  cout<<endl;
 }
 
  return 0;
}


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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<double> x(N);
    vector<string> u(N);
    for(int i=0;i<N;i++){
        cin>>x[i]>>u[i];
    }
    double ans=0.0;
    for(int i=0;i<N;i++){
        if(u[i]=="JPY") ans+=x[i];
        if(u[i]=="BTC") ans+=x[i]*380000.0;
    }
    cout<<fixed;
    cout<<setprecision(6)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=998244353;
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn=1000111;
int fac[maxn],ifac[maxn];
ll inv[maxn];
void precalc()
{
	fac[0]=1;
	for(int i=1;i<maxn;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[maxn-1]=qpow(fac[maxn-1],mod-2);
	for(int i=maxn-2;i>=0;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	inv[1]=1;
	for(int i=2;i<maxn;i++)inv[i]=(mod-1ll*inv[mod%i]*(mod/i)%mod)%mod;
}
ll C(int x,int y){return x<y?0:1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
ll f(int x,int y){return C(x+y,x);}
ll calc(int x,int y,int n,int m)
{
	return (x<0||y<0||x>n||y>m)?0:1ll*C(x,y)*C(n-x,m-y)%mod;
}
ll solve(int n,int m)
{
	ll ret=0;
	ll sum2=0,sum1=f(n-1,m);
	for(int i=1;i<=n+min(n,m);i++)
	{
		sum2=(sum2+sum1)%mod;
		if(i%2==1)sum2=(sum2-f(i/2,i/2)*f(n-(i/2),m-(i/2+1))%mod*(i/2)%mod+mod)%mod;
		else sum2=(sum2+f(i/2-1,i/2)*f(n-(i/2),m-(i/2))%mod*(i/2)%mod)%mod;
//		cerr<<i<<" "<<sum1<<" "<<sum2<<endl;
		ret=(ret+sum2*inv[i])%mod;
		if(i%2==1)sum1=(sum1-f(i/2,i/2)*f(n-(i/2+1),m-(i/2+1))%mod+mod)%mod;
		else sum1=(sum1+f(i/2-1,i/2)*f(n-(i/2+1),m-(i/2))%mod)%mod;
	}
//	cerr<<ret<<endl;
	return ret;
}
int n,m;
int main()
{
	precalc();
	cin>>n>>m;
	ll ANS=(solve(n,m)+solve(m,n))%mod;
//	cerr<<ANS<<endl;
	for(int i=1;i<=min(n,m);i++)
	{
		ANS=(ANS-1ll*C(i+i,i)*C(n+m-i-i,n-i)%mod*i%mod*inv[i+i]%mod+mod)%mod;
	}
	ANS=1ll*ANS*ifac[n+m]%mod*fac[n]%mod*fac[m]%mod;
	cout<<ANS<<endl;
	return 0;
}


Measured memory_bytes: 15872
using System;
class Mainclass 
{
    static void Main()
    {
        var s = Console.ReadLine().ToCharArray();
        var str = "";
        foreach(var c in s)
        {
            if (c=='0'||c=='1')
            {
                str += c;
            }
            else if (0 < str.Length)
            {
                str = str.Substring(0, str.Length - 1);
            }
        }
        Console.WriteLine(str);
    }
}

Measured memory_bytes: 25756
#from math import gcd
from fractions import gcd
def lcm(s,t):
    return s*t//gcd(s,t)
def not_div(b,c,d):
    return b-(b//c + b//d - b//lcm(c,d))
a,b,c,d = map(int,input().split())
print(not_div(b,c,d)-not_div(a-1,c,d))

Measured memory_bytes: 5076
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner scan = new Scanner(System.in);
    int M = scan.nextInt();
    int D = scan.nextInt();
    scan.close();
    
    int res=0, tmp=0;
    int d1=0, d10=0;
    for(int i=22; i<=D; i++) {
      d1 = i%10;
      d10 = i/10;
      if(d1<2 || d10<2) continue;

      tmp = d1 * d10;
      if(0<tmp && tmp<=M) res++;
    }
    
    System.out.println(res);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, k;
double res;

signed main() {
    cin >> n >> k;
    reps(i,1,n+1) {
        int a = i;
        double p = 1./n;
        while (a<k) a *= 2, p /= 2;
        res += p;
    }
    printf("%.14lf", res);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>

#define maxn 2222
#define mod 1000000007

inline int read(){
	int r=0,f=0;
	char c;
	while(!isdigit(c=getchar()))f|=(c=='-');
	while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
	return f?-r:r;
}

inline long long qpow(long long a,int b){
	long long ans=1;
	for(;b;b>>=1){
		if(b&1)(ans*=a)%=mod;
		(a*=a)%=mod;
	}
	return ans;
}

int n,k;

long long frac[maxn*maxn],invf[maxn*maxn],f[maxn][maxn];

inline long long C(int n,int m){
	return frac[n]*invf[m]%mod*invf[n-m]%mod;
}

int main(){
	n=read(),k=read();
	if(k==1)return puts("1"),0;
	frac[0]=1;
	for(int i=1;i<=n*k;i++)
		frac[i]=frac[i-1]*i%mod;
	invf[n*k]=qpow(frac[n*k],mod-2);
	for(int i=n*k;i>=1;i--)
		invf[i-1]=invf[i]*i%mod;
	for(int i=1;i<=n;i++)f[i][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			f[i][j]=(f[i-1][j]+f[i][j-1]*(n-j+1)%mod*C(n*k-i-1-(j-1)*(k-1),k-2)%mod)%mod;
	printf("%lld\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 88884
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int w, h, x, y; cin >> w >> h >> x >> y;
	double area = (( double) w * ( double) h) / 2;
	int flag = 0;
	if (w == 2 * x && h == 2 * y) flag = 1;
	printf("%.8f %d\n", area, flag);

	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int H,W;
  cin>>H>>W;
  vector<string>a(H);
  for(int i=0;i<H;i++)cin>>a[i];
  vector<vector<bool>>b(H,vector<bool>(W,true));
  for(int i=0;i<H;i++){
    bool black=false;
    for(int j=0;j<W;j++){
      if(a[i][j]=='#')black=true;
    }
    if(!black){
      for(int j=0;j<W;j++){
        b[i][j]=false;
      }
    }
  }
  for(int i=0;i<W;i++){
    bool black=false;
    for(int j=0;j<H;j++){
      if(a[j][i]=='#')black=true;
    }
    if(!black){
      for(int j=0;j<H;j++){
        b[j][i]=false;
      }
    }
  }
  for(int i=0;i<H;i++){
    bool c=false;
    for(int j=0;j<W;j++){
      if(b[i][j])cout<<a[i][j],c=true;
    }
    if(c)cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import Data.List
import Data.Maybe

main = do
    n <- read <$> getLine
    s <- getLine
    putStrLn $ solve n s

solve :: Int -> String -> String
solve n s = map shift s
  where
    shift c = a !! ((fromJust (elemIndex c a) + n) `mod` 26)
    a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


Measured memory_bytes: 5308
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <string>

using namespace std;

int main(){
  int k;
  cin >> k;
  if (k <= 9){
    cout << k;
    return 0;
  }
  vector <string> brojevi(1,"0");
  k++;
  for (int i = 1; i < 10; i++){
    string s = " ";
    char t = '0' + i;
    s+= t;
    brojevi.push_back(s);
  }
  int bd = 10;
  while (brojevi.size() < k){
    int si = brojevi.size() - bd;
    int nbd = 0;
    for (int i = si; i < si + bd; i++){
      int l = brojevi[i].length();
      char trazeni = brojevi[i][l-1] - 1;
      if (trazeni == '0')
       brojevi.push_back(brojevi[i] + trazeni), k++, nbd++;
      if (trazeni > '0')
       brojevi.push_back(brojevi[i] + trazeni), nbd++;
      trazeni += 1;
      if (trazeni == '0')
       brojevi.push_back(brojevi[i] + trazeni), k++, nbd++;
      if (trazeni > '0')
       brojevi.push_back(brojevi[i] + trazeni), nbd++;
      trazeni += 1;
      if (trazeni <= '9')
       brojevi.push_back(brojevi[i] + trazeni), nbd++;
    }
    bd = nbd;
  }
  cout << brojevi[k-1];
}


Measured memory_bytes: 14832
#include <algorithm>
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;

  int sl = s.length();
  string hoge = "";
  string fuga = "";

  for(int i = 0; i < sl; ++i){
    if(i % 2 == 0){
      hoge += "0";
    }
    else{
      hoge += "1";
    }
  }

  for(int i = 0; i < sl; ++i){
    if(i % 2 == 0){
      fuga += "1";
    }
    else{
      fuga += "0";
    }
  }

  int c_hoge = 0;
  int c_fuga = 0;

  for(int i = 0; i < sl; i++){
    if(s[i] == hoge[i]){
      c_hoge += 1;
    }
  }

  for(int i = 0; i < sl; i++){
    if(s[i] == fuga[i]){
      c_fuga += 1;
    }
  }

  if(c_hoge < c_fuga){
    cout << c_hoge << endl;
  }

  if(c_hoge >= c_fuga){
    cout << c_fuga << endl;
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
long long mymax(long long a,long long b){
	if(a>b)return a;
	return b;
}
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	printf("%lld",mymax(a*c,mymax(a*d,mymax(b*c,b*d))));
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,t,a,anst = 1,ansa = 1,N;
    cin >> n;
    rep0(i, n){
        cin >> t >> a;
        N = max((anst+t-1)/t, (ansa+a-1)/a);
        ansa = N * a;
        anst = N * t;
    }
    cout << anst + ansa << endl;
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
int main() {
	int n;
	int a[15];
	int x[15][15];
	int y[15][15];
	bool mujun;
	int honestMax = 0;
	int honestCou;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		for (int j = 0; j < a[i]; j++) {
			scanf("%d%d", &x[i][j], &y[i][j]);
		}
	}
	//正直(1)or不親切(0)をbit全探索
	for (int i = 0; i < pow(2, n); i++) {
		mujun = false;
		honestCou = 0;
		for (int j = 0; j < n; j++) {
			// j+1人目が不親切(0)なら無視
			if (((i >> j) & 1) == 1) {
				honestCou++;
				for (int k = 0; k < a[j]; k++) {
					//証言をチェック
					if (((i >> (x[j][k] - 1)) & 1) != y[j][k]) {
						//正直(1)or不親切(0)が一致していなければ矛盾
						mujun = true;
						break;
					}
				}
			}
		}
		if (!mujun && honestCou > honestMax) {
			honestMax = honestCou;
		}
	}
	printf("%d\n", honestMax);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <sstream>
#include <cstdlib>
typedef long long  ll;
using namespace std;
int main()
{
	int N;
	cin >> N;
	ll a[N];
	int count=0;
	int number=0;
	int ans=0;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	for(int i=0;i<N;i++){
		while(1){
			if(a[i]%2==0){
				a[i]=a[i]/2;
				ans++;
			}else{
				break;
			}
		}
	}
	cout << ans << endl;
	/*while(1){
		int count=-1;
		int number=-1;
		for(int i=0;i<N;i++){
			if(a[i]%2==0){
				if(a[i]>count){
					number=i;
					count=a[i];
				}
			}
		}
		if(number==-1){
			cout << ans << endl;
			return 0;
		}
		for(int i=0;i<N;i++){
			if(i==number){
				a[i]=a[i]/2;
			}else{
				a[i]=a[i]*3;
			}
		}
		ans++;
	}*/
}

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

using namespace std;

#define ll long long

int main()
{
	ll A, B;
	cin >> A >> B;
	ll gcd = __gcd(A, B);

	ll ans = 0;
	for (ll i = 2; i * i <= gcd; i++) {
		if (gcd % i == 0) {
			ans++;
			while (gcd % i == 0) {
				gcd /= i;
			}
		}
	}

	if (gcd != 1) {
		ans++;
	}

	cout << ans + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	a := getInts(N)
	x := 0
	y := 1000
	for i := 0; i < N; i++ {
		if i < N-1 && a[i] < a[i+1] {
			// out("buy", i, a[i])
			x += y / a[i]
			y = y % a[i]
			continue
		}
		if x != 0 && a[i] > a[i-1] {
			// out("sell", i, a[i])
			y += x * a[i]
			x = 0
		}
	}
	out(y)
}


Measured memory_bytes: 1776
n,x,d=gets.split.map(&:to_i)

if d == 0
  p (x == 0)? 1 : (n+1)
  exit
end

list = {}

(0..n).each{|nn|
  div,mod = (x*nn).divmod(d)
  top = nn*(nn-1)/2 + div
  bottom = nn*(n-1+n-nn)/2 + div
  top,bottom = bottom,top if top < bottom
  list[mod]||=[]
  list[mod].push([bottom,:start],[top+1,:end])
}

cnt = 0
list.each{|m,l|
  nest = 0
  start = 0
  l.sort.each{|i,type|
    case type
    when :start
      start = i if nest == 0
      nest += 1
    when :end
      nest -= 1
      cnt += i - start if nest == 0
    end
  }
}
p cnt


Measured memory_bytes: 58492
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int l = scanner.nextInt();

        int all = 0;
        int select = Integer.MAX_VALUE;

        for (int i = 1; i <= n; i++) {
            all += l + i - 1;
            if(Math.abs(l + i - 1) < Math.abs(select)){
                select = l + i - 1;
            }
        }

        System.out.println(all - select);
    }
}


Measured memory_bytes: 22612
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, best)
  path = ''
  loop do
    a = rear + front
    b = west + east
    c = north + south
 
    return path if a + b + c == 0
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 'E'
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 'N'
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 'S'
    #elsif west > 0 && valid?(b - 1, c, a)
    else
      rear, front, west, east = west - 1, east, front, rear
      y = 'W'
    end
     
    if best
      x = best[path.size]
      return best if x < y
      best = nil if x > y
    end
    path << y  
  end
end
 
def find(target)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, best)
    end
  end
  best
end
 
loop do
  target = gets.split.map!(&:to_i)
  break if target.max == 0
  p, q = gets.split.map!(&:to_i)
  result = find(target)
  puts result ? result[p-1...q] : 'impossible'
end

Measured memory_bytes: 10016
/*;

THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define r(i, s, l) for (int i = s; i < l; i++)
#define rr(i,s,l) for(int i=s;i>=l;i--)
#define mod 1000000007
#define int long long
#define INT_BITS 32
#define ld long double
#define pp pair<int,int>
#define ss second
#define ff first
#define INF 1e18
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
#define endl "\n"
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

signed main()
{


    string s;
    cin>>s;
    r(i,0,s.length()-1)
    if(s[i]==s[i+1])
    {
       cout<<"Bad";
       return 0;
    }

    cout<<"Good";


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[1010][1010];
int a[1010][1010];
int d[1010][1010];
int dx[] = {0, -1, 0, 1};
int dy[] = {-1, 0, 1, 0};
queue<pair<int, int> > Q;
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++ i) {
		scanf("%s", s[i] + 1);
	}
	for(int i = 1; i <= n; ++ i) {
		for(int j = 1; j <= m; ++ j) {
			if(s[i][j] == '#') {
				a[i][j] = d[i][j] = 1;
				Q.push(make_pair(i,j));
			}
		}
	}
	while(!Q.empty()) {
		pair<int, int> u = Q.front(); Q.pop();
		for(int i = 0; i <= 3; ++ i) {
			int x = u.first + dx[i];
			int y = u.second + dy[i];
			if(x < 0 || x > n || y < 0 || y > m) continue;
			if(!d[x][y]) {
				d[x][y] = d[u.first][u.second] + 1;
				Q.push(make_pair(x, y));
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 1; j <= m; ++ j) {
			ans = max(ans, d[i][j]);
		}
	}
	printf("%d\n", ans - 1);
} 

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

struct Item
{
    double w, v, cp;
};

bool compare(const Item &x, const Item &y)
{
    return x.cp > y.cp;
}

int main(){
    int N, W;
    scanf("%d%d", &N, &W);
    Item items[N];
    for(int i=0; i<N; i++)
    {
        scanf("%lf%lf", &items[i].v, &items[i].w);
        items[i].cp = items[i].v / items[i].w;
    }
    sort(items, items+N, compare);
    double answer = 0;
    for(int i=0; i<N; i++)
    {
        if(W >= items[i].w) answer += items[i].v;
        else answer += items[i].cp * (double) W;
        W -= items[i].w;
        if(W <= 0) break;
    }
    printf("%.10lf", answer);
}



Measured memory_bytes: 5548
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

int h,w,c;
int mp[8][8];
int bmp[8][8];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(deque<int> x){
  int ans=0;
  rep(i,h){
    rep(j,w){
      bmp[i][j]=mp[i][j];
    }
  }
  //cout<<'a'<<endl;
  int st;
  queue<PII> bfs;
  while(!x.empty() ){
    int nex=x.front();
    x.pop_front();
    if(nex==bmp[0][0]) continue;
    bfs.push(make_pair(0,0));
    st=bmp[0][0];
    bmp[0][0]=nex;
    while(!bfs.empty() ){
      
      PII p=bfs.front();
      bfs.pop();
      rep(i,4){
	int X=p.F+dx[i],Y=p.S+dy[i];
	if(X>=0 && X<h && Y>=0 && Y<w){
 	  if(bmp[X][Y]==st){
 	    bfs.push(make_pair(X,Y));
 	    bmp[X][Y]=nex;
 	  }
 	}
      }
    }
    //cout<<'a'<<endl;
   //    rep(i,h){
   //      rep(j,w){
   //      cout<<bmp[i][j]<<" ";
   //      }
   //     cout<<endl;
   //     }
   //     cout<<endl;
    }
   st=bmp[0][0];
   ans=1;
   bfs.push(make_pair(0,0));
   bmp[0][0]=INF;
   while(!bfs.empty() ){
     PII p=bfs.front();
     bfs.pop();
     rep(i,4){
       int X=p.F+dx[i],Y=p.S+dy[i];
       if(X>=0 && X<h && Y>=0 && Y<w){
 	if(bmp[X][Y]==st){
 	  bfs.push(make_pair(X,Y));
 	  bmp[X][Y]=INF;
 	  ans++;
 	}
       }
     }
   }
   return ans;
  
 }
 int solve(int cnt,deque<int> v){
   int num=0;
   if(cnt==4){
     v.push_back(c);
     num=max(num,solve(cnt+1,v));
     return num;
   }
   if(cnt==5){
     rep(i,5){
       // cout<<v[i]<<" ";
     }
     // cout<<endl;
     num=bfs(v);
     return num;
   }else{
     rep(i,6){
      
 	v.push_back(i+1);
 	num=max(num,solve(cnt+1,v));
 	v.pop_back();
       
     }
     return num;
   }
 }




 signed main(){
   cin.tie(0);	
   //ios::sync_with_stdio(false);
   while(1){
     cin>>h>>w>>c;
     if(h==0) break;
     rep(i,h){
       rep(j,w){
 	cin>>mp[i][j];
       }
     }
     //ans=0;
     deque<int> v={};
     cout<<solve(0,v)<<endl;
     
     // cout<<bfs({2,5,4,6,1})<<endl;
  }

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<queue<int> > Q(N);
    REP(i,N){
        REP(j,N-1){
            int a;
            cin >> a;
            a--;
            Q[i].push(a);
        }
    }

    ll ans = 0;

    set<int> sel;
    REP(i,N){
        sel.insert(i);
    }

    vector<set<int> > se(N);
    //while(1){
    REP(i, N*(N-1)/2){
        bool update = false;
        set<int> now;

        set<int> eraser;
        set<int> inserter;

        //REP(i,N){
        for(auto&& i : sel){
            if(!Q[i].empty()){
                int q = Q[i].front();
                if(se[i].find(q) != se[i].end()){
                    //if(sel.find(i) != sel.end() || sel.find(q) != sel.end()){
                    if(now.find(i) != now.end() || now.find(q) != now.end()){
                        se[q].insert(i);
                        //sel.erase(i);
                        //sel_buf.erase(i);
                        eraser.insert(i);
                    }
                    else{
                        update = true;
                        Q[i].pop();
                        Q[q].pop();
                        //sel.insert(i);
                        //sel.insert(q);
                        //sel_buf.insert(i);
                        //sel_buf.insert(q);
                        //eraser.erase(i);
                        //eraser.erase(q);
                        inserter.insert(i);
                        inserter.insert(q);
                        now.insert(i);
                        now.insert(q);
                        se[i].erase(q);
                        se[q].erase(i);
                    }
                }
                else{
                    se[q].insert(i);
                    //sel.erase(i);
                    //sel_buf.erase(i);
                    eraser.insert(i);
                }
            }
        }

        if(!update) break;
        for(auto&& e : eraser){
            sel.erase(e);
        }
        for(auto&& e : inserter){
            sel.insert(e);
        }
        ans++;
    }

    bool valid = true;
    REP(i,N){
        if(!Q[i].empty()) valid = false;
    }

    if(!valid){
        cout<< -1 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#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 it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>in(n);
  rep(i,n*(n-1)/2){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;
    if(c==d){in[a]++;in[b]++;}
    else if(c>d)in[a]+=3;
    else in[b]+=3;
  }
  //rep(i,n)cout<<in[i]<<endl;
  int num=1;
  vector<int>out(n);
  while(1){
    int maxi=-1;
    rep(i,n)if(!out[i])maxi=max(maxi,in[i]);
    if(maxi==-1)break;
    int co=0;
    rep(i,n)if(maxi==in[i]){co++;out[i]=num;in[i]=-2;}
    num+=co;
  }
  rep(i,n)cout<<out[i]<<endl;
}

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

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

  ll ans = 0;
  for (int a = 1; a <= N; ++a) {
    ans += (N - 1) / a;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  stack<int> s;
  int n;
  while(cin>>n){
    if(n>0) s.push(n);
    if(s.empty()) break;
    if(n==0){
      cout<<s.top()<<endl;
      s.pop();
    }
  }
  return 0;
}

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

string s;
int a, b[3], ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> s;
	for(int i=0; i<s.size(); ++i){
		if(s[i] == 'R'){
			if(a == 3){
				if(b[0] && b[1] && b[2]) ++ans;
				a = 0;
				b[0] = b[1] = b[2] = {};
			}else{
				++a;
				if(!b[a-1]) ++b[a-1];
			}
		}else{
			if(a == 1) b[0] = b[1] = b[2] = {};
			a = (a + 3) % 4;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3244
fun main(args: Array<String>) {
    val tree = CompleteBinaryTree(2000000)
    while (true) {
        val input = readLine()?.split(" ".toRegex()) ?: return
        when (input[0]) {
            "insert" -> tree.insert(input[1].toInt())
            "extract" -> println(tree.extract())
            "end" -> return
        }
    }
}

fun IntArray.swap(i: Int, j: Int) {
    val tmp = this[i]
    this[i] = this[j]
    this[j] = tmp
}

class CompleteBinaryTree(size: Int) {
    private val array = IntArray(size + 1)
    var heapSize = 0
        private set

    fun insert(key: Int) {
        heapSize++
        heapIncreaseKey(heapSize, key)
    }

    private fun heapIncreaseKey(index: Int, key: Int) {
        array[index] = key
        var i = index
        while (i > 1 &&  array[parent(i)] < array[i]) {
            array.swap(i, parent(i))
            i = parent(i)
        }
    }

    fun extract(): Int {
        val max = array[1]
        array[1] = array[heapSize]
        heapSize--
        maxHeapify(1)
        return max
    }

    fun maxHeapify(index: Int) {
        val l = left(index)
        val r = right(index)
        var largest = if (l <= heapSize && array[l] > array[index]) {
            l
        } else {
            index
        }
        if (r <= heapSize && array[r] > array[largest]) {
            largest = r
        }
        if (largest != index) {
            array.swap(index, largest)
            maxHeapify(largest)
        }
    }

    private fun parent(index: Int) = index / 2
    private fun left(index: Int) = 2 * index
    private fun right(index: Int) = 2 * index + 1
}



Measured memory_bytes: 552944
#include <cmath>
#include <complex>
#include <algorithm>
using namespace std;

typedef long double Real;
typedef complex<Real> Point;
#define PCR Point const &
#define X real()
#define Y imag()

const Real EPS = 1e-10;
const Real INF = 1e100;
const Real PI = acos(-1);

struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

Point rSP(Segment const & s, PCR p){
    Point v = pSP(s,p) - p;
    return p + v * Real(2);
}

enum { LEFT = 1, RIGHT = -1, BACK = 2, FRONT = -2, ON = 0 };
// Includes end-points. Comment in to exclude.
int ccw(PCR x, PCR p, PCR q){
    Point a = p - x, b = q - x;
    if(cross(a,b) > EPS) return LEFT;
    if(cross(a,b) < -EPS) return RIGHT;
    if(/* abs(a) < EPS || */ dot(a,b) < -EPS) return BACK;
    if(/* abs(b) < EPS || */ norm(a) < norm(b)) return FRONT;
    return ON;
}

bool isParallel(Segment const & s, Segment const & t){
    return abs(cross(s[1]-s[0],t[1]-t[0])) < EPS;
}

bool isOrthogonal(Segment const & s, Segment const & t){
    return abs(dot(s[1]-s[0],t[1]-t[0])) < EPS;
}


// bool iLL(Segment const & s, Segment const & t){

// }

#include <iostream>
#include <cstdio>

int main(){
    Segment s,t;
    Real x,y;
    int n; cin >> n;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        s[0] = Point(x,y);
        cin >> x >> y;
        s[1] = Point(x,y);
        cin >> x >> y;
        t[0] = Point(x,y);
        cin >> x >> y;
        t[1] = Point(x,y);

        if(isParallel(s,t)) puts("2");
        else if(isOrthogonal(s,t)) puts("1");
        else puts("0");
    }
}

Measured memory_bytes: 1180
from scipy.sparse import*
i=lambda:tuple(map(int,input().split()))
f=csgraph.floyd_warshall
n,m,l=i()
d=eval('[0]*-~n,'*-~n)
exec('a,b,c=i();d[a][b]=c;'*m)
d=f(f(d,0)<=l)
d[d>9e9]=0
for _ in'_'*i()[0]:print(int(d[i()])-1)

Measured memory_bytes: 352872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
bool was[107766];
int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.length(); i++)
    {
        was[s[i]] = true;
    }
    int a = was['N'] + was['S'];
    int b = was['E'] + was['W'];
    if (a == 1 || b == 1)
    {
        puts("No");
    }
    else
    {
        puts("Yes");
    }
    return 0;
}
        

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int cou[100];

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

    rep(i,1,m)
    {
        int a,b;
        cin >> a >>b;
        cou[a]++;
        cou[b]++;
    }

    rep(i,1,n)
    {
        cout << cou[i] << endl;
    }


}

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

int main(){
  int i,j,cnt;
  int x[2];
  cin>>x[0]>>x[1];
  int sum=0;
  for(i=0;i<=1;i++){
    if(x[i]==1)sum+=300000;
    if(x[i]==2)sum+=200000;
    if(x[i]==3)sum+=100000;
  }
  if(x[0]==1 && x[1]==1)sum+=400000;
  cout<<sum;
}

Measured memory_bytes: 256