akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<" "<<#x<<"="<<x
#define bit(k) (1LL<<(k))

typedef long long ll;
const ll MAX = 5100000;
const ll MOD = 1000000007;
ll n,a,b;
vector<ll> ue(MAX,1),shita(MAX+1,1);
ll modpow(ll a, ll n, int mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


long long modinv(long long a) {
    ll res = modpow(a, MOD - 2, MOD);
    //cerr<<"modinv"<<a<<": "<<res<<endl;
    return res;
}
void cominit(){
    ue[0] = 1;
    shita[0] = 1;
    rep(i,MAX){
        ue[i+1] = ((ue[i]%MOD) * ((n - i) % MOD)%MOD) * (modinv(i+1)%MOD);
        ue[i+1] %=MOD;
    }
}

ll COM(ll w){
    return ue[w];
}
int main() {
    cin>>n>>a>>b;
    cominit();
    /*
    rep(i,n+1){
        cerr<<ue[i]<<" ";
    }
    cerr<<endl;
    */
    ll ans = modpow(2,n,MOD) - 1;
    ans = ((ans+MOD%MOD) - ue[a] + MOD) % MOD;
    ans = ((ans+MOD%MOD) - ue[b] + MOD) % MOD;
    cout<<(ans+MOD)%MOD<<endl;
}

Measured memory_bytes: 79872
import java.util.Scanner;

class Main{
	public static void main(String[] a){
		int num1[] = new int[200];
		int num2[] = new int[200];
		int i = 0;
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			num1[i] = Integer.parseInt(scanner.next());
			num2[i] = Integer.parseInt(scanner.next());
			System.out.println(String.valueOf(num1[i] + num2[i]).length());
			i++;
		}
		
		scanner.close();
	}
}


Measured memory_bytes: 26456
def f(s, t):
    n = len(s)
    for i in range(n):
        if s[i:] == t[:n-i]:
            return len(s[:i] + t)
    return len(s + t)

def solve(n, s, t):
    return min(f(s, t), f(t, s))

n = input()
s = input()
t = input()
print(solve(n, s, t))

Measured memory_bytes: 3060
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s("CODEFESTIVAL2016");
    string t;
    int sum=0;
    cin>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]) sum+=1;
    }
    cout<<sum<<endl;
    return 0;
    
}

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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


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

const int MAX = 2010;
char field[MAX][MAX];
int arr1[MAX][MAX], arr2[MAX][MAX], arr3[MAX][MAX];

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  for (int i = 1; i <= N; i++) {
    scanf("%s", field[i] + 1);
  }

  // 青マスの数、縦に連続する青マスの数、横に連続する青マスの数の二次元累積和をとる
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      if (field[i][j] == '1') {
        arr1[i][j] = 1;
        if (field[i+1][j] == '1') arr2[i][j] = 1;
        if (field[i][j+1] == '1') arr3[i][j] = 1;
      }
    }
  }
  // 累積和をとる
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      arr1[i][j] = arr1[i-1][j] + arr1[i][j-1] - arr1[i-1][j-1] + arr1[i][j];
      arr2[i][j] = arr2[i-1][j] + arr2[i][j-1] - arr2[i-1][j-1] + arr2[i][j];
      arr3[i][j] = arr3[i-1][j] + arr3[i][j-1] - arr3[i-1][j-1] + arr3[i][j];
    }
  }

  // 質問を受け取ったら、累積和を利用して定数時間で答える
  int x1, y1, x2, y2;
  int t1, t2, t3;
  for (int i = 0; i < Q; i++) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    t1 = arr1[x2][y2] - arr1[x1-1][y2] - arr1[x2][y1-1] + arr1[x1-1][y1-1];
    t2 = arr2[x2-1][y2] - arr2[x1-1][y2] - arr2[x2-1][y1-1] + arr2[x1-1][y1-1];
    t3 = arr3[x2][y2-1] - arr3[x1-1][y2-1] - arr3[x2][y1-1] + arr3[x1-1][y1-1];
    printf("%d\n", t1 - t2 - t3);
  }
  return 0;
}


Measured memory_bytes: 53120
#include <stdio.h>
int main(){
    int m,n,s,d;
        scanf("%d", &m);
        n=m;
        s=0;
        while (n!=0) {
            d = n % 10;
            n = n / 10;
            s = s + d;
        }
        if(m%s==0){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;

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

	int n;
	cin >> n;
	string s;
	map<string,int> cnt;
	while(n--){
		cin >> s;
		cnt[s]++;
	}
	
	cout << "AC x " << cnt["AC"] << "\n";
	cout << "WA x " << cnt["WA"] << "\n";
	cout << "TLE x " << cnt["TLE"] << "\n";
	cout << "RE x " << cnt["RE"] << "\n";
	
}


Measured memory_bytes: 3660
#include <cstdio>
#include <vector>

int n;
std::vector<int> G[100000];

int solve(int x, int p, int z){
  int r = 0;
  for(auto y: G[x]){
    if(y == p || y == z) continue;
    r ^= solve(y, -1, x)+1;
  }
  return r;
}

int main(){
  scanf("%d", &n);
  for(int i=0;i<n-1;i++){
    int a, b;
    scanf("%d%d", &a, &b);
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  if(solve(0, -1, -1)) puts("Alice");
  else puts("Bob");

  return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/



signed main() {
	int n; cin >> n;
	cout << (n - 2) * 180 << endl;
}


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

int main(){
  int a;
  cin >> a;
  int now;
  cin >> now;
  long long sum = 0;
  for (int i=1;i<a;i++){
    int b;
    cin >> b;
    if (now > b){
      sum += now - b;
    } else now = b;
  }
  cout << sum << endl;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

int dist[55][55];

void Main()
{
    arrayFill(dist, -1);
    int h, w;
    cin >> h >> w;
    vstr s(h);
    rep(i, h) cin >> s[i];

    dist[0][0] = 0;
    qpint q;
    q.emplace(0, 0);

    vint dy{0, -1, 0, 1};
    vint dx{1, 0, -1, 0};

    while (!q.empty())
    {
        auto pos = q.front();
        q.pop();
        int y = pos.first;
        int x = pos.second;

        rep(i, 4)
        {
            int ny = y + dy[i];
            int nx = x + dx[i];

            if (ny < 0 || ny >= h || nx < 0 || nx >= w || dist[ny][nx] != -1 || s[ny][nx] == '#')
                continue;
            dist[ny][nx] = dist[y][x] + 1;

            q.emplace(ny, nx);
        }
    }
    if (dist[h - 1][w - 1] == -1)
    {
        M1;
        return;
    }

    int cnt = 0;
    rep(i, h) rep(j, w)
    {
        if (s[i][j] == '#')
            ++cnt;
    }
    cout << h * w - cnt - (dist[h - 1][w - 1] + 1) << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

typedef long long ll;
typedef unsigned long long u_ll;

int N;
ll ans = 0;

int main() {
	cin >> N;
	vector <int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}

	for (int i = 0; i < N-1; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ll long long
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
const ull MOD = 1e9+7;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	REP(i, H) cin >> a.at(i);
	vector<vector<int> > dp(H, vector<int>(W, 0));
	int dx[] = {1,0};
	int dy[] = {0,1};
	dp[0][0] = 1;
	REP(y, H) {
		REP(x, W) {
			REP(k, 2) {
				auto ry = y + dy[k], rx = x + dx[k];
				if(0 <= ry && ry < H && 0 <= rx && rx < W && a[ry][rx] != '#') {
					dp[ry][rx] += dp[y][x];
					dp[ry][rx] %= MOD;
				}
			}
		}
	}
	cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
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; }

signed main(){
    string s;
    cin >> s;
    
    if(s == "RRR") cout << 3;
    else if(s == "RRS" || s == "SRR") cout << 2;
    else if(s == "RSS" || s == "RSR" || s == "SSR" || s == "SRS") cout << 1;
    else cout << 0;
}

Measured memory_bytes: 3592
#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()
using namespace std;
typedef long long ll;

int main() {
	int N, M;
	cin >> N >> M;
	map<int, int> A;
	int x;
	string y;
	vector<bool> correct(N, false);
	int wrong = 0;
	rep(i, M) {
		cin >> x >> y;
		if (y=="WA") {
			A[x] += 1;
		} else if (y=="AC" && correct[x-1]==false) {
			wrong += A[x];
			correct[x-1] = true;
		}
	}
	int ans = 0;
	rep(i, N) {
		if (correct[i]) ++ans;
	}
	cout << ans << " " << wrong << endl;
}

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

using namespace std;


int main() {
  
    int k;
    scanf("%d",&k);
    
    int num1=0,num2=0;//num1 represents number of odd numbers and num2 represents number of even numbers
    if(k%2==0)
      {
          num1=k/2;
          num2=k/2;
          printf("%d",num1*num2);//total ways to choose
          
      }
      
     else
     {
         num1=k/2;
         num2=k/2+1;
         printf("%d",num1*num2);//total ways to choose
     }
        
    
    	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char img[h][w];
    //imgを格納
    for(int h_=0; h_ < h; h_++){
        for(int w_=0; w_ < w; w_++) cin >> img[h_][w_];
    }

    //一番上のレリーフを表示
    for(int i=0; i <= w+1; i++){
        cout << "#";
        if(i == w+1) cout << endl;
    }

    for(int h_=0; h_ < h; h_++){
        for(int w_=0; w_ < w; w_++){
            if(w_ == 0) cout << "#";
            cout << img[h_][w_];
            if(w_ == w-1) cout << "#\n";
        }
    }

    //一番下のレリーフを表示
    for(int i=0; i <= w+1; i++){
        cout << "#";
        if(i == w+1) cout << endl;
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        String s = scanner.next();
        int w = scanner.nextInt();
        for (int i = 0; i < s.length(); i += w) {
            System.out.print(s.charAt(i));
        }
        System.out.println();
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int n;LL q;cin >> n >> q;
    vector<vector<int>> a(63,vector<int> (n));
    for (int i = 0; i < n; i++) {
        cin >> a[0][i];
        a[0][i]--;
    }
    for (int k = 0; k < 62; k++) {
        for(int v=0;v<n;v++){
            if(a[k][v]<0) a[k+1][v]=-1;
            else a[k+1][v]=a[k][a[k][v]];
        }
    }
    int t = 0;
    for (int k = 62 - 1; k >= 0; --k){
        if (t == -1) {
            break;
        }
        if ((q >> k) & 1) {
            t = a[k][t];
        }
    }
    cout << t + 1 << endl;
    return 0;
}

Measured memory_bytes: 53420
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree 			ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<int>
#define pint        	pair<int, int>
#define umint        	unordered_map<int, int>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)		for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vector<vint> dp;

void print(vector<vint> arr){
	f(arr.size()){
		fj(arr[i].size()) cout<<arr[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
}

int32_t main() {

    om_shree_ganeshaya_namah();

    int n;
    string s;
	cin>>n>>s;
	vector<vint> dp(n+1, vint(n+1)), prefix(n+1, vint(n+1));
	dp[1][1]=1; prefix[1][1]=1;
	int index=0;
	for(int i=2; i<=n; i++){
		if(s[index]=='<'){
			int r = i-1;
			for(int k=i; k>0; k--){
				dp[i][k]=prefix[i-1][r];
				r--;
			}
		}
		else{
			int l = 1, r = i-1;
			for(int k=1; k<i; k++){
				dp[i][k]=(prefix[i-1][r]-prefix[i-1][l-1]);
				if(dp[i][k]<0)
					dp[i][k]+=mod;
				l++;
			}
		}
		index++;
		for(int j=1; j<=i; j++){
			prefix[i][j]=dp[i][j]+prefix[i][j-1];
			prefix[i][j]%=mod;
		}
	}

	// print(prefix);
	// print(dp);

	cout<<prefix[n][n];
}

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

int main(){
    string s;
    cin >> s;

    bool flag = false;
    string hitachi = "";
    for(int i=0; i<5; i++){
        hitachi += "hi";
        if(s == hitachi) flag = true;
    }

    if(flag == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(void) {
  int n;
  int z=0, o=0, t=0;
  cin>>n;
  for(int i=0; i<n; i++) {
    int x;
    int c=0;
    cin>>x;
    while(x%2==0) {
      c++;
      x=x/2;
    }
    if(c==0) z++;
    else if(c==1) o++;
    else t++;
  }
  if(o==0) {
    if(z-1<=t)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  } else {
    if(z<=t and o-1<=o+t)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int MAX = N * (N - 1) / 2 - (N - 1);
	if (K > MAX) {
		cout << -1 << endl;
		return 0;
	}
	cout << N - 1 + (MAX - K) << endl;
	for (int i = 2; i <= N; i++) cout << "1 " << i << endl;
	int now = 0;
	for (int i = 2; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (now == MAX - K) break;
			cout << i << " " << j << endl;
			now++;
		}
		if (now == MAX - K) break;
	}

}


Measured memory_bytes: 3636
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      char[][] grid = new char[h][w];
      for(int i = 0; i < h; i++)
        grid[i] = sc.next().toCharArray();
      
      int[][] cnt = new int[h][w];
      if(grid[0][0] == '#')
        cnt[0][0] = 1;
      
      for(int i = 1; i < w; i++) {
        if(grid[0][i] == '.')
          cnt[0][i] = cnt[0][i-1];
        else {
          if(grid[0][i-1] == '#')
            cnt[0][i] = cnt[0][i-1];
          else
            cnt[0][i] = cnt[0][i-1] + 1;
        }
      }

      for(int i = 1; i < h; i++) {
        cnt[i][0] = cnt[i-1][0];
        if (grid[i-1][0] == '.' && grid[i][0] == '#')
        	cnt[i][0]++;
      }

      for(int i = 1; i < h; i++) {
        for(int j = 1; j < w; j++) {
          if(grid[i][j] == '.') {
            cnt[i][j] = Math.min(cnt[i-1][j], cnt[i][j-1]);
          } else {
            int up = cnt[i-1][j];
            if(grid[i-1][j] == '.')
              up++;
            int left = cnt[i][j-1];
            if(grid[i][j-1] == '.')
              left++;
            cnt[i][j] = Math.min(up, left);
          }
        }
      }

      System.out.println(cnt[h-1][w-1]);
  }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  bool ans = true;
  for(int i = 0; i < N; i++){
  	if(A.at(i) %2 == 0){
    	if(A.at(i) %3 == 0 || A.at(i) %5 == 0){
     	 ans = true;
   	    }else{
         ans = false;
         break;
        }
  	}
  }

    if(ans){
      cout << "APPROVED" << endl;
    }
    if(!ans){
      cout << "DENIED" << endl;
    }
  }

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

using namespace std;

vector<int> p(200010);

int main() {
  int n, x, m;
  cin >> n;
  fill(p.begin(), p.end(), 0);

  for (int i = 0; i < n; i++) {
    cin >> x;
    p[x] = p[x-1]+1;
  }

  cout << n-*max_element(p.begin(), p.end()) << endl;
  return 0;
}


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

const int maxn = 1e5 + 10;
int n, a[maxn], f[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	f[1] = 0, f[2] = fabs(a[2] - a[1]);
	for (int i = 3; i <= n; i++) {
		f[i] = min(f[i - 1] + fabs(a[i] - a[i - 1]), f[i - 2] + fabs(a[i] - a[i - 2]));
	}
	printf("%d", f[n]);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int s ,f ,i ,n ,x ,y ,z;
  while( scanf ( "%d" ,&x ) != EOF ){

   if ( x == 0 ){
      break;
    }

    scanf ( "%d" ,&n );
 
    for ( i = 0 ; i < n ; i++ ){
      scanf ( "%d %d" ,&s ,&f );
      y = y + ( f - s );
    }

    z = x - y;

    if( y < x ){
      printf ( "%d\n" ,z );
    }

    else{
      printf ( "OK\n" );
    }
    y=0;
  }

  return 0;
}

Measured memory_bytes: 612
#include<iostream>
using namespace std;
char arr[100001];
int main()
{
	cin>>arr;
	int i=0;
	while(arr[i]!='\0')
	{
		if(arr[i]=='d')
		{
			if(arr[i+0]=='d'&&arr[i+1]=='r'&&arr[i+2]=='e'&&arr[i+3]=='a'&&arr[i+4]=='m')
			{
				i+=5;
			}
			else{
				break;
			}
			if(arr[i+0]=='e'&&arr[i+1]=='r'&&(arr[i+2]!='a'))
			{
				i+=2;
			}
		}
		else if(arr[i+0]=='e')
		{
			if(arr[i+0]=='e'&&arr[i+1]=='r'&&arr[i+2]=='a'&&arr[i+3]=='s'&&arr[i+4]=='e')
			{
				i+=5;
			}
			else{
				break;
			}
			if(arr[i+0]=='r')
			{
				i++;
			}
		}
		else
		{
			break;
		}
	}
	if(arr[i]=='\0')
	{
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
} 

Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N;
    cin >> N;
    if (N == 0) {
        cout << 0 << endl;
    }
    string S = "";
    while (N != 0) {
        int R = N % (-2);
        N /= (-2);
        if (R < 0) {
            R += 2;
            N += 1;
        }
        S = to_string(R) + S;
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc163/tasks/abc163_d

def main():
    MOD = 10**9 + 7
    n, k = [int(i) for i in input().strip().split()]
    table = [0] * (n + 2)
    table[1] = 1

    for i in range(2, n + 1):
        table[i] = table[i - 1] + i

    ans = 0
    for i in range(k, n + 1):
        _min = table[i - 1]
        _max = table[n] - table[n - i]
        ans += _max - _min + 1
        ans %= MOD
    print((ans + 1) % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 65648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define INF 1e9
int n,m;
int a[1111],b[1111],c[1111];
int d[111][111];
int ans=0;
signed main(){
	cin>>n>>m;
	rep(i,n){
		rep(j,n){
			d[i][j]=INF;
		}
	}
	rep(i,m){
		cin>>a[i]>>b[i]>>c[i];
		d[a[i]-1][b[i]-1]=d[b[i]-1][a[i]-1]=c[i];
	}
	
	rep(i,n)d[i][i]=0;
	rep(k,n){
		rep(i,n){
			rep(j,n){
				d[i][j]=min(d[i][j] ,d[i][k]+d[k][j]);
			}
		}
	}
	rep(i,m){
		if(c[i]!=d[a[i]-1][b[i]-1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
vector <Pli> Graph[int(1e5+5)];
ll Dist[int(1e5+5)];

int main(){
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int L, R; ll C; cin >> L >> R >> C;
    Graph[L].push_back({C, R});
  }
  for (int i = 1; i < N; i++){
    Graph[i+1].push_back({0, i});
  }
  fill(Dist, Dist + N + 1, -1);
  priority_queue <Pli, vector<Pli>, greater<Pli> > que;
  que.push({0, 1});

  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    if (Dist[Q.se] != -1) continue;
    Dist[Q.se] = Q.fi;
    for (Pli next : Graph[Q.se]){
      if (Dist[next.se] != -1) continue;
      que.push({next.fi + Q.fi, next.se});
    }
  }
  cout << Dist[N] << endl;

  return 0;
}


Measured memory_bytes: 13056
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static readonly long MOD = 1000000000 + 7;
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var a = ReadLine().Split(' ').Select(int.Parse).ToList();

            a.Sort();
            int max = a[a.Count() - 1];
            int sum = 0;
            foreach (var i in a)
            {
                sum += i;
            }
            sum -= max;
            WriteLine(max < sum ? "Yes" : "No");
        }
    }
}



Measured memory_bytes: 13396
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define siz 10000000

char buf[siz], *bit = buf;

inline int nextInt(void) {
	register int ret = 0;
	register int neg = false;

	for (; *bit < '0'; ++bit)
		if (*bit == '-')neg ^= true;

	for (; *bit >= '0'; ++bit)
		ret = ret * 10 + *bit - '0';

	return neg ? -ret : ret;
}

#define inf 2147483647

int n, m;

int tag[400005];

int find(int t, int l, int r, int p) {
	if (~tag[t])
		return tag[t];
	int mid = (l + r) >> 1;
	if (p <= mid)
		return find(t << 1, l, mid, p);
	else
		return find(t << 1 | 1, mid + 1, r, p);
}

void update(int t, int l, int r, int x, int y, int k) {
	if (l == x && r == y)
		tag[t] = k;
	else {
		int mid = (l + r) >> 1;
		if (~tag[t])
			tag[t << 1] = tag[t << 1 | 1] = tag[t], tag[t] = -1;
		if (y <= mid)
			update(t << 1, l, mid, x, y, k);
		else if (x > mid)
			update(t << 1 | 1, mid + 1, r, x, y, k);
		else {
			update(t << 1, l, mid, x, mid, k);
			update(t << 1 | 1, mid + 1, r, mid + 1, y, k);
		}
	}
}

signed main(void) {
	fread(buf, 1, siz, stdin);

	n = nextInt();
	m = nextInt();

	for (int i = 0; i < (n << 2); ++i)
		tag[i] = inf;

	for (int i = 1; i <= m; ++i) {
		int c = nextInt();
		if (c)	// find(x)
			printf("%d\n", find(1, 1, n, nextInt() + 1));
		else {
			int x = nextInt();
			int y = nextInt();
			int k = nextInt();
			update(1, 1, n, x + 1, y + 1, k);
		}
	}

	//system("pause");
}

Measured memory_bytes: 5932
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;

	cout << "Christmas";
	for (int i = 0; i < (25 - N); i++)
	{
		cout << " Eve";
	}
	cout << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


h, w = input().split(" ")
h, w = int(h), int(w)

ans = 0
if (h > 1):
    ans += comb(h, 2)
if (w > 1):
    ans += comb(w, 2)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while ( x != NIL ){
        y = x;
        if ( z->key < x->key ) x = x->left;
        else x = x->right;
    }
    
    z->parent = y;
    if ( y == NIL ) root = z;
    else{
        if ( z->key < y->key ) y->left = z;
        else y->right = z;
    }
}

void inorder(Node *u){
    if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if ( u == NIL ) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        cin >> com;
        if ( com == "insert" ){
            scanf("%d", &x);
            insert(x);
        }
        else if ( com == "print" ){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } 
    }
    
    return 0;
}


Measured memory_bytes: 26652
from collections import Counter, OrderedDict


n = int(input())
lst_v = list(map(int, input().split()))


if len(set(lst_v)) == 1:
    ans = n // 2
else:
    lst_odd = lst_v[::2]
    lst_even = lst_v[1::2]
    cnt_odd = sorted(Counter(lst_odd).items(), key=lambda x: -x[1])
    cnt_even = sorted(Counter(lst_even).items(), key=lambda x :-x[1])

    if cnt_odd[0][0] == cnt_even[0][0]:
        rem_number = max(cnt_odd[0][1] + cnt_even[1][1], cnt_odd[1][1] + cnt_even[0][1])
    else:
        rem_number = cnt_odd[0][1] + cnt_even[0][1]
    sum_odd = sum(t[1] for t in cnt_odd)
    sum_even = sum(t[1] for t in cnt_even)
    ans = sum_odd + sum_even - rem_number


print(ans)


Measured memory_bytes: 21076
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;


signed main(){
    int n,k; cin >> n >> k;
    int res=1;
    int ans=0;
    while(n>=res){
        res*=k;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
r = int(input())
tp = tuple(map(int,input().split()))
tq = tuple(map(int,input().split()))

import itertools

for i, ti in enumerate(itertools.permutations(range(1,r+1))):
    if tp == ti:
        p = i
        break

for i, ti in enumerate(itertools.permutations(range(1,r+1))):
    if tq == ti:
        q = i
        break

print(abs(p-q))

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

using namespace std;
using pii = pair<int, int>;
using ppii = pair<int, pii>;

int n;
vector<pair<int, pii>> a;
vector<pii> edge[100010];

bool less_x(ppii s, ppii t) {
  return s.second.first < t.second.first;
}

bool less_y(ppii s, ppii t) {
  return s.second.second < t.second.second;
}

long long prim() {
  priority_queue<pii, vector<pii>, greater<pii>> q;
  vector<bool> visited(n, false);
  q.push(make_pair(0, 0));
  long long ans = 0;
  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    int cost = p.first, u = p.second;
    if (visited[u]) {
      continue;
    }
    visited[u] = true;
    ans += cost;
    for (auto e: edge[u]) {
      int v = e.first, c = e.second;
      if (visited[v]) {
        continue;
      }
      q.push(make_pair(c, v));
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  a = vector<ppii>(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = make_pair(i, make_pair(x, y));
  }
  sort(a.begin(), a.end(), less_x);
  auto p0 = a[0];
  for (int i = 1; i < n; i++) {
    auto p1 = a[i];
    int cost = min(abs(p0.second.first - p1.second.first), abs(p0.second.second - p1.second.second));
    edge[p0.first].push_back(make_pair(p1.first, cost));
    edge[p1.first].push_back(make_pair(p0.first, cost));
    p0 = p1;
  }
  sort(a.begin(), a.end(), less_y);
  p0 = a[0];
  for (int i = 1; i < n; i++) {
    auto p1 = a[i];
    int cost = min(abs(p0.second.first - p1.second.first), abs(p0.second.second - p1.second.second));
    edge[p0.first].push_back(make_pair(p1.first, cost));
    edge[p1.first].push_back(make_pair(p0.first, cost));
    p0 = p1;
  }
  cout << prim() << endl;
  return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);

            HashSet<int> modset = new HashSet<int>();
            int mod = A;
            mod %= B;

            while (modset.Add(mod))
            {
                mod += A;
                mod %= B;
            }

            Console.WriteLine(modset.Contains(C) ? "YES":"NO");
        }
    }
}


Measured memory_bytes: 13396
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = Array.new(n, 0)
b[0] = 1
nex = 0
roop = 0
offset = 0
ans = 0
k.times do |i|
    if b[a[nex]-1] == 0
        b[a[nex]-1] = i+2
        nex = a[nex]-1
    else
        roop = i - b[a[nex]-1] + 2
        offset = b[a[nex]-1]-1
        rem = (k - offset)%roop
        ans = b.index(b[a[nex]-1]+rem)+1        
        break
    end
    if i == k-1
        ans = nex+1
    end
end
puts ans


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

map<char,int> mp;
int main(int argc, char const *argv[])
{
    string x,y;
    cin >> x >> y;
    int a = 0,b= 0;
    mp['A'] = 10;
    mp['B'] = 11;
    mp['C'] = 12;
    mp['D'] = 13;
    mp['E'] = 14;
    mp['F'] = 15;

    reverse(x.begin(), x.end());
    reverse(y.begin(), y.end());
    for(int i = 0;i < x.length(); i++){
        a += mp[x[i]];
        a *= 16;
    }

    for(int i = 0;i < y.length(); i++){
        b += mp[y[i]];
        b *= 16;
    }
    if(a == b){
        cout << "=";
    }
    else if (a > b ){
        cout << ">";
    }
    else
        cout << "<";
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
a_sum=sum(a)
count=0
for i in range(m):
    if  a[i] >= a_sum/(4*m):
        count+=1

if count==m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
n, m, X = map(int, input().split())
C = [0] * n
A = [0] * n
for i in range(n):
    c, *a = map(int, input().split())
    C[i] = c
    A[i] = a

inf = 10 ** 20
ans = inf
for bit in range(2**n):
    yen = 0
    x = [0] * m
    for i in range(n):
        if bit >> i & 1 == 1:
            for j in range(m):
                x[j] += A[i][j]
            yen += C[i]
    if all(i >= X for i in x) and ans > yen:
        ans = yen
if ans == inf:
    ans = -1
print(ans)


Measured memory_bytes: 9220
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;

int n;
inline ll ct(ll k)
{
	return max(k*(k-1)/2,0LL);
}
map <string, ll> m;
int main()
{
	usecppio
	cin >> n;
	for (int i = 0; i<n; i++)
	{
		string str;
		cin >> str;
		sort(all(str));
		m[str]++;
	}
	ll ans = 0;
	for (auto it:m)
	{
		ans += (ct(it.second));
	}
	cout << ans;
}


Measured memory_bytes: 11264
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun x y z -> [|x; y; z|])) in
  let dp = Array.init 3 (fun _ -> Array.make (n+1) 0) in
  for i = 1 to n do
    for d = 0 to 2 do
      dp.(d mod 3).(i) <-
        a.(i-1).(d) + max dp.((d+1) mod 3).(i-1) dp.((d+2) mod 3).(i-1)
    done;
  done;
  Printf.printf "%d\n" (dp.(0).(n) |> max dp.(1).(n) |> max dp.(2).(n))
  

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

int main(){
    int n; cin >> n;
    vector<int> s(n+1);
    rep(i, n){
        cin >> s.at(i);
    }
    int q; cin >> q;
    vector<int> t(q);
    rep(i, q){
        cin >> t.at(i);
    }

    int ans = 0;
    for(int i = 0; i < q; i++){
        int j = 0;
        s.at(n) = t.at(i); //番兵の設置 
        while(t.at(i) != s.at(j)){
            j++;
        }
        if(j == n){
        }else{
            ans++;
        }
    }

    cout << ans << endl;
}


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

#define ll  int
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll>
#define pll pair<ll,ll>
vector<ll>mp(1e7,0);
bool helper(ll n){
    for (int i=1; i<=sqrt(n); i++){

        if (n%i == 0)
        {
            if (n/i == i){
            if(mp[i]>0){
             return false;}
            }
            else  {
               if(mp[n/i]>0 || mp[i]>0)
               return false;
            }
        }
    }
  //  cout<<"k";
    return true;
}
int main(){
ll n,res=0;
cin>>n;
 int f=0;
     vector<ll>vec(n);
     for(int i=0;i<n;i++){
     cin>>vec[i];
        if(vec[i]==1)
           f=1;
     mp[vec[i]]++;
   }

   for(int i=0;i<n;i++){
           mp[vec[i]]--;
    if( helper(vec[i]) )
         res++;
       mp[vec[i]]++;

     }
    cout<<res;
  }


Measured memory_bytes: 43124
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  ll max_p = 0;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    max_p = max(p[i], max_p);
  }
  vector<ll> accum(max_p + 1, 0);
  accum[0] = 0;
  for (int i = 1; i <= max_p; i++) {
    accum[i] = accum[i - 1] + i;
  }
  vector<long double> e(N);
  long double exp;
  e[0] = (long double)((long double)accum[p[0]] / (long double)p[0]);
  for (int i = 1; i < N; i++) {
    exp = (long double)((long double)accum[p[i]] / (long double)p[i]);
    e[i] = e[i - 1] + exp;
  }
  long double ans = 0.0;
  for (int i = 0; i < N; i++) {
    if (i >= K) ans = max(e[i] - e[i - K], ans);
  }
  if (N == K) ans = e[N - 1];
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
#define INF (1 << 30)
#define rep(i,n) for(int i=0; i<n; ++i)

int main()
{
	int N; cin >> N;
	string C; cin >> C;

	int rr = 0, lw = 0;
	rep(i, C.size()) {
		if (C[i] == 'R') ++rr;
	}
	int ans = max(rr, lw);
	rep(i, C.size()) {
		if (C[i] == 'W') ++lw;
		else --rr;
		ans = min(ans, max(rr, lw));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3464
N=int(input())
from collections import defaultdict
branch=defaultdict(dict)
for i in range(N-1):
    a,b,c=map(int,input().split())
    branch[a-1][b-1]=c
    branch[b-1][a-1]=c
Q,K=map(int,input().split())
dist=[float('inf') for i in range(N)]
K-=1
dist[K]=0
check={K}
while len(check)>0:
    now=check.pop()
    for nex,cost in branch[now].items():
        if dist[nex]>dist[now]+cost:
            dist[nex]=dist[now]+cost
            check|={nex}
for i in range(Q):
    x,y=map(int,input().split())
    print(dist[x-1]+dist[y-1])

Measured memory_bytes: 69852
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**10
for i in range(N-K+1):
    if x[i] >= 0 and x[i+K-1] >= 0:
        ans = min(ans, x[i+K-1])
    elif x[i] < 0 and x[i+K-1] < 0:
        ans = min(ans, abs(x[i]))
    else:
        ans = min(ans, abs(x[i]) * 2 + x[i+K-1])
        ans = min(ans, abs(x[i]) + x[i+K-1] * 2)
print(ans)


Measured memory_bytes: 14240
#include <stdio.h>
#define min(a, b) a<b?a:b
#define INF 2110001000

int v, e;
int d[101][101];

int main(void)
{
    int i, j, k, s, t, c;
    scanf("%d %d", &v, &e);
    v;
    for (i = 0; i < v; i++) {
        for (j = 0; j < v; j++) {
            d[i][j] = INF;
        }
        d[i][i] = 0;
    }
    for (i = 0; i < e; i++) {
        scanf("%d %d %d", &s, &t, &c);
        d[s][t] = c;
    }
    for (k = 0; k < v; k++) {
        for (i = 0; i < v; i++) {
            for (j = 0; j < v; j++) {
                if (d[i][k] != INF && d[k][j] != INF) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    }
    for (i = 0; i < v; i++) {
        if (d[i][i] < 0) {
            puts("NEGATIVE CYCLE");
            return 0;
        }
    }
    for (i = 0; i < v; i++) {
        if (d[i][0] != INF) {
            printf("%d", d[i][0]);
        } else {
            printf("INF");
        }
        for (j = 1; j < v; j++) {
            if (d[i][j] == INF) {
                printf(" INF");
            } else {
                printf(" %d", d[i][j]);
            }
        }
        puts("");
    }
    return 0;
}

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

int main() {
    int N, T;
    cin >> N >> T;

    int ans = 10000;
    for (int i = 0; i < N; ++i) {
        int c, t;
        cin >> c >> t;
        if (t <= T) ans = min(ans, c);
    }

    if (ans == 10000) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


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

string ans(int n, vector<int> &s) {
  vector<char> c(n);
  string str;
  
  for(int i=0; i<n; i++){
    c[i]='a'+s[i];
    str = str + c[i];
  }
  
  return str;
  
}
  
int judge(int n, vector<int> &s){
  for(int i=0; i<n; i++){
    if(s[i]==s[n]) return 1;
  }
  
  return 0;

}

int main() {
  int n;
  cin>>n;
  
  vector<int> a(n);
  for(int i=0; i<n; i++) a[i]=0; //配列初期化
  cout << ans(n,a) << endl; //初期答え
    
  for(int i=0; i<n; i++){
    if(judge(n-1-i,a)){
      a[n-1-i]++;
      for(int l=n-1; l>n-1-i; l--) a[l]=0;
      cout << ans(n,a) << endl;
      i=-1;
    }
  }  
}


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

long long int save = 0;

void generate_all_subsets(string s, int step, int arr[])
{
	if( step < s.size() - 1 )
	{
		arr[step] = 0;
		generate_all_subsets(s,step+1,arr);
		arr[step] = 1;
		generate_all_subsets(s,step+1,arr);
	}else{
		long long int sum = 0;
		for(int i = 0; i < s.size()-1; i++)
		{
			sum *= 10;
			sum += (int)( s[i] - '0' );
			if( arr[i] == 1 )
			{
				save += sum;
				sum = 0;
			}
		}
		sum *= 10;
		sum += (int)( s[s.size() - 1] - '0' );
		save += sum;
	}
}
int main()
{
	string s;
	cin >> s;
	int arr[s.size() - 1];
	generate_all_subsets(s,0,arr);
	cout << save;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main()
{
	int a[100];
	memset(a,0,sizeof(a));
	int in;
	while(cin>>in)a[in-1]++;
	vector<pair<int,int>> P;
	rep(i,100)P.push_back(make_pair(a[i],i));
	sort(P.begin(),P.end(),[](const pair<int,int> p1,const pair<int,int> p2)
	{
		return p1.first==p2.first?p1.second>p2.second:p1.first<p2.first;
	});
	cout<<P[99].second+1<<endl;
	int c=99;
	while(P[c].first==P[c-1].first)
	{
		cout<<P[--c].second+1<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int num;
  register int i;
  string name;
  set <string> fruits;
  cin >> num;
  for (i = 0; i < num; i++){
    cin >> name;
    fruits.insert(name);
  }
  cout << fruits.size() << '\n';
  return 0;
}


Measured memory_bytes: 19184
#include "bits/stdc++.h"
using namespace std;

int main() {
  int a, b; cin >> a >> b;
  int ans = 1e9;
  for (int i = 1; i < 10000; i++) {
    int x = (int)((double)i * 0.08);
    int y = (int)((double)i * 0.1);
    if (x == a && y == b) {
      ans = min(ans, i);
    }
  }
  cout << (ans == 1e9 ? -1 : ans) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		//入力の読み込み
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();  //整数Nの値
		int base = sc.nextInt();  //進数Kの値

//		//パターン1
//		int i = 0;  //基数を何乗するかを表す数
//
//		//基数の値^iごとに桁が増える
//		while(Math.pow(base, i) <= n) {
//			i++;
//		}
//		System.out.print(i);

		//パターン2
		int count = 0;  //基数で割った回数＝桁数
		while(n > 0) {  //Nが0になるまで繰り返す
			n = n/base;
			count++;
		}
		System.out.print(count);
	}
}

Measured memory_bytes: 21844