akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;

const ll MOD = 1000000007;

template<typename T> class BIT {
private:
    int n,m; vector<vector<T> > bit;
public:
    void add(int i, int j, T val){
        for(int i_ = i+1; i_ < n; i_ += i_ & -i_)
            for(int j_ = j+1; j_ < m; j_ += j_ & -j_)
                (bit[i_][j_] += val) %= MOD;
    }
    // [0,i]×[0,j]の範囲の和を求める
    T sum(int i, int j){
        T s = 0;
        for(int i_ = i+1; i_ > 0; i_ -= i_ & -i_)
            for(int j_ = j+1; j_ > 0; j_ -= j_ & -j_)
                (s += bit[i_][j_]) %= MOD;
        return s;
    }
    // [lx, rx)×[ly, ry)の範囲の和を求める
    T sum(int lx, int rx, int ly, int ry){
        return ((sum(rx-1, ry-1) - sum(lx-1, ry-1) - sum(rx-1, ly-1) + sum(lx-1, ly-1)) % MOD + MOD) % MOD;
    }
    BIT(int sz1, int sz2){
        n = sz1 + 1, m = sz2 + 1;
        bit.resize(n, vector<T>(m, 0));
    }
    BIT(vector<vector<T> >& v){
        n = (int)v.size()+1, m = (int)v[0].size()+1;
        bit.resize(n, vector<T>(m, 0));
        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++)
                add(i, j, v[i][j]);
    }
    void print(){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                cout<< sum(i-1, i, j-1, j) << " ";
            }
            cout << "\n";
        }
    }
    void print_sum(){
        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++)
                cout<< sum(i-1, j-1) << " ";
        cout << "\n";
    }
};

int N, M;
int A[2010];
int B[2010];

void solve() {
    cin >> N >> M;
    REP(i, N) cin >> A[i];
    REP(i, M) cin >> B[i];

    BIT<ll> bit = BIT<ll>(N+1, M+1);
    bit.add(0, 0, 1);

    REP(i, N) REP(j, M) if (A[i] == B[j]) {
        bit.add(i+1, j+1, bit.sum(i, j));
    }

    cout << bit.sum(N, M) << endl;
}

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


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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using D = double;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main(int argc, char const *argv[]) {
  L l, a, b, c, d;
  cin >> l >> a >> b >> c >> d;

  cout << l - max(ceil(float(a) / c), ceil(float(b) / d)) << endl;;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    long mul = 1;
    for(int i = 1; i <= n; i++){
        mul = mul * i;
        if(mul > 1000000007){
            mul = mul % 1000000007;
        }
    }
    cout << mul << endl;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcount(n)
#define si(x) scanf("%d",&x);
#define sli(x) scanf("%ld",&x);
#define sll(x) scanf("%lld",&x);
#define slu(x) scanf("%lu",&x);
#define sllu(x) scanf("%llu",&x);
#define si2(x,y) si(x);si(y);
#define si3(x,y,z) si(x);si(y);si(z);
#define slli2(x,y) slli(x);slli(y);
#define slli3(x,y,z) slli(x);slli(y);slli(z);

#define pi(x) printf("%d",x);
#define pli(x) printf("%ld",x);
#define plli(x) printf("%lld",x);
#define plu(x) printf("%lu",x);
#define pllu(x) printf("llu",x);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c",c);
typedef long long int  ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = 2 * acos((ld) 0);
ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> void setmin(T& a, T val) {if (a > val) a = val;}
template<class T> void setmax(T& a, T val) {if (a < val) a = val;}
void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}


const int MAXN = 1 << 20;
ll mx=200200;
vector<pair<ll,ll>> adj[200200];
bool vis[200200];
ll val[200200];
void dfs(int u,int xx)
{
	vis[u]=1;
	val[u]=xx;
	for(auto v:adj[u])
	{
		if(vis[v.fi])
		{
			if(val[v.fi]!=xx+v.se)
			{
				printf("No");
				exit(0);
			}
			
		}else
		{
				dfs(v.fi,xx+v.se);
		}
	}
}

int main() {
	
	ll n,m,u,v,d;
	sll(n);
	sll(m);
	for(int i=0;i<m;i++)
	{
		sll(u);
		sll(v);
		sll(d);
		adj[u].pb(mp(v,d));
		adj[v].pb(mp(u,-d));
				
	}
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			dfs(i,0);
		}
	}
	printf("Yes");
	
	return 0;
}


Measured memory_bytes: 18944
n, m = map(int, input().split())
end = 0
for x in range(n+1):
    for y in range(n-x+1):
        if(10000*x + 5000*y + 1000*(n-x-y) == m):
            print(str(x)+' '+str(y)+' '+str(n-x-y))
            end += 1
            break
    if(end==1):
        break
if(end==0):
    print('-1 '+'-1 '+'-1')

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

int solve(){
    string s;
    cin>>s;
    int n = s.size();
    int l,r;
    if(n%2==0){
        l = n/2-1;
        r = n/2;
        if(s[l]!=s[r]) return n/2;
        rep(i,n/2-1){
            if(s[l-i]!=s[l-i-1] || s[r+i]!=s[r+i+1]){
                return n/2+i+1;
            }
        }
        return n;
    }else{
        l = n/2;
        r = n/2;

        rep(i,n/2){
            if(s[l-i]!=s[l-i-1] || s[r+i]!=s[r+i+1]){
                return n/2+i+1;
            }
        }
        return n;
    }
}

int main(void){
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc139/tasks/abc139_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N;
    cin >> N;
    // A % B = A となるBの最小値はA+1
    // 例）5 % 6 = 5
    // よって、1〜(N-1)の総和を求める
    N--;
    cout << N * (N + 1) / 2 << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

const int N = 200000;
int a[N+5], b[N+5], t[N+5];

int main(){
    int n;
    long long k;
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; ++i){
        scanf("%d", a+i);
    }
    int cur = 1, cnt = 0;
    while (!t[a[cur]]){
        t[a[cur]] = ++cnt;
        b[cnt] = cur = a[cur];
    }
    int res = t[a[cur]] - 1, clr = cnt - res;
    printf("%d\n", b[k <= res ? k : (k - res - 1) % clr + 1 + res]);
    return 0;
}

Measured memory_bytes: 5972
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int hell = 1e9 + 7 ; 

int binpow(int a,int b){
	int res = 1;
	while(b){
		if(b&1) (res *= a)%=hell;
		(a*=a)%=hell;
		b =b/2;
	}
	return res;
}

int ncr(int n,int r){
	int res = 1;
	for(int i=1;i<=r;i++){
		(res*=n-i+1)%=hell;
		(res*=binpow(i,hell-2))%=hell;
	}
	return res ;
}

signed main(){
	IOS;
	int n , a , b; 
	cin >> n >> a >> b ; 
	int ans = binpow(2,n)-1;
	(ans -= -hell+ncr(n,a))%=hell;
	(ans -= -hell+ncr(n,b))%=hell;
	cout << ans << endl ;
	return 0;
}







Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    if(n==2)
    {
        cout<<2<<nl;
    }
    else
    {
        while(1)
        {
            bool fl=false;
            for(int i=2;i*i<=n;i++)
            {
                if(n%i==0)
                {
                    fl=true;
                    break;
                }
            }
            if(!fl)
            {
                cout<<n<<nl;
                return 0;
            }
            else
            {
                n++;
            }
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> W(N);
    for (int i = 0;i < N;i++) {
        cin >> W[i];
    }
    int ans = 1000000000;
    for (int t = 0;t < N;t++) {
        int sf = 0;
        int ss = 0;
        int x = 0;
        for (int i = 0;i < N;i++) {
            if(i <= t){
                sf+=W[i];
            }else{
                ss+=W[i];
           }
            }
        x = max(sf,ss)-min(sf,ss);
        if(ans > x){
            ans=x;
         }
    }
    cout<<ans<<endl;
            return 0;
}


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

using namespace std;

typedef pair<int, int> P;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  vector<P> pos(N);

  int parity = abs(X[0] + Y[0]) % 2;
  for (int i = 0; i < N; i++) {
    int parity2 = abs(X[i] + Y[i]) % 2;
    pos[i] = make_pair(X[i]+Y[i], X[i]-Y[i]);
    if (parity2 != parity) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<int> ds;
  for (int i = 30; i >= 0; i--) {
    ds.push_back(1LL << i);
  }
  if (parity == 0) {
    ds.push_back(1);
  }
  cout << ds.size() << endl;
  for (auto d : ds) {
    cout << d << " ";
  }
  cout << endl;
  for (int i = 0; i < N; i++) {
    int xsum = 0;
    int ysum = 0;
    int xdir, ydir;
    for (auto d : ds) {
      if (xsum >= pos[i].first) {
        xdir = -1;
        xsum -= d;
      } else {
        xdir = 1;
        xsum += d;
      }
      if (ysum >= pos[i].second) {
        ydir = -1;
        ysum -= d;
      } else {
        ydir = 1;
        ysum += d;
      }
      if (xdir > 0 && ydir > 0) {
        cout << 'R';
      } else if (xdir > 0 && ydir < 0) {
        cout << 'U';
      } else if (xdir < 0 && ydir > 0) {
        cout << 'D';
      } else {
        cout << 'L';
      }
    }
    cout << endl;
  }
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vll a(N);
  ll ans = 0;
  REP(i,N){
    IN(a[i]);
    if(i%2==0 && a[i]%2==1){
      ans++;
    }
  }

  OUT(ans);

  return 0;
}

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

int main(){
  	int M1, D1, M2, D2;
  	cin >> M1 >> D1 >> M2 >> D2;
  	if(D2==1){
    	cout << 1 << endl;
    }else{
    	cout << 0 << endl;
    }
	return 0;
}

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

int main() {
    int time[5], cost[5] = {0};
    for (int i=0; i<5; i++) cin >> time[i];
    for (int i=0; i<5; i++) {
        int target = time[i];
        while(1) {
            if (target % 10 == 0) break;
            cost[i]++;
            target++;
        }
    }
    for (int i=1; i<5; i++) {
        for (int j=0; j<i; j++) {
            if (cost[j] > cost[i]) {
                int tmp = cost[j];
                cost[j] = cost[i];
                cost[i] = tmp;

                tmp = time[j];
                time[j] = time[i];
                time[i] = tmp;
            }
        }
    }


    int res = 0;
    for (int i=0; i<4; i++) res += time[i] + cost[i];
    res += time[4];

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)


struct edge {
    int from,to,money,time;
};
int d[101];
vector<edge> E;

int main(){
    int n,m;
    while(cin>>n>>m, n|m){
        E.resize(n);
        for(edge& e:E){
            cin>>e.from>>e.to>>e.money>>e.time;
        }
        int k; cin>>k;
        rep(i,k){
            int a,b,c; cin>>a>>b>>c;
            for(int& x:d) x=1<<30;
            d[a]=0;
            while(1){
                bool end=true;
                for(edge& e:E){
                    rep(dir,2){
                        int cost=(c==0 ? e.money : e.time);
                        if(d[e.to]>d[e.from]+cost){
                            d[e.to]=d[e.from]+cost;
                            end=false;
                        }
                        swap(e.from,e.to);
                    }
                }
                if(end) break;
            }
            cout<<d[b]<<endl;
        }
    }
}

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

int main() {
  string s[2];
  cin >> s[0] >> s[1];
  for(int i=0; i<3; i++) {
    if(s[0][i]!=s[1][2-i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	P := make([]int, N)
	for i := range P {
		fmt.Scan(&P[i])
	}
	min := P[0]
	res := 0
	for i := range P {
		if min >= P[i] {
			res++
		}
		if min > P[i] {
			min = P[i]
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define append push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for(i++; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for(i++; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l,int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int n,q;
  cin >> n >> q;
  vector<int> c(n);
  rep(i,0,n) cin >> c[i];
  vector<int> p(n+1,-1);
  vector<vector<int>> s(n);
  rep(i,0,n) {
    int l = p[c[i]];
    if (l != -1) s[l].push_back(i);
    p[c[i]] = i;
  }
  vector<vector<P>> qs(n);
  rep(i,0,q) {
    int l,r;
    cin >> l >> r;
    l--; r--;
    qs[l].push_back(P(r,i)); 
  }

  vector<int> ans(q);
  BIT<int> d(n+1);
  rrep(x,n,0) {
    for (int y : s[x]) d.add(y,1);
    for (P query : qs[x]) {
      int r = query.fi, i = query.se;
      ans[i] = (r-x+1) - d.sum(r);
    }
  }
  rep(i,0,q) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 59820
def main():
    n = input()
    if n[0] == "A" and n[1] =="A" and n[2] == "A":
        print("No")
    elif n[0] == "B" and n[1] =="B" and n[2] == "B":
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
    int a, b;
    int sum1 = 0, sum2 = 0;
    scanf("%d,", &a);
    scanf("%d,", &b);
    for(int i =1; i < a; i++)
    {
        sum1 += i;
    }
    for (int i = 1; i < b; i++)
    {
        sum2 += i;
    }
    sum1 = sum1 + sum2;
    printf("%d\n", sum1);
    return 0;
}

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

int main(){
    int n, x, i, a1, a2 = 0;
    long long c = 0;
    cin >> n >> x;
    for(i=0; i<n; i++){
        cin >> a1;
        if(a1+a2 > x){
            c += (long long)a1+a2-x;
            a1 = x- a2;
        }
        a2 = a1;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << ((sizeof...(tail)!=0)?" ":""); print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a << ((&a!=&vec.back())?" ":""); } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }

const int dh[] = {-1 ,0, 1, 0};
const int dw[] = {0, 1, 0, -1};

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

    int h, w; cin >> h >> w;
    vector<string> mat(h);
    rep(i, h) cin >> mat[i];

    int black = 0;
    rep(i, h) rep(j, w) if (mat[i][j]=='#') black++;

    queue<P> que;
    que.push(P(0, 0));
    vector<vector<int>> dist(h, vector<int>(w, -1));
    dist[0][0] = 1;
    while(!que.empty()) {
        P p = que.front(); que.pop();
        int ch = p.fi, cw = p.se;
        rep(i, 4) {
            int nh = ch+dh[i], nw = cw+dw[i];
            if (nh<0||nh>h-1||nw<0||nw>w-1) continue;
            if (mat[nh][nw]=='#') continue;
            if (dist[nh][nw]!=-1) continue;
            dist[nh][nw] = dist[ch][cw]+1;
            que.push(P(nh, nw));
        }
    }
    // print(dist);
    int total = dist[h-1][w-1];
    if (total == -1) cout << -1 << endl;
    else cout << h*w - total - black << endl;
}

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

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

typedef long long ll;

int main(){
  char ch;
  stack<int> STK1;
  stack<pair<int,int>> STK2;

  int N;

  int SumSpace = 0;
  int EverySpace;

  for ( int i = 0; cin >> ch; i++ ){
    if ( ch == '\\' ){
      STK1.push(i);
    }
    else if ( ch == '/' && STK1.size() > 0 ){
        //水たまりができる
        int a = STK1.top();
        EverySpace = i - a;
        SumSpace += EverySpace;
        STK1.pop();
        //水たまりの統合
        while ( STK2.size() > 0 && STK2.top().first > a ){
          EverySpace += STK2.top().second;
          STK2.pop();
        }
        STK2.push(make_pair(a, EverySpace));
    }
  }

  vector<int> ans;
  while ( STK2.size()> 0 ){
    ans.push_back(STK2.top().second);
    STK2.pop();
  }
  reverse( ans.begin(), ans.end() );

  N = ans.size();

  cout << SumSpace << endl;
  cout << N;
  REP( ll, i , 0, N){
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#include<string> 
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<utility>
#include<sstream>
using namespace std;

#define sf scanf
#define pf printf
#define pfn printf("\n");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfld(n) scanf("%lld",&n);
#define sflf(n) scanf("%lf",&n);
#define sfc(n) scanf("%c",&n);
#define sfs(n) scanf("%s",&n);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);

#define csh(a,n) memset(a,n,sizeof(a));
int main(){
	ll a,b;
	sfld(a)
	sfld(b)
	int sum=1;
	while(a<=b/2)
	{
		sum++;
		b/=2;
	}
	pfd(sum)
}

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

using namespace std;

int main()
{
    char in[3];
    int ans = 0;
    cin >> in;
    for (int i = 0; i < 3; i++)
    {
        if (in[i] == 'o')
            ans++;
    }
    cout << 700 + 100 * ans << endl;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int C[4];
    rep(i,4) C[i] = 0;
    rep(i,N) {
        string s;
        cin>> s;
        if(s == "AC") C[0]++;
        else if(s == "WA") C[1]++;
        else if(s == "TLE") C[2]++;
        else if(s == "RE") C[3]++;
    }
    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3096
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    String S = sc.next();
    if (K >= S.length()){
      System.out.println(S);
    }else{
      String[] ss = S.split("");
      for (int i = 0; i < K; i++){
        System.out.print(ss[i]);
      }
      System.out.println("...");
    }
  }
}

Measured memory_bytes: 35784
h, w = map(int, input().split(' '))
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    #たて
    res = h * w
    for i in range(1, w):
        A = h * i
        B_a = h * ((w - i) // 2)
        C_a = h * w - A - B_a
        B_b = (h // 2) * (w - i)
        C_b = h * w - A - B_b
        res = min(res, max(A, B_a, C_a) - min(A, B_a, C_a), max(A, B_b, C_b) - min(A, B_b, C_b))
        
    #よこ
    for i in range(1, h):
        A = w * i
        B_a = w * ((h - i) // 2)
        C_a = h * w - A - B_a
        B_b = (w // 2) * (h - i)
        C_b = h * w - A - B_b
        res = min(res, max(A, B_a, C_a) - min(A, B_a, C_a), max(A, B_b, C_b) - min(A, B_b, C_b))
        
    print(res)

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

using namespace std;
int main()
{
    long long n,c=0,k=0;
    cin>>n;
    long long n1=n;
    for(long long i=1;;i++){
        k+=pow(26LL,i);
        if(k>=n){
            n1-=k-pow(26LL,i);
            c=i;
            break;
        }
    }
    n1--;
    string ans="";
    for(long long i=0; i<c; i++){
        ans=(char)('a'+n1%26LL)+ans;
        n1/=26LL;
    }
    cout<<ans;
}


Measured memory_bytes: 4104
n = gets.to_i
a = gets.split.map(&:to_i)
b = [0] + gets.split.map(&:to_i)
c = [0] + gets.split.map(&:to_i)

pre = 0
ans = 0
a.each do |e|
    ans += b[e]
    ans += c[pre] if (pre == e - 1)
    pre = e
end

puts ans

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

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int N; cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];
    map<string,int> mp;
    int M = 0;
    rep(i,N){
        mp[S[i]]++;
        M = max(M,mp[S[i]]);
    }
    for(auto u : mp){
        if(u.second == M){
            cout << u.first << endl;
        }
    }
}



Measured memory_bytes: 27392
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class402
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = NM[0], M = NM[1];
            if (N == 1 && M == 1)
            {
                Console.WriteLine(1);
            }
            else if (N == 1 || M == 1){
                Console.WriteLine(Math.Max(N,M)-2);
            }
            else
            {
                Console.WriteLine(N*M-2*N-2*M+4);
            }


        }
    }
}


Measured memory_bytes: 28128
import math
ans=0

K=int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    num=math.gcd(i,j)
    for k in range(1,K+1):
      if num==1:
        ans+=1
      else:
        ans+=math.gcd(num,k)
print(ans)

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

void CountnigSort(vector<int> &A, vector<int> &B, int k){
	vector<int> C(k+1,0);

	for(int i=0;i<A.size();i++)
		C[A[i]]++;

	for(int i=1;i<=k; i++)
		C[i] += C[i-1];

	for(int i=A.size()-1; i>=0; i--){
		B[C[A[i]]-1] = A[i];
		C[A[i]]--;
	}
}

int main(void){
	int n; cin >> n;
	vector<int> A(n,0);
	vector<int> B(n,0);
	int k=0;
	for(int i=0; i<n; i++){
		cin >> A[i];
		if(k<A[i])
			k = A[i];
	}

	CountnigSort(A,B,k+1);

	for(int i=0; i<n; i++)
		cout << B[i] << (i<n-1?" ":"");
	cout << endl;

}

Measured memory_bytes: 18316
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
int main()
{
    fastio();
  
    string s;
    cin>>s;
    int n = s.size()-1;
    if(s[n]=='s')
        s+='e';
    s+='s';
    cout<<s<<endl;
    
}

Measured memory_bytes: 3652
s=gets.chomp.split(/ /)
n=s.length
hash=Hash.new(0)
max=s[0]
max_len=s[0]
for i in 0..n-1
  hash[s[i]]+=1
  if(hash[s[i]]>hash[max])
    max=s[i]
  end
  if s[i].length>max_len.length
    max_len=s[i]
  end
end

print max," ",max_len,"\n"

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

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;
    for (int a = 0; a <= A; ++a){
        for (int b = 0; b <= B; ++b){
            for (int c = 0; c <= C; ++c){
                int total = 500*a + 100*b + 50*c;//合計金額
                if (total == X) ++res;
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
integer N
character(100) a,b,c
integer ans
read*,N
read*,a,b,c
ans=N*2
do i=1,N
  if(a(i:i)==b(i:i))ans=ans-1
  if(b(i:i)==c(i:i))ans=ans-1
  if(c(i:i)==a(i:i))ans=ans-1
  if(a(i:i)==b(i:i).and.b(i:i)==c(i:i))ans=ans+1
end do
print"(i0)",ans
end

Measured memory_bytes: 256
def main():
    N = int(input())
    d = list(map(int, input().split()))
    ans = 0

    for xi in range(len(d)):
        for yi in range(xi+1, len(d)):
            if xi != yi:
                ans += d[xi] * d[yi]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    t.pop_back();
    if (s==t) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3592
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;
ll a[200005];

int main() {
	ll n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int>s;
	vector<int>ord(n + 1, -1);
	int c = 1,l = 0;
	
	{
		int v = 1;
		
		while (ord[v] == -1) {
			ord[v] = s.size();
			s.push_back(v);
			v = a[v - 1];
		}
		c = s.size() - ord[v];
		l = ord[v];
	}
	if (k < l) {
		cout << s[k] << endl;
	}
	else {
		k -= l;
		k %= c;
		cout << s[l + k] << endl;
	}
	return 0;
}

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

int main() {
    
    string s; cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    if (a + b + c + d == 7) cout << s[0] << "+" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;

    else if (a + b + c - d == 7) cout << s[0] << "+" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
    else if (a + b - c + d == 7) cout << s[0] << "+" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
    else if (a - b + c + d == 7) cout << s[0] << "-" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;

    else if (a + b - c - d == 7) cout << s[0] << "+" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
    else if (a - b + c - d == 7) cout << s[0] << "-" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
    else if (a - b - c + d == 7) cout << s[0] << "-" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;

    else if (a - b - c - d == 7) cout << s[0] << "-" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;

    return 0;
}

Measured memory_bytes: 3632
//////// Don't_be_late 
// https://atcoder.jp/contests/abc177/tasks/abc177_a
// date: 2020-08-29T21:00:28.777315
// memo: 

//<editor-fold desc="my macro">

#include<bits/stdc++.h>
#ifdef LOCAL
    #include<my/dump.h>
#else
    #define dump(...) 42 
    #define dumpi(x) 42 
#endif

typedef long long ll;
using namespace std;

#define repe(x, a) for(auto& (x) : (a))
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rep3(i, a, b) for(ll i=a, i##_len=(b);i<i##_len;i++)
#define _rep2(i, n) _rep3(i,0,n)
#define repd(...) _overload3(__VA_ARGS__,_repd3,_repd2,)(__VA_ARGS__)
#define _repd3(i, a, b) for(ll i=b-1, i##_len=(a);i>=i##_len;i--)
#define _repd2(i, n) _repd3(i,0,n)
#define loop(...) _overload3(__VA_ARGS__,,_loop2,_loop1)(__VA_ARGS__)
#define _loop2(i, a) for(ll i=a;; i++)
#define _loop1(i) _loop2(i,0)

#define all(x) x.begin(),x.end()
#define SIZE(x) ((ll)(x).size())

#define F first
#define S second
#define vec vector
#define umap unordered_map
#define uset unordered_set

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

#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define inrange(x,start,stop) ((start) <= (x) && (x) < (stop))
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; }

template <typename Cont, typename Func>
Cont fmap(const Cont &container, Func functor) {
    Cont result(container.size());
    std::transform(container.begin(), container.end(), result.begin(), functor);// [](int x){return x * 2;}
    return result;
}
template <typename Cont, typename Pred>
Cont filter(const Cont &container, Pred predicate) {
    Cont result;
    std::copy_if(container.begin(), container.end(), std::back_inserter(result), predicate);// [](int x){return x == 2;}
    return result;
}   

template<typename T, typename ...Args>
void ci(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args)); //C++17
}

template<char Sep, typename T, typename ...Args>
void print_seq(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args)); //C++17
}

void co(){ cout << endl; }
template<typename... Words>
void co(Words... words) {
    print_seq<' '>(words...);
    cout << endl;
}
#define coi(x) cout<<(x)<<" "

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define sankou(n,a,b) cout << ((n) ? (a) : (b) ) << endl

#define asrt(expr...) assert((expr))
//</editor-fold>

#define INF 1e19
#define MOD 1e9+7
#define MAXR 1e5

int solve() {
    ll D,T,S;
    ci(D,T,S);
//    co(D <= T * S );
    Yes(D <= T * S );
    return 0;

}

int main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    
    solve();
    return 0;
}


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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular
using namespace modular;

namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 607

int N, M;
int mc[MAX_N], g[MAX_N], f[MAX_N][MAX_N], su[MAX_N][MAX_N];

inline bool check(int l, int r) {
    if ((r ^ l ^ 1) & 1) return false;
    rep(i, l, r) if (mc[i] && (mc[i] < l || mc[i] > r)) return false;
    return true;
}

void solve() {
    read(N), read(M);
    N <<= 1;
    Rep(i, N) mc[i] = 0; 
    int x, y;
    Rep(i, M) {
        read(x), read(y);
        mc[mc[y] = x] = y;
    }
    g[0] = 1;
    for (int i = 2; i <= N; i += 2)
        g[i] = mul(g[i - 2], i - 1);
    Rep(i, N) {
        rep(j, i, N) su[i][j] = su[i][j - 1] + (mc[j] ? 0 : 1);
    }
    int res = 0;
    Rep(i, N) {
        rep(j, i, N) if (check(i, j)) {
            int &fx = f[i][j];
            fx = g[su[i][j]];
            lep(k, i + 1, j) {
                inc(fx, MOD - mul(f[i][k], g[su[k + 1][j]]));
            }
            inc(res, mul(fx, g[su[1][i - 1] + su[j + 1][N]]));
        }
    }
    Rep(i, N) rep(j, i, N) f[i][j] = 0;
    printf("%d\n", res);
}

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


Measured memory_bytes: 3072
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(M)]

#REVEDGE=[[] for i in range(N+1)]
EDGELIST=[[] for i in range(N+1)]
LEAF=[]
for x,y in EDGE:
    #REVEDGE[y].append(x)
    EDGELIST[x].append(y)

for i in range(1,N+1):
    if EDGELIST[i]==[]:
        LEAF.append(i)

DIST=[-1]*(N+1)
for l in LEAF:
    DIST[l]=0

def distance(x):
    if DIST[x]!=-1:
        return DIST[x]
    ANS=0
    for to in EDGELIST[x]:
        if ANS<distance(to)+1:
            ANS=distance(to)+1

    DIST[x]=ANS
    return ANS

for i in range(1,N+1):
    DIST[i]=distance(i)

print(max(DIST))


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint S;
    cin >> S;
    lint X1 = 0, Y1 = 0, X2 = 1e9, Y2 = 1, X3, Y3;
    // |X2*Y3-X3*Y2| == S を満たすX2,Y2,X3,Y3を求める．
    // X2==1e9,Y2 = 1とする
    // 1e9*Y3-X3*1 == S を満たすX2,Y2,X3,Y3を求める．
    if (S % (int)1e9 == 0) {
        Y3 = S / (int)1e9;
        X3 = 0;
    } else {
        Y3 = S / 1000000000 + 1;
        X3 = 1000000000 * Y3 - S;
    }

    cout << X1 << ' ' << Y1 << ' ' << X2 << ' ' << Y2 << ' ' << X3 << ' ' << Y3
         << endl;
    return 0;
}

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

int main() {
    int n,m,x,ans = 2e9;
    cin >> n >> m >> x;
    int c[n],d[n][m];
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> d[i][j];
        }
    }
    rep(i,1<<n){
        int e[12]={},f=0;
        bitset<12> a(i);
        rep(j,n){
            if(a.test(j)){
                rep(k,m) e[k] += d[j][k];
                f += c[j];
            }
        }
        int flag = 1;
        rep(k,m){
            if(e[k]<x) flag = 0;
        }
        if(flag) ans = min(ans,f);
    }
    if(ans==2e9) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3632
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  bool operator < (Point p){return (p.x!=x)?p.x<x:p.y<y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

//a -> b -> c
int ccw(Point a, Point b, Point c) {
  b = b-a; c = c-a;
  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;    // a--b--c on line
  return 0;                              // a--c--b on line
}

struct Line{
  Point a,b;

  Line(){}
  Line(Point a,Point b):a(a),b(b){}

  bool on(Point c){return abs(ccw(a,b,c))!=1;}
  Real dist(Point c){return abs((b-a).cross(c-a))/(b-a).norm();}
  bool isOrthogonal(Line l){return (a-b).dot(l.a-l.b)==0.0;}
  bool isParallel(Line l){return (a-b).cross(l.a-l.b)==0.0;}
  bool isIntersection(Line l){return !((a-b).cross(l.a-l.b)==0.0);}
  //平行でない前提
  Point intersectionPoint(Line l){
    return a+(b-a)*((l.b-l.a).cross(l.a-a)/(l.b-l.a).cross(b-a));
  }

};

int main(void){

  int q;
  cin >> q;
  while(q--){
    Line a,b;
    cin >> a.a.x >> a.a.y >> a.b.x >> a.b.y;
    cin >> b.a.x >> b.a.y >> b.b.x >> b.b.y;
    if(a.isOrthogonal(b))cout << 1 << endl;
    else if(a.isParallel(b))cout << 2 << endl;
    else cout << 0 << endl;
  }

  return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  vector<int> a(100010, 0);
  int ans=0;
  int tmp=0;
  for (int i=0; i<n; i++) {
    int t; cin>>t;
    if (!a[t]) {
      a[t]++;
      ans++;
    }
    else {
      tmp++;
    }
  }
  cout << ans-(tmp%2) << endl;
}

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


Measured memory_bytes: 640