akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	string s,t;
	cin>>s>>t;
	ll n,m;
	n=s.length();
	m=t.length();
	ll dp[n+1][m+1];
	//string k[n+1][m+1];
	for(ll i=0;i<=n;i++){
		dp[i][0]=0;
		//k[i][0]="";
	}
	for(ll i=0;i<=m;i++){
		dp[0][i]=0;
		//k[0][i]="";
	}
	//string ans="";
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=m;j++){
			dp[i][j]=INT_MIN;
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1>=max(dp[i-1][j],dp[i][j-1]) ? dp[i-1][j-1]+1 : max(dp[i-1][j],dp[i][j-1]);
				//k[i][j]=dp[i-1][j-1]+1>=max(dp[i-1][j],dp[i][j-1]) ? k[i-1][j-1]+s[i-1] : "";
				//ans=dp[i-1][j-1]+1>max(dp[i-1][j],dp[i][j-1]) ? ans+t[j-1] : "";
			}
			else{
				dp[i][j]=(dp[i-1][j]>=dp[i][j-1]) ? dp[i-1][j] : dp[i][j-1];
				//k[i][j]=(dp[i-1][j]>=dp[i][j-1]) ? k[i-1][j] : k[i][j-1];
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	string an = "";
  ll i = s.size(), j = t.size();
  while (i >= 1 && j >= 1) {
    if (dp[i][j] == dp[i-1][j]) i--;
    else if (dp[i][j] == dp[i][j-1]) j--;
    else {
      an += s[i-1];
      i--;
      j--;
    }
  }
 
  reverse(an.begin(),an.end());
  cout << an << '\n';
	return 0;
}

Measured memory_bytes: 70656
#pragma GCC optimize "trapv" 
#include<bits/stdc++.h>
#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define inarr(arr,n)   rep(i,a,n)cin>>arr[i]
#define ll             long long int
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define IOS            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret            return 0
#define pi             3.1415926536
#define hell           1000000007
#define narak          998244353
const int inf1=1e9;
const ll inf2=1e18;
const int N=100000;
using namespace std;
int dirs[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};

int solve(){
 int n;cin>>n;
 map<ll,ll>mp;
 ll arr[n];
 rep3(n){
     int t;cin>>t;
     mp[t]++;
     arr[i]=t;
 }
 ll ans=0;
 for(auto i:mp){
     ans=ans+(i.y)*(i.y-1)/2;
 }
 rep3(n){
     ll t=ans-mp[arr[i]]*(mp[arr[i]]-1)/2;
     t=t+(mp[arr[i]]-1)*(mp[arr[i]]-2)/2;
     cout<<t<<endl;
 }
 ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef cat
    cat();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    if ( n%2 == 0 ) {
        cout << "No";
        return 0;
    }
    string k;
    string r;
    for  ( int i = 0; i <= (n-1)/2-1; i++ )
        k+= s[i];
    for  (int i = (n+3)/2-1; i < n ; i++ )
        r+= s[i];
    if ( k == r ) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_K = 100000;
int K;
ll A[MAX_K];
Pll dp[MAX_K+1]; // dp[i] := i回目のゲームの前の人数としてあり得る最大値と、最小値。

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

  cin >> K;
  rep(i, K) cin >> A[i];

  dp[K] = Pll(2, 2);

  for (ll i = K-1; i >= 0; --i) {
      ll lb = dp[i+1].fi, ub = dp[i+1].sc;
      ll mi = ((lb+A[i]-1)/A[i])*A[i];
      ll ma = (ub/A[i])*A[i];
      if (mi > ub || ma < lb) {
          cout << -1 << endl;
          return 0;
      }
      dp[i] = Pll(mi, ma+A[i]-1);
  }


  cout << dp[0].fi << ' ' << dp[0].sc << endl;
  return 0;
}


Measured memory_bytes: 2560
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

n = int(input())
a = 1
b = 1
tmp_ans = 0
ans = 10**12

if is_prime(n) == True:
    print(n - 1)
elif is_prime(n) == False:
    for i in range(2, int(math.sqrt(n))+1):
        j = n // i
        if n == i*j:
            tmp_ans = (i-a) + (j-b)
            if tmp_ans < ans:
                ans = tmp_ans
    print(ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

typedef long long int ll;

int vecfind(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int n = 3;
  vector<int> a(n), b(n), c(n);
  rep(i, n) { cin >> a[i]; }
  rep(i, n) { cin >> b[i]; }
  rep(i, n) { cin >> c[i]; }

  int m;
  cin >> m;
  vector<int> v(m);
  rep(i, m) { cin >> v[i]; }

  sort(all(v));
  if ((vecfind(v, a[0]) && vecfind(v, a[1]) && vecfind(v, a[2])) ||
      (vecfind(v, b[0]) && vecfind(v, b[1]) && vecfind(v, b[2])) ||
      (vecfind(v, c[0]) && (vecfind(v, c[1]) && vecfind(v, c[2])) ||
       (vecfind(v, a[0]) && vecfind(v, b[0]) && vecfind(v, c[0])) ||
       (vecfind(v, a[1]) && vecfind(v, b[1]) && vecfind(v, c[1])) ||
       (vecfind(v, a[2]) && vecfind(v, b[2]) && vecfind(v, c[2])) ||
       (vecfind(v, a[0]) && vecfind(v, b[1]) && vecfind(v, c[2])) ||
       (vecfind(v, a[2]) && vecfind(v, b[1]) && vecfind(v, c[0])))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(){
  int A, B;
  cin >> A >> B;
  rep(i, 10000){
    if (((i+1) * 8 / 100) == A && ((i+1) * 10 / 100) == B){
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto it = begin(v); it != end(v); ++it) {
    if (it != begin(v)) os << " ";
    os << *it;
  }
  return os;
}

const string ln = "\n";
template <class T>
ostream &operator,(ostream &os, const T &v) { return os << " " << v; }
ostream &operator,(ostream &os, const string &s) {
  return (s == ln ? os << endl : os << " " << s);
}

// =============================================================================

int main() {
  int N, L, p = -1;
  cin >> N >> L;
  vector<int> a(N);
  for (int &i: a) cin >> i;
  REP(i,N-1) {
    if (a[i] + a[i+1] >= L) p = i;
  }
  if (p == -1) {
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  for (int i = 0; i < p; ++i)
    cout << i + 1 << endl;
  for (int i = N-2; i >= p; --i)
    cout << i + 1 << endl;
  return 0;
}


Measured memory_bytes: 1152
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def factorization(n):
    factors = []

    if n < 2:
        return n

    while n % 2 == 0:
        factors.append(2)
        n //= 2

    for i in range(3, int(n ** 0.5) + 5, 2):
        while n % i == 0:
            factors.append(i)
            n //= i

    if n != 1:
        factors.append(n)

    return factors


def main():
    from collections import Counter

    n = int(input())

    if n == 1:
        print(0)
        sys.exit()

    factors = Counter(factorization(n))

    ans = 0
    i = 0
    flag = True

    while flag:
        flag = False
        i += 1
        for key in factors.keys():
            if factors[key] >= i:
                ans += 1
                factors[key] -= i
                flag = True

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 66296
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

typedef pair<int, int> pii;

int n, k, l, p, q, r, s;
int pa[2][200000], sz[2][200000];
pii rts[200000];

int root(int k, int v) {
	while (pa[k][v] != -1) v = pa[k][v];
	return v;
}

int merge(int k, int u, int v) {
	int ru = root(k, u), rv = root(k, v);
	if (ru == rv) return ru;
	if (sz[k][ru] > sz[k][rv]) return merge(k, v, u);
	pa[k][ru] = rv;
	sz[k][rv] += sz[k][ru];
	return rv;
}

int main(int argc, char **argv) {
	cin >> n >> k >> l;
	REP(i, n) {
		pa[0][i] = pa[1][i] = -1;
		sz[0][i] = sz[1][i] = 1;
	}
	REP(i, k) {
		cin >> p >> q;
		--p; --q;
		merge(0, p, q);
	}
	REP(i, l) {
		cin >> r >> s;
		--r; --s;
		merge(1, r, s);
	}

	map<pii, int> cnt;
	REP(i, n) {
		rts[i] = MP(root(0, i), root(1, i));
		if (cnt.find(rts[i]) == cnt.end()) {
			cnt.insert(MP(rts[i], 1));
		}
		else {
			++cnt[rts[i]];
		}
	}

	REP(i, n) {
		if (i != 0) cout << " ";
		cout << cnt[rts[i]];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 16640
#include<iostream>
using namespace std;
int a[3][101];
int n;
int sum=0;
/*int dfs(int x,int y)
{
	
}*/
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[1][i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>a[2][i];
	}
//	dfs(1,1)
	int k[101];
	for(int i=1;i<=n;i++)
	{
		int t=0;
		for(int j=1;j<=i;j++)
		{
			t+=a[1][j];
		}
		for(int j=i;j<=n;j++)
		{
			t+=a[2][j];
		}
		k[i]=t;
	}
	int l=0;
	for(int i=1;i<=n;i++)
	{
		if(k[i]>l) l=k[i];
	}
	cout<<l<<endl;
	return 0;
 } 

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

int main()
{
	int N,K;
	cin >> N >> K;
	int ans = 1;
	for (int i = 0; i < N; i++)
	{
		if (ans <= K)
			ans *= 2;
		else
			ans += K;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n,m;cin>>n>>m;
  int x[m+10],y[m+10];
  rep(i,0,m){
    cin>>x[i]>>y[i];
    x[i]--,y[i]--;
  }

  vector<int>count(n+10,1);
  vector<bool>visited(n+10,false);
  visited[0]=true;

  rep(i,0,m){
    int a,b;a=x[i],b=y[i];

    count[a]--;
    count[b]++;

    if(visited[a])visited[b]=true;

    if(count[a]==0)visited[a]=false;
    if(count[b]==0)visited[b]=false;
  }


  int ans=0;
  rep(i,0,n)if(visited[i])ans++;

  out(ans);

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define ld double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
ll binpow(ll a,ll b,ll m=mod)
{
    a%=mod;
    ll res=1;
    while(b>0)
    {
        if(b&1)
        res=(a*res)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
string s[2];
ll n;
vector<ll> aw;
void fun(ll i)
{   //cout<<s[0]<<" ";
    string r=s[0].substr(0,i);
    aw.pb(n-i);
    string e=s[0].substr(i);
    reverse(e.begin(),e.end());
      s[0]=e+r;
      //cout<<i<<" "<<s[0]<<"\n";
}
main()
{
    IO
    ll n;
    cin>>n;
    ll g=n%1000;
    g=(1000-g)%1000;
    cout<<g;
}


Measured memory_bytes: 3612
ans = 0
N, M, C = map(int,input().split())
B = list(map(int, input().split()))
for i in range(N):
  a = list(map(int, input().split()))
  curr = C
  for i in range(M):
    curr += B[i] * a[i]
  if curr > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3064
let read () = 
  let rec iter n =
    if n = 0 then []
    else let arr = Array.of_list @@ List.map int_of_string @@ Str.split (Str.regexp "") (read_line ()) in
         arr :: iter (n - 1) in
  Array.of_list @@ iter 12
       
let rec iteri s t f = if s > t then () else begin f s; iteri (s + 1) t f end

let solve arr =
  let rec remove x y =
    if x >= 0 && x <= 11 && y >= 0 && y <= 11 && arr.(x).(y) = 1 then 
      begin
        arr.(x).(y) <- 0;
        remove (x+1) y;
        remove (x-1) y;
        remove x (y+1);
        remove x (y-1)
      end
    else () in
  let cnt = ref 0 in
  iteri 0 11 (fun i -> iteri 0 11 (fun j -> if arr.(i).(j) = 1 then begin incr cnt; remove i j end else ()));
  !cnt

let _ = 
  let rec loop () =
    let arr = read () in
    Printf.printf "%d\n" @@ solve arr;
    ignore @@ read_line ();
    loop ()
  in try loop () with End_of_file -> ()

Measured memory_bytes: 2588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int ans = n, left = 0, right = n-1;
    while(left < right){
        while(left + 1 < n && a[left] != a[left+1]) left++;
        while(right - 1 > 0 && a[right] != a[right-1]) right--;
        if (left >= right) break;
        ans -= 2;
        left++;
        right--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

string op;
ll a;
ll b;


int main() {
    while(1){
        cin >> a >> op >> b;
        if(op == "+"){
            cout << a + b << endl;
        } else if(op == "-"){
            cout << a - b << endl;
        } else if(op == "/"){
            cout << a / b << endl;
        } else if(op == "*") {
            cout << a * b << endl;
        } else if(op == "?"){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  V<int> a;
  cin >> n;
  a.resize(n);

  rep(i, n) {
    cin >> a[i];
  }

  int odd_count = 0;
  rep(i, n) {
    if(a[i] % 2 == 1) {
      odd_count++;
    }
  }

  if(odd_count % 2 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
const int N = 100005, L = 400005, C = 27;

int n, q, ans[N], dt[N][C][C], cc;
string a[N], ord;

struct node {
	int c[C], t[C];
	void upd (int P, int I);
	void calc (int P, int I);
} x[L];

void node::upd (int P, int I) {
	if(I == a[P].size()) return;
	int T = a[P][I] - 'a'; c[T]++;
	if(c[T] == 1) t[T] = ++cc;
	x[t[T]].upd(P, I+1);
}

void node::calc (int P, int I) {
	if(I == a[P].size()) {
		for(int i=0;i<26;i++) ans[P] += c[i];
		return;
	}
	int T = a[P][I] - 'a';
	for(int i=0;i<26;i++) {
		dt[P][T][i] += c[i];
	}
	x[t[T]].calc(P, I+1);
}

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++) {
		cin >> a[i];
		x[0].upd(i, 0);
	}
	for(int i=1;i<=n;i++) {
		x[0].calc(i, 0);
	}
	cin >> q;
	for(int i=1;i<=q;i++) {
		int T, K;
		cin >> T >> ord;
		K = ans[T];
		for(int i=0;i<26;i++) {
			for(int j=i+1;j<26;j++) {
				K += dt[T][ord[i]-'a'][ord[j]-'a'];
			}
		}
		printf("%d\n",n-K);
	}
}


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

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A, A+N);

    ll ans = 1, size = A[0];
    for(int i = 1; i < N; i++){
        if(size*2 >= A[i])    ans++;
        else    ans = 1;
        size += A[i];
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
h, w = map(int, input().split())
grid = []

def method(grid, cnt, i):
    if cnt == len(grid) - 1 and grid[cnt][i] == '.':
        w_list.append(i)
    elif cnt < len(grid) - 1 and grid[cnt][i] == '.':
        method(grid, cnt + 1, i)
    else:
        False


for i in range(h):
    n = list(input())
    if n.count('.') == len(n):
        pass
    else:
        grid.append(n)

w_list = []
cnt = 0
for i in range(w):
    # ここで最初の値が。なら、次の配列も見に行くアルゴリズムをつくる
    # [
    # [000], ここで最初は０なので、下の配列も見に行く。これを。があるだけ繰り返す
    # [010],
    # [010],
    # [010]
    # ]
    method(grid, cnt, i)

w_list.reverse()

for n in w_list:
    for i in grid:
        i.pop(n)


for i in grid:
    print(''.join(i))


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int N;
    cin >> N;
    int min = 1000;
    int max = 0;
    REP(i,N){
        int a;
        cin >> a;
        if(a < min) min = a;
        if(a > max) max = a;
    }
    cout << max-min << endl;
    return 0;
}


Measured memory_bytes: 256
s=input()
ct1=0;ct2=0
for i in range(len(s)):
  if i%2==0:
    if s[i]=='0':
      ct1+=1
  else:
    if s[i]=='1':
      ct1+=1
for i in range(len(s)):
  if i%2==0:
    if s[i]=='1':
      ct2+=1
  else:
    if s[i]=='0':
      ct2+=1
print(len(s)-max(ct1,ct2))

Measured memory_bytes: 3188
X = int(input())

if 400 <= X and X <= 599:
  print(8)
elif 600 and X <= 799:
  print(7)
elif 800 <= X and X <= 999:
  print(6)
elif 1000 <= X and X <= 1199:
  print(5)
elif 1200 <= X and X <= 1399:
  print(4)
elif 1400 <= X and X <= 1599:
  print(3)
elif 1600 <= X and X <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9188
#include <stdio.h>
typedef long long ll;
int main()
{
	ll a,b,yue,bei;
	ll gcd(ll a,ll b);
	while(scanf("%lld %lld",&a,&b)!=EOF)
	{
		yue=gcd(a,b);
		bei=a*b/yue;
		printf("%lld %lld\n",yue,bei);
	}
	
}
ll gcd(ll a,ll b)
{
	return b==0? a:gcd(b,a%b);
}


Measured memory_bytes: 2000
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *r,*l,*p,*z;
  int key;
};
 
typedef struct node * Node;
Node root, NIL;
int max;

Node find(int k,Node u){
  if(u==NULL ||k==u->key){
    return u;
  }
  if(k<u->key){
    return find(k,u->l);
  }
  else {
    return find(k,u->r);
  }
}
void insert(int k){
  int H;
  Node y=NIL,x=root,z;
    z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  while( x != NIL ){   
    y = x;
    if ( z->key < x->key ){ 
      x = x->l; 
    }
    else {
      x = x->r; 
    }
  } 
  z->p = y; 
  if ( y == NIL ){  
    root = z;
  }   
  else {
    if (z->key < y->key) { 
      y->l = z; 
    }
    else { 
      y->r = z; 
    }
  }
}
  
void inorder(Node u){   
  if ( u == NIL ) return; 
  inorder(u->l); 
  printf(" %d", u->key);
  inorder(u->r); 
}
 
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
  
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  max = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp(com,"find")==0){
      scanf("%d",&x);
      if(find(x,root)==NULL){
	printf("no\n");
      }
      else{
	printf("yes\n");
      }
    }
      
  }
  return 0;
}

Measured memory_bytes: 19360
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    int n=readI();
    long d = readLong();
    d = d*d;
    int count=0;
    for(int i=0;i<n;i++){
      long x = readLong(),y=readLong();
      x = x*x+y*y;
      if(x<=d){
        count++;
      }
    }
    pl(count+"");
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static int readI(){
    return stoi(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
  public static int[] Itoi(Integer a[]){
    int[]result=new int[a.length];
    for(int i=0;i<a.length;i++){
      result[i]=a[i];
    }
    return result;
  }
}


Measured memory_bytes: 54092
cr = input().split()
c = int(cr[0])
r = int(cr[1])
i = 0
n = []
michi = []
citi = [0] * c
while(i < r):
    michi.append(input().split())
    i += 1
    pass
i = 0
while(i < r):
    src = int(michi[i][0])
    dst = int(michi[i][1])
    citi[src-1] += 1
    citi[dst-1] += 1
    i += 1
    pass
i = 0
while(i < c):
    print(citi[i])
    i += 1

Measured memory_bytes: 3064
x, y, a, b, c = map(int,input().split())

red = [0] + list(map(int,input().split()))
red.sort()
green = [0] + list(map(int,input().split()))
green.sort()
colorless = [0] + list(map(int,input().split()))
colorless.sort()

#print(red,green, colorless)

z = x + y
deliscious = 0
countx = 0
county = 0
for i in range(z):
    p = red[len(red)-1]
    q = green[len(green)-1]
    r = colorless[len(colorless)-1]
    #print(p,q,r,countx,x,county,y)
    if p >= q and p > r and countx < x:
        deliscious += p
        red.pop()
        countx += 1
    elif q >= p and q > r and county < y:
        deliscious += q
        green.pop()
        county += 1
    else:
        deliscious += r
        colorless.pop()
    if countx == x:
        red.append(0)
        countx += 1
    if county == y:
        green.append(0)
        county += 1
        
    
    #print(red,green, colorless,deliscious)
    
print(deliscious)

Measured memory_bytes: 23072
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  char c[5] = {'a','e','i','o','u'};
  char p;
  cin>>p;
  int ans=0;
  rep(i,0,5){
    if(p==c[i]) ans++;
  }
  cout<<(ans?"vowel":"consonant");
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

std::vector<int > edge[300005];

int main(){
    int N, M;
    scanf("%d", &N);
    scanf("%d", &M);
    int u, v;
    std::vector<int> dist(300005, -1);

    for (int i=0; i<M; i++){
        scanf("%d", &u);
        scanf("%d", &v);
        u--;
        v--;
        edge[u].push_back(v+N);
        edge[u+N].push_back(v+2*N);
        edge[u+2*N].push_back(v);
    }
    int S, T;
    scanf("%d", &S);
    scanf("%d", &T);
    S--;
    T--;
    dist[S]=0;
    std::queue<int> queue;
    queue.push(S);
    while(queue.size()>0){
        int v = queue.front();
        queue.pop();
        for (int vv : edge[v]){
            if (dist[vv]==-1){
                dist[vv]=dist[v]+1;
                queue.push(vv);
            }
        }
    }
    if (dist[T]!=-1) dist[T]=dist[T]/3;
    printf("%d\n", dist[T]);
}

Measured memory_bytes: 20544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);

  rep(i,n) {
    cin >> a.at(i);
  }

  ll sum_money = 1000;
  ll stock_count = 0;

  rep(i,n) {
    if(i == n - 1) {
      sum_money += stock_count * a.at(n - 1);
      //cout << 1 << endl;
      break;
    }
    else if(a.at(i) < a.at(i + 1)) {
      stock_count += sum_money / a.at(i);
      sum_money = sum_money % a.at(i);
    //  cout << 2 << endl;
    }
    else if(a.at(i) > a.at(i + 1)) {
      sum_money += stock_count * a.at(i);
      stock_count = 0;
    //  cout << 3 << endl;
    }
    else if( a.at(i) == a.at(i+1)) {
    //  cout << 4 << endl;
      continue;
    }
  }

  //sum_money += stock_count * a.at(n - 1);
  
  cout << sum_money << endl;
}


Measured memory_bytes: 3628
program double_helix
  implicit none
  character(1) :: b
  read(*,*) b
  write(*,'(a)') achar(pair(ichar(b)))
contains
  integer function pair(n)
    integer, intent(in) :: n
    pair = (44687-703*n)/(703-11*n)
  end
end program double_helix

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000

/*
  考え方
  10^9+7 で割ったあまりを求めるということなので、積か和を 10^9+7 で割りながらやっていくやつだろうなと。
  まあじゃあ、各文字についてでしょう。
  そう、それぞれの文字について考えていけば良いというように分解できることが全て。
*/

int main(){
  char buf[100010];
  int N;

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%d", &N);

  char *s=(char *)malloc(sizeof(char)*N);

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%s", s);

  int *count=(int *)calloc(26, sizeof(int));
  rep(i,N){
    count[s[i]-'a']++;
  }

  int ans=1;
  rep(i,26){
    ans=((long)ans*(count[i]+1))%1000000007;
    //printf("%d\n", ans);
  }

  printf("%d\n", ans-1);

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i<n;i++){
            a[i] = sc.nextInt();
        }

        // sort begin
        boolean flag = true;
        int cnt = 0;
        while (flag){
            flag = false;
            for (int j = n-1; j>0; j--){
                if (a[j]<a[j-1]){
                    int temp = a[j];
                    a[j] = a[j-1];
                    a[j-1] = temp;
                    flag = true;
                    cnt++;
                }
            }
        }
        //sort end
        print(a);
        System.out.println(cnt);
    }

    public static void print(int[] a){
        System.out.print(a[0]);
        for (int i=1;i<a.length;i++){
            System.out.print(" "+a[i]);
        }
        System.out.println();
    }
}

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

int main() {
    int N;
    cin >> N;
    int w[N];
    for(int i = 0; i < N; i++){
        cin >> w[i];
    }
    int result = 1000000;
    for(int T = 1;T < N - 1;T++){
        int l = 0;
        int r = 0;
        for(int i = 0; i < N; i++){
            if(i <= T){
                l += w[i];
            }else{
                r += w[i];
            }
        }
        result = min(result,abs(r - l));
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
char dummy;
int r,c,i,j;

scanf("%d %d",&r,&c);

int race[r][c];

for(i = 0; i < r; i++){

  for(j = 0; j < c; j++){
  scanf("%d",&race[i][j]);
  }
}
int sum[r*c];
for(i = 0; i < r; i++){
sum[i] = 0;
  for(j = 0; j < c; j++){
  printf("%d ",race[i][j]);
  sum[i] += race[i][j]; 
  }
printf("%d\n",sum[i]);

}
int total;
total = 0;

for(i = 0 ; i < c; i++){
sum[i] = 0;
  for(j = 0; j < r; j++){
  sum[i] += race[j][i];
  total += race[j][i];
  }
printf("%d ",sum[i]);
}
printf("%d\n",total);

return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

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

	int N;
	cin >> N;
	VT( LL ) as( N );
	cin >> as;

	int M;
	cin >> M;
	VT( LL ) bs( M ), cs( M );
	cin >> bs >> cs;

	
	sort( ALL( as ) );

	VT( LL ) csum( 1 );
	partial_sum( ALL( as ), BI( csum ) );

	REP( i, M )
	{
		cout << ( cs[i] <= csum[ upper_bound( ALL( as ), bs[i] ) - as.begin() ] ? "Yes" : "No" ) << endl;
	}

	return 0;
}

Measured memory_bytes: 13428
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	minimum := math.MaxInt32
	m := make(map[int]bool)
	uniq := []int{}
	for _, e := range nums {
		if !m[e] {
			m[e] = true
			uniq = append(uniq, e)
		}
	}
	if len(uniq) == 1 {
		fmt.Print(0)
		return
	}
	for i := -100; i <= 100; i++ {
		sum := 0
		for _, v := range nums {
			sum += int(math.Pow(math.Abs(float64(v-i)), 2))
		}
		if minimum > sum {
			minimum = sum
		}
	}
	fmt.Print(minimum)
}


Measured memory_bytes: 1880
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m[2];
int a[51],b[51],c[51];
int dp[2][401][401];
int main(void){
	scanf("%d%d%d",&n,&m[0],&m[1]);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	for(int i=0;i<2;i++){
		for(int j=0;j<=400;j++){
			for(int k=0;k<=400;k++){
				dp[i][j][k]=INF;
			}
		}
	}

	dp[0][0][0]=0;
	int lobi=0;
	int lobi2=0;
	int now=1;
	int prev=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=lobi;j++){
			for(int k=0;k<=lobi2;k++){
				for(int l=0;l<=1;l++){
					dp[now][j+a[i]*l][k+b[i]*l]=min(dp[now][j+a[i]*l][k+b[i]*l],dp[prev][j][k]+c[i]*l);
				}
			}
		}
		swap(now,prev);
		lobi=lobi+a[i];
		lobi2=lobi2+b[i];
		for(int j=0;j<=lobi;j++){
			for(int k=0;k<=lobi2;k++){
				dp[now][j][k]=INF;
			}
		}
	}
	int ans=INF;
	for(int i=1;i<=400;i++){
		int j=i*m[0];
		int k=i*m[1];
		if(j<=400 && k<=400){
			ans=min(ans,dp[prev][j][k]);
		}
	}
	printf("%d\n",ans==INF?-1:ans);
	return 0;
}

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

int main() {

	int a, b, c, d; cin >> a >> b >> c >> d;
	if (b <= c || d <= a) {
		cout << 0 << endl;
	}
	else {
		cout << min(b, d) - max(a, c) << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
class Node
  attr_accessor :id, :key, :parent, :left, :right

  def initialize(id, key)
    @id = id
    @key = key
    @parent = nil
    @left = nil
    @right = nil
  end

  def to_s
    parent_s =
      if @parent != nil
        "parent key = #{@parent.key}, "
      else
        ""
      end

    left_s =
      if @left != nil
        "left key = #{@left.key}, "
      else
        ""
      end

    right_s =
      if @right != nil
        "right key = #{@right.key}, "
      else
        ""
      end

    "node #{@id}: key = #{@key}, #{parent_s}#{left_s}#{right_s}"
  end
end

def left_p(i)
  2 * i
end
def right_p(i)
  2 * i + 1
end
def parent_p(i)
  i / 2
end


n = STDIN.gets.to_i
arr = STDIN.gets.split(' ')

tree = []
arr.each_with_index { |a, i|
  id = i + 1
  left_p = left_p(id)
  right_p = right_p(id)

  node = Node.new(id, a)

  if arr.size >= left_p
    left = Node.new(left_p, arr[left_p - 1])
    left.parent = node
    node.left = left
  end
  if arr.size >= right_p
    right = Node.new(right_p, arr[right_p - 1])
    right.parent = node
    node.right = right
  end
  node.parent = tree[parent_p(i+1) - 1]
  tree[i] = node
}

tree.each {|a|
  puts a
}

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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

//put debug temp

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  int n;
  cin >> n;
  map <char, int> cnt[n+1];
  for (int i = 1; i <= n; i++) {
  	string s;
  	cin >> s;
  	for (char c : s) {
  		cnt[i][c]++;
  	}
  }
  string res = "";
  for (auto x : cnt[1]) {
  	char c = x.first;
  	int mn = x.second;
  	for (int i = 1; i <= n; i++)
  		mn = min (mn, cnt[i][c]);
 	  for (int j = 0; j < mn; j++)
      res.pb(c);
 }
 cout << res;

  return 0;
}





// Coded by Z..

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9;
const ll MAX = 1e5+10;
const ll inf = 1e18+7;

int main(){
	fastio;
	ll n,ans=0;
	cin>>n;
	f(i,1,n+1){
		ans+=(n-1)/i;
	}
	cout<<ans<<"\n";
    return 0; 
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (ll i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
    ll n;cin>>n;
    ll k,mx,r,l;cin>>k;
    vector<ll>a(n);
    rep(i,n){cin>>a[i];mx = max(mx,a[i]);}
    l = 0,r = mx+1;

    while(r>l+1){
        ll md = (l+r)/2;
        ll sum = 0;
         //printf("md:%d, l:%d, r: %d\n",md,l,r);
        rep(i,n){
            if(a[i]%md==0)sum += a[i]/md-1;
            else sum += a[i]/md;    
        }
        if(sum>k)l = md;
        else r = md;
       
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------

void solve()
{
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll c=x/d;
    if(c>k)
        cout<<x-(d*k)<<endl;
    else
    {
        k-=c;
        if(k%2==0)
            cout<<abs(x%d)<<endl;
        else
            cout<<abs(d-x%d)<<endl;
    }
}

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


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<class A> ostream& operator <<(ostream& out, const vector<A> &v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        if(i) out << ", ";
        out << v[i];
    }
    return out << "]";
}

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

    double n;
    cin >> n;
    cout << 2.0 * 3.14159265359 * n << '\n';

    return 0;
}


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

void solve(){
    int n,wn;
    cin>>n>>wn;
    int item[n];
    int w[n];
    long long dp[105][100005];
    for (int i = 0; i < n; ++i) cin>>w[i]>>item[i];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= wn; ++j) {
            /*if (i == 0 && j >= w[i]) dp[i][j] = item[i];
            else if (j - w[i] >= 0) dp[i][j] = max(item[i] + dp[i-1][j-w[i]], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];*/
                if (j - w[i] >= 0)
                    dp[i+1][j] = max(dp[i+1][j], dp[i][j - w[i]] + item[i]);
 
                 dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            }
        }
    
    cout<<dp[n][wn];
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

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 int INF = 1001001001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

  int n, x;
  cin >> n >> x;
  vector<int> a(n+1);
  rep(i, n) cin >> a[i];
  a[n] = x;
  sort(ALL(a));

  int d = a[1] - a[0];
  rep(i, n) {
    d = gcd(d, a[i+1] - a[i]);
  }

  cout << d << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int a;
    int lf = 0, c = 0;
    for(int i = 0; i < n; i++){
    cin >> a;
    if(a >= lf){
        c++;
        lf = a;
    }
    }
    cout << c;
    
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
S = input()
black = [int(s=="#") for s in S]
white = [int(s==".") for s in S[::-1]]

a_black = [0]+list(accumulate(black))
a_white = list(accumulate(white))[::-1]+[0]

ans = 1000000
for b,w in zip(a_black,a_white):
    ans = min(ans, b+w)
print(ans)

Measured memory_bytes: 23824
N, M, K = map(int, input().split())

MOD = 998244353
invmod = [pow(i, MOD-2, MOD) for i in range(200002)]

if N == 1:
  print(M)
  exit()

if M == 1:
  if K == N-1:
    print(1)
  else:
    print(0)
  exit()
  
now = M * pow(M-1, N-1, MOD)
ans = now
if K == 0:
  print(ans % MOD)
  exit()

for ki in range(1, K+1):
  now = now * invmod[M-1] * (N-ki) * invmod[ki] % MOD
  ans += now
  
print(ans % MOD)


Measured memory_bytes: 17092
#include <iostream>     // std::cout
#include <algorithm>    // std::sort
#include <vector>       // std::vector
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  
    int n, k;
    cin >> n >> k;
    vector<int> lis;
    int answer = 0;
    while(n--){
        int p;
        cin >> p;
        lis.push_back(p);
        sort(lis.begin(), lis.end());
    }
    for(int i=0; i<k; i++){
        answer += lis[i];
    }
    cout << answer;
}

Measured memory_bytes: 3608
# https://atcoder.jp/contests/abc108/tasks/arc102_a



N, K = gets.split.map(&:to_i)

x = N / K
y = if K.odd?
      0
    else
      x * K + K / 2 <= N ? x + 1 : x
    end

puts x ** 3 + y ** 3


Measured memory_bytes: 1788