akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1<<29;


int main(){
  string s1, s2; cin >> s1 >> s2;

  int n = s1.size(), m = s2.size();
  vector<vector<int> > dp(n+1, vector<int>(m+1));
  for(int i=0; i <= n; ++i) dp[i][0] = i;
  for(int i=0; i <= m; ++i) dp[0][i] = i;

  for(int i=1; i <= n; ++i) {
    for(int j=1; j <= m; ++j) {
      // insert delete replace
      int replace = 1;
      if(s1[i-1] == s2[j-1]) replace = 0;

      dp[i][j] = min(dp[i-1][j] + 1, min(dp[i][j-1] + 1, dp[i-1][j-1] + replace));
    }
  }

  cout << dp[n][m] << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

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

ll ts = 1000000007;

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

  char c;
  cin >> c;
  c++;
  cout << c << "\n";
}

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

int main(){
  string s;
  cin>>s;
  if(s.size()<4){
    cout<<"No"<<endl;
    return 0;
  }else if(s.substr(0,4)=="YAKI"){
    cout<<"Yes"<<endl;
    return 0;
  }else cout<<"No"<<endl;
}

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

using namespace std;

int main(){
    int n;
    int counter=1;
    cin>>n;
    
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }

    sort(s,s+n);

    for(int i=1;i<n;i++){
        if(s[i-1]!=s[i]){
            counter+=1;
        }
    }

    cout<<counter<<endl;

}

Measured memory_bytes: 9840
open Batteries
(* --------------Encoder-------------- *)
(* -----function----- *)
(*
let encoder = 0
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Decoder-------------- *)
(* -----function----- *)
(*
let decoder ans = ""
*)

(* -------test------- *)
(* ----------------------------------- *)

(* --------------Processor-------------- *)
(* -----function----- *)
(*
let processor dat = 0
*)

(* -------test------- *)
(* ----------------------------------- *)


(* ----------------main---------------- *)
(*
let () = print_endline (decoder (processor encoder))
*)
(* ------------------------------------ *)
let () = Scanf.scanf "%1d %1d %1d" (fun a b c -> 
                        let fil = List.filter (fun x -> x = 1) [a; b; c] in
                        List.fold_right (+) fil 0 
                        |> Printf.printf "%d\n"
)


Measured memory_bytes: 1408
#include <stdio.h>

int sort(int x[],int l){
	int i,j,k;
	for(i=1;i<=l;i++){
		for(j=l;j>=i+1;j--){
			if(x[j-1]>x[j]){
				k=x[j];
				x[j]=x[j-1];
				x[j-1]=k;
			}
		}
	}
	return 0;
}

int main(void) {
	int a,i,s[1024],g=0;
	scanf("%d",&a);
	for(i=1;i<=2*a;i++){
		scanf("%d",&s[i]);
	}
	sort(s,2*a);
	for(i=1;i<=2*a-1;i+=2){
		g+=s[i];
	}
	printf("%d\n",g);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int main(){
  int N,x=0,ans=0;
  cin >> N;
  char c;
  FOR(i,0,N){
    cin >> c;
    if(c == 'I')x++;
    else x--;
    ans = max(ans,x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*************************************************************************
  >         File: B.cc
  >       Author: Riho.Yoshioka
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 31 Jul 2016 08:11:45 PM CST
*************************************************************************/
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

const int N = 1e5 + 5;
int cnt[N];

int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cnt[i] = 1;
  set<int> s;
  s.insert(1);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (s.count(x)) {
      s.insert(y);
    }
    cnt[x]--, cnt[y]++;
    if (cnt[x] == 0) {
      s.erase(x);
    }
  }
  cout << s.size() << endl;


  return 0;
}


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

int main() {
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2])
    cout << "Yes" << endl;
  else if (N[1] == N[2] && N[2] == N[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double INF = 10000000;
int main(){
  cout << fixed << setprecision(3);
  while (1){
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0){
      break;
    }
    int s, g;
    cin >> s >> g;
    s--;
    g--;
    vector<vector<pair<double, int>>> E(n * n * 30 + 1);
    for (int i = 0; i < m; i++){
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      x--;
      y--;
      for (int j = 1; j <= 30; j++){
        for (int k = j - 1; k <= j + 1; k++){
          if (1 <= k && k <= c){
            for (int l = 0; l < n; l++){
              if (l != y){
                E[l * n * 30 + x * 30 + j - 1].push_back(make_pair((double) d / k, x * n * 30 + y * 30 + k - 1));
              }
              if (l != x){
                E[l * n * 30 + y * 30 + j - 1].push_back(make_pair((double) d / k, y * n * 30 + x * 30 + k - 1));
              }
            }
          }
        }
      }
      if (y == s){
        swap(x, y);
      }
      if (x == s){
        E[n * n * 30].push_back(make_pair((double) d, x * n * 30 + y * 30));
      }
    }
    vector<double> d(n * n * 30 + 1, INF);
    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
    pq.push(make_pair(0, n * n * 30));
    while (!pq.empty()){
      double c = pq.top().first;
      int v = pq.top().second;
      pq.pop();
      if (d[v] == INF){
        d[v] = c;
        for (auto P : E[v]){
          int w = P.second;
          if (d[w] == INF){
            pq.push(make_pair(c + P.first, w));
          }
        }
      }
    }
    double ans = INF;
    for (int i = 0; i < n; i++){
      ans = min(ans, d[i * n * 30 + g * 30]);
    }
    if (ans == INF){
      cout << "unreachable" << endl;
    } else {
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 66440
from math import log10
N = int(input())
ndig = int(log10(N))+1
def dfs(n, s):
    if n==0:
        return 1 if int(s)<=N and "7" in s and "5" in s and "3" in s else 0
    return sum([dfs(n-1,i+s) for i in ["7","5","3"]])
ans = 0
for i in range(3,ndig+1):
    ans += dfs(i, "")
print(ans)

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

int main()
{
	int H, R;
	cin >> H >> R;

	if (R + H == 0)
		cout << 0 << endl;
	else {
		if (R + H < 0)
			cout << -1 << endl;
		else
			cout << 1 << endl;
	}
    return 0;
}


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

const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime（mintが必要）
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// nCkを求めて結果をansに格納したい場合、
// combination c(n);
// mint ans = c(n, k);
// cout << ans.x << endl;
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	// combination C(c*d);
	// mint ans = C(c*d-a*b, c-a+d-b);
	vector<vector<mint>> dp(c+2, vector<mint>(d+2));
	dp[a][b] = 1;
	dp[a][b+1] = a;
	for(int j = b+1; j < d; j++) {
		dp[a][j+1] = dp[a][j]*a;
	}
	dp[a+1][b] = b;
	for(int i = a+1; i < c; i++) {
		dp[i+1][b] = dp[i][b]*b;
	}
	for(int i = a+1; i <= c; i++) {
		for(int j = b+1; j <= d; j++) {
			dp[i][j] = dp[i][j-1]*i + dp[i-1][j]*j - dp[i-1][j-1]*(i-1)*(j-1);
		}
	}
	cout << dp[c][d] << endl;
	// for(int i = 1; i <= c; i++) {
	// 	for(int j = 1; j <= d; j++) {
	// 		cout  << dp[i][j];
	// 		printf("%c", ((j==d)?'\n':' '));
	// 	}
	// }
	return 0;
}

Measured memory_bytes: 73656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353
#define dd double
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int> 
#define int long long 
#define pii pair<int,int>
#define mx 1000000000
#define level 15

int get(int x){
    
}

void solve(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s<<endl;
}

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

    int t=1;
    // cin>>t;
    rep(i,1,t+1){
        solve();
    }
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	string s,t;
	cin>>s>>t;
	int sum=0;
	int i;
	for(i=0;i<L(s);i++)
	sum += s[i]!=t[i];
	cout<<sum<<'\n';
}

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


Measured memory_bytes: 3788
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

int cnt [200];

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

  int n;
  cin >> n;

  string s;
  cin >> s;

  for (char c : s) {
    cnt[c]++;
  }

  Modint ans (1);
  for (int i = 'a'; i <= 'z'; i++) {
    ans *= Modint(cnt[i] + 1);
  }
  ans -= Modint(1);

  cout << ans << endl;
}


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

int main()
{
	char str[255];
	char pass[255];
	
	scanf("%s", &str);
	
	for(int i = 0, j = 0; str[i] != '\0'; i++){
		if(str[i] == '1'){
			pass[j] = '1';
			++j;
			pass[j] = '\0';
		}else if(str[i] == '0'){
			pass[j] = '0';
			++j;
			pass[j] = '\0';
		}else{
			if(j > 0){
				pass[--j] = '\0';
			}
		}
	}
	printf("%s\n", pass);
}

Measured memory_bytes: 1604
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
const int MAXN=200010;
int n,k,c;
char ch[MAXN];
int l[MAXN],r[MAXN];
int main()
{
	read(n),read(k),read(c);
	scanf("%s",ch+1);
	int pre=-3*n,cnt=0;
	for(int i=1;i<=n;i++)
	if(ch[i]!='x'&&i-pre>c&&cnt<=k)
	{
		l[++cnt]=i;
		pre=i;
	}
	pre=3*n,cnt=k;
	for(int i=n;i>=1;i--)
	if(ch[i]!='x'&&pre-i>c&&cnt)
	{
		r[cnt--]=i;
		pre=i;
	}
	for(int i=1;i<=k;i++)
	if(l[i]==r[i]) write(l[i]),putchar('\n');
	return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int M;
	while (~scanf("%d%d", &N, &M)) {
		vector<vector<int> > g(N);
		for (int i = 0; i < M; ++ i) {
			int u, v;
			scanf("%d%d", &u, &v), -- u, -- v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		bool ans = false;
		reu(i, 1, N - 1) {
			bool a = false, b = false;
			for (int j : g[i]) {
				a |= j == 0;
				b |= j == N - 1;
			}
			ans |= a && b;
		}
		puts(ans ? "POSSIBLE" : "IMPOSSIBLE ");
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> A(N+1);
  for (int i = 1; i < N+1; i++) {
    cin >> A.at(i);
  }
  vector<int64_t> B(N+2);
  B.at(N+1)=0;
  for (int i=N; i>0; i--){
    B.at(i)=(B.at(i+1)+A.at(i)) % 1000000007;
  }
  int64_t ans=0;
  for (int i=1; i<N; i++){
    ans += (A.at(i) * B.at(i+1));
    ans = ans % 1000000007;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
int hito[4][3][10];
int main() {
    int a,b,c,d,e;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b>>c>>d>>e;
        hito[b-1][c-1][d-1]+=e;
    }
    for(int x=0;x<4;x++){
        for(int y=0;y<3;y++){
    for(int z=0;z<10;z++){
     cout<<" "<<hito[x][y][z];   
    }
    cout<<endl;
        }
      if(x==3)break;
        for(int i=0;i<20;i++){
            cout<<"#";
        }
        cout<<endl;
    }
}


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

 
ll  INF=101010101010;
vector<ll> h(10101010);
vector<ll> dp(10101010);

ll saiki(int i){
    if(i==0)return 0;
    if(i==1)return abs(h[1]-h[0]);
    if(dp[i]<INF)return dp[i];

    dp[i]=min(saiki(i-1)+abs(h[i]-h[i-1]),saiki(i-2)+abs(h[i]-h[i-2]));
    return dp[i];
}
int main(){
    int n;
    cin>>n;
    rep(i,n)cin>>h[i];
    //INFで初期化
    rep(i,n)dp[i]=INF;

    cout<<saiki(n-1)<<endl;
}

Measured memory_bytes: 160384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld float
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
const ll N = 1e6 + 3 ;
vector<ll> fact(N,0) , invFac(N,0) ;
ll powMod( ll base , ll expo )
{
    ll ans = 1 ;
    while( expo > 0 ){
        if( expo & 1 ){

            ans = ( ans * base ) % hell ;
        }
        base = ( base * base ) % hell ;
        expo >>= 1 ;
    }
    return ans ;
}
ll add( ll x , ll y ){
    return ( x + y ) % hell ;
}
ll sub( ll x , ll y ){
    ll ans = x ;
    ans = ( x - y + hell ) % hell ;
    ans = ( ans + hell ) % hell ;
    return ans; 
}
ll mult( ll x , ll y ){
    ll ans = ( x * y ) % hell ;
    //ans = ( ans + hell ) % hell ;
    return ans ;
}
ll inv( ll x ){
    return powMod( x , hell -2 ) ;
}
ll C( ll x , ll y )
{
    if( x < y || y < 0 )return 0 ;
    ll ans = mult( fact[x] , mult( invFac[y] , invFac[x-y] ) ) ;
    return ans ;
}
void solve()
{
    ll n , ans = 0 , a , b , c , cur = 0 ;
    cin >> n >> a >> b >> c ;
    a = mult( a , inv(100));
    b = mult( b , inv(100));
    c = mult( c , inv(100));
    a = mult( a , inv(sub(1,c)));
    b = mult( b , inv(sub(1,c)));
    //cout << "a : " << a << " b : " << b << " c : " << c << "\n" ; 
    rep( i , n , 2*n )
    {
        //cout << C(i-1,n-1) << "\n" ;
        cur = mult( C(i-1,n-1) , mult(powMod(a,n),powMod(b,i-n)));
        //cout << C(i-1,n-1) << " " << mult(powMod(a,n),powMod(b,i-n)) << " " ;
        cur = add(cur,mult(C(i-1,n-1),mult(powMod(a,i-n),powMod(b,n))));
        //cout << mult(powMod(a,i-n),powMod(b,n)) << "\n" ;
        ans = add( ans , mult(i,cur) ) ;
    }
    ans = mult( ans ,inv(sub(1,c)));
    cout << ans << "\n" ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fact[0] = 1 ;
    rep( i , 1 , N )
        fact[i] = ( fact[i-1] * i ) % hell ;
    invFac[N-1] = inv(fact[N-1]) ;
    for( ll i = N - 2 ; i >= 0 ; i-- ){
        invFac[i] = ( invFac[i+1] * (i+1) ) % hell ;
    }
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 15872
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (1) {
		C -= B;
		if (C <= 0) {
			cout << "Yes";
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No";
			return 0;
		}
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double c1=h*30+m*0.5;
  double c2=m*6;
  
  c1*=pi/180;
  c2*=pi/180;
  double x1=a*cos(c1);
  double y1=a*sin(c1);
  double x2=b*cos(c2);
  double y2=b*sin(c2);
  
  double ans=hypot(x1-x2,y1-y2);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;     
}


Measured memory_bytes: 4116
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main(){
    int N;
    cin>>N;
    if(N>=195)cout<<5<<endl;
    else if(N>=189)cout<<4<<endl;
    else if(N>=165)cout<<3<<endl;
    else if(N>=135)cout<<2<<endl;
    else if(N>=105)cout<<1<<endl;
    else cout<<0<<endl;
}

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

typedef struct {
	int id;
	long long sales;
} Data;

Data data[ 4000 ];

int main( void ) {
	int i, j;
	int n;

	while( scanf( "%d", &n ), n ) {
		int cnt, flag;

		memset( data, 0, sizeof data );

		cnt = 0;
		for ( i = 0; i < n; i++ ) {
			int id, p, q;

			scanf( "%d %d %d", &id, &p, &q );

			for ( j = 0; j < cnt && data[ j ].id != id; j++ ) ;
			if ( j == cnt )
				data[ cnt++ ].id = id;
			data[ j ].sales += (long long)p * q;
		}

		flag = 0;
		for ( i = 0; i < cnt; i++ )
			if ( data[ i ].sales >= 1000000LL ) {
				printf( "%d\n", data[ i ].id );
				flag = 1;
			}
		if ( !flag )
			puts( "NA" );
	}

	return 0;
}

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

using namespace std;
long int N;
int ans=0;

void ame(long long int x,int a,int b,int c){
  if(x>N){
    return ;
  }
  if(a==1&&b==1&&c==1){
    ans++;
  }
  ame(10*x+7,1,b,c);
  ame(10*x+5,a,1,c);
  ame(10*x+3,a,b,1);
}

int main(){
  cin >> N;
  ame(0,0,0,0);
  cout << ans << endl;
}


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

int main(void) {
  int N;
	cin >> N;
  int A[3*N];
  REP(i,3*N) { cin >> A[i]; }
  sort(A, A+3*N,greater<int>());
  ll sum = 0;
  REP(i,N) { sum += A[2*i+1]; }

  cout << sum << '\n';
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
//#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}



int32_t main(int32_t argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
    vs args(argv, argv+argc);
    string sample = make_sample(args, "sample-1");
    ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#endif


    int H,W; cin>>H>>W;
    vs S(H); REP(i,H) cin>>S[i];

    int black = 0;
    REP(i,H)
        REP(j,W) if (S[i][j] == '#') black += 1;

    queue<pii> que;
    var vis = vvb(H, vb(W, False));
    var dist = vvi(H, vi(W, INF));
    que.push(mkpr(0,0));
    dist[0][0] = 0;
    int dx[4] = {-1,1,0,0};
    int dy[4] = {0,0,-1,1};

    while (!que.empty()) {
        var pr = que.front(); que.pop();
        int x = pr.first, y = pr.second;
        vis[x][y] = True;

        REP(i,4) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx<0 or H<=nx or ny<0 or W<=ny or S[nx][ny] == '#')
                continue;

            if (vis[nx][ny])
                continue;

            if (dist[nx][ny] > dist[x][y] + 1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(mkpr(nx,ny));
            }
        }
    }

    int ans = -1;
    if (vis[H-1][W-1]) {
        int path = dist[H-1][W-1] + 1;
        ans = H*W - black - path;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a=0,b=0;
    cin>>n;
    while(n--){
        string s1,s2;
        cin>>s1>>s2;
        if(s1>s2)a+=3;
        else if(s1<s2)b+=3;
        else a++,b++;
    }
    cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 3128
#include <stdio.h>

int main(void){
    int n, m, i;
    scanf("%d %d", &n, &m);
    int a[m];
    for(i=0; i<m; i++)
    scanf("%d", &a[i]);

    int sum = 0;

    for(i=0; i<m; i++)
    sum += a[i];

    int ans;
    if(n-sum>=0)
    ans = n-sum;
    else
    ans = -1;

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 1744
#include <iostream>

int main(){
  int L,R,d,count=0;
  std::cin >> L >> R >> d;
  
  for(int i=L; i<=R; i++){
    if(i%d == 0){count++;}
  }
  
  std::cout << count << std::endl;
  
  return 0;
}


Measured memory_bytes: 3620
function main(input)
{
    const args = input.split('\n');
    const houses = args[1].split(' ').map(x => parseInt(x, 10));
    const heros = args[2].split(' ').map(x => parseInt(x, 10));
    // console.log(houses);
    // console.log(heros);

    var answerCount = 0;

    for (var i = 0; i < heros.length; i++)
    {
    	var enemyCount = houses[i] + houses[i + 1];
    	var killCount = Math.min(enemyCount, heros[i]);
        answerCount += killCount;

        houses[i + 1] = houses[i + 1] - 
          Math.max(killCount - houses[i], 0);
    }
    console.log(answerCount);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main (void){
  int a = 0,b = 0;

  cin >> a >> b;

  if(a % 2 == 0 || b % 2 == 0){
    cout << "Even\n";
  }else{
    cout << "Odd";
  }

  return 0;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n')
	const n = parseInt(args[0], 10)
	const a = args[1].split(' ').map(Number).sort((a, b) => b - a)
	let alice = 0
	let bob = 0

	for (let i = 0; i < n; i++) {
		if (i % 2 === 0) {
			alice += a[i]
		} else {
			bob += a[i]
		}
	}

	console.log(alice - bob)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def cummax(li, first=-float('inf')):
    """
    累積 max
    :param collections.Iterable li:
    :param float first:
    :return:
    """
    cm = first
    ret = []
    for v in li:
        cm = max(v, cm)
        ret.append(cm)
    return ret


N, C = list(map(int, input().split()))
X, V = zip(*[list(map(int, input().split())) for _ in range(N)])

X = np.array(X)
V = np.array(V)

# cs1[i]: 時計回りに i 番目まで食べたときの累計カロリー
cs1 = V.cumsum() - X
# 累積 max
cm1 = np.array(cummax(cs1, first=0))

# cs2[i]: 反時計回りに i 番目まで食べたときの累計カロリー
cs2 = V[::-1].cumsum() - (C - X)[::-1]
# 累積 max
cm2 = np.array(cummax(cs2, first=0))
cs2 = cs2[::-1]
cm2 = cm2[::-1]

ans = max(cm1[-1], cm2[0])
# 時計回りに X[L] まで行って折り返したときの最大
for L in range(len(X) - 1):
    ans = max(ans, cm1[L] + cm2[L + 1] - X[L])
# 反時計回りが先の場合
for r in reversed(range(1, len(X))):
    ans = max(ans, cm2[r] + cm1[r - 1] - (C - X[r]))
print(ans)


Measured memory_bytes: 45152
import math

a,b = map(int,input().split())

x = (a+b)/2

if a % 2 == 0 and b % 2 ==0:
	print(int(x))

if a % 2 == 1 and b % 2 ==0:
	print(int(x+0.5))

if a % 2 == 0 and b % 2 ==1:
	print(int(x+0.5))

if a % 2 == 1 and b % 2 ==1:
	print(int(x))

Measured memory_bytes: 3064
#include <stdio.h>

main() {
    int n;
    scanf("%d",&n);
    int cntEven[100001],cntOdd[100001];

    for (int i = 0; i < 100001; ++i) {
        cntEven[i]=0;
        cntOdd[i]=0;
    }

    int tmp;
    for (int i = 0; i < n; ++i) {
        scanf("%d",&tmp);
        if(i%2==0)cntEven[tmp]++;
        else cntOdd[tmp]++;
    }

    int odd[4]={0,0,0,0},even[4]={0,0,0,0};
    //[max1cnt,max1num,max2cnt,max2num]
    for (int i = 0; i < 100001; ++i) {
        if (even[0] < cntEven[i]) {
            even[2] = even[0];
            even[3] = even[1];
            even[0] = cntEven[i];
            even[1] = i;
        } else if (even[2] < cntEven[i]) {
            even[2] = cntEven[i];
            even[3] = i;
        }
        if (odd[0] < cntOdd[i]) {
            odd[2] = odd[0];
            odd[3] = odd[1];
            odd[0] = cntOdd[i];
            odd[1] = i;
        } else if (odd[2] < cntOdd[i]) {
            odd[2] = cntOdd[i];
            odd[3] = i;
        }
    }

    if(even[1]!=odd[1]){
        printf("%d",n-even[0]-odd[0]);
    } else{
        int a=n-even[2]-odd[0],b=n-even[0]-odd[2];
        printf("%d",a<b?a:b);
    }
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;cin >> n;
	vector<int> v(n);
	
	int ma = 0;
	int mi = 1000000;
	
	REP(i,n)
	{
		cin >> v[i];
		ma = max(ma,v[i]);
		mi = min(mi,v[i]);
	}
	
	if(ma==mi)
	{
		if(ma == n-1 ||ma <= n/2)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else if(ma-mi == 1)
	{
		int cou = 0;
		REP(i,n)
		{
			if(v[i] == mi)cou++;
		}
		int tmp = (n - cou)/2 + cou;
		if(ma > cou && ma <= tmp)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] val = new long[m];
		int[] key = new int[m];
		for(int i = 0; i < m; i++) {
			val[i] = sc.nextLong();
			int b = sc.nextInt();
			int mask = 0;
			for(int j = 0; j < b; j++) {
				int c = sc.nextInt()-1;
				mask += (1 << c);
			}
			key[i] = mask;
		}
		int N = 1 << n;
		long[] cost = new long[N];
		Arrays.fill(cost, Integer.MAX_VALUE);
		cost[0] = 0;
		PriorityQueue<Pair> q = new PriorityQueue<>();
		q.add(new Pair(0, 0));
		while(!q.isEmpty()) {
			Pair p = q.poll();
			if(cost[p.u] < p.w) continue;
			for(int i = 0; i < m; i++) {
				int v = p.u | key[i];
				long w = cost[p.u] + val[i];
				if(w < cost[v]) {
					cost[v] = w;
					q.add(new Pair(v, w));
				}
			}
		}
		if(cost[N-1] == Integer.MAX_VALUE) {
			System.out.println(-1);
		}
		else {
			System.out.println(cost[N-1]);
		}
	}
	static class Pair implements Comparable<Pair>{
		int u; long w;
		public Pair(int _n, long _w) {
			 u = _n; w = _w;
		}
		@Override
		public int compareTo(Pair p) {
			return (w-p.w > 0) ? 1 : (w-p.w < 0) ? -1 : 0;
		}
	}

}


Measured memory_bytes: 34692
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
int main()
{
    lli n, a, b;
    cin >> n >> a >> b;
    // a a a .. a b
    // a a a .. a+1 b
    // a a a .. b b
    // [a * (n-1) + b , b*(n-1)+a]

    cout << max(0LL, b * (n - 1) + a - a * (n - 1) - b + 1) << endl;
}


Measured memory_bytes: 256
thisinput=str(input())
lengthofdelete=len(thisinput)-7
key="keyence"
if lengthofdelete==0:
    if thisinput==key:
        print("YES")
    else:
        print("NO")
else:
    #code
    for x in range(8):
        newstr = thisinput[:x] + thisinput[x+lengthofdelete:]
        if newstr==key:
            print("YES")
            break
        else:
            if x==7:
                print("NO")
            else:
                continue


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main(void) {
	int m, f, r;
	while (true) {
		cin >> m >> f >> r;
		if (m == -1 And f == -1 And r == -1) break;
		if (m == -1 Or f == -1) cout << "F" << endl;
		else if (m + f >= 80)cout << "A" << endl;
		else if (m + f >= 65)cout << "B" << endl;
		else if (m + f >= 50)cout << "C" << endl;
		else if (m + f >= 30 And r < 50)cout << "D" << endl;
		else if (r >= 50)cout << "C" << endl;
		else cout << "F" << endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;

long long n;

int main(){

    cin >> n;
    long long lim;
    lim = sqrt(n) + 1;

    long long i, x, y, x_mem = 1, y_mem = 1, distance, min = INF;
    for (i=1; i<=lim; i++){
        x = i;
        y = n/x;
        distance = x + y - 2;
//        cout << distance << endl;
        if ((n == x*y) && (distance < min)){
            min = distance;
            x_mem = x;
            y_mem = y;
        }
    }

//    cout << "x = " << x_mem << " y = " << y_mem << endl;
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m;
ll v[1005][3];

int main() {
    cin >> n >> m;
    rep(i, n) cin >> v[i][0] >> v[i][1] >> v[i][2];

    ll ans = 0;
    for (int bits = 0; bits < 1<<3; bits++) {
        vector<ll> t(n, 0);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                if (bits & (1 << j)) t[i] += v[i][j];
                else t[i] -= v[i][j];
            }
        }
        sort(t.begin(), t.end(), greater<ll>());
        ll sum = 0;
        rep(i, m) sum += t[i];
        chmax(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,A[50];
int choice(int i,int m){
  if (m==0) return 1;
  if(i>=n) return 0;
  int up=choice(i+1,m)||choice(i+1,m-A[i]);
  return up;                                                   
}

int main(){
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q); 
  for(i=0;i<q;i++){
    scanf("%d",&M);
     if(choice(0,M)==1)printf("yes\n");
     else printf("no\n");
  }  
  return 0;
}
  



Measured memory_bytes: 2104
s=input()
t=input()
n=len(s)
m=len(t)
sl=[0]
for i in s:
    sl.append(sl[-1])
    if i=="A":sl[-1]+=1
    else:sl[-1]+=2
    sl[-1]%=3
tl=[0]
for i in t:
    tl.append(tl[-1])
    if i=="A":tl[-1]+=1
    else:tl[-1]+=2
    tl[-1]%=3
q=int(input())
for _ in range(q):
    a,b,c,d=map(int,input().split())
    a-=1
    c-=1
    ss=sl[b]-sl[a]
    tt=tl[d]-tl[c]
    if ss%3==tt%3:print("YES")
    else:print("NO")

Measured memory_bytes: 11032
def check_block(str)
  q = []
  str.gsub(/[^()\[\]]/, '').chars.each do |c|
    if c == '(' or c == '['
      q.push(c)
    elsif c == ')'
      r = q.pop() rescue nil
      return 'no' if r != '('
    elsif c == ']'
      r = q.pop() rescue nil
      return 'no' if r != '['
    end
  end
  q.count == 0 ? 'yes' : 'no'
end

while gets
  break if $_.chomp == '.'
  puts check_block($_.chomp)
end

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

int main() {
    ll a, b, tmp;
    int k;
    cin >> a >> b >> k;
    bool what = true;
    while (k--) {
        if (what) {
            if (a % 2) {
                tmp = (a-1) / 2;
                a = tmp;
                b += tmp;
                what = !what;
            }
            else {
                tmp = a / 2;
                a = tmp;
                b += tmp;
                what = !what;
            }
        }
        else {
            if (b % 2) {
                tmp = (b-1) / 2;
                a += tmp;
                b = tmp;
                what = !what;
            }
            else {
                tmp = b / 2;
                a += tmp;
                b = tmp;
                what = !what;
            }
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
lst = []
for _ in range(int(input())):
    moji = input().split()
    method = moji[0]
    if len(moji) == 2:
        x = moji[1]
    if method == "0":
        lst.append(x)
    elif method == "1":
        print(lst[int(x)])
    elif method == "2":
        del lst[-1]


Measured memory_bytes: 19828
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(n);
    vector<vll> counter(26, vll(n, 0));

    rep(i, n) {
        ins(s);
        for(auto c: s)
            counter[c - 'a'][i]++;
    }

    rep(i, 26) {
        auto nums = counter[i];
        rep(j, *min_element(nums.begin(), nums.end()))
            cout << (char)(i + 'a');
    }
    out();
}


Measured memory_bytes: 3596
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import bisect
from collections import deque

def main():
	n=II()
	A=[II() for _ in range(n)]

	Q=deque()
	Q.append(A[0])

	for i in A[1:]:
		x=bisect.bisect_left(Q,i)
		if x==0:
			Q.appendleft(i)
		else:
			Q[x-1]=i
	print(len(Q))





















if __name__ == "__main__":
	main()


Measured memory_bytes: 14668
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    n, k = makeMultiInteger(input_string[0])
    return n-k+1


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve()
{
    int ans = 0 , n , tot = 0 , u , v;
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)
        tot += (i*(n-i+1));
    for(int i = 1;i <= n-1 ; ++i)
        cin >> u >> v , ans += (min(u,v)*(n-max(u,v)+1));
    cout << tot-ans;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main() 
{
  long n,m,i,count=0;
  cin>>n>>m;
  long a[n+1];
  bool ans[n+1];
  memset(ans,true,sizeof(ans));
  for(i=1;i<=n;i++)
     cin>>a[i];
   for(i=0;i<m;i++)
   {
   	  long a1,b1;
   	  cin>>a1>>b1;
   	  if(a[a1]>=a[b1])
   	    ans[b1]=false;
   	  if(a[b1]>=a[a1])
   	    ans[a1]=false;
   }
   for(i=1;i<=n;i++)
   {
   	 if(ans[i])
   	 count++;
   }
   cout<<count<<"\n";
   
}

Measured memory_bytes: 4512
def rotate(l, d):
    if d == 'S':
        return [l[4], l[0], l[2], l[3], l[5], l[1]]
    if d == 'N':
        return [l[1], l[5], l[2], l[3], l[0], l[4]]
    if d == 'W':
        return [l[2], l[1], l[5], l[0], l[4], l[3]]
    if d == 'E':
        return [l[3], l[1], l[0], l[5], l[4], l[2]]

l = list(map(int, input().split()))
for c in input():
    l = rotate(l, c)

print(l[0])



Measured memory_bytes: 5600
from operator import itemgetter
N, M = map(int, input().split())
PY = [list(map(int, input().split()))+[i] for i in range(M)]
PY.sort()
now = 1
cnt = 1
for j in range(M):
    if now != PY[j][0]:
        cnt = 1
        now = PY[j][0]
        PY[j].append(cnt)
    else:
        PY[j].append(cnt)
    cnt += 1
PY.sort(key=itemgetter(2))
for i in range(M):
    print(str(PY[i][0]).zfill(6) + str(PY[i][3]).zfill(6))


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

int main(){
  ll N,K,one,co,co2;
  cin >> N >> K;
  
  vector <int> A(N);
  
  rep(i,N){
    cin >> A.at(i);
    if(A.at(i)==1)
      one=i;
  }
  if((N-K)%(K-1)==0)
    N=(N-K)/(K-1)+1;
  else
    N=(N-K)/(K-1)+2;
  
 /* if(one<K || (one>=N-K && one<=N-1)){
    if((N-K)%(K-1)==0)
    	N=(N-K)/(K-1)+1;
    else
      N=(N-K)/(K-1)+2;
   }else{
    
    if((one+1-K)%(K-1)==0)
      co=(one+1-K)/(K-1)+1;
    else
      co=(one+1-K)/(K-1)+2;
    
    if((N-one-K)%(K-1)==0)
      co2=(N-one-K)/(K-1)+1;
    else
      co2=(N-one-K)/(K-1)+2;
    
    
    N=co+co2;
    
  }

  */
  
  
  
  cout << N << endl;
  
}

Measured memory_bytes: 640
mod = [0]
pw = 1
for c in input()[::-1]:
    # 大きい数字での計算方法
    # a と z が互いに素のとき
    # x == y (mod z)なら
    # ax == ay (mod z)
    # 10000 == 1924 (mod 2019)
    # 100000 == 19240 (mod 2019)
    # 100000 == 1060 (mod 2019) 前のpwを10で掛けた分に2019を割る
    mod.append((int(c) * pw + mod[-1]) % 2019)
    pw = pw * 10 % 2019
from collections import *
# 8646 % 2019 = 余り570
# 282668646 % 2019 = 余り570
# 282668646 - 8646 = 282660000
# 282660000 % 2019 = 140000 余り0
# 余りが同じものをn(n - 1) / 2する
print(sum(v * (v - 1) // 2 for v in Counter(mod).values()))

Measured memory_bytes: 75964
#include <stdio.h>
#include<string.h>
 
int main()
{
    int n;
    int p_1=0,p_2=0;
    int vic;
    char x[100],y[100];
    scanf("%d\n",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s %s",x,y);
        vic=strcmp(x,y);
        if(vic==0){
            p_1+=1;
            p_2+=1;
        }else if(vic>0){
            p_1+=3;
        }else{
            p_2+=3;
        }
    }
    printf("%d %d\n",p_1,p_2);
    return 0;
}


Measured memory_bytes: 2740
N = int(input())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    c, s, f = map(int, input().split())
    C[i] = c
    S[i] = s
    F[i] = f

ans_list = [0] * N
for i in range(N-1):
    time = 0
    time = C[i] + S[i]
    for k in range(i+1, N-1):
        if time < S[k]:
            time = S[k] + C[k]
        else:
            time += (S[k] - time) % F[k]
            time += C[k]
    ans_list[i] = time

for i in range(N):
    print(ans_list[i])

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

#define fi first
#define se second

const int N = 111;
const long long mod = 998244353;

using namespace std;

bool bad[N][N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        int n;
        cin >> n;
        if(n % 2){
                for(int i = 1; i <= n / 2; i++){
                        bad[i][n - i] = 1;
                }
        }
        else{
                for(int i = 1; i <= n / 2; i++){
                        bad[i][n - i + 1] = 1;
                }
        }
        vector < pair < int, int > > res;
        for(int i = 1; i <= n; i++){
                for(int j = i + 1; j <= n; j++){
                        if(!bad[i][j]){
                                res.push_back({i, j});
                        }
                }
        }
        cout << res.size() << "\n";
        for(auto p: res){
                cout << p.fi << " " << p.se << "\n";
        }
}


Measured memory_bytes: 384