akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
#define int long long int
#define ld long double
#define mod 1000000007 
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define forn(i,s, e) for (int i = s; i <= e; i++)
#define fornd(i,s, e) for (int i = s ; i >= e; i--)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define print(x) for(auto el: x) cout<<el<<" ";cout<<"\n"
#define PSET(x,y) fixed<<setprecision(y)<<x
#define bits(x) __builtin_popcount(x)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 

 
template <typename T> 
void swap(T& a, T& b){
    T temp = a;
    a = b;
    b = temp;
}

const int N = 100005; 

void selfadd(int& a, int b){
    a = (a+b)%mod;
}

int dp[1001][1001];
char a[1001][1001];

void solve(){
    int n,m;
    cin>>n>>m;

    forn(i,0,n-1){
        forn(j,0,m-1){
            cin>>a[i][j];
        }
    }
    memset(dp,0,sizeof(dp));

    dp[0][0] = 1;

    for(int i=0;i<n;i++){

        for(int j=0;j<m;j++){
            if(a[i][j] == '#') continue;
            if(i>0)
                selfadd(dp[i][j], dp[i-1][j]);
            if(j>0)
                selfadd(dp[i][j], dp[i][j-1]);
        }
    }

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


}
 
int32_t main()
{
    fast;
    // int t;
    // cin>>t;
    // for(int y=1;y<=t;y++)
    {
        // cout<<"Case #"<<y<<": ";
        solve();
    }
    return 0;
} 

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> d(n);
  for (int i = 0; i < n; i++) { std::cin >> d.at(i); }
  
  sort(d.begin(), d.end(), std::greater<int>());
  int ret = 1;
  for (int i = 0; i < n - 1; i++) {
    if (d.at(i+1) < d.at(i)) {
      ret += 1;
    }
  }
  std::cout << ret << std::endl;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// ouls
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  var(int, n, a, b);
  i64 p1 = a * n;
  i64 p2 = b;
  outl(min(p1, p2));
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Data[] data = new Data[N];
    for (int i = 0; i < N; i++) {
      data[i] = new Data(Long.parseLong(sc.next()), i);
    }
    sc.close();
    Arrays.parallelSort(data);
    long midMin = data[(N - 1) / 2].getX();
    long midMax = data[N / 2].getX();
    long[] ans = new long[N];
    for (int i = 0; i < N; i++) {
      if (data[i].getX() >= midMax) {
        ans[data[i].getIdx()] = midMin;
      } else {
        ans[data[i].getIdx()] = midMax;
      }
    }
    for (int i = 0; i < N; i++) {
      System.out.println(ans[i]);
    }
  }

  public static class Data implements Comparable<Data> {
    private long X;
    private int idx;

    public Data(long X, int idx) {
      this.setX(X);
      this.setIdx(idx);
    }

    public long getX() {
      return this.X;
    }

    public void setX(long x) {
      this.X = x;
    }

    public int getIdx() {
      return this.idx;
    }

    public void setIdx(int idx) {
      this.idx = idx;
    }

    @Override
    public int compareTo(Data data) {
      return (int) (this.getX() - data.getX());
    }

  }

}


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

struct Edge {
	int from;
	int to;
	int score;
};

int main(void) {
	using namespace std;
	const long long INF = 1e15;
	int N, M;
	cin >> N >> M;
	vector<Edge> edges;
	for(int i = 0; i < M; ++i) {
		Edge e;
		cin >> e.from >> e.to >> e.score;
		--e.from;
		--e.to;
		edges.push_back(e);
	}
	vector<long long> score(N, -INF);
	score[0] = 0;
	long long tmp;
	for(int counter = 0; counter < 2 * N; ++counter) {
		bool update = false;
		for(int i = 0; i < M; ++i) {
			Edge e = edges[i];
			if(score[e.from] != -INF && score[e.to] < score[e.from] + e.score) {
				score[e.to] = score[e.from] + e.score;
				update = true;
			}
		}
		if(!update) {
			break;
		}
		if(counter == N - 1) {
			tmp = score[N - 1];
		}
		if(counter == 2 * N - 1) {
			if(score[N - 1] != tmp) {
				cout << "inf\n";
				return 0;
			}
		}
	}
	cout << score[N - 1] << '\n';
	return 0;
}



Measured memory_bytes: 256
import collections


if __name__ == "__main__":
    N = int(input())
    A = [int(x) for x in input().split(" ")]
    counter = collections.Counter(A)

    duplicates = [key for key, val in counter.items() if val >= 2]
    A = [key for key in counter]

    A.sort()
    max_a = A[-1]
    multiples = set()
    ans = []

    for a in A:
        if a not in multiples:
            ans.append(a)
            for i in range(1, 10 ** 9):
                if a * i > max_a:
                    break
                multiples.add(a * i)

    print(len(set(ans) - set(duplicates)))

Measured memory_bytes: 180976
#include <iostream>

using namespace std;

void print_interval(void)
{
    for (int i=0; i<20; i++)
        cout << "#";
    cout << endl;
}

int main(void)
{
    int n;
    int room[4][3][10] = {0};

    cin >> n;

    for (int i=0; i<n; i++)
    {
        int b, f, r, v;
        cin >> b >> f >> r >> v;

        room[b-1][f-1][r-1] += v;
    }

    for (int i=0; i<4; i++)
    {
        for (int j=0; j<3; j++)
        {
            for (int k=0; k<10; k++)
            {
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) 
            print_interval();
    }
}


Measured memory_bytes: 3100
#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;
typedef long long int lli;
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 dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(all(v));
    rep(i,n-1){
        v[i+1] = (v[i] + v[i+1]) / 2.0;
    }
    printf("%.6lf\n", v[n-1]);
    return 0;
}

Measured memory_bytes: 3824
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t H, W;
    std::cin >> H >> W;

    boost::multi_array<char, 2> mat(boost::extents[H][W]);
// const auto Y = mat.shape()[0];
// const auto X = mat.shape()[1];

//std::fill(mat.data(), mat.data() + mat.num_elements(), almost_max<char>());

    for (auto p = mat.data(); p < (mat.origin() + mat.num_elements()); ++p) {
        std::cin >> *p;
    }

    std::vector<bool> hnoskip(H);
    std::vector<bool> wnoskip(W);
    
    for (int64_t h = 0; h < H; ++h) {
        for (int64_t w = 0; w < W; ++w) {
            if (mat[h][w] == '#') {
                hnoskip[h] = wnoskip[w] = true;
            }
        }
    }

    for (int64_t h = 0; h < H; ++h) {
        bool out = false;
        for (int64_t w = 0; w < W; ++w) {
            if (hnoskip[h] && wnoskip[w]) {
                out = true;
                std::cout << mat[h][w];
            }
        }
        if (out) {
            std::cout << std::endl;
        }
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll a, b, c, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> a >> b >> c >> k;
    if (abs(a - b) >= (ll)1e18) cout << "Unfair" << endl;
    else if (k % 2) cout << b - a << endl;
    else cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const double pi = acos(-1.0);
const double EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    string S;
    cin >> N >> S;
    int a = 0, b = 0, M = 0;
    rep(i, N){
        (S[i] == '('? a : b)++;
        chmax(M, b-a);
    }
    string l(M, '('), r(M+a-b, ')');
    cout << l+S+r << endl;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    char s;
    cin >> s ;
    for(char ss='a';ss<='z';ss++){
        if(ss==s){
            cout<<"a"<<endl;
            return 0;
        }
    }
    for(char ss='A';ss<='Z';ss++){
        if(ss==s){
            cout<<"A"<<endl;
            return 0;
        }
    }
    return 0;
}

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

vector<int> tree[100001];

ll dp1[100001];
ll dp2[100001];


void solve2(int src,vector<bool> vis, ll m,ll ans){

    vis[src]=true;
    dp2[src]=(dp1[src]*(1+ans))%m;

    vector<ll> suffix;
    vector<ll> prefix;

    for(auto child : tree[src]){
        
        if(!vis[child]){
        suffix.push_back(1+dp1[child]);
        prefix.push_back(1+dp1[child]);
        }

    }

    for(int i=1;i<prefix.size();i++){
        prefix[i]=(prefix[i]*prefix[i-1])%m;
    }

    for(int i=suffix.size()-2;i>=0;i--){
        
        suffix[i]=(suffix[i]*suffix[i+1])%m;

    }


    int cno=0;

    for(auto child : tree[src]){

        ll ways=(1+ans)%m;
        if(!vis[child]){
        ways=(cno==0)?ways:ways*prefix[cno-1];
        ways=ways%m;
        ways=(cno==suffix.size()-1)?ways:ways*suffix[cno+1];
        ways=ways%m;
        
        solve2(child,vis,m,ways);
        cno++;
        

        }

    }

    

    
}


void solve1(int src ,vector<bool> vis, ll m){

    vis[src]=true;
    dp1[src]=1;

    for(auto child: tree[src]){
        if(!vis[child]){
            solve1(child,vis,m);
            dp1[src]=(dp1[src]*(1+dp1[child]))%m;

        }
    }

}

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

    for(int i=1;i<=n-1;i++){
        int x,y;
        cin>>x>>y;
        tree[x].push_back(y);
        tree[y].push_back(x);

    }

    vector<bool> vis(n+1,0);
    solve1(1,vis,m);
    vis=vector<bool>(n+1,0);

    solve2(1,vis,m,0);
    for(int i=1;i<=n;i++){
        cout<<dp2[i]<<endl;
    }
 
}


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

typedef long long ll;

void solve() {
  ll N;
  cin >> N;
  ll a[100000];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a+N);
  ll maximum = 0;
  ll prev = -1;
  for (int i = 0; i < N; i++) {
    if (prev == a[i]) {
      continue;
    }
    ll base = a[i];
    prev = base;
    ll len = 0;
    for (int j = i; j < N; j++) {
      if (a[j] > a[i] + 2) {
        break;
      }
      len += 1;
    }
    if (len > maximum) {
      maximum = len;
    }
  }
  cout << maximum << endl;
}

int main() {
  solve();
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

#define MAX_S 4000
#define MAX_T 4000
template<typename T> int longest_common_substring(T s,T t){
    int lens=s.size(), lent=t.size();
    static int dp[MAX_S+1][MAX_T+1];
    rep(i,MAX_S+1)rep(j,MAX_T+1)dp[i][j]=0;
    
    int maxi=0;
    
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j])  dp[i+1][j+1] = dp[i][j]+1;
            else            dp[i+1][j+1] = 0;
            maxi = max(maxi,dp[i+1][j+1]);
        }
    }
    
    return maxi;
}


int main(){
    string a,b;
    while(cin>>a>>b){
        cout<<longest_common_substring(a,b)<<endl;
    }
}

Measured memory_bytes: 65776
/*
Author : N_o_o_B
Created : April 22 2020 22:10:48 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    vector<vector<char>> a(n+2,vector<char>(m+2,'#'));
    rep(i,1,n){
        rep(j,1,m){
            cin >> a[i][j];
        }
    }
    fori(i,n+2){
        fori(j,m+2){
            cout << a[i][j];
        }
        cout << endl;
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 256
main = do
  (k:a:b:xs) <- map read . words <$> getLine
  putStrLn . show $ solve' k a b

solve' :: Integer -> Integer -> Integer -> Integer
solve' k a b
  | b - a <= 2 || k - (a - 1) <= 0 = k + 1
  | otherwise = let k1 = k - (a - 1)
                in (b - a) * (k1 `div` 2) + (k1 `mod` 2) + a


Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;

struct s {
	int P, Y, tmp1, tmp2;
};

int compare1(const void *x, const void *y) {
	return ((s*)x)->Y - ((s*)y)->Y;
}

int compare2(const void *x, const void *y) {
	return ((s*)x)->tmp1 - ((s*)y)->tmp1;
}

int main() {
	int N, M, tmp2[100000] = {0};
	s tmp1[100000];
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> tmp1[i].P >> tmp1[i].Y;
		tmp1[i].tmp1 = i;
	}
	qsort(tmp1, M, sizeof(s), compare1);
	for (int i = 0; i < M; ++i) {
		++tmp2[tmp1[i].P - 1];
		tmp1[i].tmp2 = tmp2[tmp1[i].P - 1];
	}
	qsort(tmp1, M, sizeof(s), compare2);
	for (int i = 0; i < M; ++i) cout << setw(6) << setfill('0') << tmp1[i].P << setw(6) << setfill('0') << tmp1[i].tmp2 << endl;
}

Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
#define ll           long long int
#define ld           long double
#define vi           vector<ll>
#define vvi          vector<vi>
#define vs           vector<string>
#define pb           push_back
#define pf           push_front
#define mp           make_pair
#define fs           first
#define se           second
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define fall(x)      (x).begin(),(x).end(),x.begin()
#define fastio       ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    fastio
    string s,s1,s2=""; cin>>s>>s1;
    for(ll i=0;i<s1.size()-1;i++)
    {
        s2+=s1[i];
    }
    if(s2==s)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n, a, b, c, x;
    cin >> n >> a >> b >> c >> x;
    if(n == 0) break;
    int fl = 0;
    for(int i = 0; i < n; i++) {
      int y;
      cin >> y;
      if(fl > 10000) continue;
      if(i > 0) {
        fl++;
        x = (a * x + b) % c;
      }
      while(y != x) {
        fl++;
        x = (a * x + b) % c;
        if(fl > 10000) {
          y = x;
        }
      }
      // can't use the same one
    }
    cout << (fl > 10000 ? -1 : fl) << endl;
  }
  return 0;
}



Measured memory_bytes: 2964
#include <cstdio>

int main(){
    char s[101];
    scanf("%s",s);
    int count = 0;
    for(int i = 0; s[i] != '\0'; i++){
        count++;
    }
    printf("%c%d%c\n",s[0],count - 2,s[count - 1]);

    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin>>n;
    REP(i,n.size())
    {
        if(n[i] == '1')n[i] = '9';
        else n[i] = '1';
    }     
    PUTS(n);
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; i++)
        cin >> A[i];
    long long ans = 0;
    int max_height = 0;
    for (int i = 0; i < n; i++) {
        max_height = max(max_height, A[i]);
        int stool = max_height - A[i];
        ans += stool;
    }        
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int main(){
	int n;
	scanf("%d",&n);
	ll ans=1LL*n*(n+1)*(n+2)/6;
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(u>v) swap(u,v);
		ans-=1LL*u*(n-v+1); 
	}
	printf("%lld\n",ans); 
	return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	vector<int> AA;
	string S;
	int f = 0;
	cin >> S;
	
	for (int i = 0; i < 4; i++)
	{
		int c = (int)(S[i] - '0');
		AA.push_back(c);
	}
	for (int i = 0;i<3;i++)
	{
		if (AA[i] == AA[i + 1]) { f = 1; }
	}
	
	if (f == 1) { cout << "Bad" << endl; }
	if (f == 0) { cout << "Good" << endl; }

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)
























int main(){
    ll n;
    cin >> n;
    vector<ll> c(n + 1);
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        for(ll j = i; j <= n; j += i){
            c[j]++;
        }
        ans += i * c[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 81412
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
 
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define MAX_V 100000

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
 
using namespace std;
 
typedef pair<int,int> pii;
 
struct edge{int to;llong cost;};

vector<edge> G[MAX_V];
llong depth[MAX_V];

void dfs(int v, int par, llong d){
  depth[v] = d;
  REP(i,(int)G[v].size()){
    if(G[v][i].to == par) continue;
    dfs(G[v][i].to, v, d + G[v][i].cost);
  }
}

int main(){

  int n;
  scanf("%d", &n);

  REP(i,n-1){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a--; b--;

    G[a].push_back({b,c});
    G[b].push_back({a,c});
  }

  int q, k;
  scanf("%d %d", &q, &k);

  k--;
  dfs(k, -1, 0);
  REP(i,q){
    int x, y;
    scanf("%d %d", &x, &y);
    x--; y--;
    printf("%lld\n", depth[x] + depth[y]);
  }
  return 0;
}



Measured memory_bytes: 17408
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    return gcd_ori(b, a % b);
}

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);

    if(n==2){
       ll tmp;
       tmp = max(a.at(0), a.at(1));
       cout << tmp << endl; 
       return 0;
    }

    sort(a.begin(), a.end());
    ll gcdn = a.at(0);
    rep(i, n){
        gcdn = gcd_ori(a.at(i), gcdn);
    }
    
    ll allgcd2 = a.at(1);
    for(int i=2; i<n; i++){
        allgcd2 = gcd_ori(a.at(i), allgcd2);
    }

    ll allgcd = a.at(0);
    int cnt = 0;
    rep(i, n){
        if(i==0) continue;
        ll tmp;
        tmp = gcd_ori(a.at(i), allgcd); 

        if(gcdn==tmp && cnt==0){
            a.at(i) = allgcd;
            tmp = allgcd;
            cnt++;
        }
        else if(gcdn==tmp && cnt==1){
            allgcd = gcdn;
            break;
        }
        
        allgcd = tmp;
    }

    ll ans = max(allgcd, allgcd2);
    cout << ans << endl;
    return 0;
}


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

const Int INF = 1e18;

vector<Int> P, Ng, Z;
Int K;

bool PtimesNg(Int x) {
    Int sum = 0;
    rep(i, P.size()) {
        Int d = (x + P[i] - 1) / P[i];
        sum += Ng.end() - lower_bound(Ng.begin(),Ng.end(), d);
    }
    return (sum >= K);
}

bool PtimesP_NgtimesNg(Int x) {
    Int sum = 0;
    rep(i, P.size()) {
        Int d = (x + P[i] - 1) / P[i];
        Int temp = P.end() - lower_bound(P.begin(), P.end(), d);
        if (temp + i >= P.size()) temp--;
        sum += temp;
    }

    rep(i, Ng.size()) {
        Int d = (x + Ng[i] - 1) / Ng[i];
        Int temp = Ng.end() - lower_bound(Ng.begin(), Ng.end(), d);
        if (temp + i >= Ng.size()) temp--;
        sum += temp;
    }

    sum /= 2;

    return (sum >= K);
}

int main(){ 
    Int N, p, n, z, negative, zero, positive, p_max = 0, n_max = 0;
    cin >> N >> K;

    rep(i,N) {
        Int A; cin >> A;
        if (A > 0) P.push_back(A);
        else if (A < 0) Ng.push_back(-A);
        else Z.push_back(A);
    }

    sort(P.begin(), P.end());
    sort(Ng.begin(), Ng.end());

    p = P.size();
    n = Ng.size();
    z = Z.size();

    //cout << p << " " << z << " " << n << endl;


    negative = n * p;
    positive = p * (p-1) / 2 + n * (n-1) / 2;
    zero = z * (n + p) + z * (z-1) / 2;

    if (K <= negative) {
        Int U = INF, B = 1;
        while (U - B > 1) {
            Int mid = (U + B) / 2;
            if (PtimesNg(mid)) B = mid;
            else U = mid;
        }
        cout << -B << endl;
    }

    else if (K <= negative + zero) {
        cout << 0 << endl;
        return 0;
    }

    else {
        K = N * (N-1) / 2 - K + 1;
        Int U = INF, B = 1;
        while (U - B > 1) {
            Int mid = (U + B) / 2;
            if (PtimesP_NgtimesNg(mid)) B = mid;
            else U = mid;
        }
        cout << B << endl;
    }
}


Measured memory_bytes: 2548
#[allow(unused_imports)]
use std::collections::HashSet;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let hw = read_vec::<usize>();
    let h = hw[0];
    let w = hw[1];

    let mut shogai_yoko : Vec<Vec<usize>> = Vec::with_capacity(h);
    let mut shogai_tate : Vec<Vec<usize>> = Vec::with_capacity(w);
    for _i in 0..w {
        let v : Vec<usize> = Vec::with_capacity(h);
        shogai_tate.push(v)
    }
    
    for i in 0..h {
        let mut v : Vec<usize> = Vec::with_capacity(w);
        let s = read::<String>();
        for (j, c) in s.chars().enumerate() {
            if c == '#' {
                v.push(j);
                shogai_tate[j].push(i)
            }
        }
        v.push(w);
        shogai_yoko.push(v);
    }
    for j in 0..w {
        shogai_tate[j].push(h)
    }


    let answer = solve(h, w, &shogai_yoko, &shogai_tate);
    println!("{}", answer);
}

fn solve(h: usize, w: usize, shogai_yoko: &[Vec<usize>], shogai_tate: &[Vec<usize>]) -> usize {
     // (yoko, tate)
     let mut dp : Vec<Vec<usize>> = Vec::with_capacity(h);
     for _i in 0..h {
        let v : Vec<usize> = vec![0; w];
        dp.push(v);
     }

     // yoko
     for i in 0..h {
        let mut from = 0;
        for x in &shogai_yoko[i] {
            let d = x - from;
            if d > 1 {
                for j in from..*x {
                    dp[i][j] = d - 1;
                }
            }
            from = x + 1;
        }
    }

    // tate (and total)
    let mut max = 0;
    for j in 0..w {
        let mut from = 0;
        for x in &shogai_tate[j] {
            let d = x - from;
            if d > 0 {
                for i in from..*x {
                    let val = dp[i][j] + (d - 1);
                    if val > max {
                        max = val
                    }
                }
            }
            from = x + 1;
        }
    }
    return max + 1
}

Measured memory_bytes: 192764
#include <iostream>
using namespace std;
int main(){
  int n,m,k,l;
  cin >> n>>m;
  int a[n]={0};
  for(int i=0;i<m;i++){
    cin >>k>>l;
    a[k-1]++;a[l-1]++;
  }
  for(int i=0;i<n;i++){
    cout << a[i]<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool g[101][101];
int main(){
	int m,n;
	cin>>m>>n;
	cout<<"100 100"<<endl;
	for(int i=0;i<50;i++)
	for(int j=0;j<100;j++)
	g[i][j]=1;
	m--;
	for(int i=0;i<50;i+=2)
	for(int j=0;j<100;j+=2){
		if(m==0)
		break;
		g[i][j]=0;
		m--;
	}
	n--;
	for(int i=99;i>=50;i-=2)
	for(int j=0;j<100;j+=2){
		if(n==0)
		break;
		g[i][j]=1;
		n--;
	}
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++)
		if(g[i][j]) cout<<"#";
		else
		cout<<".";
		cout<<endl;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
char a;

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);
	cin>>a;
	cout<<(char)(a-'0'+49);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;
typedef long long ll;


int main()
{
	ll x,y;
	cin>>x>>y;
	ll i=0,tot=1;
	ll sum=y/x;
	while(tot<=sum){
		tot*=2;
		i++;
	}
	printf("%lld",i);
	return 0;
}	 


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

int main()
{
	long A;
	long double B;
	long C;
	cin >> A >> B;
	
	C = A * B; 
	cout << C << endl;
	
	return 0;
	

}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int m, d;
		cin >> m >> d;
		int ret = 0;
		for(int i=1; i <= m; i++){
			for(int j = 1; j <= d; j++){
				if(j % 10 < 2)continue;
				if(j/ 10 < 2)continue;
				if(i == (j%10) * (j / 10)){
					ret++;
				}
			}
		}
		cout << ret << endl;
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

inline int apply(int bit, string &s){
    return s[bit]-'0';
}

int main(){
    string s;
    while(cin>>s, s[0]!='#'){
        bool flag=true;
        for(int b=0;b<(1<<19);b++){
            //bit3
            int bit0=apply(((b>>0)&1)*1+((b>>1)&1)*2+((b>>3)&1)*4+((b>>4)&1)*8+((b>>5)&1)*16+((b>>8)&1)*32+((b>>9)&1)*64, s);
            int bit1=apply(((b>>1)&1)*1+((b>>2)&1)*2+((b>>4)&1)*4+((b>>5)&1)*8+((b>>6)&1)*16+((b>>9)&1)*32+((b>>10)&1)*64, s);
            int bit2=apply(((b>>3)&1)*1+((b>>4)&1)*2+((b>>7)&1)*4+((b>>8)&1)*8+((b>>9)&1)*16+((b>>12)&1)*32+((b>>13)&1)*64, s);
            int bit3=apply(((b>>4)&1)*1+((b>>5)&1)*2+((b>>8)&1)*4+((b>>9)&1)*8+((b>>10)&1)*16+((b>>13)&1)*32+((b>>14)&1)*64, s);
            int bit4=apply(((b>>5)&1)*1+((b>>6)&1)*2+((b>>9)&1)*4+((b>>10)&1)*8+((b>>11)&1)*16+((b>>14)&1)*32+((b>>15)&1)*64, s);
            int bit5=apply(((b>>8)&1)*1+((b>>9)&1)*2+((b>>12)&1)*4+((b>>13)&1)*8+((b>>14)&1)*16+((b>>16)&1)*32+((b>>17)&1)*64, s);
            int bit6=apply(((b>>9)&1)*1+((b>>10)&1)*2+((b>>13)&1)*4+((b>>14)&1)*8+((b>>15)&1)*16+((b>>17)&1)*32+((b>>18)&1)*64, s);
            if(bit3!=apply(bit0*1+bit1*2+bit2*4+bit3*8+bit4*16+bit5*32+bit6*64, s)){
                flag=false;
                break;
            }
        }
        cout<<(flag?"yes":"no")<<endl;
    }

    return 0;
}


Measured memory_bytes: 3124
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,m = map(int,input().split())
    xyz = [list(map(int,input().split())) for i in range(n)]
    anslist = []
    for i in range(8):
        sub = []
        for j in range(n):
            tmp = 0
            for k in range(3):
                if ((i>>k)&1):
                    tmp -= xyz[j][k]
                else:
                    tmp += xyz[j][k]
            sub.append(tmp)
        sub.sort(reverse = True)
        anslist.append(sum(sub[:m]))
    print(max(anslist))

if __name__ == "__main__":
    main() #endline===============================================
    

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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<int>> vec(10,vector<int>(10));
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin>>vec.at(i).at(j);
      }
    }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<10;k++){
        vec.at(j).at(k)=min(vec.at(j).at(k),vec.at(j).at(i)+vec.at(i).at(k));
        }
      }
    }
  int p,q=0;
  for(int i=0;i<h*w;i++){
    cin>>p;
    if(p!=-1){
      q+=vec.at(p).at(1);
      }
    }
  cout<<q<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=[]
B=[]

for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

l=[]
r=[]
A.sort()
B.sort()

if N%2==1:
    n=N//2
    ans=B[n]-A[n]+1
else:
    n1=N//2-1
    n2=N//2
    ans=B[n1]-A[n1]+B[n2]-A[n2]+1

print(ans)

Measured memory_bytes: 25312
#include <iostream>
using namespace std;
 
bool is_prime[1000000+1];
void prime(int n){
    for(int i=0;i<n+1;i++){
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<n+1;i++){
        if(is_prime[i]==true){
            for(int j=i+i;j<n+1;j+=i){
                is_prime[j] = false;
            }
        }
    }
}
 
int main()
{
    int n,m;
    prime(1000000);
    while(cin >> n >> m){
        if(!n && !m)
            break;
        bool DP[1000000+1];
        for(int i=0;i<m+1;i++)
            DP[i] = false;
        DP[0] = true;
        int ryori;
        for(int i=0;i<n;i++){
            cin >> ryori;
            for(int j=0;j<m+1-ryori;j++)
                if(DP[j])
                    DP[j+ryori] = true;
        }       
         
        for(int i=m;i>=0;i--){
            if(is_prime[i] && DP[i]){
                cout << i << endl;
                break;
            }
            else if(i==0){
                cout << "NA" << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
    int n,q;
    int S[10100];
    int t;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> S[i];
    }
    cin >> q;
    int cnt=0;
    for(int i=0;i<q;i++){
        cin >> t;
        S[n] =t;
        int j=0;
        while(S[j]!=t){
            j++;
        }
        if(j!=n)cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3136
H, W = map(int, input().split())

P = [[0 if x == "#" else 1 for x in input()] for _ in range(H)]
C = [[-3*P[x][y] for y in range(W)] for x in range(H)]

for j in range(W):
    cntU = 0
    cntD = 0
    for i in range(H):
        if P[i][j] == 0:
            cntD = 0
        else:
            cntD += 1
        C[i][j] += cntD 

        if P[H-1-i][j] == 0:
            cntU = 0
        else:
            cntU += 1
        C[H-1-i][j] += cntU 

for i in range(H):
    cntR = 0
    cntL = 0
    for j in range(W):
        if P[i][j] == 0:
            cntR = 0
        else:
            cntR += 1
        C[i][j] += cntR 

        if P[i][W-1-j] == 0:
            cntL = 0
        else:
            cntL += 1
        C[i][W-1-j] += cntL 




print(max((x for ci in C for x in ci)))


Measured memory_bytes: 115804
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

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

        for(int i=0; i<N; i++){
            for(int j=0; j<10; j++){
                F[i][j] = sc.nextInt();
            }
        }

        int[][] P = new int[N][11];
        for(int i=0; i<N; i++){
            for(int j=0; j<11; j++){
                P[i][j] = sc.nextInt();
            }
        }
        int ans = -1 * Integer.MAX_VALUE;
        for(int i=1; i<(1<<10); i++){
            int cost = 0;
            for(int j=0; j<N; j++){
                int c =0;
                for(int k=0; k<10; k++){
                    if((i>>k&1)==1 && F[j][k]==1){
                        c++;
                    }
                }
                cost += P[j][c];
            }
            ans = Math.max(ans, cost);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 26220
from collections import Counter
n,k = map(int,input().split())
L = list( map(int,input().split()))
l = len(L)
L = Counter(L)
L = sorted(list(L.most_common(k)))

ans = 0
for i in range(len(L)):
    ans += L[i][1]
if l >= ans:
    print(l - ans)
else:
    print(0)

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

typedef long long lint;
#define MAX 501
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int N;
lint C[MAX];
lint S[MAX];
lint F[MAX];

int main() {
    cin >> N;
    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];
    
    rep(j, N) {
        lint x = 0;
        for(int i = j; i < N - 1; i++) {
            if(x < S[i]) x = S[i];
            if(x % F[i]) x = F[i] * (x / F[i] + 1);
            x += C[i];
        }
        cout << x << endl;
    }
}

Measured memory_bytes: 256
var 
  a, b: Integer;
begin
  // 入力
  Readln(a, b);
  if a = b then
    Writeln('Draw')
  else if a = 1 then
    Writeln('Alice')
  else if b = 1 then
    writeln('Bob')
  else if a > b then
    writeln('Alice')
  else
    writeln('Bob');
end.

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

int main(){
  int N;
  cin >> N;
  
  uint64_t out=0;
  for (int i = 1; i <=N; i++) {
     int no = i;
     
     if((no % 3 == 0)  && (no % 5 == 0) ){
         out += 0;
     }
     else if((no % 3 == 0) && (no % 5 != 0) ){
         out += 0;
     }
     else if((no % 3 != 0) && (no % 5 == 0) ){
         out += 0;
     }
     else{
        out += no;
     }
  }
  std::cout <<out << std::endl;
  
}



Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#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 ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(ll i=a;i<(b);i++)
#define fj(a,b) for(ll j=a;j<(b);j++)
#define fk(a,b) for(ll k=a;k<(b);k++)
//hash base 177013


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		//if(b>=0&&d>=0)
		//{
			//cout<<b*d<<'\n';
		//}
		//else if(b<0&&d<0)
		//{
			//cout<<a*c<<'\n';
		//}
		//else if(b<0&&d>=0)
		//{
			//cout<<b*d<<'\n'
		//}
		//else 
		//{
			//cout<<b
		//}
		cout<<max({a*c,a*d,b*c,b*d});
		
	}
}



Measured memory_bytes: 3644
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a <= 9 && b <= 9) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
        sc.close();
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N,K,counter=0;
	cin >> N >> K;
	vector<int> h(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> h.at(i);
		if (h.at(i) >= K) counter++;
	}
	cout << counter<<endl;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  
  REP(i, n) {
    double x[4], y[4];
    REP(i, 4) cin >> x[i] >> y[i];

    double x1, x2, y1, y2;
    x1 = x[0] - x[1];
    y1 = y[0] - y[1];
    x2 = x[2] - x[3];
    y2 = y[2] - y[3];
    
    if(abs(x1 * y2 - x2 * y1) < EPS) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1224