akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int H, W, K; 
string S[305];
int T[305][305];


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> K;
    for (int i = 0; i < H; ++i) { cin >> S[i]; }

    int idx = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] != '.') {
                T[i][j] = ++idx;
            } else if (j > 0) {
                T[i][j] = T[i][j-1];
            }
        }
        for (int j = W-1; j >= 0; --j) {
            if (S[i][j] == '.' && j < W-1) {
                T[i][j] = T[i][j+1];
            }
        }

    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '.' && T[i][j] == 0 && i > 0) {
                T[i][j] = T[i-1][j];
            }
        }
    }

    for (int i = H-1; i >= 0; --i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '.' && T[i][j] == 0 && i < H-1) {
                T[i][j] = T[i+1][j];
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << T[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


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

	if ( r < 1200 )
	{
		cout << "ABC" << endl;
	}
	else if ( r < 2800 )
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "AGC" << endl;
	}

	return 0;
}


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

int main() {
  int64_t N,M,X,ans=INF;
  cin>>N>>M>>X;
  vector<int64_t> C(N);
  vector<vector<int64_t>> A(N,vector<int64_t>(M));
  rep(i,N){
    cin>>C.at(i);
    rep(j,M){
      cin>>A.at(i).at(j);
    }
  }
  for(int i=0;i<(1<<12);i++){
    bitset<12> s(i);
    bool finish=true;
    int64_t total=0;
    vector<int64_t> score(M,0);
    rep(j,N){
      if(s.test(j)){
        rep(k,M){
          score.at(k)+=A.at(j).at(k);
        }
        total+=C.at(j);
      }
    }
    rep(j,M){
      if(score.at(j)<X) finish=false;
    }
    if(finish) ans=min(ans,total);
  }
  if(ans==INF) cout<<-1;
  else cout<<ans; 
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

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

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 300005;

ll sum[N], v[N];

void add_self(ll &a, ll b){
	a += b;
	if(a >= mod)
		a-=mod;
}

ll mul(ll a, ll b){
	return 1ll* a * b % mod;
}

ll sub(ll a, ll b){
	return (a-b+mod)%mod;
}

int main(){
	fastio;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> v[i];
	sum[0] = v[0];
	for(int i = 1; i < n; i++){
		add_self(sum[i], v[i]);
		add_self(sum[i], sum[i-1]);
	}
	ll ans = 0;
	for(int i = 0; i < n-1; i++){
		add_self(ans, mul(v[i], sub(sum[n-1],sum[i])));
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 6724
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner cin = new Scanner(System.in);

		int N = cin.nextInt();
		long T = cin.nextLong();


		long before = cin.nextLong();
		long tmp;
                if(N>1){
                    tmp = cin.nextLong();
                }else{
                    tmp = 0L;
                }
		long sum =0L;

		for(int i=0;i<N-1;i++){
			if(tmp-before<T){
				sum += T-(tmp-before);
			}
			if(i<N-2){
				before = tmp;
				tmp = cin.nextLong();
			}
		}
		System.out.println(N*T-sum);
	}
}


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

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

    long long ans = (N-1)*(N)/2;
    cout << ans << endl;
    return 0;
}

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

int main() {
	ll x;
	cin >> x;
	if (x<=6) cout << 1 << endl;
	else if (x<=11) cout << 2 << endl;
	else {
		ll p = x / 11;
		ll r = x % 11;
		if (r==0) cout << 2*p << endl;
		else if (r<=6) cout << 2*p+1 << endl;
		else cout << 2*p+2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
<?php
$target = trim(fgets(STDIN));
list($min, $max) = explode(' ', trim(fgets(STDIN)));

$result = 'NG';
for($i=$min; $i<=$max; $i++){
    if($i % $target == 0){
        $result = 'OK';
        break;
    }
}

echo $result;


Measured memory_bytes: 16112
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans = 0;

		int i = 1;
		while (i <= B) {
			if ((long) A * i % B == 0) {
				ans = (long) A * i;

				break;
			} else {
				i++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
from bisect import *

N = int(input())
A = []
for i in range(N):
    A.append(-int(input()))

inf = float('inf')
ret = [inf] * N

ind = 0
for elem in A:
    i = bisect_right(ret, elem)
    ret[i] = elem
    if ind < i:
        ind = i

print(ind+1)
        


Measured memory_bytes: 55768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  int a, b;
  cin >> a >> b;

  double taxa = 0.08;
  double taxb = 0.1;

  int ans = -1;  

  rep(i, 10009) {
    int za = i * 8 / 100 ;
    int zb = i * 10 / 100;
    
    if ((a == za) && b == zb) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;
  int arr[100];
  cin >> N;
  for(int i=0; i < N; i++){
  	cin >> arr[i]; 
  }
  
  int answer = 0;
  
  for(int i=0; i < N-2; i++)
    for(int k=i+1; k < N-1; k++)
      for(int j=k+1; j < N; j++)
        if(arr[i]!=arr[k] && arr[k]!=arr[j] && arr[i]!=arr[j]){
          int tmp = arr[i]>arr[k] ? arr[i] : arr[k];
          tmp = tmp > arr[j] ? tmp : arr[j];
          int tmp2 = arr[i]+arr[k]+arr[j]-tmp-tmp;
          if(tmp2 > 0) answer++;
        }
  cout << answer;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

ll dp[10010][110][2];

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    string s; cin >> s;
    int D; cin >> D;
    int k = s.length();

    dp[0][0][0] = 1ll;
    rep(i,k) rep(d,D) rep(isless,2) {
        int c = s[i] - '0';
        rep(j,10){
            int dj = (d + j) % D;
            if(j < c)
                dp[i+1][dj][1] += dp[i][d][isless];
            else if(j == c)
                dp[i+1][dj][isless] += dp[i][d][isless];
            else{
                if(isless) dp[i+1][dj][isless] += dp[i][d][isless];
            }
            dp[i+1][dj][0] %= mod;
            dp[i+1][dj][1] %= mod;
        }
    }
    cout << (dp[k][0][0] + dp[k][0][1] - 1 + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 17408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;


int main()
{
	long long output = 0;
	int R, B, G, N;
	cin >> R >> B >> G >> N;
	for (int r = 0; r*R <= N; r++)
	{
		for (int g = 0; r*R + g*G <= N; g++)
		{
			int b = (N - r*R - g*G) / B;
			if (r*R + g*G + b*B == N)
			{
				output++;
			}

		}
	}

	cout << output << endl;

}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
#include<iomanip>
#define _USE_MATH_DEFINES
#include<cmath>

int main(){
    double r;
    cin >> r;

    double area =0;
    double circ =0;
    double pi = M_PI;

    area = pi * r * r;
    circ = 2.0 * pi * r;

    cout << fixed << setprecision(6) << area << " " << circ << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 998244353;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ll ans = 1;
    int N; cin>>N;
    map<int, int> mp;
    int d[N]; CINA(d,N);
    sort(d+1,d+N);
    REP(i,N){
        if(i==0){
            if(d[i]==0){
                ++mp[d[i]];
            }else{
                ans = 0;
                break;
            }
        }else if(mp[d[i]-1]>0){
            ans *= mp[d[i]-1];
            ans %= MOD;
            ++mp[d[i]];
        }else{
            ans = 0;
            break;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long a[n][3];
	for(int i=0;i<n;i++)
	{
		for(long long j=0;j<3;j++)
			cin>>a[i][j];
	}
	long long dp[n][3];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(long long i=1;i<n;i++)
	{
		for(long long k=0;k<3;k++)
		{long long m=0;
			for(long long j=0;j<3;j++)
			{
				if(j!=k)
				{
					if(m<dp[i-1][j])
						m=dp[i-1][j];
				}
			}
			dp[i][k]=m+a[i][k];
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	
}

Measured memory_bytes: 4992
#include <iostream>
#include <queue>
using namespace std;
static const int N = 100;
static const int NAV = -1;

int M[N][N];

void bfs(int s, int n, int M[N][N], int d[]) {
    queue<int> Q;
    for (int i = 0; i < n; i++) d[i] = NAV;
    d[s] = 0;
    Q.push(s);

    int u;
    while (!Q.empty()) {
        u = Q.front();
        Q.pop();
        for (int v = 0; v < n; v++) {
            if (M[u][v] != 0 && d[v] == NAV) {
                d[v] = d[u] + 1;
                Q.push(v);
            }
        }
    }
}

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

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    int d[n];
    bfs(0, n, M, d);

    for (int i = 0; i < n; i++) {
        cout << i + 1 << " " << d[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3092
#include<stdio.h>
int main(){
  int i,j,mi,k;
  double c[3],d,min;
  char s[8];
  char w[]={"0123456789abcdef"};
  char n[][10]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
  int p[][3]={{0,0,0},{0,0,255},{0,255,0},{0,255,255},
	     {255,0,0},{255,0,255},{255,255,0},{255,255,255}
  };
  while(scanf("%s",s),s[1]){
    for(i=0;i<3;i++){
      for(j=0;s[i*2+1]-w[j];j++);
      for(k=0;s[i*2+2]-w[k];k++);
      c[i]=j*16+k;
    }
    min=256*256*4;
    for(i=0;i<8;i++){
      for(j=d=0;j<3;j++)d+=(p[i][j]-c[j])*(p[i][j]-c[j]);
      if(min>d){
	min=d;
	mi=i;
      }
    }
    printf("%s\n",n[mi]);
  }
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int64_t N, K;
	cin >> N >> K;

	vector<pair<int64_t, int64_t>> v(N);
	for (int64_t i = 0; i < N; i++) {
		cin >> v.at(i).first >> v.at(i).second;
	}
	sort(v.begin(), v.end());

	int64_t sum = 0;
	for (int64_t i = 0; i < N; i++) {
		sum += v.at(i).second;
		if (K <= sum) {
			cout << v.at(i).first << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    string X;
    cin>>N>>X;
    int pcx=0;
    rep(i,N){
        if(X.at(i)=='1')pcx++;
    }
    if(pcx==1){
        rep(i,N){
            if(X.at(i)=='1'){
                cout<<0<<endl;
            }
            else{
                if(i<N-1){
                    if(X.at(N-1)=='1'){cout<<2<<endl;}
                    else{cout<<1<<endl;}
                }
                if(i==N-1){
                    cout<<2<<endl;
                }
            }
        }
        return 0;
    }
    if(pcx==0){
        rep(i,N){
            cout<<1<<endl;
        }
        return 0;
    }
    vector<int> first(N);//操作一回したあとの数
    vector<int> plus(N,0),minus(N,0);
    int plussum=0,minussum=0;
    if(pcx>1){
        minus.at(N-1)=1%(pcx-1);
        for(int i=N-1;i>=1;i--){
            minus.at(i-1)=minus.at(i)*2%(pcx-1);
        }
        rep(i,N){
            if(X.at(i)=='1'){
            minussum+=minus.at(i);
            minussum%=pcx-1;
            }
        }
    }
    if(pcx>0){
        plus.at(N-1)=1;
        for(int i=N-1;i>=1;i--){
            plus.at(i-1)=plus.at(i)*2%(pcx+1);
        }
        rep(i,N){
            if(X.at(i)=='1'){
            plussum+=plus.at(i);
            plussum%=pcx+1;
            }
        }
    }
    rep(i,N){
        if(X.at(i)=='1'){
            first.at(i)=minussum-minus.at(i);
            if(first.at(i)<0)first.at(i)+=pcx-1;
        }
        else{
            first.at(i)=plussum+plus.at(i);
            first.at(i)%=pcx+1;
            if(first.at(i)<0)first.at(i)+=pcx+1;
        }
    }
    
    /*rep(i,N){
        cout<<first.at(i)<<" ";
    }
    cout<<endl;
    rep(i,N){
        cout<<plus.at(i)<<" ";
    }
    cout<<endl;
    rep(i,N){
        cout<<minus.at(i)<<" ";
    }
    cout<<endl;
    cout<<plussum<<" "<<minussum<<endl;*/

    vector<int> kai(200100);
    kai.at(0)=0;
    for(int i=1;i<200100;i++){
        int x=0;
        bitset<24> s=i;
        rep(j,24){
            if(s.test(j))x++;
        }
        kai.at(i)=kai.at(i%x)+1;
    }
    rep(i,N){
        cout<<kai.at(first.at(i))+1<<endl;
    }
}

Measured memory_bytes: 6812
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;

int main(){
    int N,K;
    cin >>N>>K;
    vi su(N,0);
    rep(i,K){
        int d;
        cin >>d;
        rep(i,d){
            int A;
            cin >>A;
            su[A-1]=1;
        }
    }
    int ans=0;
    rep(i,N){
        if(su[i]==0) ans++;
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 3624
n = int(input())
s = list(map(str, input().strip()))
seed = 131
mod1 = 10 ** 9 + 7
mod2 = 10 ** 9 + 7
lsd = [1] * 6000
lsd2 = [1] * 6000
hs = [1] * 6000
hs2 = [1] * 6000
hs[0] = ord(s[0]) - ord('a')
hs2[0] = ord(s[0]) - ord('a')
for i in range(1, n):
    lsd[i] = lsd[i - 1] * seed % mod1
    lsd2[i] = lsd2[i - 1] * seed % mod2
    hs[i] = (hs[i - 1] * seed + ord(s[i]) - ord('a')) % mod1
    hs2[i] = (hs2[i - 1] * seed + ord(s[i]) - ord('a')) % mod2


def check(x):
    from collections import defaultdict
    g = defaultdict(int)
    for i in range(n - x + 1):
        if i:
            t = (hs[i + x - 1] - hs[i - 1] * lsd[x]) % mod1
        else:
            t = hs[i + x - 1]
        # print(i,t)
        if not g[t]:
            g[t] = i + 1
        elif g[t] + x - 1 <= i:
            return True
    return False


l = 0
r = n
while l < r - 1:
    m = (l + r) // 2
    if check(m):
        l = m
    else:
        r = m - 1

if check(r):
    print(r)
else:
    print(l)


Measured memory_bytes: 44016
prj = {}
prj_inv = {}
s = input()
t = input()
for i, j in zip(s, t):
    if i not in prj and j not in prj_inv:
        prj[i] = j
        prj_inv[j] = i
    elif i in prj and j in prj_inv:
        if prj[i] == j:
            continue
        else:
            print('No')
            break
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int main()
{
	double pi=3.14159265359;
	int n=rd();
	printf("%.10lf\n",pi*2*n);
	return 0;
}

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

signed main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if((a * b) % 2 == 1){
		printf("Odd\n");
	}
	else{
		printf("Even\n");
	}
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int R,G,B,N; cin >> R >> G >> B >> N;

  int cnt = 0;
  for (int r=0;r<=N/R;r++){
    for (int g=0;g<=N/G;g++){
      int res = N - r*R - g*G;
      if (res<0) break;
      if (res%B==0) cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def kouyakusuu(kyori, num):
    ans = kyori[0]
    pre = kyori[0]
    for i in range(num - 1):
        now_point = kyori[i + 1]
        while now_point:
            pre, now_point = now_point, pre % now_point
        if pre < ans:
            ans = pre
        pre = kyori[i + 1]
    return ans


def main():
    num, start = map(int, input().split())
    data = list(map(int, input().split()))
    kyori = [0 for i in range(num)]

    for i in range(num):
        kyori[i] = abs(data[i] - start)

    ans = kouyakusuu(kyori, num)

    print(ans)





if __name__ == '__main__':
    main()

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

int main() {
  int n, a;
  cin >> n >> a;
  n = n % 1000;
  if(n >= 500) {
    n -= 500;
  }
  if(n <= a) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    string s,t;
    cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}

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

int main() {
  long long n,k;
  cin>>n>>k;
  vector<long long> h(n);
  rep(i,n) cin>>h.at(i);
  ///////////////////////
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  long long c=0;
  for(long long i=k;i<n;i++){
    c+= h.at(i);
  }
   cout<<c<<endl;
}




 







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

const ll INF = 1E18+5;
const ll mod = 1E9+7;
int main(){
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    int i, j;
    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
            cin>>a[i][j];
    ll dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    dp[1][1] = 1;
    for(i=1;i<=h;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i][j]!='#'){
            if(a[i][j-1]=='.')
                dp[i][j] = (dp[i][j]+dp[i][j-1])%mod;
            if(a[i-1][j]=='.')
                dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;}
        }
    }
    cout<<dp[h][w];
}




Measured memory_bytes: 12320
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;


int main() {

    int n, a[100000];

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

    sort(a, a + n);
    double r = a[n - 1] / 2.0;
    int mini = 1000000001, ans = 0;
    for(int i = 0; i < n - 1; i++) {
        if(mini > abs(r - a[i])) {
            mini = abs(r - a[i]);
            ans = a[i];
        }
    }

    cout << a[n - 1] << " " << ans << endl;
}


Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    e = IR(m)
    f = [0 for i in range(n+1)]
    ans = [None for i in range(n)]
    i = m-1
    while i >= 0:
        if not f[e[i]]:
            f[e[i]] = 1
        else:
            e.pop(i)
        i -= 1
    ans[:len(e)] = e[::-1]
    k = sum(f)
    for i in range(1,n+1):
        if not f[i]:
            ans[k] = i
            k += 1
    for i in ans:
        print(i)
    return

#B
def B():
    def mul(a,b):
        return (a[0]*b[0]-a[1]*b[1])**2+(a[0]*b[1]+a[1]*b[0])**2
    def factorize(n):
        if n < 4:
            return []
        i = 2
        res = []
        while i**2 < n:
            if n%i == 0:
                res.append(i)
            i += 1
        return res
    q = I()
    power = [i**2 for i in range(1000000)]
    f = defaultdict(lambda : 0)
    for i in power:
        f[i] = 1
    for _ in range(q):
        a,b = LI()
        k = mul((a,b),(a,b))
        fa = factorize(k)
        ans = None
        for i in fa:
            j = k//i
            s = 0
            for m in power:
                if m > i:break
                n = i-m
                if f[n]:
                    s += 1
                    break
            for m in power:
                if m > j:break
                n = i-m
                if f[n]:
                    s += 1
                    break
            if s == 2:
                ans = "C"
                break
        if ans == None:
            print("P")
        else:
            print("C")
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()



Measured memory_bytes: 109248
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			if ((i+1) % 2 == 1 && tmp % 2 == 1) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 35972
#include<bits/stdc++.h>
using namespace std;
const int M=2005;
int n,x,sum;
bitset<M*M>dp;
void in(){scanf("%d",&n);}
void ac()
{
    dp[0]=1;
    for(int i=1;i<=n;++i)scanf("%d",&x),dp|=dp<<x,sum+=x;
    for(int i=sum+1>>1;i<=sum;++i)if(dp[i])printf("%d",i),exit(0);
}
int main(){in();ac();}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

const int MAX = 100000;
const int SENTINEL = 2000000000;

struct Card {
    char suit;
    int val;
};

Card a[MAX], b[MAX];
Card L[MAX/2+1], R[MAX/2+1];

int partition(Card a[], int left, int right) {
    int x = a[right].val;
    int i = left - 1;
    for (int j = left; j < right; ++j) {
        if (a[j].val <= x) {
            ++i;
            Card t = a[j];
            a[j] = a[i];
            a[i] = t;
        }
    }
    Card t = a[right];
    a[right] = a[i+1];
    a[i+1] = t;
    return i + 1;
}

void quick_sort(Card a[], int left, int right) {
    if (left < right) {
        int p = partition(a, left, right);
        quick_sort(a, left, p-1);
        quick_sort(a, p+1, right);
    }
}

void merge(Card a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    L[n1].val = SENTINEL;
    R[n2].val = SENTINEL;

    for (int i = 0; i < n1; ++i) L[i] = a[left+i];
    for (int j = 0; j < n2; ++j) R[j] = a[mid+j];

    int i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        if (L[i].val <= R[j].val) {
            a[k] = L[i++];
        } else {
            a[k] = R[j++];
        }
    }
}

void merge_sort(Card a[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(a, left, mid);
        merge_sort(a, mid, right);
        merge(a, left, mid, right);
    } 
}

void print(Card a[], int n) {
    for (int i = 0; i < n; ++i) {
        cout << a[i].suit << " " << a[i].val << endl;
    }
}

int
main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        char s;
        int v;
        cin >> s >> v;
        a[i].suit = b[i].suit = s;
        a[i].val = b[i].val = v;
    }

    quick_sort(a, 0, n-1);
    merge_sort(b, 0, n);

    bool stable = true;
    for (int i = 0; i < n; ++i) {
        if (a[i].suit != b[i].suit) {
            stable = false;
            break;
        }
    }
    if (stable) cout << "Stable";
    else cout << "Not stable";
    cout << endl;

    print(a, n);

    return 0;
}

Measured memory_bytes: 5436
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    bool ans = false;
    for(int i = 1;i<=9;i++){
    	if(n % i == 0){
    		if(n/i <= 9 and n/i >= 1){
    			ans = true;
    			cout<<"Yes"<<endl;
    			return 0;
    		}
    	}
    }    
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;
ll const MOD = 998244353;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

    if(x%2==0){
        ll a = powM(n,x/2);
        return (a*a)%MOD;
    }else{
        return (n*powM(n,x-1))%MOD;
    }
}

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}

ll dp[100100];


void solve(){
    ll n,W;
    cin>>n>>W;
    vl v(n),w(n);
    ll tot_v = 0;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
        tot_v+=v[i];
    }
    vl dp(tot_v+1,10e9+5);
    dp[0] = 0;

    for(int i=0;i<n;i++){
        for(int j = tot_v-v[i];j>=0;j--){
            dp[j+v[i]] = min(dp[j+v[i]],dp[j]+w[i]);
        }
    }

    ll mx = 0;
    for(ll i=0;i<=tot_v;i++){
        if(dp[i]<=W)
            mx = max(i,mx);
    }
    cout<<mx<<'\n';
}

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

    return 0;
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define MAX_NUM 1005

typedef vector<int> vi;

int main()
{
	while (1)
	{
		int n; cin >> n;
		if (n == 0) return 0;

		vi rec(MAX_NUM, -1);
		vi sum(MAX_NUM, 0);

		rep(i, 0, n)
		{
			string s;

			cin >> s;
			int d = (s[3] - '0') * 10 + (s[4] - '0');

			cin >> s;
			int h = (s[0] - '0') * 10 + (s[1] - '0');
			int m = (s[3] - '0') * 10 + (s[4] - '0');

			int time = d * 60 * 60 + h * 60 + m;

			char e; cin >> e;
			int p; cin >> p;

			if (e == 'I')
			{
				rec[p] = time;
			}
			else if (e == 'O')
			{
				if (p == 0)
				{
					rep(j, 1, MAX_NUM)
					{
						if (rec[j] >= 0)
						{
							sum[j] += time - max(rec[j], rec[0]);
						}
					}

					rec[0] = -1;
				}
				else
				{
					if (rec[0] >= 0)
					{
						sum[p] += time - max(rec[0], rec[p]);
					}

					rec[p] = -1;
				}
			}
		}

		int ans = 0;
		rep(i, 0, MAX_NUM) ans = max(ans, sum[i]);

		cout << ans << endl;
	}
}

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

int main() {
	int N;
	cin >> N;
	map<int, int> Nums;
	for (int i = 2; i <= N; i++) {
		int n = i;
		for (auto& p : Nums) {
			while (n % p.first == 0) {
				n /= p.first;
				p.second++;
			}
			if (n < p.first * p.first) break;
		}
		if (n > 1) Nums[n]++;
	}
	int two = 0, four = 0, fourteen = 0, twentyfour = 0, seventyfour = 0;
	for (auto p : Nums) {
		int& n = p.second;
		if (n >= 2 && n < 4) two++;
		if (n >= 4 && n < 14) four++;
		if (n >= 14 && n < 24) fourteen++;
		if (n >= 24 && n < 74) twentyfour++;
		if (n >= 74) seventyfour++;
	}
	int ans = 0;
	//1 1 75
	ans += seventyfour;
	//1 3 25 
	int n = twentyfour + seventyfour;
	ans += (two + four + fourteen) * n + n * (n - 1);
	//1 5 15
	n = fourteen + twentyfour + seventyfour;
	ans += four * n + n * (n - 1);
	//3 5 5
	n = four + fourteen + twentyfour + seventyfour;
	ans += two * n * (n - 1) / 2 + n * (n - 1) * (n - 2) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));
    int n = sc.nextInt();
    int t = sc.nextInt();
    double a = sc.nextDouble();

    Double[] temps = IntStream.range(0, n).boxed().map(dumy-> t-(sc.nextInt()*0.006)).toArray(Double[]::new);
    
    int ans = 0;
    double min = Double.MAX_VALUE;
    for (int i = 0; i < temps.length; i++) {
        double sub = 0;
        if (a>temps[i]){
            sub = a - temps[i];
        }else{
            sub = temps[i] - a;
        }

        double accu = Math.abs(sub);
        if (accu<min){
            min = accu;
            ans = i+1;
        }
    }
    out.println(ans);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 26964
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string s;
int main()
{
	cin>>s;int n=s.size();
	rep(i,n){
		if(i+1<n && s[i]==s[i+1]){
			cout<<i+1<<' '<<i+2<<endl;return 0;
		}
		if(i+2<n && s[i]==s[i+2]){
			cout<<i+1<<' '<<i+3<<endl;return 0;
		}
	}
	cout<<"-1 -1"<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

struct K {
    int kei;
    bool no_zero;
    K(int kei,bool no_zero) :
        kei(kei),no_zero(no_zero) {};
};

int mypow(int x,int n){
    int ret = 1;
    for(int i=0;i<n;i++){
        ret *= x;
    }
    return ret;
}

int combi(int n,int r){
    if(n < r) return 0;
    int ret = 1;
    for(int i=0;i<r;i++){
        ret *= n-i;
        ret /= i+1;
    }
    return ret;
}

int solve(vector<K> vec){
    for(int i=0;i<vec.size();i++){
        //cout << vec[i].kei << " ";
    }
    //cout << endl;
    int ret = 0;
    vector<int> kei(10);
    for(int i=0;i<10;i++){
        kei[i] = i;
    }
    do{
        int now = 0;
        for(int i=0;i<vec.size();i++){
            if(kei[i] == 0 and vec[i].no_zero) goto end_next;
            now += vec[i].kei * kei[i];
        }
        if(now == 0){
            ret++;
        }
end_next:
        ;
    } while(next_permutation(kei.begin(),kei.end()));
    for(int i=1;i<=10-vec.size();i++){
        ret /= i;
    }
    return ret;
}

int main(){
    while(true){
        map<char,bool> no_zero;
        map<char,int> kei;

        int N;
        cin >> N;
        if(N == 0) break;
        for(int i=0;i<N;i++){
            string s;
            cin >> s;
            if(s.length() != 1){
                no_zero[s[0]] = true;
            }
            for(int j=0;j<s.size();j++){
                no_zero[s[j]] = max(no_zero[s[j]],false);
                if(i == N-1){
                    kei[s[j]] -= mypow(10,s.size()-1-j);
                }else{
                    kei[s[j]] += mypow(10,s.size()-1-j);
                }
            }
        }
        vector<K> vec;
        for(map<char,bool>::iterator it=no_zero.begin();
                it != no_zero.end();
                ++it){
            bool z = (*it).second;
            int k = kei[(*it).first];
            vec.push_back(K(k,z));
        }
        cout << solve(vec) << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
 string s;
 cin >> s;
 bool flag = true;
 for(int i =1 ; i < s.size() ; i++){
 	if(s[i]==s[i-1]){
      flag = false;
      break ;
    }
 }
 cout << (flag?"Good":"Bad") << endl;
  
  return 0;
}

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

struct die_t {
	int top, front, right, left, back, bottom;

	die_t (int t, int f, int r, int l, int bk, int b)
	: top(t), front(f), right(r), left(l), back(bk), bottom(b) { }

	void rotate_swap ( int &a, int &b, int &c, int &d ) {
	swap(a, b); swap(b, c); swap(c, d);
	}

	void rotate_right( void ) { rotate_swap(top,left,bottom,right); }
	void rotate_left ( void ) { rotate_swap(top,right,bottom,left); }
	void rotate_front( void ) { rotate_swap(top,back,bottom,front); }
	void rotate_back ( void ) { rotate_swap(top,front,bottom,back); }
	void rotate_cw   ( void ) { rotate_swap(back,left,front,right); }
	void rotate_ccw  ( void ) { rotate_swap(back,right,front,left); }
};


int main(void) {
	int n;
	while (cin >> n, n) {
		cin.ignore();
		die_t die(1, 2, 3, 4, 5, 6);
		int cnt = 1;
		
		string str;
		for (int i = 0; i < n; i++) {
			getline(cin, str);
			if (str == "North")
				die.rotate_back();
			else if (str == "East")
				die.rotate_right();
			else if (str == "West")
				die.rotate_left();
			else if (str == "South")
				die.rotate_front();
			else if (str == "Right")
				die.rotate_cw();
			else if (str == "Left")
				die.rotate_ccw();
			cnt += die.top;
		}
		
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1216
import sys
from collections import Counter
from decimal import Decimal

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

def gcd(a, b):
    while b: a, b = b, a % b
    return a

N = INT()
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
for i in range(N):
    a = Decimal(input())
    A[i] = int(a * K)
    C[gcd(A[i], L)] += 1

ans = 0
for k1, v1 in C.items():
    for k2, v2 in C.items():
        if k1 == k2:
            if k1*k2 % L == 0:
                ans += v1*(v1-1) // 2
        elif k1 < k2:
            if k1*k2 % L == 0:
                ans += v1 * v2
print(ans)


Measured memory_bytes: 214772
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary
int main()
{
	fast;ll t;t=1;
	while(t--)
	{
		ll k,a,p;
		cin>>k;
		if(k==1){cout<<"1\n";continue;}
		if(k%2==0 || k%5==0){cout<<"-1\n";continue;}
		a=7;p=1;
		while(1)
		{
			a=a%k;
			if(a==0){cout<<p<<"\n";break;}
			p++;
			a=10*a+7;
			//if(p>100000){break;}
		}
	}
}

Measured memory_bytes: 3616
while True :
    a, b = map(int, input().split())
    if a == 0 and b == 0 :
        break
    
    hit = 0
    blow = 0
    if a//1000 == b//1000 :
        hit += 1
    if (a%1000)//100 == (b%1000)//100 :
        hit += 1
    if (a%100)//10 == (b%100)//10 :
        hit += 1
    if a%10 == b%10 :
        hit += 1
    if a//1000 == (b%1000)//100 or a//1000 == (b%100)//10 or a//1000 == b%10 :
        blow += 1
    if (a%1000)//100 == b//1000 or (a%1000)//100 == (b%100)//10 or (a%1000)//100 == b%10 :
        blow += 1
    if (a%100)//10 == b//1000 or (a%100)//10 == (b%1000)//100 or (a%100)//10 == b%10 :
        blow += 1
    if a%10 == b//1000 or a%10 == (b%1000)//100 or a%10 == (b%100)//10 :
        blow += 1
    print(hit, blow)
        


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

int main(){
    ios::sync_with_stdio(false);
    int n = input(), m = input();
    vector<bool> kids(n);
    for(int i = 1; i <= m; ++i){
        int num = input();
        for(int j = 1; j <= num; ++j) kids[input()-1] = true; 
    }
    cout << count_if(all(kids), [](bool cur){return cur == false;});
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<"\n";
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
// #define find(m,i) (m.find(i)!=m.end())
// #define find(m,i) (m.find(i)==m.end())
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 1000000000000000000
#define imin -1000000000000000000
// #define NP 50000
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
//  IIITA
//SUNEET KUMAR -->  ਸੁਨੀਤ
 
// scanning numbers extremely fast/////////
void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
// ========================================
int power(int a,int x)
{
        a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
 
void nhi_degi()
{
   int a,b,n;cin>>a>>b>>n;
   int z=(n-b);
   int x=b+min(b-1,z);
   int a1=(x/b)*a;
   int a2=((a*x)/b);
   int v=min(b-1,n);
   int a3=(a*v)/b;
//    int a4=
   cout<<max(a2-a1,a3);el
}
signed main()
{
    // cases(t)
    // {
        nhi_degi();
    // }
}

Measured memory_bytes: 3680
N=int(input())
A=[int(x) for x in input().split()]
A=sorted(A,reverse = True)
b=float('inf')
for i in range(1,N):
  b=min(b,abs(A[0]/2-A[i]))
  if b ==abs(A[0]/2-A[i]):
    q=A[i]
  
print(A[0],q)

Measured memory_bytes: 14388