akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vs a(n-1);
    rep(i, n-1) cin >> a[i];
    vector<vector<bool>> win(n, vector<bool>(n));
    rep1(i, n-1) rep(j, i) {
        win[i][j] = (a[i-1][j] == '1');
        win[j][i] = !(a[i-1][j] == '1');
    }
    vector<bitset<2005>> dpfl(n), dpfr(n), dpbl(n), dpbr(n);
    rep(i, n) dpfl[i][i] = dpfr[i][i] = dpbl[i][i] = dpbr[i][i] = true;
    rep1(i, n-1) rep(a, n-i) {
        int b = a + i;
        bool lok = false;
        if ((dpfl[b]&dpbl[a]).any()) lok = true;
        if (!lok && win[a][b]) {
            if (((dpfr[b]>>1)&dpbl[a]).any()) lok = true;
        }
        dpfl[b][a] = dpbl[a][b] = lok;
        bool rok = false;
        if ((dpfr[b]&dpbr[a]).any()) rok = true;
        if (!rok && win[b][a]) {
            if (((dpfr[b]>>1)&dpbl[a]).any()) rok = true;
        }
        dpfr[b][a] = dpbr[a][b] = rok;
    }
    int ans = 0;
    rep(i, n) if (dpbr[0][i] && dpfl[n-1][i]) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8788
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
using ui = unsigned int;
using ul = unsigned long;
#pragma GCC optimize("Ofast")
#define loop(i, n) for (ui i = 0; i < n; i++)
ul bit[550001];
struct BIT
{
    ui n;
    inline ul sum(ui x)
    {
        ul ret = 0;
        while (x > 0)
        {
            ret += bit[x];
            x -= x & -x;
        }
        return ret;
    }
    BIT(ui n0) : n(n0) {}
    inline ul sum(ui l, ui r)
    {
        return sum(r + 1) - sum(l);
    }
    inline void add(ui i, ul x)
    {
        i++;
        while (i <= n)
        {
            bit[i] += x;
            i += i & -i;
        }
    }
};
class FastIO
{
    static const int rdata_sz = (1 << 25), wdata_sz = (1 << 25);
    char rdata[rdata_sz], wdata[wdata_sz], *rb, *wb;
    char tmp_s[20];

public:
    FastIO()
    {
        fread(rdata, 1, rdata_sz, stdin);
        rb = rdata;
        wb = wdata;
    }
    ~FastIO()
    {
        fwrite(wdata, 1, wb - wdata, stdout);
    }

    template <typename T>
    inline void read(T &x)
    {
        bool neg = false;
        x = 0;
        while ((*rb < '0' || *rb > '9') && *rb != '-')
            ++rb;
        if (*rb == '-')
        {
            neg = true;
            ++rb;
        }
        while ('0' <= *rb && *rb <= '9')
        {
            x = 10 * x + (*rb - '0');
            ++rb;
        }
        if (neg)
            x = -x;
    }

#define pc(x) *(wb++) = x
    template <typename T>
    inline void write(T x)
    {
        if (x == 0)
        {
            pc('0');
            pc('\n');
            return;
        }
        if (x < 0)
        {
            pc('-');
            x = -x;
        }
        char *t = tmp_s;
        while (x)
        {
            T y = x / 10;
            *(t++) = (x - y * 10) + '0';
            x = y;
        }
        while (t != tmp_s)
            pc(*(--t));
        pc('\n');
    }
#undef pc
};
int main()
{
    FastIO io;
    ui N, Q;
    io.read(N);
    io.read(Q);
    BIT data(N);
    loop(i, N)
    {
        ul A;
        io.read(A);
        bit[i + 1] = A;
    }
    for (ui i = 1; i < N; i++)
        bit[i + (i & -i)] += bit[i];
    loop(i, Q)
    {
        ui a, b, c;
        io.read(a);
        io.read(b);
        io.read(c);
        if (a == 0)
            data.add(b, c);
        else
            io.write(data.sum(b, c - 1));
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int64_t x[100], y[100];
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }

    double ans = 0;
    double cx, cy;
    int64_t N1 = 100000;
    for(int i=0;i<N1;i++){
        double v[2] = {cos(2.0*M_PI*i/N1), sin(2.0*M_PI*i/N1)};
        cx = cy = 0.0;
        for(int j=0;j<n;j++){
            if(v[0]*x[j] + v[1]*y[j] >= 0){
                cx += x[j];
                cy += y[j];
            }
        }
        if(cx*cx + cy*cy >= ans){
            ans = cx*cx + cy*cy;
        }
    }
    cout.precision(12);
    cout.setf(ios_base::floatfield, ios_base::fixed);
    cout << sqrt(ans) << endl;
    
    return 0;
}

Measured memory_bytes: 512
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char
import Data.List

solve :: VU.Vector Int -> Int -> [Int]
solve xs n = map snd . sort . VU.toList $ (VU.zip xs ids)
    where
        ids = VU.fromList [1..n] 
        
main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    putStrLn . unwords . map show $ solve xs n

Measured memory_bytes: 28284
// template version 1.2
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0LL)
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

template<typename A, size_t N, typename T> // n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n;cin>>n;

  vi x(n);
  vi y(n);
  vi h(n);
  rep(i, n){
    cin>>x[i]>>y[i]>>h[i];
  }

  rep(i, 101){
    rep(j, 101){
      vi s;
      int u = INF;
      rep(q, n){
        int tmp = h[q]+(abs(x[q]-i)+abs(y[q]-j));
        if (h[q]>0){
          if (sz(s)==0 or s[0]!=tmp) s.pb(tmp);
        }
        else{
          chmin(u, tmp);
        }
      }
      if (sz(s)==1 and s[0]<=u) {
        cout << i << " " << j << " " << s[0] << endl;
        return 0;
      }
      else if(sz(s)==0 and u==1){
        cout << i << " " << j << " " << 1 << endl;
        return 0;
      }
    }
  }

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int a, b, k;
    cin>>a>>b>>k;
    for (int i=0; i<k; i++)
    {
        if (i%2==0)
        {
            if (a%2==1) a--;
            b+=a/2;
            a/=2;
        }
        else{
            if (b%2==1) b--;
            a+=b/2;
            b/=2;
        }
    }
    cout<<a<<' '<<b<<endl;
    return 0;
}


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

int main(){
  int P, Q, R;
  cin >> P >> Q >> R;
  int ANS=P+Q;
  
  if(ANS>Q+R){
    ANS = Q+R;
  }
  if(ANS>R+P){
    ANS = R+P;
  }
  
  cout << ANS <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    double pi = 3.1415926535;
    cin.tie(0); ios::sync_with_stdio(false);
    double a,b,h,m;
    IN(a,b,h,m);
    int x = 30*(int)h%360;
    double v = x-5.5*m;
    double ans = sqrt(a*a+b*b-2*a*b*cos(v*pi/180));
    printf("%.10lf\n",ans);
    debug(v);
}

Measured memory_bytes: 4248
N = int(input())

num3 = N//3
num5 = N//5
num15 = N//15

ans = 1/2*N*(N+1) - 1/2*num3*(num3+1)*3 - 1/2*num5*(num5+1)*5 + 1/2*num15*(num15+1)*15
print(int(ans))

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n;
    char tmp[20];
    while (~scanf("%d", &n)) {
        double sum = 0.0;
        REP(i,1,n) {
            double x;
            scanf("%lf %s",&x,tmp);
            if (tmp[0]=='J') sum += x;
            else sum += x * 380000;
        }
        printf("%.10f\n", sum);
    }
    
    return 0;
}



Measured memory_bytes: 256
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken().to!int; }
long readLong() { return readToken().to!long; }
real readReal() { return readToken().to!real; }

void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }


int N;
int A, B;
int[] P;

void main() {
  try {
    for (; ; ) {
      N = readInt();
      A = readInt();
      B = readInt();
      P = new int[N];
      foreach (i; 0 .. N) {
        P[i] = readInt();
      }
      const cnt1 = P.count!(p => (p <= A));
      const cnt2 = P.count!(p => (A + 1 <= p && p <= B));
      const cnt3 = P.count!(p => (B + 1 <= p));
      assert(cnt1 + cnt2 + cnt3 == N);
      writeln(min(cnt1, cnt2, cnt3));
    }
  } catch (EOFException e) {
  }
}


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

vector <int64_t>num(3);
vector<int>ans(1000010);

void jadge(int i,int p,int q){
  ans.at(i)=p;
  num.at(p)++;
  num.at(q)--;
}

int main()
{
  int N,p,q;
  cin >>N>>num.at(0)>>num.at(1)>>num.at(2);
 
  vector<vector<int>>x(N,vector<int>(2));
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    x.at(i).at(0)=s.at(0)-'A';
    x.at(i).at(1)=s.at(1)-'A';
  }
  for(int i=0;i<N;i++){
    p=x.at(i).at(0);
    q=x.at(i).at(1);
    if(num.at(p)==0&&num.at(q)==0){
      cout <<"No"<<endl;
      return 0;
    }
    else if(num.at(p)==0)
      jadge(i,p,q);
    else if(num.at(q)==0)
      jadge(i,q,p);
    else if(i!=N-1&&p==3-x.at(i+1).at(0)-x.at(i+1).at(1))jadge(i,q,p);
    else jadge(i,p,q);
  }
  cout <<"Yes"<<endl;
  for(int i=0;i<N;i++){
    cout <<(char)(ans.at(i)+'A')<<endl;
  }
  return 0;
}

Measured memory_bytes: 12768
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n;string s;
	lint x=0,a=0,b=0,c=0;
	cin>>n;cin>>s;
	rep(i,n){
		if(s[i]=='R') a++;
		if(s[i]=='G') b++;
		if(s[i]=='B') c++;
	}
	rep(i,n) REP(j,1,n-i){
		if(i+j+j>=n) continue;
		if(s[i]!=s[i+j] && s[i]!=s[i+j+j] && s[i+j]!=s[i+j+j]) x++;
	}
	cout<<a*b*c-x<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> Q;

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=998244353;
const int maxn=1e5+9;
const int maxx=1e9+9;

string a,b;
int num[20];

int main()
{
    cin>>a>>b;
    int la=a.size();
    for(int i=la-1,j=0;i>=0;i--,j++) num[j]=a[i]-'0';
    int lx=2;
    if(b[3]=='0')
    {
        lx--;
        if(b[2]=='0') lx--;
    }
    int m=b[0]-'0';
    if(lx>=1)
    {
        m=m*10+b[2]-'0';
        if(lx>=2) m=m*10+b[3]-'0';
    }
    if(m==0)
    {
        printf("0\n");
        return 0;
    }
    for(int i=0;i<la;i++) num[i]*=m;
    for(int i=0;i<la;i++)
    {
        if(num[i]>=10)
        {
            while(num[i]>=10) num[i]-=10,num[i+1]++;
            if(i==la-1) la++;
        }
    }
    int flag=0;
    for(int i=la-1;i>=lx;i--) printf("%d",num[i]),flag=1;
    if(flag==0) printf("0");
    printf("\n");
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<string> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int ac=0;
  int w=0;
  int t=0;
  int r=0;
  
  for(int i=0;i<n;i++){
    if(a.at(i)=="AC"){
      ac++;
    }
    if(a.at(i)=="WA"){
      w++;
    }
    if(a.at(i)=="TLE"){
      t++;
    }
    if(a.at(i)=="RE"){
      r++;
    }
  }
  cout<<"AC x "<<ac<<endl<<"WA x "<<w<<endl<<"TLE x "<<t<<endl<<"RE x "<<r<<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

ll N;
void input(){
    cin>>N;
    return;
}

void solve(){
    cout<<N*(N-1)/2<<endl;
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

int main(){
  ll n,t;
  cin >> n >> t;
  ll h;
  cin >> h;
  cout << t/h + 1 << endl;
  ll neck = h; // ??????
  ll sum = h; // ??\????????§?????????
  for(int i=1;i<n;i++){
    cin >> h;
    if(h <= neck){
      cout << max((ll)1, (t - sum) / neck + 1 + ((t - sum) - ((t - sum) / neck * neck) >= h)) << endl;
      sum += h;
    }else{
      neck = h;
      cout << max((ll)1, (t - sum) / neck + 1) << endl;
      sum += h;
    }
  }
  return 0;
}
/*
3 9
5 3 7
 */

Measured memory_bytes: 3116
#include <stdio.h>

int main(void){
    char s[5];
    int i;
    
    scanf("%s", s);
    
    switch(s[0]){
        case '0':
            if(s[1] == '0'){
                if((s[2] == '0' && s[3] >= '1') || (s[2] == '1' && s[3] <= '2')){
                    puts("YYMM");
                }else{
                    puts("NA");
                }
            }else{
                if((s[2] == '0' && s[3] >= '1') || (s[2] == '1' && s[3] <= '2')){
                    puts("AMBIGUOUS");
                }else{
                    puts("MMYY");
                }
            }
            
        
        break;
        
        case '1':
            if(s[1] <= '2'){
                if((s[2] == '0' && s[3] >= '1') || (s[2] == '1' && s[3] <= '2')){
                    puts("AMBIGUOUS");
                }else{
                    puts("MMYY");
                }
            }else{
                if((s[2] == '0' && s[3] >= '1') || (s[2] == '1' && s[3] <= '2')){
                    puts("YYMM");
                }else{
                    puts("NA");
                }
            }
        
        break;
        
        default:
        //MMXX
            if((s[2] == '0' && s[3] >= '1') || (s[2] == '1' && s[3] <= '2')){
                puts("MMYY");
            }else{
                puts("NA");
            }
        
        break;
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

constexpr int P_MAX = 400000;

vector<int> table(P_MAX, 0); // ずらしテーブル

void make_table(vector<int> p, int m) {
    int j = 0;
    for(int i=1;i<m;++i) {
        table[i] = j;
        if(p[i] == p[j]) {
            ++j;
        } else {
            j = 0;
        }
    }
}

vector<int> kmp(vector<int> s, vector<int> p, int n, int m, int start=0) {
    int i = start, j = 0;
    vector<int> ret;
    while(i < n) {
        if(s[i] == p[j]) {
            if(j == m-1) {
                ret.push_back(i-j);
                j = table[j];
            } else {
                ++i;
                ++j;
            }
        } else if(j == 0) {
            ++i;
        } else {
            j = table[j];
        }
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), a_diff, b_diff;
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    for(int i=1;i<2*n;++i) {
        a_diff.push_back(a[(i-1)%n]^a[i%n]);
    }
    for(int i=0;i<n;++i) {
        cin >> b[i];
    }
    for(int i=1;i<n;++i) {
        b_diff.push_back(b[i-1]^b[i]);
    }
    make_table(b_diff, n-1);
    
    vector<int> vk = kmp(a_diff, b_diff, 2*n-1, n-1);
    for(int k: vk) {
        if(k >= n) break;
        cout << k << " " << (a[k]^b[0]) << endl;
    }
}


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

using namespace std;
using ll = long long;

int main(){
    string s; cin >> s;
    int l = s.length();
    int count = 0;
    for (int i = 0; i < l; i++)
    {
        if(i % 2 == 0){
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
                count++;
            }
        }else{
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
                count++;
            }
        }
    }
    if(count == l) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
/* An ACEASH Source code  */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double

#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>

#define vvi vector< vector < int > >
#define vvl vector< vector < ll > >

#define pii pair< int , int >
#define pll pair< ll , ll >

#define vpl vector< pll >
#define vpi vector< pii >

#define MOD 1000000007

#define mp make_pair
#define pb push_back

#define sare(v) (v).begin(),(v).end()

#define F first
#define S second

#define tez  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ld pie = 3.1415926535897932384626 ;

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)));
    return 0;
}




Measured memory_bytes: 3640
#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>
#include <functional>

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 EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
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;

int main(void) {
    string S;
    cin >> S;

    cout << string(S.length(), 'x') << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++){
        if(A[i] == 0){
            cout << 0 << "\n";
            return 0;
        }
    }
    ll sum = 1;
    for(int i=0; i<N; i++){
        if(A[i] <= INF/sum){
            sum *= A[i];
        }else{
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << sum << "\n";
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M,S;
ll C[111],D[111];
vector<pair<ll,pll>> uvv[1111];

ll i, j, k;

void query(ll aa){
    ll i,j,k;
    priority_queue<pair<ll,pll>> q;
    vector<vector<bool>> mk(N + 5, vector<bool>(5555));
    q.push({0, {1, S > 5000 ? 5000 : S}});
    while(q.size()){
        ll d = q.top().first;
        pll qa = q.top().second;
        q.pop();
        ll a = qa.first;
        ll c = qa.second;
        if(a==aa){
            printf("%lld\n", -d);
            return;
        }
        if(mk[a][c])
            continue;
        mk[a][c] = true;
        if(c<5000){
            q.push({d - D[a], {a, min(5000ll, c + C[a])}});
        }
        fornum(i,0,uvv[a].size()){
            auto bbb = uvv[a][i];
            ll bb = bbb.first;
            ll cc = bbb.second.first;
            ll dd = bbb.second.second;
            if(c<cc)
                continue;
            if(mk[bb][c-cc])
                continue;
            q.push({d - dd, {bb, c - cc}});
        }
    }
}

int main(){
    scanf("%lld%lld%lld", &N, &M, &S);
    fornum(i,0,M){
        ll u, v, a, b;
        scanf("%lld%lld%lld%lld", &u, &v, &a, &b);
        uvv[u].push_back({v, {a, b}});
        uvv[v].push_back({u, {a, b}});
    }
    fornum(i,0,N){
        scanf("%lld%lld", &C[i+1], &D[i+1]);
    }

    fornum(i,1,N){
        query(i + 1);
    }
    return 0;
}

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

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

    int A, B;
    cin >> A >> B;

    int ans = B;
    if (A <= 5) ans = 0;
    else if (A <= 12) ans /= 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  bool ans = false;
  for(int i = 0;i<s.size();i++){
    if( s == t){
      ans = true;
      break;
    }
    s = s.back() + s.substr(0,s.size()-1);
  }
  if( ans ){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#AGC40 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
f = [i for i in range(n+1)]
f = list(accumulate(f))
lst = []
lst2 = []
i = 0
flg = False
while i < n:
    cnt = 0
    tmp = s[i]
    while i < n:
        if tmp == s[i]:
            i += 1
            cnt += 1
        else:
            break
    if s[i-1] == '<':
        t = cnt
        flg = True
    elif flg:
        lst2.append(min(t,cnt))
        flg = False
    lst.append(f[cnt])
cnt = 0
print(sum(lst) - sum(lst2))


Measured memory_bytes: 83264
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=4e4+5;
 
 
 
int main(){
	int N;
	cin>>N;
	int t[101];
	int v[101];
	rep1(i,N)cin>>t[i];
	rep1(i,N)cin>>v[i];
	
	//0.5秒ごとの区間に分け、各点での制限速度をメモ、速度は2倍で転記
	vi lm;
	v[0]=0;
	rep1(i,N){
		lm.push_back(2*min(v[i],v[i-1]));
		rep(j,2*t[i]-1)lm.push_back(2*v[i]);
	}
	lm.push_back(0);
	//前から見た最大速度と、後ろから見た最大速度を見る
	int l=sz(lm);
	int a[MAX];
	rep(i,l)a[i]=1e9;
	rep(i,l){
		for(int j=i-200;j<=i+200;j++){
			if(0<=j && j<=l-1){
				a[i]=min(a[i],lm[j]+abs(j-i));
			}
		}
	}
	double ans=0;
	rep(i,l)ans+=a[i];
	ans/=4;
	cout<<fixed;
	cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 640
#from scipy.special import comb
def ge():
    return map(int,input().split())
def main():
    #a,b,c,d=ge()
    #a=list(map(int,input().split()))
    #a=input()
    N=int(input())
    if N==1:
        print(0)
    #elif N==2:
        #print(2)
    else:
        #comb(N, 1, exact=True)
        #ans=N*(N-1)*(10**(N-2))
        ans=10**N-(9**N)*2+8**N
        print(ans%(10**9+7))
    #comb(4, 2, exact=True)


main()

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

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void solve(int test_case) {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*c,max(a*d,max(b*c,b*d)));
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3648
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
ll a[1010],b[1010],c[1010];
vector<ll> v,v1;
int main()
{
	int i,j,k,n,m,x,y,z,w;
	scanf("%d%d%d%d",&x,&y,&z,&w);
	for(i=0;i<x;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(i=0;i<y;i++)
	{
		scanf("%lld",&b[i]);
	}
	for(i=0;i<z;i++)
	{
		scanf("%lld",&c[i]);
	}
	for(i=0;i<x;i++)
	{
		for(j=0;j<y;j++)
		{
			v.push_back(a[i]+b[j]);
		}
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	v.resize(w);
	for(i=0;i<v.size();i++)
	{
		for(j=0;j<z;j++)
		{
			v1.push_back(v[i]+c[j]);
		}
	}
	sort(v1.begin(),v1.end());
	reverse(v1.begin(),v1.end());
	for(i=0;i<w;i++)
	{
		printf("%lld\n",v1[i]);
	//	cout<<v[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 43364
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	ll ans = 0;
	rep(i, n) {
		ll p = c.end() - (upper_bound(c.begin(), c.end(), b[i]));
		ll t = (lower_bound(a.begin(), a.end(), b[i])) - a.begin();
		ans += p * t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int s = Integer.parseInt(strArr[0]);
		HashSet<Integer> f = new HashSet<Integer>();
		f.add(s);
		int ans = 2;
		for (int a = s;; ans++) {
			if (a % 2 == 0)
				a = a / 2;
			else
				a = 3 * a + 1;

			// System.out.println(a + " " + f);

			if (f.contains(a))
				break;
			f.add(a);

		}
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
//  long long int n,k,ans=1;
 long long int a,b;
  cin>>a>>b;
  if((a>=10) ||(b>=10))
    cout<<"-1";
  else
    cout<<a*b;

  }


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
   return a%b ==0 ? b : gcd(b,a%b);
}
int main()
{
    int t;
    cin>>t;
    if(t<1200)
    cout<<"ABC"<<endl;
    else if( t<2800)
    cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    priority_queue<PLL> left,right;
    ll lctr=0,rctr=0;
    rp(i,n){
        string s;
        cin >> s;
        ll climb=0,lowest=0;
        int si=s.size();
        rp(j,si){
            if(s[j]=='(') {
                climb++;
                lctr++;
            }
            else{
                climb--;
                chmin(lowest,climb);
                rctr++;
            }
        }
        if(climb>=0) left.push(mp(lowest,climb));
        else right.push(mp(lowest-climb,-climb));
    }
    ll altitude=0;
    bool ok=true;
    if(lctr!=rctr) ok=false;
    while(ok&&!left.empty()){
        PLL pl=left.top(); left.pop();
        if(altitude+pl.first<0){
            ok=false;
            break;
        }
        altitude+=pl.second;
    }
    altitude=0;
    while(ok&&!right.empty()){
        PLL pl=right.top(); right.pop();
        if(altitude+pl.first<0){
            ok=false;
            break;
        }
        altitude+=pl.second;
    }
    Yes(ok);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

typedef pair<int,char> p;
p cond [5];
bool changed[3];
char num[3];
int main(void){
  int N,M;
  cin >> N >> M;
  //N桁の最小は 100....
  string str = "1";
  for(int i=0;i<N-1;i++){
    str = str + "0";
    changed[i] = false;
  }
  changed[N-1] = false;
  // N=1でM=0なら0 例外
  if(N==1 && M==0){
    cout << 0 << endl;
    return 0;
  }
  int max = 0;
  for(int i=0;i<M;i++){
    int s;
    char c;
    cin >> s >> c;
    cond[i] = make_pair(s,c);
    if(max < s)
      max = s;
  }
  //桁数がmax未満なら不可能
  if(max > N){
    cout << -1 << endl;
    return 0;
  }

  for(int i=0;i<M;i++){
    int s;
    char c;
    s = cond[i].first;
    c = cond[i].second;
    if(s == 1 && c == '0' && N > 1){
      cout << -1 << endl;
      return 0;
    }
    if(!changed[s]){
      str[s-1] = c;
      changed[s] = true;
      num[s] = c;
    }else if(num[s] != c){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << str << endl;
  return 0;
  
}


Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input())
    M = int(input())
    T = []
    for _ in range(M):
        T.append(input())

    ans = 0
    for s in S:
        ans = max(ans, S.count(s) - T.count(s))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
import sys

def solve():
    n = int(input())
    alps = [0] * 26

    for i in range(n):
        s = input()

        if i == 0:
            for ch in s:
                alps[ord(ch) - ord('a')] += 1
        else:
            tmp = [0] * 26

            for ch in s:
                tmp[ord(ch) - ord('a')] += 1

            for i in range(26):
                alps[i] = min(alps[i], tmp[i])

    ans = ''

    for i in range(26):
        ans += chr(i + ord('a')) * alps[i]

    print(ans)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;

int main() {

  int a, b, c;
  cin >> a >> b >> c;
  if( a == b ) cout << c << endl;
  if( a == c ) cout << b << endl;
  if( b == c ) cout << a << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;
#define length 800010

int main(void){
  char* S=(char*)malloc(sizeof(char)*length);
  string s;
  cin>>s;
  long left=length/2;
  long right=left+s.size()-1;
  for(int i=0;i<s.size();i++){
    S[length/2+i]=s[i];
  }
  int t,f;
  char c;
  int rev=0;
  int Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    cin>>t;
    if(t==1){
      rev++;
      rev=rev%2;
    }
    else{
      cin>>f>>c;
      if((f==1 and rev==0) || (f==2 and rev==1)){
        left--;
        S[left]=c;
      }
      else{
        right++;
        S[right]=c;
      }
    }
  }
  if(rev==0){
    for(long i=left;i<=right;i++){
      cout<<S[i];
    }
  }
  else{
    for(long i=right;i>=left;i--){
      cout<<S[i];
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int prime(int n) {
	int a;

	for (a = 2; a * a <= n; a++)
		if (n % a == 0)
			return 0;
	return 1;
}

int main() {
	int x;

	scanf("%d", &x);
	while (!prime(x))
		x++;
	printf("%d\n", x);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  int S, h, m, s2;
  scanf("%d", &S);
  h = S / 3600;
  m = (S - h*3600) / 60;
  s2 = S - h*3600 - m*60;

  printf("%d:%d:%d\n", h, m, s2);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>

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

using namespace std;



int main() {
    int r,d,x;
    cin>>r>>d>>x;
    rep(i,10){
        x=r*x-d;
        cout<<x<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys

N,M = map(int,input().split())

AB = []
lis = [ [] for i in range(N)]

for i in range(M):

    A,B = map(int,input().split())

    A -= 1
    B -= 1

    lis[A].append(B)

q = deque([])

first = [-1] * (N+1)
first[0] = 0
first[-1] = 0

q.append( first )

end = [True] * N
end[0] = False

while len(q) > 0:

    now = q.pop()
    lasp = now[-1]
    nownum = now[lasp] 

    #print (q,now,lasp,nownum)

    for nex in lis[lasp]:

        if now[nex] == -1:
            ncopy = now.copy()
            ncopy[nex] = nownum + 1
            ncopy[-1] = nex
            end[nex] = False
            q.append(ncopy)

        else:

            flag = True

            for i in range(N):

                if now[i] >= 0:

                    for j in lis[i]:

                        if (now[j] >= now[nex] and now[j] != now[i] + 1) and not (i == lasp and j == nex):
                            flag = False
                            break

                if not flag:
                    break

            if flag:
                ans = []

                for i in range(N):
                    if now[i] >= now[nex]:
                        ans.append(i + 1)

                print (len(ans))
                for i in ans:
                    print (i)

                sys.exit()

    if len(q) == 0:
        for i in range(N):
            if end[i]:

                first = [-1] * (N+1)
                first[i] = 0
                first[-1] = i
                q.append(first)
                end[i] = False
                break
            #print (flag,nex,lasp)

print (-1)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <vector>	

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long long> vl;

typedef pair<int,int> pi;
typedef pair<double,double> pd;

#define pb push_back
#define mp make_pair

#define endl "\n"
typedef long long ll;
typedef unsigned int uint;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

int INF = 1e9+1;

int main(){
	fastio();
	string s;
	cin>>s;
	if (s[0] == 'A' && s[1] == 'B' || s[1] == 'A' && s[2] == 'B' || s[0] == 'B' && s[1] == 'A' || s[1] == 'B' && s[2] == 'A' )
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,i)for(typename make_signed<decltype(i.second)>::type t=i.first,_l##t=i.second;t<_l##t;t++)
#define RREP(t,i)for(typename make_signed<decltype(i.second)>::type t=i.second-1,_l##t=i.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(i)begin(i),end(i)
#define rall(i)i.rbegin(),i.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; Next(a); return a; }
  template<class A, class B>void Next(pair<A, B>& a) { cin >> a.first >> a.second; }
  template<class A>void Next(A& a) { cin >> a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) (*this), i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;
/*---------------------------------------------------------------------*/


void Calc() {

  var(ll, n, x);
  auto a = in.Array(n);
  rep(i, n)a.push_back(a[i]);
  const ll INFL = 1e18 - 1;

  ll ans = INFL;
  deque<int> s;

  rep(i, n + 1) {
    rep(j, i) {
      int index = j + n - i;
      int c = a[index];
      while (s.size() && a[s.back()] >= c) {
        s.pop_back();
      }
      s.push_back(index);
    }
    ll tmp = 0;
    rep(j, n, n * 2) {
      int c = a[j];
      while (s.size() && a[s.back()] >= c) {
        s.pop_back();
      }
      s.push_back(j);
      while (s.size() && s.front() < j - i) {
        s.pop_front();
      }
      err(s, i, j, j - i);
      auto pos = s.front();
      tmp += a[pos];
    }
    tmp += x * i;
    amin(ans, tmp);
  }
  cout << (ans) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    long long n = (x / 11) * 2;
    long long l = x % 11;

    if (l != 0) {
        if (l <= 6)
            n += 1;
        else
            n += 2;
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 888