akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int count = 0;
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <= c;k++){
                int X = 500 * i + 100 * j + 50 * k;
                if(X == x) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF (1<<30)
#define LLINF (1ll<<60)
typedef long long ll;
int main(void){
	char s[15];
	scanf("%s",s);
	printf("2018/01/%c%c\n",s[8],s[9]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int X;
  int flg;
  cin >> X;
  while(true){
    flg = 0;
    for(int j=2;j<=X/2;j++){
      if(X%j == 0){
        flg = 1;
        break;
      }
    }
    if(flg == 0){
        break;
    }
    X++;
  }
  cout << X;
}

Measured memory_bytes: 384
from collections import Counter
from copy import deepcopy


def solve(c_d):
    one = [24]
    all_d = []
    for i in range(13):
        if c_d[i] >= 3:
            return 0
        elif c_d[i] == 2:
            all_d.append(i)
            all_d.append(24 - i)
        elif (i == 0 or i == 12) and c_d[i] == 1:
            all_d.append(i)
        elif c_d[i] == 1:
            one.append(i)
    ans = 0
    for i in range(1 << len(one)):
        now = deepcopy(all_d)
        for j in range(len(one)):
            if (i >> j) & 1:
                now.append(one[j])
            else:
                now.append(24 - one[j])
        now_ans = float("inf")
        for j in range(len(now)):
            for k in range(j + 1, len(now)):
                now_ans = min(now_ans, abs(now[j] - now[k]))
        ans = max(ans, now_ans)
    return min(ans, 24 - ans)


def main():
    n = int(input())
    d = list(map(int, input().split()))
    d.append(0)
    print(solve(Counter(d)))


if __name__ == '__main__':
    main()


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define LLINF LLONG_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define MAX_H 1100
#define MAX_W 1100

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input values
    ll H, W;
    cin >> H >> W;

    vector<vector<char>> a(H, vector<char>(W, '0'));
    rep (i, H) {
        rep (j, W) {
            cin >> a[i][j];
        }
    }

    // dp table
    // init dp table
    vector<vector<ll>> dp(MAX_H, vector<ll>(MAX_W, 0));

    // init condition
    dp[0][0] = 1;

    // loop
    rep (i, H) {
        rep (j, W) {
            if (i+1 < H && a[i+1][j] == '.') {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            if (j+1 < W && a[i][j+1] == '.') {
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 10752
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//


signed main(){
    int x=re;
    int ans=0;
    if(x>=500)ans+=x/500*1000,x%=500;
    if(x>=5)ans+=x/5*5,x%=5;
    pr(ans);
    return 0;
}


Measured memory_bytes: 256
n,h,w = (int(i) for i in input().split())
a = []
for i in range(n):
  tmp = list(int(i) for i in input().split())
  a.append(tmp)
ct = 0
for i in range(n):
  if a[i][0] >= h and a[i][1] >=w: ct += 1
print(ct)

Measured memory_bytes: 3188
A=input()
n=len(A)
ans=0
if n == 1:
  ans=int(A)
elif n == 2:
  ans=9
elif n == 3:
  ans=int(A)-90
elif n == 4:
  ans=909
elif n == 5:
  ans=int(A)-9090
else:
  ans = 90909
print(ans)

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

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char> > s(h+2, vector<char>(w+2, '.'));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> s[i][j];
        }
    }
    bool ok = true;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(s[i][j] == '.') continue;
            bool isolated = true;
            for(int d=0; d<4; d++){
                if(s[i+dy[d]][j+dx[d]] == '#'){
                    isolated = false;
                }
            }
            if(isolated){
                ok = false;
            }
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	bb := make([]int, n)
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		b := getNextInt(scanner)
		m := getNextInt(scanner)
		e := getNextInt(scanner)
		for i := b; i < e; i++ {
			bb[b+(i-b+e-m)%(e-b)] = aa[i]
		}
		for i := b; i < e; i++ {
			aa[i] = bb[i]
		}
	}

	for i := 0; i < n; i++ {
		if i > 0 {
			fmt.Fprint(writer, " ")
		}
		fmt.Fprint(writer, aa[i])
	}
	fmt.Fprintln(writer, "")
}



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


int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> a(H, vector<char>(W,0));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  for (int i=-1; i<H+1; i++) {
    for (int j=-1; j<W+1; j++) {
      if (i==-1 || i==H || j==-1 || j==W) cout << '#';
      else cout << a.at(i).at(j);
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <random>
#include <complex>

#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define reset(x, y) memset(x, y, sizeof(x))
#define BUG(x) cerr << #x << " = " << (x) << endl
#define BUGP(x) cout << #x << " = " << (x)._1 << ", " << (x)._2 << endl
using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};
// Head

const int N = 112345;
const int MOD = int(1e9) + 7;

LL fac[N];
int n;
string s;

int main() {
    cin >> n;

    fac[0] = 1;
    for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;

    cin >> s;
    LL ans = 1;
    LL cur = 0;

    for (int i = 0; i < s.length(); i++) {
        int tmp = 0;
        if (s[i] == 'B') tmp = 1;

        if ((tmp + cur) % 2 == 1) ++cur;
        else {
            //cout << ans << ' ' << i << endl;
            ans = ans * cur % MOD;
            --cur;
        }
    }

    if (cur) {
        cout << 0 << '\n';
        return 0;
    }
    //cout << ans << endl;

    cout << ans * fac[n] % MOD << '\n';
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
#include <algorithm>
#include <vector>
int main(){
int n,l;
std::cin >> n>>l;
std::vector<string> s(n);
for (int i = 0; i < n; i++) {
  std::cin >>  s[i];
}

sort(s.begin(),s.end());

for (int i = 0; i < n; i++) {
  std::cout << s[i];
}

std::cout << '\n';


return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <vector>

int main()
{
  int s, t; //number of integers for S and T

  int count = 0; // number of integers of T in S
  
  std::set<int> S; // set S to be checked against

  scanf("%d", &s);
  
  for (int i = 0; i < s; ++i) {
    int input;
    scanf("%d", &input);
    S.insert(input);
  }

  scanf("%d", &t);

  std::vector<int> T (t, 0);

  for (int i = 0; i < t; ++i) {
    int input;
    scanf("%d", &input);
    T[i] = input;
  }

  for (int i = 0; i < t; ++i) {
    if ( S.find(T[i]) != S.end() ) ++count; // increment count if found in S
  }

  printf("%d\n", count);
}
    

Measured memory_bytes: 2812
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		if (s.at(i) != t.at(i)) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] l = new Integer[n];
        for(int i=0; i<n; i++) {
            l[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(l,Comparator.reverseOrder());

        //l[i] >= l[j] >= l[k]
        int cnt = 0;
        for(int i=0; i<n-2; i++) {
            for(int j=i+1; j<n-1; j++) {
                for(int k=j+1; k<n; k++) {
                    if(l[j]-l[k]<l[i] && l[i]<l[j]+l[k]) cnt++;
                    else break;
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 26816
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i32> = get_vec();
    if  v[0] + v[1] < 10  {
        println!("{}", v[0] + v[1]);
    } else {
        println!("{}", "error");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n;cin>>n;
  vector<ll> a(n),b(n);
  vector<pl> c(n);
  rep(i,n){
    cin>>a[i]>>b[i];
    c[i].fi=a[i]+b[i];
    c[i].se=i;
  }

  sort(all(c),greater<pl>());

  bool flg=true;
  ll ans=0;
  rep(i,n){
    if(flg){
      ans+=a[c[i].se];
      flg=!flg;
    }else{
      ans-=b[c[i].se];
      flg=!flg;
    }
  }

  cout<<ans<<endl;
    
  return 0;
}








Measured memory_bytes: 3328
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>

#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong n, k;
    cin >> n >> k;
    vector<llong> dp(n,INF);
    vector<llong> h(n,0);
    for(int i=0; i<h.size(); i++){
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i=1; i<dp.size(); i++){
        for(int j=1; j<=k; j++){
            if(i-j<0){
                continue;
            }
            dp[i] = min(dp[i], dp[i-j]+abs(h[i-j]-h[i]));
        }
    }
    cout << dp[dp.size()-1] << endl;
    return 0;
}





Measured memory_bytes: 4492
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
 
		for(int i = 1; i <= 9; i++) {
			if(n % i == 0) {
				int tmp = n / i;
				if( 1 <= tmp && tmp <= 9) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 22228
//
//AtCoder Beginner Contest 176
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    int H,W;
    cin >> H >> W;

    int ch,cw;
    cin >> ch >> cw;
    ch--;cw--;

    int dh,dw;
    cin >> dh >> dw;
    dh--;dw--;

    vector<string> MAP(H);
    REP(h, H) cin >> MAP[h];

    vector<vector<int>> visited(H, vector<int>(W, 0));

    queue<pair<int, int>> walkQ,magicQ;
    walkQ.push(make_pair(ch, cw));
    visited[ch][cw] = 1;

    int ans=0;
    while(!walkQ.empty()){
        while (!walkQ.empty()) {
            int cx = walkQ.front().first;
            int cy = walkQ.front().second;
            magicQ.push(walkQ.front());
            walkQ.pop();

            REP(i,4){
                int ex = cx + dx[i];
                int ey = cy + dy[i];
                if ((ex<0) || (ex>=H)) continue;
                if ((ey<0) || (ey>=W)) continue;
                if (MAP[ex][ey] == '#') continue;
                if (visited[ex][ey] == 1) continue;
                walkQ.push(make_pair(ex, ey));
                visited[ex][ey] = 1;
            }
        }
        if (visited[dh][dw]==1) break;
        /*
        REP(h,H){
            REP(w,W) {
                cout << visited[h][w];
            }
            cout << endl;
        }
        */
        while(!magicQ.empty()){
            int cx = magicQ.front().first;
            int cy = magicQ.front().second;
            magicQ.pop();
            FOR(i,-2,2){
                FOR(j,-2,2){
                    int ex = cx + i;
                    int ey = cy + j;
                    if ((ex<0) || (ex>=H)) continue;
                    if ((ey<0) || (ey>=W)) continue;
                    if (MAP[ex][ey] == '#') continue;
                    if (visited[ex][ey] == 1) continue;
                    walkQ.push(make_pair(ex, ey));
                    visited[ex][ey] = 1;
                }
            }
        }
        ans++;
    }
    if (visited[dh][dw]==1) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 9420
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

#define N_MAX 100001

void solv()
{
	int N; scanf("%d", &N);
	int tmpA[N_MAX], tmpB[N_MAX];

	for (int i = 0; i < N; i++){
		scanf("%d", tmpA + i);
	}
	for (int i = 0; i < N; i++){
		scanf("%d", tmpB + i);
	}

	pair<int, int> table[N_MAX];
	for (int i = 0; i < N; i++){
		table[i] = make_pair(tmpB[i], tmpA[i]);
	}

	sort(table, table + N);

	int A[N_MAX], B[N_MAX];
	pair<int, int> sortA[N_MAX];
	for (int i = 0; i < N; i++){
		A[i] = table[i].second;
		B[i] = table[i].first;
		sortA[i] = make_pair(A[i], i);
	}

	sort(sortA, sortA + N);

	for (int i = 0; i < N; i++){
		if (sortA[i].first > B[i]){
			printf("No");
			return;
		}
	}

	for (int i = 0; i < N - 1; i++){
		if (sortA[i + 1].first <= B[i]){
			printf("Yes");
			return;
		}
	}

	int rev[N_MAX];
	for (int i = 0; i < N; i++){
		rev[sortA[i].second] = i;
	}

	int visit[N_MAX];
	fill(visit, visit + N, 0);
	int cur = 0;
	for (int i = 0; i < N; i++){
		if (0 == visit[rev[cur]]){
			visit[rev[cur]] = 1;
			cur = rev[cur];
		}
		else{
			printf("Yes");
			return;
		}
	}

	printf("No");
	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 3712
public class Main {


  private static void solve() {
    char[] s = ns();
    int a = Integer.parseInt("" + s[0] + s[1]);
    int b = Integer.parseInt("" + s[2] + s[3]);
    
    if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
      System.out.println("AMBIGUOUS");
    } else if (1 <= a && a <= 12) {
      System.out.println("MMYY");
    } else if (1 <= b && b <= 12) {
      System.out.println("YYMM");
    } else {
      System.out.println("NA");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 21332
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    ret = YES
    for i in range(len(S)):
        if i % 2 == 0 and S[i] in ['R', 'U', 'D']:
            continue
        if i % 2 == 1 and S[i] in ['L', 'U', 'D']:
            continue
        ret = NO
        break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
# coding: utf-8

S = input()

s1 = int(S[0]) * 10 + int(S[1])
s2 = int(S[2]) * 10 + int(S[3])

if 1 <= s1 <= 12:
	if 1 <= s2 <= 12:
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if 1 <= s2 <= 12:
		print("YYMM")
	else:
		print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n;
vector<int> e[100000];
bool col[100000];
bool dead[100000];
int dep[100000];
int sorter[100000];
int par[100000];

bool cmp(int left, int right){
    return dep[left] > dep[right];
}

void dfs(int v){
    rep(i,e[v].size()){
        if(dep[e[v][i]] != INF){
            par[v] = e[v][i];
            continue;
        }
        dep[e[v][i]] = dep[v]+1;
        dfs(e[v][i]);
    }
}

int main(){
    I(n);
    rep(i,n) dep[i] = INF;
    rep(i,n-1){
        int a, b;
        I(a, b);
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    rep(i,n) par[i] = -1;
    dep[0] = 0;
    dfs(0);
    rep(i,n) sorter[i] = i;
    sort(sorter, sorter+n, cmp);
    rep(ii,n){
        int i = sorter[ii];
        if(dead[i]) continue;
        if(par[i] != -1){
            if(dead[par[i]]){
                cout << "First" << endl;
                return 0;
            }
            dead[par[i]] = true;
        } else{
            cout << "First" << endl;
            return 0;
        }
        dead[i] = true;
    }
    cout << "Second" << endl;
}
































Measured memory_bytes: 7424
defmodule Main do
  def main do
    [d, t, s] =
      IO.read(:line)
      |> String.trim |> String.split
    d = String.to_integer(d)
    t = String.to_integer(t)
    s = String.to_integer(s)
    if d / s <= t do
      IO.puts("Yes")
    else
      IO.puts("No")
    end
  end
end


Measured memory_bytes: 30664
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  int s,a[100100];
  std::cin >> s;
  a[1]=s;
  for(int i=2; i<100000; i++){
    if(a[i-1]%2==0) a[i]=a[i-1]/2;
    else a[i]=3*a[i-1]+1;
  }

  int ans=0;
  for(int i=1; i<100000; i++){
    for(int j=i+1; j<100000; j++){
      if(a[i]==a[j]){
        std::cout << j << '\n';
        return 0;

      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main(){
    int N,x;
    cin >> N >> x;
    int a[N];
    for (int i=0;i<N;i++) cin >> a[i];
    sort(a,a+N);
    int j=0;
    int ans = 0;
    for (int i=0;i<N;i++) {
        if(x >= a[i]) {
            ans++;
            x-=a[i];
        }
    }
    if(ans == N&&x>0) --ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e18 + 7LL;
constexpr ll MOD = 1e9 + 7;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main()
{
    int a,b;
    cin >> a >> b;
    if (2*b >= a){
        cout << 0 << endl;
    }else{
        cout << a - 2 * b << endl;
    }
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll dp[100];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int X; cin >> X;
    dp[1] = 3;
    for(int i = 2; i <= 41; i++){
        dp[i] = dp[i-1]*2+1;
    }
    cout << dp[X+1]-1 << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2]){
    cout << "Yes" << endl;
  }
  else if(S[0]==S[2] && S[1]==S[3] && S[0]!=S[1]){
    cout << "Yes" << endl;
  } 
  else if(S[0]==S[3] && S[1]==S[2] && S[0]!=S[1]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if len(s) == 2 {
		fmt.Println(s)
		return
	}

	var s2 = make([]byte, 3)
	s2[0] = s[2]
	s2[1] = s[1]
	s2[2] = s[0]
	fmt.Println(string(s2))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  string S; cin >> S;
  
  unordered_map<int,int> R, G, B;
  rep(i, N) {
    if(S[i] == 'R') R[i]++;
    else if(S[i] == 'G') G[i]++;
    else if(S[i] == 'B') B[i]++;
  }

  int ans = R.size()*G.size()*B.size();
  
  for(auto r : R) for(auto g : G) {
    int a = r.first, b = g.first;
    if(a < b) swap(a, b);
      if(B[a+(a-b)] > 0) ans--;
      if(B[b-(a-b)] > 0) ans--;
      if((a-b)%2 == 0 && B[(a+b)/2] > 0) ans--;
  }
  cout << ans << endl;

}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

vector<int> tpsort(const vector<vector<int>>& g) {
	int V = g.size();
	vector<int> indeg(V, 0);
	stack<int> S;

	for (int i = 0; i < V; ++i) {
		for (int j = 0; j < g[i].size(); ++j) {
			++indeg[g[i][j]];
		}
	}
	for (int i = 0; i < V; ++i) {
		if (indeg[i] == 0) { S.push(i); }
	}

	vector<int> ret;
	while (S.size() > 0) {
		int u = S.top(); S.pop();
		ret.push_back(u);
		for (int i = 0; i < g[u].size(); ++i) {
			--indeg[g[u][i]];
			if (indeg[g[u][i]] == 0) {
				S.push(g[u][i]);
			}
		}
	}
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1 + M; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u].emplace_back(v);
	}

	auto t = tpsort(g);
	vector<int> ans(N, 0);
	for (auto v : t) {
		for (auto u : g[v]) {
			ans[u] = v + 1;
		}
	}
	for (auto v : ans) { cout << v << "\n"; }

	return 0;
}


Measured memory_bytes: 9772
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size();
}

Measured memory_bytes: 256
d,m=1e9+7,p[10001][200]={1};i,j,k,x,I;char s[11111];main(L){for(scanf("%s%d",s,&d);s[i];i+=j,j^=1)for(x=L=j?9:s[i]-48,k=0;~x;x-=++k/d,k%=d)p[i+1][I=(j|x<L)*d+(k+x)%d]+=p[i][j*d+k],p[i+1][I]%=m;printf("%d",(*p[i]+p[i][d]-1+m)%m);}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main(){
	int N, K;
	scanf("%d%d", &N, &K);
	double ans = 0;
	
	for(int i = 1; i <= N; i++){
		int Point  = i;
		double rate = 1.0 / N;
		while(Point < K){
			Point *= 2;
			rate *= 0.5;
		}
		ans += rate;
	}
	
	printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=1e5+5;
int prime[N],sum[N];
bool is_pr[N];
int cnt;
inline int Scan()
{
    int r = 0,f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        r = (r << 3) + (r << 1) + ch - '0';
        ch = getchar();
    }
    return r * f;
}
inline void Print(int x)
{
    if(x < 0)
    {
        x = -x;
        putchar('-');
    }
    if(x > 9)Print(x/10);
    putchar(x % 10 + '0');
}
void sieve()
{
    cnt=0;
    mem(is_pr,0);
    for(int i=2; i*i<=N; i++)
    {
        if(!is_pr[i])
        {
            for(int j=i*i; j<=N; j+=i)
                is_pr[j]=1;
        }
    }
    for(int i=2; i<N; i++)
        if(!is_pr[i]) prime[cnt++]=i;
    mem(sum,0);
    for(int i=1; i<cnt; i++)
    {
        int tmp=(prime[i]+1)/2;
        int pos=lower_bound(prime,prime+i,tmp)-prime;
        if(prime[pos]==tmp) sum[prime[i]]++;
    }
    for(int i=1; i<cnt; i++) sum[prime[i]]+=sum[prime[i-1]];
}
int main()
{
    sieve();
    int q;
    q=Scan();
    rep(i,0,q)
    {
        int l,r;
        l = Scan();r = Scan();
        int pos1=lower_bound(prime,prime+cnt,l)-prime;
        int pos2=lower_bound(prime,prime+cnt,r)-prime;
        if(prime[pos2]==r) r=prime[pos2];
        else r=prime[pos2-1];
        int ans=sum[r]-sum[prime[pos1-1]];
        Print(ans);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	vector<ll>a(n); REP(i, n)scanf("%lld", &a[i]);
	map<ll, ll>app;
	ll sum = 0, ans = 0;
	REP(i, n) {
		sum += a[i];
		if (sum == 0) {
			ans += app[0] + 1;
		} else {
			ans += app[sum];
		}
		++app[sum];
	}
	cout << ans << endl;
}

Measured memory_bytes: 14336
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    while(1){
        cin >> m>>f>>r;
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f==-1){
            cout<<"F"<<endl;
        }else if(m+f >= 80){
            cout<<"A"<<endl;
        }else if(65<=m+f && m+f<80){
            cout<<"B"<<endl;
        }else if(50<=m+f && m+f<65){
            cout<<"C"<<endl;
        }else if(30<=m+f && m+f<50){
            if(r>=50){
                cout<<"C"<<endl;
            }else cout<<"D"<<endl;
        }else cout<<"F"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#define NMAX 2000
#define GMAX 10
int compare(const void *a, const void *b);
int main(void)
{
  int l, i, j, n, k, c, g, sell[GMAX+1][NMAX+1] = {0}, ssz[GMAX+1] = {0}, dp[GMAX+1][NMAX+1] = {0};
  scanf("%d %d", &n, &k);
  for (l = 1; l <= GMAX; l++) ssz[l] = 1;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &c, &g);
    sell[g][ssz[g]++] = c;
  }
  for (l = 1; l <= GMAX; l++) {
    qsort(sell[l] + 1, ssz[l] - 1, sizeof(int), compare);
    if (ssz[l] - 1 > k) ssz[l] = k + 1;
    for (i = 1; i < ssz[l]; i++) {
      sell[l][i] += sell[l][i-1] + 2 * (i - 1);
    }
    for (i = 1; i <= k; i++) {
      dp[l][i] = dp[l-1][i];
      for (j = 1; j < ssz[l]; j++) {
        if (i >= j) {
          if (dp[l][i] < dp[l-1][i-j] + sell[l][j]) {
            dp[l][i] = dp[l-1][i-j] + sell[l][j];
          }
        }
      }
    }
  }
  printf("%d\n", dp[GMAX][k]);
}
 
int compare(const void *a, const void *b)
{
  int ta = *(int*)a, tb = *(int*)b;
  return tb - ta;
}


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

int main(){
	int n,k,d,x;
	set<int>s;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		cin>>d;
		for(int j=0;j<d;j++){
			cin>>x;
			s.insert(x);
		}
	}
	cout<<n-s.size();
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
    }

    ll ans = 0;
    sort(A.begin(), A.end(), greater<ll>());

    int t = N-1;

    REP(i, N){
        int lim = 2;
        if (i == 0) lim = 1;
        REP(j, lim){
            if (t > 0){
                ans += A[i];
                t--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4820
#include <iostream>

using namespace std;

int S[100000];

bool bs(int A[], int n, int key)
{
    int l=0, r=n-1, m;
    while(l<=r) {
        m=(l+r)/2;
        if(A[m]==key) return true;
        if(A[m]<key) l=m+1;
        else r=m-1;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>S[i];
    }
    int c=0;
    int q, t;
    cin>>q;
    for(int i=0; i<q; i++) {
        cin>>t;
        if(bs(S, n, t)) c++;
    }
    cout<<c<<'\n';
    return 0;
}

Measured memory_bytes: 1584
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int n,m,l; cin >> n >> m >> l;
    int A[n][m],B[m][l];
    rep(i,n) rep(j,m) cin >> A[i][j];
    rep(i,m) rep(j,l) cin >> B[i][j]; 
    rep(i,n){
        rep(j,l){
            int pos=0;
            rep(k,m){
                pos+=A[i][k]*B[k][j];
            }
            cout << pos << (j==l-1 ? "":" ");
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3244
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;

void usacoio(string s) {
  freopen((s+".in").c_str(), "r", stdin);
  freopen((s+".out").c_str(), "w", stdout);
}

ll dp[105][100005];
int n, maxw;
int w[105];
ll v[105];
ll solve(int idx, int ww) {
  if(idx == 0) return 0;
  if(dp[idx][ww] >= 0) return dp[idx][ww];
  dp[idx][ww] = solve(idx-1, ww);
  if(w[idx-1] <= ww) dp[idx][ww] = max(dp[idx][ww], v[idx-1] + solve(idx-1, ww - w[idx-1]));
  return dp[idx][ww];
}
void solve() {
  cin >> n >> maxw;
  for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
  memset(dp, -1, sizeof(dp));
  cout << solve(n, maxw) << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

int main()
{
  long long N;
  scanf("%lld",&N);
  bool F=0;
  for(int i=1;i<=3500&&!F;i++){
    for(int j=1;j<=3500&&!F;j++){
      long long a=4*i*j-N*i-N*j,b=N*i*j;
      if(a>0&&b%a==0){
	printf("%d %d %lld\n",i,j,b/a);
	F=1;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
n=int(input())
arr=[]
arr2=[]
s=set()
for _ in range(n):
	x,y=map(int,input().split())
	if((x,y) not in s):
		arr.append(x+y)
		arr2.append(x-y)
		s.add((x,y))
arr.sort()
arr2.sort()
if(len(arr)==1):
	print(0)
else:
	ans=arr[-1]-arr[0]
	ans=max(ans,arr2[-1]-arr2[0])
	print(ans)

Measured memory_bytes: 134536
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;

int main()
{
  int x1,y1,x2,y2;
  in x1>>y1>>x2>>y2;
  int x=x2-x1;
  int y=y2-y1;
  cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    while(q--){
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if(t==0){
            d.merge(u, v);
        }else{
            if(d.same(u, v)) printf("1\n");
            else printf("0\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x;
    cin >> x;
    ll v = 100, ans = 0;
    while(v < x) {
        v = (ll)(v * 1.01);
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;

  if(a == 1) a += 13;
  if(b == 1) b += 13;

  if(a == b)
  {
    cout << "Draw" << endl;
  }
  else if(a > b)
  {
    cout << "Alice" << endl;
  }
  else
  {
    cout << "Bob" << endl;
  }
}

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 ALL(x) (x).begin(),(x).end()
 
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) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      int a,p;
      cin >> a >> p;
      cout << (a*3+p)/2 << endl;
      return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	string s;
	cin >> s;
	int count = 0;
	FOR(i,1, s.size()) {
		if (s[i] != s[i - 1]) {
			count++;
		}
	}
	cout << count<< endl;
}


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

int main()
{
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    string ans = "NG";
    for(int i=a; i<=b; i++){
        if(i%k==0){
            ans="OK";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	vector<int> b(n);
	rep(snip_i, n) cin >> b.at(snip_i);
	rep(i, n){
		if(a.at(i) <= b.at(i)) continue;
		else{
			int dif = a.at(i) - b.at(i);
			rep(j, n){
				if(a.at(j) < b.at(j)){
					int temp = b.at(j) - a.at(j);
					if(temp >= 2 * dif){
						a.at(j) += 2 * dif;
						b.at(i) += dif;
						dif = 0;
					}else{
						a.at(j) += temp/2*2;
						b.at(i) += temp/2;
						dif -= temp/2;
					}
				}
				if(dif <= 0) break;
				else if(j == n-1){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}

	// rep(i, n){
	// 	if(i != 0) cerr << " ";
	// 	cerr << a.at(i);
	// }
	// cerr << endl;
	// rep(i, n){
	// 	if(i != 0) cerr << " ";
	// 	cerr << b.at(i);
	// }
	// cerr << endl;

	if(a.at(n-1) <= b.at(n-1)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  d = N % 10;
  c = (N / 10) % 10;
  b = (N / 100) % 10;
  a = (N / 1000);

  if ( (a==b && b==c) || (b==c && c==d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){int n,x,y;std::cin>>n>>x>>y;int a[2001];for(int i=0;i<n;i++){std::cin>>a[i];}std::cout<<std::max(abs(a[n-2]-a[n-1]),abs(a[n-1]-y))<<"\n";return 0;}

Measured memory_bytes: 256