akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
 
using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
 
const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
 
// O(|V||E|)
struct edge {int from, to, cost;};
bool Bellman_Ford(int V, int E, int s, edge es[], LL dist[]) {
    fill(dist, dist + V, LLINF);
    dist[s] = 0;
    int cnt = 0;
    while (true) {
        bool update = false;
        VI v;
        for (int i = 0; i < E; ++i) {
            bool f = (dist[es[i].from] != LLINF && chmin(dist[es[i].to], dist[es[i].from] + es[i].cost));
            if (f) v.EB(es[i].to);
            update |= f;
        }
        if (!update) break;
        if (cnt == V - 1) {
            FORE(el, v) if (el == V - 1) return true;
            break;
        }
        ++cnt;
    }
    return false;
}
 
const int MAX_N = 1010;
const int MAX_M = 2020;
int N, M;
edge e[MAX_M];
 
int main(void) {
    scanf("%d%d", &N, &M);
    REP(i, M) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        e[i] = {a - 1, b - 1, -c};
    }
    vector<LL> dist(N);
    if (Bellman_Ford(N, M, 0, e, dist.data())) {
        cout << "inf" << endl;
        DEBUG(-dist[N - 1])
    } else cout << -dist[N - 1] << endl;
}

Measured memory_bytes: 256
x, y = gets.chomp.split(" ").map(&:to_i)

ans = []

if y - x >= 0
  ans << y - x
end

if y - (-x) >= 0
  ans << y - (-x) + 1
end

if -y - x >= 0
  ans << -y - x + 1
end

if -y - (-x) >= 0
  ans << -y - (-x) + 2
end

puts ans.min

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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

pair<ll, string> find(string S, string sub, ll k, ll K) {
    string s = sub + "a";
    for (ll i = 0; i < 26; i++) {
        s[s.length()-1] = 'a' + i;
        if (S.find(s) != string::npos) {
            k++;
            if (k == K) return make_pair(K, s);
            else {
                auto result = find(S, s, k, K);
                if (result.first == K) return result;
                else k = result.first;
            }
        }
    }
    return make_pair(k, string(""));
}

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

    string S;
    ll K;
    cin>>S>>K;

    auto result = find(S, "", 0, K);
    cout<<result.second<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "cstring"
#include<cstdio>
#include<algorithm>

#define MAX 2000000
#define INFINITY -1

int N=0; 
int data[MAX+1];

int getParentNum(int i){
  return int(i/2);
}

int getLeftChildNum(int i){
  return 2*i;
}

int getRightChildNum(int i){
  return 2*i+1;
}

void swapHeap(int num1, int num2){
  int dummy;
  dummy  = data[num1];
  data[num1] = data[num2];
  data[num2] = dummy;
}

void maxHeapify(int data[], int i){
  int num_child_left  = getLeftChildNum(i);
  int num_child_right = getRightChildNum(i);

  int largest;

  if(num_child_left <= N && data[num_child_left] > data[i]){
      largest = num_child_left;
  }else{
      largest = i;
  }

  if(num_child_right <=N && data[num_child_right] > data[largest]){
    largest = num_child_right; 
  }

  if(largest != i){
    swapHeap(i, largest);
    maxHeapify(data, largest);
  }
}


void heapIncreaseKey(int data[], int N, int key){

  if(data[N] >= key){
    return;
  }

  int i=N;

  data[N] = key;

  while(1<i && i<= N && data[getParentNum(i)] < data[i]){
    swapHeap(getParentNum(i), i);
    i = getParentNum(i);  
  }
}

void insert(int key){
  N = N+1;
  data[N] = INFINITY;
  
  heapIncreaseKey(data, N, key);

}

int extract(){
  int max_key = data[1];

  swapHeap(1, N);
  N = N-1;

  maxHeapify(data, 1);

  return max_key;

}



int main(void){
  
  char command[10];
  int key;

  while(true){
    scanf("%s", command);
  
    if(command[0] == 'e' && command[1] == 'n'){
      break;
    }else if(command[0] == 'e'){
      printf("%d\n", extract());
    }else if(command[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }else{
      printf("Input Error!\n");
    }
  }
  
  return 0;

}


Measured memory_bytes: 6504
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # 
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

H, W, A, B = rl()
answer = ['0'*(W-A) + '1'*A for _ in range(H-B)]
answer += ['1'*(W-A) + '0'*A for _ in range(B)]
for x in answer:
    print(*x, sep='')


Measured memory_bytes: 71996
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,count;
count=0;
cin>>N;
int d[N];
for (int i = 0; i < N; i++) {
  cin>>d[i];
}
sort(d,d+N);
d[N+1]=d[N];
for (int i = 0;i<N ; i++) {
  if(d[i]!=d[i+1])count++;
}

cout<<count<<endl;




















}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s;
    cin >> s;
    if(s == "RRR"){
        cout << 3 << endl;
    }else if(s.substr(0, 2) == "RR"){
        cout << 2 << endl;
    }else if(s.substr(1, 2) == "RR"){
        cout << 2 << endl;
    }else if(s == "SSS"){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <math.h>
#include <stdio.h>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define REV(v) for (auto itr = v.rbegin(); itr != v.rend(); itr++)
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define Vl(v,n) vector<ll> v(n);
#define Read_vll(v,n) vector<ll> v(n);REP(i,0,n)cin>>v[i];
#define sumV(v,n) Vl(ac,n) REP(i,0,n) ac[i] = v[i] + ( i == 0 ? 0 : ac[i - 1]);
#define EPS (1e-10)
#define INF 1000000000000LL

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(n)
    Read_vll(a,n)
    SORT(a)
    sumV(a,n)

    bool same = true;
    REP(i,0,n-1){
      if( a[i] != a[i+1] ) same = false;
    }

    if( same ){
       cout << n << endl;
       return 0;
    }

    ll ma = 0;
    for( ll i = n - 1; i >= 0; i-- ){
      if( 2 * ac[i-1] < a[i] ){
        ma = fmax( ma, i );
      }
    }
    cout << n - ma << endl;
    return 0;
}


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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

ll n;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n;
    cout << n * (n - 1) / 2ll << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
long long int f[50];

long long int fib(int n){
    if(f[n]!=0);
    else if(n==0||n==1){
        f[n]=1;
    }else{
        f[n]=fib(n-1)+fib(n-2);
    }
    return f[n];
}

int main(){
    int n;
    cin>>n;
    cout<<fib(n)<<endl;
    
    return 0;
}

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

char *flag;
int head,rear;
int *que;
int factorial[10];

int cal_factorial(int n) {
  if(n == 0) return 1;
  return cal_factorial(n-1)*n;
}

int stotag(char *s) {
  int tag = 0;
  int i;
  for(i = 0; i < 9; i++) {
    int t,j;
    t = 0;
    for(j = 0; j < i; j++) {
      if(s[j] < s[i]) t++;
    }
    tag += factorial[8-i]*(s[i]-'0'-t);
  }
  return tag;
}

char *tagtos(int tag) {
  int i;
  char *s;
  s = (char*)malloc(sizeof(char)*10);
  for(i = 0; i < 9; i++) {
    s[i] = tag%factorial[9-i]/factorial[8-i] + '0';
  }
  s[9] = '\0';
  for(i = 7; i >= 0; i--) {
    int j;
    for(j = 8; j > i; j--) {
      if(s[i] <= s[j]) s[j]++;
    }
  }
  return s;
}


char *move_up(char s[], int x) {
  if(x < 3) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x-3];
  s_new[x-3] = s[x];
  return s_new;
}

char *move_left(char s[], int x) {
  if(x%3 == 0) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x-1];
  s_new[x-1] = s[x];
  return s_new;
}

char *move_right(char s[], int x) {
  if(x%3 == 2) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x+1];
  s_new[x+1] = s[x];
  return s_new;
}

char *move_down(char s[], int x) {
  if(x > 5) return NULL;
  char *s_new;
  s_new = (char*)malloc(sizeof(char)*10);
  strcpy(s_new,s);
  s_new[x] = s[x+3];
  s_new[x+3] = s[x];
  return s_new;
}

int create(char s[], int t) {
  if(strcmp(s,"123456780") == 0) return t;
  int tag = stotag(s);
  if(flag[tag]) return 0;
  flag[tag] = t;
  que[rear] = tag;
  rear++;
  return 0;
}

int check_x(char *s) {
  int i = 0;
  while(s[i] != '0') i++;
  return i;
}

int cal() {
  char *s_right,*s_left,*s_up,*s_down;
  int k,tag;

  tag = que[head];
  char *s = tagtos(tag);
  int x = check_x(s);
  
  if((s_right = move_right(s, x)) != NULL) {
    if((k = create(s_right,flag[tag]+1))) return k;
    free(s_right);
  }
  if((s_left = move_left(s, x)) != NULL) {
     if((k = create(s_left,flag[tag]+1))) return k;
     free(s_left);
  }
  if ((s_up = move_up(s, x)) != NULL) {
    if((k = create(s_up,flag[tag]+1))) return k;
    free(s_up);
  }
  if((s_down = move_down(s, x)) != NULL) {
    if((k = create(s_down,flag[tag]+1))) return k;
    free(s_down);
  }
  free(s);
  head++;
  return 0;
}
  

int solve(char s0[]) {
  int k;
  if((k = create(s0,1))) return k;
  
  while(!(k = cal())) {
    if(head == rear) break;
  }
  return k;
}

int main()
{

  int i,d;
  char s[10];
  for(i = 0; i < 10; i++) factorial[i] = cal_factorial(i);
  flag = (char*)malloc(sizeof(char)*factorial[9]);
  memset(flag , 0, factorial[9]);
  que = (int*)malloc(sizeof(int)*factorial[9]);
  head = 0;
  rear = 0;
  for (i = 0; i < 9; i++) {
    scanf("%d", &d);
    s[i] = d+'0';
  }
  s[9] = '\0';
  printf("%d\n",solve(s)-1);
  
  return 0;
}



Measured memory_bytes: 2880
#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main(){
  int a,b;
  double c,d,ans;
  cin>>a;
  b=a/2;
  c=a;
  d=b;
  ans=(c-d)/c;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a, b, x;
    int t[999];
    int flag = 1;
    scanf("%d %d", &a, &b);

    for (int i = 0; i < 999; i++) {
        t[i] = ((1 + i + 1) * (i + 1)) / 2;
    }

    for (int i = 0; i < 998; i++) {
        x = t[i] - a;
        if (t[i + 1] - x == b) {
            break;
        }
    }

    printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define ll long long
using namespace std;
int main(void){
    double l;
    cin>>l;
    
    cout<<setprecision(20)<<l*l*l/27<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N+1,0);
    rep1(i,N) cin>>A[i];
    
    vector<ll> ans(N+1,0);
    rrep1(i,N){
        if(i>=N/2+1) ans[i]=A[i];
        else{
            ll tmp=0;
            for(ll j=2*i;j<=N;j+=i){
                tmp+=ans[j];
            }
            tmp%=2;
            
            ans[i]=tmp^A[i];
        }
    }
    
    ll M=0;
    rep1(i,N){
        if(ans[i]==1) M++;
    }
    cout<<M<<endl;
    rep1(i,N){
        if(ans[i]==1) cout<<i<<" ";
    }
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) cin >> a[i][j];
  }

  queue<pair<int, int>> Q1, Q2;
  for (int i = 0; i < h; i ++) {
    if (i % 2 == 0) {
      for (int j = 0; j < w; j ++) {
        if (i == h - 1 && j == w - 1) continue;
        if ((i != h - 1 && j == w - 1) && a[i][j] % 2 == 1) {
          a[i][j] --;
          a[i + 1][j] ++;
          Q1.push(make_pair(i + 1, j + 1));
          Q2.push(make_pair(i + 2, j + 1));
        } else if (a[i][j] % 2 == 1) {
          a[i][j] --;
          a[i][j + 1] ++;
          Q1.push(make_pair(i + 1, j + 1));
          Q2.push(make_pair(i + 1, j + 2));
        }
      }
    } else {
      for (int j = w - 1; j >= 0; j --) {
        if (i == h - 1 && j == 0) continue;
        if ((i != h - 1 && j == 0) && a[i][j] % 2 == 1) {
          a[i][j] --;
          a[i + 1][j] ++;
          Q1.push(make_pair(i + 1, j + 1));
          Q2.push(make_pair(i + 2, j + 1));
        } else if (a[i][j] % 2 == 1) {
          a[i][j] --;
          a[i][j - 1] ++;
          Q1.push(make_pair(i + 1, j + 1));
          Q2.push(make_pair(i + 1, j));
        }
      }
    }
  }

  cout << Q1.size() << endl;
  pair<int, int> q1, q2;
  while (!Q1.empty()) {
    q1 = Q1.front(); Q1.pop();
    q2 = Q2.front(); Q2.pop();
    cout << q1.first << " " << q1.second << " ";
    cout << q2.first << " " << q2.second << endl;
  }
}

Measured memory_bytes: 5120
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
map<pair<string,string>,long>M;
int n;string s;
main()
{
  cin>>n>>s;
  for(int i=0;i<1<<n;i++)
  {
    string a="",b="";
    for(int j=0;j<n;j++)
    {
      if(i&1<<j)a+=s[j];
      else b+=s[j];
    }
    M[make_pair(a,b)]++;
  }
  long ans=0;
  for(int i=0;i<1<<n;i++)
  {
    string a="",b="";
    for(int j=0;j<n;j++)
    {
      if(i&1<<j)a+=s[n+j];
      else b+=s[n+j];
    }
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    ans+=M[make_pair(b,a)];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 87040
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n,0),b(n,0);
	int prev,now;
	
	for(int i=0;i<n;i++){
		prev=now;
		cin >> now;
		if(i==0)continue;
		a[i]=prev-now;
	}
	
	int x=0;
	for(int i=1;i<n;i++){
		if(a[i]>=0)b[x]++;
		else x++;
	}
	
	sort(b.begin(),b.end(),greater<int>());
	
	cout << b[0] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define m_p make_pair
#define pb push_back
#define pob pop_back
#define pf pop_front
#define puf push_front
#define st stack
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll> ml;
typedef map<ll,ll>::iterator itll;
typedef queue<P> BFs;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size()<=k)
		cout<<s<<endl;
	else
	{
		cout<<s.substr(0,k)<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
fn calc(mut m: u64, n: u64, k: u64) -> bool {
    for _ in 1..n {
        if m < 1 + (m - 1) / k {
            return false;
        }
        m = m - 1 - (m - 1) / k;
    }
    m > 0
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: u64 = it.next().unwrap().parse().unwrap();
    let k: u64 = it.next().unwrap().parse().unwrap();
    let mut l = 0;
    let mut r = 1_000_000_000_000_000_000 + 1;
    while r - l > 1 {
        let m = (l + r) / 2;
        if calc(m, n, k) {
            r = m;
        } else {
            l = m;
        }
    }
    println!("{}", l);
}

fn main() {
    run();
}


Measured memory_bytes: 5020
#include <bits/stdc++.h>
#define Min(a,b) (a<b?a:b)
#define mst(a,b) (memset(a,b,sizeof(a)))
using namespace std;
int gi(){
  char ch=getchar(); int x=0,q=0;
  while(ch<'0' || ch>'9') (ch=='-'?q=1:0),ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int t[30],p[30];
char s[100];
int main(){
  int n=gi(),l;
  mst(t,100);
  for (int i=1; i<=n; ++i){
    mst(p,0);
    scanf("%s",s);
    l=strlen(s);
    for (int i=0; i<l; ++i)
      ++p[s[i]-'a'];
    for (int i=0; i<26; ++i)
      t[i]=Min(t[i],p[i]);
  }
  for (int i=0; i<26; ++i)
    for (int j=1; j<=t[i]; ++j)
      putchar('a'+i);
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int

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


Measured memory_bytes: 256
# Meet Arora

def fibonacci(n):
    f = [[1,1],[1,0]]
    if n==0:
        return 0
    f=power(n-1, f)
    return f[0][0]

def multiply(f, m):
    x = f[0][0]*m[0][0] + f[0][1]*m[1][0]
    y = f[0][0]*m[0][1] + f[0][1]*m[1][1]
    z = f[1][0]*m[0][0] + f[1][1]*m[1][0]
    w = f[1][0]*m[0][1] + f[1][1]*m[1][1]

    f[0][0] = x
    f[0][1] = y
    f[1][0] = z
    f[1][1] = w

    return f

def power(n, f):
    if n==0 or n==1:
        return f

    m = [[1,1], [1,0]]
    f=power(n//2, f)
    f=multiply(f,f)

    if n%2==1:
        f=multiply(f, m)

    return f

arr = [int(x) for x in input().split()]
a = int(arr[0])
b = int(arr[1])
c = int(arr[2])
k = int(arr[3])

if abs(a-b)>10**18:
    print("Unfair")
else:
    if k%2==0:
        print(a-b)
    else:
        print(b-a)






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

#define PI 3.14159265358979323846

// #define ll long long int
#define ff first
#define ss second
// #define int long long int
#define pb push_back

#define N 10000010
#define MOD 1000000007

int bexp(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }   
    k++;
    int dp[n] = {};
    dp[0] = 0;
    for (int i = 1; i < n; ++i)
     {
        dp[i] = INT_MAX;
        for (int j = 1; j < k; ++j)
        {
            dp[i] = min(dp[i], (i - j >= 0 ? dp[i - j] + abs(a[i] - a[i - j]) : INT_MAX));
        }
     } 
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 4376
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int a, b, c;
        read a >> b >> c;
        int ans = b;
        if ( b+a < c ) {
            ans += a+b+1;
        }
        else {
            ans += c;
        }
        echo ans fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


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


int main() {
  string K; cin >> K;
  int A, B, C, D;
  A = K[0] - '0';
  B = K[1] - '0';
  C = K[2] - '0';
  D = K[3] - '0';
  vector<string> op = {"+++","++-","+-+","+--","-++","-+-","--+","---"};
  
  rep(i, 8) {
    int a = A;
    if(op[i][0] == '+') a+=B;
    else a-=B;
    if(op[i][1] == '+') a+=C;
    else a-=C;
	if(op[i][2] == '+') a+=D;
    else a-=D;
    if(a == 7) {
      cout << A << op[i][0] << B << op[i][1] << C << op[i][2] << D << "=7" << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    s, w = LI()
    if w >= s:
        print('unsafe')
    else:
        print('safe')
    return


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


Measured memory_bytes: 65468
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> L(2*N);
  for(int i=0; i<2*N; i++){
    cin >> L.at(i);
  }
  int sum=0;
  sort(L.begin(),L.end());
  for(int i=0; i<2*N; i+=2){
    sum += min(L.at(i),L.at(i+1));
  }
  cout << sum << endl;
}

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

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int N = 1e5 + 7;
const int M = 107;
const ll mod = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k;
int a[N];
int d[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin >> n >> k;
    for( int i = 1; i <= n; i++ )cin >> a[i];
    d[0] = 2;
    for( int i = 1; i <= k; i++ ){
        d[i] = 2;
        for( int j = 1; j <= n; j++ ){
            if( a[j] > i )continue;
            if( d[i - a[j]] == 2 ){
                d[i] = 1;
                break;
            }
        }
    }
    if( d[k] == 1 )cout << "First";
    else cout << "Second";
}


Measured memory_bytes: 4048
from math import *
from collections import *
from itertools import *
from bisect import *
def io():
    return map(int,input().split())
def op():
    return list(map(int,input().split()))
def kl(con,x=0):
    if x==0:print('Yes') if con else print('No')
    elif x==1:print('yes') if con else print('no')
    elif x==2:print('YES') if con else print('NO')
MOD = 1000000007
MAX=2147483647
MIN=-2147483648
p=input
# for _ in range(int(p())):
a,b,c,d=io()
s=0
s+=min(a,d)
d-=min(d,a)
d-=min(d,b)
s-=min(d,c)
print(s)

Measured memory_bytes: 65520
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
 
ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
//cout<< fixed << setprecision(10)
//multiset<int>f[200005];
int main(){
 
    fast;
    int T;
    T=1;
   // cin>>T;
    while(T--){
    ll n,m,k;
    cin>>n>>m>>k;
    
    vector<ll>  a,b;
    for(int i=0;i<n;i++){
    	ll x;
    	cin>>x;
    	a.push_back(x);
	}
	for(int i=0;i<m;i++){
    	ll x;
    	cin>>x;
    	b.push_back(x);
	}
    ll c=0;
    ll pre_a=0,pre_b=0;
    for(int i=0;i<n;i++){
    	if(pre_a+a[i]<=k){
    		pre_a+=a[i];
    		c++;
		}
		else
		break;
	}
	
	ll j=c;
	ll ans=c;
	int e=0;
	while(j>=0){
		if((pre_a+pre_b+b[e])<=k){
			while(e<m && (pre_a+pre_b+b[e])<=k){
				pre_b+=b[e];
				e++;
			}
			ans=max(ans,j+e);
		}
		
			
			j--;
			if(j>=0)
			pre_a-=a[j];
		
	}
	
	
 cout<<ans<<"\n";
    }
	return 0;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,k;
	cin>>n>>k;
	n=n%k;
	n=min(n,abs(n-k));
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
s = input()
t = s.rstrip().split(' ')
c = 0
for a in t:
  c += int(a)
d = 0
for a in t:
  if int(a) >= c/4/m :
    d += 1
if d < m:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3064
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int dp[110][10010]={}; //[v][w]

int main() {
   int n,l;
   cin>>n>>l;
   int sum=0,a=l;
   rep(i,n){
       sum+=a;
       a+=1;
   }
   if(sum==0){
       cout<<sum<<endl;
   }else if(l+n-1<=0){
       cout<<sum-(l+n-1)<<endl;
   }else if(l>=0){
       cout<<sum-l<<endl;
   }else{
       cout<<sum<<endl;
   }

}



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

using namespace std;

int main(){

    int N;
    cin >> N;

    map<int, int> M;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        int b = a % 4;
        M[b] ++;
    }

    bool flag = false;

    if (M[2] != 0){
        N -= M[2];
        if (N % 2 == 0){
            if (N / 2 <= M[0]){
                flag = true;
            }
        }else{
            if ((N + 1) / 2 <= M[0]){
                flag = true;
            }
        }
    }else{
        if (N / 2 <= M[0]){
            flag = true;
        }
    }
    
    if (flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<set>
#include<string>
#define debug cout<<"debug"<<endl
using namespace std;
string s;
string sub;
set<string> se;
int k;

void debug1(){
    debug;
    set<string>::iterator it=se.begin();
    for(;it!=se.end();it++)
        cout<<*it<<endl;
    debug;
}

int main(){
    std::ios::sync_with_stdio(false);
        cin>>s;
        cin>>k;
        int len=s.length();
        for(int i=0;i<26;i++){
            if(se.size()>5) break;
            char ch='a'+i;
            for(int j=0;j<len;j++)
            for(int t=1;t<=k;t++){
                if(j+t>len) break;
                sub=s.substr(j,t);
                se.insert(sub);
            }
        }
        set<string>::iterator it=se.begin();
        for(int i=1;i<k&&it!=se.end();i++,it++);
         cout<<*it<<endl;
    //return 0;
}


Measured memory_bytes: 1664
N,M = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(M)]

# 区間スケジューリング

AB.sort(key=lambda x: x[1])

cnt = 0
right = -1
for A,B in AB:
    if A >= right:
        cnt += 1
        right = B

print(cnt)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  ll N;
  scanf("%lld",&N);
  if ((N/10)%10==9||N%10==9) cout << YES << endl;
  else cout << NO << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int n;
  scanf("%d",&n);
  if(n==1) printf("No");
    else if(n==2) printf("No");
  else if(n==3) printf("No");
  else if(n==5) printf("No");
  else if(n==6) printf("No");
  else if(n==9) printf("No");
  else if(n==10) printf("No");
  else if(n==13) printf("No");
  
else if(n==17) printf("No");
    else printf("Yes");
  return 0;
}

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

using namespace std;

int main()
{
    string str;
    cin>>str;
    int n=str.length();
    
    if(str[0]=='A'&&str[1]=='R'&&str[2]=='C'&&n==3)
    cout<<"ABC"<<endl;
    else
    cout<<"ARC"<<endl;

    return 0;
}


Measured memory_bytes: 3568
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        for (int i = 0; i < 100; i ++) {
                for (int j = 0; j < 100; j ++) {
                        int res = 4 * i + 7 * j;
                        if (res == n) {
                                printf("Yes\n");
                                return 0;
                        }
                }
        }
        printf("No\n");
        return 0;
}



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

using namespace std;

#define int long long int
#define cont continue;
#define ff first
#define ss second
#define pb push_back
#define ins insert
#define mp make_pair
#define endl '\n'

typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef map<int, int> mi;

//const
#define EPS 1e-9
#define INF LLONG_MAX
const int mod = 1000 * 1000 * 1000 + 7; //1e9+7
const double PI = 3.14159265358979323846264;
const pi steps[] = {{1, 0}, {0, 1}, { -1, 0}, {0, -1}, {1, -1}, {1, 1}, { -1, -1}, { -1, 1}}; //for (auto [dx,dy] : steps)
//const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

// inputs & output & debug
#define w(t) int t; cin>> t; while(t--)

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

//useful functions
//#define deb(x) cout<<#x<<": "<<x<<endl;
#define isPowOfTwo(x) return (x && (!(x&(x-1))));
#define sz(a) (int)((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define ip_arr(a,n)   for(int i=0;i<n;i++) cin>>a[i];
#define op_arr(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<"\n"; cout<<endl;
#define fill_arr(arr,n,i) fill(arr,arr+n,i)
#define fill_vec(v,n,i) fill(v.begin(),v.begin()+n,i);
#define sortv(a) sort(a.begin(),a.end())

void fio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
void setUpLocal()
{
#ifndef ONLINE_JUDGE
	freopen("/Users/asuryana/Documents/CP/input.txt", "r", stdin);
	freopen("/Users/asuryana/Documents/CP/output.txt", "w", stdout);
#else
#define cerr if(0) cerr
#endif
}

const int maxN = (int)1e6 + 7;
// vi gp[gp_size];
// int vis[gp_size];
// int cnt[gp_size];

void solve()
{
	int n; cin >> n;
	vi v(n);
	ip_arr(v, n);

	int dp[n]; // cost of reaching n

	dp[0] = 0;
	dp[1] = abs(v[1] - v[0]);

	for (int i = 2; i < n; i++)
	{
		int cost1 = dp[i - 1] + abs(v[i] - v[i - 1]); //prevCostToReach(i-1) + newCost
		int cost2 = dp[i - 2] + abs(v[i] - v[i - 2]);
		dp[i] = min(cost1, cost2);
	}

	cout << dp[n - 1] << endl;

}

int32_t main()
{
	fio();
	//setUpLocal();
	return solve(), 0;
}


Measured memory_bytes: 4688
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp
int main() {
  i64 N;
  std::cin >> N;

  std::vector<i64> osa_k(N + 1, 1);
  for (i64 i = 2; i <= N; ++i) {
    if (osa_k[i] == 1) {
      for (i64 j = i; j <= N; j += i) {
        if (osa_k[j] == 1) {
          osa_k[j] = i;
        }
      }
    }
  }

  std::vector<std::pair<i64, i64>> dp(N + 1, std::make_pair<i64, i64>(1, 1));
  for (i64 i = 2; i <= N; ++i) {
    if (osa_k[i] < osa_k[i / osa_k[i]]) {
      dp[i] = std::make_pair<i64, i64>(2, dp[i / osa_k[i]].first * dp[i / osa_k[i]].second);
    } else {
      dp[i] = std::make_pair(dp[i / osa_k[i]].first + 1, dp[i / osa_k[i]].second);
    }
  }

  std::cout << std::accumulate(dp.begin() + 1, dp.begin() + N, static_cast<i64>(0), [](const i64& sum, const std::pair<i64, i64>& pair) { return sum + pair.first * pair.second; }) << '\n';
  return 0;
}

Measured memory_bytes: 26648
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	t, x, y := 0, 0, 0
	f := true
	for i := 0; i < n; i++ {
		p, q, r := iScan(), iScan(), iScan()
		c := abs(p - t)
		d := abs(q-x) + abs(r-y)
		if c%2 != d%2 || d > c {
			f = false
		}
		t, x, y = p, q, r
	}
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2828
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, K;
  std::cin >> N >> K;

  ll ans = N % K;
  print(ans);

  return 0;
}


Measured memory_bytes: 256
import numpy as np
n, m=map(int,input().split())

n_grid=np.array([list(input()) for _ in range(n)])
m_grid=np.array([list(input()) for _ in range(m)])

found=False
for i in range(n-m+1):
  for j in range(n-m+1):
    if (m_grid == n_grid[i:i+m, j:j+m]).all():
      found=True
      break
if found:
  print("Yes")
else:
  print("No")
    

Measured memory_bytes: 12440
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int s;
    cin >> s;
    unordered_set<int> visit = {s};
    int i = 1;
    while (true) {
        i++;
        if (s % 2 == 1)
            s = s * 3 + 1;
        else
            s /= 2;
        if (visit.count(s) > 0) {
            cout << i << endl;
            return 0;
        }
        visit.insert(s);
    }
    return 0;
}




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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  string s;
  cin>>s;
  int co[30]= {0};
  for(int i=0; i<s.length(); i++)
  {
    co[s[i]-'a']++;
  }
  for(int i=0; i<30; i++)
  {
    if(co[i]&1 == 1){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int N,M;
  cin>>N>>M;
  string ans="No";
  vector <string> A(N),B(M);
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=0;i<M;i++) cin>>B[i];
  for(int i=0;i<N-M+1;i++){
    for(int j=0;j<N-M+1;j++){
      bool flag = true;
      for(int k=0;k<M;k++){
        if (A[k+i].substr(j,M)!=B[k]) flag=false;
      }      
      if (flag) ans="Yes";
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val t = sc.nextLine().toCharArray()
    val n = t.count()
    for (i in 0 until n) {
        if (t[i] == '?') {
            t[i] = 'D'
        }
    }
    println(t.joinToString(""))
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 42668