akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w, d; cin >> h >> w >> d;
    auto a = vec<int>(h, w); cin >> a;
    VI y(h * w), x(h * w);
    FOR(i, 0, h)FOR(j, 0, w) {
        --a[i][j];
        y[a[i][j]] = i;
        x[a[i][j]] = j;
    }

    VI acc(h * w);
    FOR(i, 0, h* w - d) {
        acc[i + d] = acc[i];
        acc[i + d] += abs(y[i] - y[i + d]);
        acc[i + d] += abs(x[i] - x[i + d]);
    }

    int q; cin >> q;
    while (q--) {
        int l, r; cin >> l >> r;
        --l, --r;
        cout << acc[r] - acc[l] << "\n";
    }
}

Measured memory_bytes: 2816
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = input()
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    else:
        print("Sunny")
    return

#B
def B():
    s = S()
    for i in range(len(s)):
        if i%2:
            if s[i] not in ["L","U","D"]:
                print("No")
                return
        else:
            if s[i] not in ["R","U","D"]:
                print("No")
                return
    print("Yes")
    return

#C
def C():
    n,k,q = LI()
    a = IR(q)
    f = [k-q]*(n)
    for i in range(q):
        ai = a[i]-1
        f[ai] += 1
    for i in f:
        if i <= 0:
            print("No")
        else:
            print("Yes")
    return

#D
def D():
    n,m = LI()
    a = LI()
    q = []
    for i in range(n):
        heappush(q,-a[i])
    for i in range(m):
        x = heappop(q)
        x *= -1
        x >>= 1
        heappush(q,-x)
    print(-sum(q))
    return

#E
def E():
    n = I()
    s = S()
    l = 0
    r = n
    M = 10**640+1
    b = 26
    alp = list("abcdefghijklmnopqrstuvwxyz")
    f = {}
    for i in alp:
        f[i] = ord(i)-ord("a")
    pb = [pow(b,i,M) for i in range(n+1)]
    while r-l > 1:
        m = (l+r)>>1
        d = defaultdict(lambda : float("inf"))
        hash = 0
        for i in s[:m]:
            hash *= b
            hash += f[i]
            hash %= M
        d[hash] = 0
        t = pb[m]
        for i in range(n-m):
            si = s[i]
            hash *= b
            hash -= t*f[si]
            hash += f[s[i+m]]
            hash %= M
            if d[hash]+m <= i+1:
                l = m
                break
            if i+1 < d[hash]:
                d[hash] = i+1
        else:
            r = m
    print(l)
    return

#F
def F():

    return

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


Measured memory_bytes: 57436
X, N = list(map(int, input().split()))
if N > 0:
    P = list(map(int, input().split()))
    l = X
    h = X
    while True:
        if l not in P:
            print(l)
            break
        if h not in P:
            print(h)
            break
        l -= 1
        h += 1
else:
    input()
    print(X)

Measured memory_bytes: 9192
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, T;
  cin >> N >> T;
  vector<int> c(N), t(N);
  int ans = 1001;
  for(int i=0; i<N; i++) {
    cin >> c[i] >> t[i];
    if(t[i] <= T && ans > c[i]) {
      ans = c[i];
    }
  }
  if(ans == 1001)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        a[i]--;
    }

    int p = 0;
    for (int i = 0; i < n; i++)
        if (a[a[i]] == i)
            p++;

    printf("%d\n", p / 2);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)
#define MOD_PRIME = 1e9 + 7;

bool sub(LL a)
{
    string str = to_string(a);
    for(auto it = str.rbegin(); it<str.rend()-1; it++)
    {
        LL diff = (LL)(*it) - (LL)(*(it+1));
        if(abs(diff)<=1)
        {
            continue;
        }
        else
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    LL k;
    cin >> k;
    deque<LL> deq;
    deq.push_back(1);
    deq.push_back(2);
    deq.push_back(3);
    deq.push_back(4);
    deq.push_back(5);
    deq.push_back(6);
    deq.push_back(7);
    deq.push_back(8);
    deq.push_back(9);

    LL ret = 0;
    auto it = deq.begin();
    LL i=0;
    LL j=0;
    while(k>i)
    {
        LL temp = deq.at(j);
        j++;
        if(temp % 10 != 0)
        {
            deq.push_back((10 * temp) + (temp % 10) - 1);
            i++;
        }
        deq.push_back(10 * temp +  + (temp % 10));
        i++;
        if(temp % 10 != 9)
        {
            deq.push_back((10 * temp) + (temp % 10) + 1);
            i++;
        }
    }

      cout << deq.at(k-1) << endl;
    return 0;
}

Measured memory_bytes: 1024
while True:
    a,op,b=input().split()
    if( op == '+'):
        print(int(a) + int(b))
    elif( op == '-'):
        print(int(a) - int(b))
    elif( op == '*'):
        print(int(a) * int(b))
    elif( op == '/'):
        print(int(a) // int(b))
    elif( op == '?'):
        break
    
    



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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

#define MOD 1000000007

ll cr[100100];
ll cl[100100];
int K, N, cntr, cntl;

void init()
{
	rep(i, 100100) {
		cr[i] = cl[i] = 1e18;
	}
	cr[0] = cl[0] = 0;
}

signed main()
{
	init();
	cin >> N >> K;
	cntr++;
	cntl++;
	rep(i, N) {
		CIN(ll, t);
		if (t < 0) {
			cl[cntl++] = -t;
		}
		if (t >= 0) {
			cr[cntr++] = t;
		}
	}
	ll mi = 1e18;
	sort(cl, cl+cntl);
	rep(i, K+1) {
		mi = min(mi, cr[i] * 2 + cl[K-i]);
		mi = min(mi, cr[i] + cl[K-i] * 2);
	}
	cout << mi << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int X;
	scanf("%d", &X);

	int max = 1;
	for(int i=2;i<=X;i++){
		for(int j=i*i;j<=X;j*=i){
			if(j>max) max = j;
		}
	}

	printf("%d\n", max);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    int N; cin>>N;
    double ans=0;

    for (int i = 0; i < N; ++i) {
        double tmp; cin>>tmp;
        ans += 1/tmp;
    }
    ans = 1 / ans;
    cout<<ans<<endl;

    return 0;
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 42;
int N;
int X, Y, Z;

const int S = 1 << 17;
num dp[MAXN][S];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> X >> Y >> Z;

	int good = ((1 << (X+Y+Z)) + (1 << (Y+Z)) + (1 << Z)) >> 1;
	dp[0][0] = 1;
	num ans = 0;
	for (int i = 0; i < N; i++) {
		for (int m = 0; m < S; m++) {
			for (int x = 1; x <= 10; x++) {
				int m1 = ((m << x) | (1 << (x-1))) & (S-1);
				dp[i+1][m1] += dp[i][m];
			}
		}
		
		num ways = 1;
		for (int j = 0; j < N-(i+1); j++) ways *= 10;
		for (int m = 0; m < S; m++) {
			if ((m & good) == good) {
				ans += ways * dp[i+1][m];
				dp[i+1][m] = 0;
			}
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 21760
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    lint N;
    vector<pair<lint, lint> > vec;
    cin >> N;
    rep(i, N){
        lint A, B;
        cin >> A >> B;
        vec.push_back(make_pair(B, A));
    }
    sort(vec.begin(), vec.end());
    lint time=0;
    rep0(i, vec.size()){
        time += vec[i].second;
        if (time > vec[i].first){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 6256
// OURL: https://atcoder.jp/contests/abc051/tasks/abc051_b
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int K,S;
  cin >> K >> S;
  ll ans = 0;
  REP(x,K+1) REP(y,K+1) {
    if (x+y<=S && x+y+K>=S) ans++;
  }
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty = map(int, input().split())
p1 = 'U'*(ty-sy) + 'R'*(tx-sx)
p2 = 'D'*(ty-sy) + 'L'*(tx-sx)
p3 = 'L' + 'U'*(ty-sy+1) + 'R'*(tx-sx+1) + 'D'
p4 = 'R' + 'D'*(ty-sy+1) + 'L'*(tx-sx+1) + 'U'
print(p1+p2+p3+p4)

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
int main(){
    int n,m;cin>>n>>m;
    int a[n];
    int sum=0;
    rep(i,m){
    cin>>a[i];
    sum+=a[i];
    }
    if(n>=sum)cout<<n-sum<<endl;
    else cout<<-1<<endl;
    
   
}

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

int main(){
	int n,count;
	while(cin>>n){
		count=n%39;
		if(count==0)count=39;
		cout<<"3C";
		(count/10==0)?cout<<"0"<<count:cout<<count;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
using namespace std;

const int maxn=200010,mod=998244353;
int n,a[maxn],tot,b[maxn],c[maxn],ans,d[maxn];
char s[maxn];

int inc(int a,int b)
{
	a+=b;
	if (a>=mod)
		return a-mod;
	return a;
}

int mul(int a,int b)
{
	return 1ll*a*b-1ll*a*b/mod*mod;
}

int main()
{
	int i,j,k;
	scanf("%d%s",&n,s+1);
	for (i=1;i<=n;i++)
		a[i]=(s[i]^48);
	for (k=1;k<=n;k++)
		if (n%k==0&&((n/k)&1))
		{
			b[++tot]=(k<<1);
			for (i=1;i<=k;i++)
				c[tot]=((c[tot]<<1)+a[i])%mod;
			c[tot]++;
			for (i=1;i<=k;i++)
				d[i]=a[i];
			for (i=k+1;i<=n;i++)
				d[i]=d[i-k]^1;
			for (i=k+1;i<=n;i++)
				if (a[i]^d[i])
				{
					c[tot]-=(a[i]<d[i]);
					break;
				}
		}
	for (i=1;i<=tot;i++)
		for (j=1;j<=i-1;j++)
			if (b[i]%b[j]==0)
				c[i]=inc(c[i],mod-c[j]);
	for (i=1;i<=tot;i++)
		ans=inc(ans,mul(b[i],c[i]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include<algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;


int main(){
    int n;
    cin>>n;
    vector<string> v(n);
    bool ans=true;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(v[i]==v[j]){
                ans=false;
            }
        }
        
    }
    for(int i=0;i<n-1;i++){
        if(v[i].back()!=v[i+1].front()){
            ans=false;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from math import ceil,sqrt,log,gcd,pi
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())

    
k=ii()
s=si()
if(len(s)<=k):
    print(s)
else:
    print(s[:k],end="")
    print('...')

Measured memory_bytes: 61908
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a,b;
int gcd(int x,int y)
{
	if(x>y) swap(x,y);
	int r=x%y;
	while(r)
	{
		r=x%y;
		x=y;y=r;
	}
	return x;
}
int main()
{
	scanf("%d%d",&a,&b);
	if(a<b) printf("%d\n",a);
	else
		if(a%b==0) printf("%d\n",-1);
		else
		{
			int G=gcd(a,b);
			int A=a/G,B=b/G;
			
			printf("%lld\n",1ll*G*A*(B-1));
		}
	return 0;
}

Measured memory_bytes: 128
use proconio::input;

fn main() {
    input! {
        n: usize,
        x: usize,
        mut aa: [usize; n],
    }

    let mut count = 0;

    if aa[0] > x {
        count += aa[0] - x;
        aa[0] = x;
    }

    for i in 1..n {
        if aa[i-1] + aa[i] > x {
            let sub = aa[i-1] + aa[i] - x; 
            count += sub;
            aa[i] -= sub;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 3796
r=input().split()
a=int(r[0])
b=int(r[1])
if a>=b:
    ans=""
    for i in range(a):
        ans+=str(b)
    print(int(ans))
else:
    ans=""
    for i in range(b):
        ans+=str(a)
    print(int(ans))

Measured memory_bytes: 8884
#include <cstdio>
using namespace std;

const int N_MAX = 100000;
const int Q_MAX = 50000;

int main() {
  int n, q;
  int s[N_MAX], t[Q_MAX];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &s[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++) scanf("%d", &t[i]);

  int ans = 0;
  for (int i = 0; i < q; i++) {
    int left = 0;
    int right = n;
    while (left < right) {
      int mid = (left + right) / 2;
      if (s[mid] == t[i]) {
        ans++;
        break;
      } else if (s[mid] > t[i]) {
        right = mid;
      } else {
        left = mid + 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    LL i,j,k,l,m,n,w;

    cin>>n>>w;

    LL cost[n+10],wt[n+10];
    LL dp[n+10][w+10];
    memset(dp,0,sizeof dp);

    for(i=1;i<=n;i++)cin>>wt[i]>>cost[i];

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(wt[i]<=j)
            {
                dp[i][j] = max(cost[i]+dp[i-1][j-wt[i]] , dp[i-1][j]);

            }
            else dp[i][j] = dp[i-1][j];
          //  cout<<dp[i][j]<<" ";
        }

     //   cout<<endl;
    }

    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 86144
#include<stdio.h>
         
        int main(){
          int i,a[101]={},n,m,x,box[101]={},left=0,right=0;
          scanf("%d %d %d",&n,&m,&x);
          for(i=0;i<m;i++){
            scanf("%d",&a[i]);
            box[a[i]]=1;
          }
          for(i=0;i<=n;i++){
            if(i<x) left+=box[i];
            else right+=box[i];
          }
          if(left<right) printf("%d\n",left);
          else printf("%d\n",right);
        }

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int min,max;
    int n;
    scanf("%d%d%d",&n,&min,&max);
    if(n==1)
    {
        if(min==max)

                printf("1\n");

        else
            printf("0\n");
    }
    else
    {
        if(min>max)
            printf("0\n");
            else
                printf("%lld\n",(long long )(max-min)*(n-2)+1);
    }
    return 0;

}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<b+2; i++) {
			sb.append("#");
		}
		System.out.println(sb.toString());
		for(int i=0; i<a; i++) {
			System.out.println("#"+sc.next()+"#");
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22228
package main

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

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type event struct {
	time    int
	mode    string
	channel int
}

type events []event

func (e events) Len() int {
	return len(e)
}

func (e events) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

func (e events) Less(i, j int) bool {
	return e[i].time < e[j].time
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, _ := nextInt(), nextInt()
	var events events = make([]event, n*2)
	for i := 0; i < n; i++ {
		s, t, c := nextInt(), nextInt(), nextInt()
		events[i*2] = event{s*2 - 1, "start", c}
		events[i*2+1] = event{t * 2, "end", c}
	}
	sort.Sort(events)
	ans := 0
	channels := make(map[int]int)
	for _, e := range events {
		switch {
		case e.mode == "start":
			_, ok := channels[e.channel]
			switch {
			case ok:
				channels[e.channel]++
			default:
				channels[e.channel] = 1
				if len(channels) > ans {
					ans = len(channels)
				}
			}
		case e.mode == "end":
			channels[e.channel]--
			if channels[e.channel] == 0 {
				delete(channels, e.channel)
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
ll dp[MAXn][2];
int main(){
    IOS();
    ll n;
    cin >> n;
    REP1 (i,n) cin >> d[i];

    dp[2][0] = d[1], dp[2][1] = d[2];
    for (int i=3;i<=n;i++) {
        if (i&1) {
            dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
            dp[i][1] = d[i] + max({dp[i-2][0],dp[i-2][1],dp[i-3][0],dp[i-3][1]});
        }
        else {
            dp[i][0] = dp[i-2][0] + d[i-1];
            dp[i][1] = d[i] + max(dp[i-2][1],dp[i-2][0]);
        }
    }
    cout << max(dp[n][0],dp[n][1]) << endl;
}


Measured memory_bytes: 8272
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	if(n==1){
		if(a!=b) cout<<0<<endl;
		else cout<<1<<endl;
	}else if(a>b){
		cout<<0<<endl;
	}else{
		int mi=a+b+(n-2)*a;
		int ma=a+b+(n-2)*b;
		cout<<ma-mi+1<<endl;


	}
	return 0;
}



Measured memory_bytes: 3592
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int N, ans = 0;
    string S;
    cin >> N >> S;
    for (int i = 0; i < N - 2; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
            ans++;
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(scanner.nextLine());
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (i == n - 1) {
                sum += arr[i] / 2;
            } else {
                sum += arr[i];
            }
        }

        System.out.println(sum);
    }
}


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

int main(){
    string s;

    cin >> s;
    
    int counter=0;
    const int NUM=3;
    for (int i=0; i<NUM; i++){
        if (s[i]=='1'){
            counter++;
        }
    }

    cout << counter <<endl;

    return 0;
}

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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    
    int cnt = 0;
    for(int i=1; i<=n; i++){
        std::string str = std::to_string(i);
        int sum = 0;
        for(int j=0; j<str.length(); j++){
            //char c = str[j];
            int tmp = char(str[j]) - '0';
            //cout << char(str[j]) << "->" << tmp << endl;
            sum += tmp;
        }
        //cout << sum << endl;
        if(sum >= a && sum <= b){
            cnt += i;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long lint;
int main(){
    string s;
    cin >> s;
    if(s[2] == s[3])
        if(s[4] == s[5]){
            cout << "Yes" << endl;
            return 0;
        }
    cout << "No" << endl;
    return 0;
}

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



int main() {
  ll X;
  cin>>X;
  bool s=false;
  rep(i,201)
  {
    rep(j,201)
    {
      ll a=i;
      ll b=j;
      if(a*a*a*a*a-b*b*b*b*b==X)
      {
        cout<<a<<" "<<b<<endl;
        s=true;
        break;
      }
      b=-b;
      if(a*a*a*a*a-b*b*b*b*b==X)
      {
        cout<<a<<" "<<b<<endl;
        s=true;
        break;
      }
    }
    if(s)
    {
      break;
    }  
  }
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[8]={2,3,4,6,8,9,10,12};
int hoge[9]={};
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	if(N==3) {
		cout<<"2 5 63"<<endl;
		return;
	}
	int mask;
	FOR(mask,1<<8) {
		int g=0;
		int S=0;
		FOR(i,8) if(mask&(1<<i)) {
			g=__gcd(g,A[i]);
			S+=A[i];
		}
		if(g==1 && S%6==0) hoge[__builtin_popcount(mask)]=mask;
	}
	
	
	
	hoge[1]=1<<7;
	hoge[2]=(1<<2)|(1<<4);
	hoge[3]=(1<<0)|(1<<2)|(1<<3);
	
	x=N%8;
	if(x==0) x=8;
	N-=x;
	FOR(i,8) if(hoge[x]&(1<<i)) cout<<A[i]<<" ";
	for(x=1;x<=N/8;x++) {
		FOR(y,8) cout<<12*x+A[y]<<" ";
	}
	cout<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

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

using namespace std;

int main(void)
{
	ll n, m, ans=0;
	cin >> n >> m;
	ll t[m+1];
	rep(i, m+1){
		t[i] = 0;
	}
	rep(i, n){
		ll k;
		cin >> k;
		rep(j, k){
			ll a;
			cin >> a;
			t[a]++;
		}
	}
	rep(i, m+1){
		if (t[i] == n){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
  var r int
  if sc.Scan() {
    tmp:= sc.Text()
    r,_ = strconv.Atoi(tmp)
  }
  fmt.Println(r * r)
}

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

#define ll              long long int
#define ull             unsigned long long int
#define pii             pair < int, int>
#define pll             pair < ll, ll>
#define sc              scanf
#define scin(x)         sc("%d",&(x))
#define scln(x)         sc("%lld",&(x))
#define pf              printf
#define NL              pf("\n")
#define ms(a,b)         memset(a,b,sizeof(a))
#define pb(a)           push_back(a)
#define mp              make_pair
#define db              double
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define vi              vector< int >
#define vl              vector< ll >
#define vii             vector<vector< int > >
#define vll             vector<vector< ll > >
#define DBG             pf("HI\n")
#define MOD             1000000007
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define RUN_CASE(t,T)   for(__typeof(t) t=1;t<=T;t++)
#define CASE(t)         printf("Case %d: ",t)
#define CASEL(t)        printf("Case %d:\n",t)
#define intlimit        2147483648
#define longlimit       9223372036854775808
#define infinity        (1<<28)
#define gcd(a, b)       __gcd(a,b)
#define lcm(a, b)       (((a)/gcd(a,b))*b)
#define mx              1234567899
#define TC              int t;scin(t);while(t--)
#define PI              2*acos(0.0)
#define rep(i,a,b)      for( i=a; i<=b; i++)
#define rev(i,a,b)      for( i=a; i>=b; i--)
#define file            freopen("E:\\file.txt", "r", stdin);ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x)          x.begin(),x.end()
#define DEBUG(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;
using namespace std;
int get(int n,int p){int res = 0;while(n>=p) res+=n/p,n/=p;return res;}
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1); }
void VC(vector<ll> &v){for(int i=0;i<v.size();i++) printf("%lld ", v[i]);printf("\n");}

template< typename T > void print(const T& v) {    cerr << v << ' ' ;}
template< typename T1, typename... T2 >
void print( const T1& first, const T2&... rest ){
    print(first);
    print(rest...) ;
}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

long long BigMod(long long int a, long long int b, int M) { long long remainder, answer = 1;remainder = a%M; while(b!=0){if(b%2==1) answer = (answer*remainder)%M;remainder = (remainder*remainder)%M;b/=2;}return answer;}
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n;
    cin >> n;
    cout << power(n,3)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <iostream>

#pragma warning(disable:4996)

using namespace std;


int main()
{
	int r, g, b;
	while (cin >> r >> g >> b)
	{
		bool res = (r * 100 + g * 10 + b) % 4 == 0 ? 1 : 0;
		cout << (res ? "YES" : "NO") << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INFTY (1 << 30)
int main(){
  int mas[101][101] = {{}}, n;
  cin >> n;
  for(int i = 1 ; i <= n ; i++ ){
    for(int j = 1 ; j <= n ; j++ ){
      cin >> mas[i][j];
      mas[i][j] += mas[i-1][j] + mas[i][j-1] - mas[i-1][j-1];
    }
  }
  int ret = -INFTY;
  for(int i = 1 ; i <= n ; i++ ){
    for(int j = 1 ; j <= n ; j++ ){
      for(int k = 1 ; k <= i ; k++ ){
        for(int l = 1 ; l <= j ; l++ ){
          ret = max( ret, mas[i][j] - mas[k-1][j] - mas[i][l-1] + mas[k-1][l-1]);
        }
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef vector<int> vi;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a) (a).begin(), (a).end()
#define out(a) cout << (a) << endl

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;

	f = 1000000;
	rep(i, n+1){
		int t 		= 0;
		int six 	= 6 * 6 * 6 * 6 * 6 * 6;
		int nin 	= 9 * 9 * 9 * 9 * 9;
		int count = 0;
		t = i;

		while(six){
			count += (t/six)%6;
			six /= 6;
		}
		t = n-i;
		while(nin){
			count += (t/nin)%9;
			nin /= 9;
		}

		f = min(f, count);
	}

	out(f);
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
#include <iomanip>
using namespace std;
//#define int long long
//#define double long double
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pii > pip;
typedef pair<pii, pii > piipii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define all(vec) vec.begin(), vec.end()
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60)
#define mod 1000000007
#define se second
#define fi first

int H, W, K;
string s[330];
int fld[330][330];

signed main(){
    cin >> H >> W >> K;
    for(int i = 0; i < H; i++){
        cin >> s[i];
    }
    int cnt = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(s[i][j] == '#'){
                fld[i][j] = cnt;
                cnt++;
            }
            if(fld[i][j] == 0 && j > 0){
                fld[i][j] = fld[i][j - 1];
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = W; j >= 0; j--){
            if(fld[i][j] == 0 && j < W){
                fld[i][j] = fld[i][j + 1];
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(fld[i][j] == 0 && i > 0){
                fld[i][j] = fld[i - 1][j];
            }
        }
    }
    for(int i = H; i >= 0; i--){
        for(int j = 0; j < W; j++){
            if(fld[i][j] == 0 && i < H){
                fld[i][j] = fld[i + 1][j];
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            printf("%d", fld[i][j]);
            if(j == W - 1){
                printf("\n");
            }
            else {
                printf(" ");
            }
        }
    }
    
    
    
    return 0;
}

/*

*/

Measured memory_bytes: 1280
# https://atcoder.jp/contests/abc082/tasks/abc082_b

s = [i for i in input()]
t = [i for i in input()]

s.sort()
t.sort(reverse=True)

s = ''.join(s)
t = ''.join(t)

ans = [(s, 0), (t, 1)]
ans.sort()
if s == t:
    print('No')
elif ans[0][1] == 0:
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll = long long;


int main()
{
	int a[3];
	for(int i = 0; i < 3; i++)cin >> a[i];

	if(a[0] % 2 || a[1] % 2 || a[2] % 2) {
		cout << 0 << endl;
		return 0;
	}

	if(a[0] == a[1] && a[1] == a[2]) {
		cout << -1 << endl;
		return 0;	
	}
	int cnt = 0;
	while(a[0] % 2 == 0 && a[1] % 2 == 0 &&  a[2] % 2 == 0) {
		int nxt[3] = {};
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(i == j)continue;
				nxt[j] += a[i] / 2;
			}
		}
		for(int i = 0; i < 3; i++)a[i] = nxt[i];
		cnt++;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
# abc135_b.py
# https://atcoder.jp/contests/abc135/tasks/abc135_b

# B - 0 or 1 Swap /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# {1, 2, ..., N} を並び替えた数列 p = {p1, p2, ..., pN} があります。
# あなたは一度だけ、整数  i, j (1≤i<j≤N) を選んで  pi  と  pj を入れ替える操作を行うことができます。
# 操作を行わないことも可能です。
# pを昇順にすることができるなら YES を、できないならば NO を出力してください。

# 制約
#     入力は全て整数である。
#     2≤N≤50
#     pは {1, 2, ..., N} を並び替えた数列である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# p1 p2 ... pN

# 出力
# pを昇順にすることができるなら YES を、できないならば NO を出力せよ。

# 入力例 1
# 5
# 5 2 3 4 1

# 出力例 1
# YES

# p1と p5 を入れ替えることで pを昇順にできます。

# 入力例 2
# 5
# 2 4 3 5 1

# 出力例 2
# NO

# この場合、どのような操作を行っても pを昇順にすることはできません。

# 入力例 3
# 7
# 1 2 3 4 5 6 7

# 出力例 3
# YES

# pが最初から昇順なので、操作を行う必要はありません。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # X, A = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    values_c = values.copy()
    values_c.sort()

    cnt = 0

    for n in range(N):
        if values[n] != values_c[n]:
            cnt += 1
    
    if cnt <= 2:
        result = 'YES'
    else:
        result = 'NO'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5', '5 2 3 4 1']
        lines_export = ['YES']
    if pattern == 2:
        lines_input = ['5', '2 4 3 5 1']
        lines_export = ['NO']
    if pattern == 3:
        lines_input = ['7', '1 2 3 4 5 6 7']
        lines_export = ['YES']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
		int m = sc.nextInt();

		int[] l = new int[m];
		for (int i = 0; i < n; ++i) {
			int c = sc.nextInt();
			for (int j = 0; j < c; ++j) {
				int x = sc.nextInt();
				l[x - 1] += 1;
			}
		}
		int r = 0;
		for (int i = 0; i < m; ++i) {
			if(l[i] == n) {
				r++;
			}
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 23500
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if (a-1>=b){
    cout<<a*2-1<<endl;
  }else if (b-1>=a){
    cout<<b*2-1<<endl;
  }else{
    cout<<a*2<<endl;
  }
  return 0;
}
     

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long a, long long b) {
	long long c;
	if (a < b)a += b, b = a - b, a -= b;
	while (b != 0) c = a % b, a = b, b = c;
	return a;
}
int main() {
	long long t, a, b, c, d;
	cin >> t;
	for (int i = 0; i < t; i++) {
		cin >> a >> b >> c >> d;
		int x = 0;
		long long z = (a - c) % gcd(b, d);
		if (z == 0) z = gcd(b, d);
		if (b - c <= z) x = 1;
		if (a < b || d < b) x = 0;
		if (x == 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {

            int n = int.Parse(Console.ReadLine());
            int preTime = 0;
            int x = 0, y = 0;
            bool canTravel = true;

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split().Select(tmp => int.Parse(tmp)).ToArray();
                int t = input[0];
                int xt = input[1];
                int yt = input[2];

                if (!CanTravel(x, y, xt, yt, t - preTime))
                {
                    canTravel = false;
                    break;
                }
                preTime = t;
                x = xt;
                y = yt;
            }
            Console.WriteLine(canTravel ? "Yes" : "No");
        }

        bool CanTravel(int currentX, int currentY, int nextX, int nextY, int deltaTime)
        {
            int dx = Math.Abs(nextX - currentX);
            int dy = Math.Abs(nextY - currentY);
            deltaTime -= (dx + dy);

            if (deltaTime >= 0 && deltaTime % 2 == 0)
            {
                return true;
            }
            else
            {
                return false;
            }

        }
    }
}


Measured memory_bytes: 17360
import java.io.*;
import java.util.*;

public class Main {
    static List<HashSet<Integer>> adjSet;
    static int[] vis;
    
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        adjSet = new ArrayList<HashSet<Integer>>();
        vis = new int[N];
        for(int i = 0; i < N; ++i){
            adjSet.add(new HashSet<Integer>());
        }
        for(int i=0;i<M;i++) {
            st = new StringTokenizer(br.readLine());
            int a = Integer.parseInt(st.nextToken())-1;
            int b = Integer.parseInt(st.nextToken())-1;
            adjSet.get(a).add(b);
            adjSet.get(b).add(a);
        }
        int mx = 0;
        for(int i = 0; i < N; ++i){
            if(vis[i] == 0){
                int got = dfs(i, -1);
                mx = Math.max(mx, got);
            }
        }
        System.out.println(mx);
    }
    
    static int dfs(int start, int parent){
        vis[start] = 1;
        int tot = 1;
        for(int nbr : adjSet.get(start)){
            if(nbr != parent && vis[nbr] == 0)
                tot += dfs(nbr, start);
        }
        return tot;
    }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,w;
  cin >> h >> w;
  vector<vector<int32>> c(10,vector<int32>(10));
  REP(i,10)REP(j,10)cin >> c[i][j];
  REP(k,10)REP(i,10)REP(j,10){
    c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  }
  int64 ans = 0;
  REP(i,h)REP(j,w){
    int32 a;
    cin >> a;
    if(a != -1)ans += c[a][1];
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int r,l;
	int i;

	while (1) {
		scanf("%d%d",&r,&l);
		if (r == 0 && l == 0) {
			break;
		}
		while (r--) {
			for (i = 0;i != l;++i) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}	
	return 0;
}

Measured memory_bytes: 572