akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
int main(){
	string s;
	cin>>s;
	int year=0;
	int mon=0;
	int day=0;
	for(int i=0;i<4;i++) year=year*10+(s[i]-'0');
	for(int i=5;i<=6;i++) mon=mon*10+(s[i]-'0');	
	for(int i=8;i<=9;i++) day=day*10+(s[i]-'0');
	if(year>2019){
		puts("TBD");return 0;
	}
	if(year==2019){
		if(mon>4){
			puts("TBD");return 0;
		}
		if(mon==4){
			if(day>30){
				puts("TBD");return 0;
			}
		}
	}
	puts("Heisei");
	return 0;
}




Measured memory_bytes: 256
n, m = map(int, input().split())
H = list(map(int, input().split()))

L = [-1]*n
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    L[a] = max(L[a], H[b])
    L[b] = max(L[b], H[a])

ans = 0
for i in range(n):
    if H[i] > L[i]:
        ans += 1
print(ans)


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    int64 N, D;
    cin >> N >> D;
    cout << (N+2*D)/(2*D+1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  long n, k;
  scanf("%ld %ld", &n, &k);
  long ten[k];
  long hasZero = -1;
  for (long i = 0; i < k; i++){
    scanf("%ld", &ten[i]);
    if(ten[i] == 0){
      hasZero = i;
    }
  }

  long pos = 0;
  for (long i = k; i < n; i++){
    long new_ten = 0;
    scanf("%ld", &new_ten);
    if(hasZero == pos){
      hasZero = -1;
    }
    if(hasZero == -1 && ten[pos] < new_ten){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
    if(new_ten == 0){
      hasZero = pos;
    }

    ten[pos] = new_ten;
    pos = (pos+1) % k;
  }
  return 0;
}

Measured memory_bytes: 5204
use std::cmp::{max, min};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        r: usize,
        g: usize,
        b: usize,
    }
    if(100*r + 10*g + b) % 4 == 0{ 
        println!("YES"); }else{
            println!("NO");
        }
}


Measured memory_bytes: 4352
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();

    if(n%2==0){
      System.out.println(n/2);
    }
    else{
      System.out.println(n/2+1);
    }



    //System.out.println();

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

int main(){
    int N, D;
    cin >> N >> D;
    int X[N][D];
    rep(i, N){
        rep(j, D){
            cin >> X[i][j]; 
        }
    }

    int cnt=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int d = 0;
            rep(k, D){
                d += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            
            for(int l = 1;l<=(int)sqrt(d);l++){
                if(d == l*l){
                    cnt++;
                }
            }
            // if(d - (int)d==0){
            //     cnt++;
            // }
        }
    }
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 256
import sys


fin = sys.stdin.readline
N = int(fin())
A_list = tuple(int(elem) for elem in fin().split())
num_valid_intervals = 0
# [l, r) is the considered interval
r = 0
cur_sum = 0
cur_xor = 0
for l in range(N):
    item_left = A_list[l]
    while r < N and cur_sum + A_list[r] == cur_xor ^ A_list[r]:
        cur_sum += A_list[r]
        cur_xor ^= A_list[r]
        r += 1
    num_valid_intervals += r - l
    cur_sum -= item_left
    cur_xor ^= item_left
print(num_valid_intervals)


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  V a(n);
  rep(i,n)cin>>a[i];
  int max=a[0];
  int cnt=0;
  rep(i,n){
      if(a[i]>=max)cnt++,max=a[i];
  }
  out(cnt);
  

  
  
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<pii, ll> ppiil;
typedef pair<pii, int> ppiii;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define btoe(obj) (obj).begin(), (obj).end()
#define pb push_back
#define str to_string
#define mkp make_pair
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

template<typename T>
void print(T out) {
    cout << out << '\n';
}

template<typename T1, typename T2>
void print(pair<T1, T2> out) {
    cout << out.first << ' ' << out.second << '\n';
}

template<typename T>
void print(vector<T> A) {
    rep(i, 0, A.size()) {
        cout << A[i];
        cout << (i == A.size()-1 ? '\n' : ' ');
    }
}

template<typename T>
void print(set<T> S) {
    vector<T> A(btoe(S));
    print(A);
}

ll sum(vector<ll> A) {
    ll res = 0;
    for (ll a: A) res += a;
    return res;
}

ll max(vector<ll> A) {
    ll res = -INF;
    for (ll a: A) chmax(res, a);
    return res;
}

ll min(vector<ll> A) {
    ll res = INF;
    for (ll a: A) chmin(res, a);
    return res;
}

ll sum(ll A[], int len) {
    ll res = 0;
    rep(i, 0, len) res += A[i];
    return res;
}

ll max(ll A[], int len) {
    ll res = -INF;
    rep(i, 0, len) chmax(res, A[i]);
    return res;
}

ll min(ll A[], int len) {
    ll res = INF;
    rep(i, 0, len) chmin(res, A[i]);
    return res;
}

ll toint(string s) {
    ll res = 0;
    for (char c : s) {
        res *= 10;
        res += (c - '0');
    }
    return res;
}

int toint(char c) {
    return c - '0';
}

ll grid1[87][87], grid2[87][87], grid[87][87];
bool dp[87][87][13007];
const ll MAXV = 80 * 160;
int H, W;

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

    cin >> H >> W;
    rep(i, 0, H) rep(j, 0, W) cin >> grid1[i][j];
    rep(i, 0, H) rep(j, 0, W) cin >> grid2[i][j];
    rep(i, 0, H) {
        rep(j, 0, W) {
            grid[i+1][j+1] = abs(grid1[i][j]-grid2[i][j]);
        }
    }

    dp[1][1][grid[1][1]] = 1;
    rep(i, 1, H+1) {
        rep(j, 1, W+1) {
            int v = grid[i][j];
            rep(k, 0, MAXV+1) {
                dp[i][j][k] |= dp[i-1][j][abs(k-v)];
                if (k+v <= MAXV) {
                    dp[i][j][k] |= dp[i-1][j][k+v];
                }
                dp[i][j][k] |= dp[i][j-1][abs(k-v)];
                if (k+v <= MAXV) {
                    dp[i][j][k] |= dp[i][j-1][k+v];
                }
            }
        }
    }
    ll ans = INF;
    rep(k, 0, MAXV+1) {
        if (dp[H][W][k]) {
            chmin(ans, k);
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 91392
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int W = sc.nextInt();

        long[] dp = new long[W + 1];
        Arrays.fill(dp, -1);

        dp[0] = 0;
        int maxW = 0;
        for (int i = 0; i < N; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            for (int j = Math.min(maxW, W - w); j != -1; j--) {
                if (dp[j] == -1) continue;

                dp[j + w] = Math.max(dp[j + w], dp[j] + v);
                maxW = Math.max(maxW, j + w);
            }
        }

        System.out.println(Arrays.stream(dp).max().getAsLong());
    }
}


Measured memory_bytes: 27220
import java.util.*;

public class Main{
    public static void main(String args[])throws Exception{
        Scanner stdin = new Scanner(System.in);

        String S = stdin.next();

        if(S.equals("SUN")){
            System.out.print("7");
        }
        else if(S.equals("MON")){
            System.out.print("6");
        }
        else if(S.equals("TUE")){
            System.out.print("5");
        }
        else if(S.equals("WED")){
            System.out.print("4");
        }
        else if(S.equals("THU")){
            System.out.print("3");
        }
        else if(S.equals("FRI")){
            System.out.print("2");
        }
        else if(S.equals("SAT")){
            System.out.print("1");
        }
    }
}

Measured memory_bytes: 21972
N = int(input())
P = list(map(int, input().split()))
R = list(range(N))
L = list(range(N))
I = [-1] * (N+1)
for i, p in enumerate(P):
    I[p] = i

ans = 0
for n, idx in enumerate(I[1:], 1):
    l = idx-1
    while l>=0 and l!=L[l]:
        l = L[l]
    r = idx+1
    while r<N and r!=R[r]:
        r = R[r]
    L[idx] = l
    R[idx] = r

    if l != -1:
        l2 = l-1
        while l2>=0 and l2!=L[l2]:
            l2 = L[l2]
        ans += n * (l-l2) * (r-idx)
    if r != N:
        r2 = r+1
        while r2<N and r2!=R[r2]:
            r2 = R[r2]
        ans += n * (idx-l) * (r2-r)
print(ans)


Measured memory_bytes: 20168
#include<iostream>
#include<stack>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;

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

const int maxn = 101, maxm = 5500,INF = 11100;

int cost[maxn][maxn];
int mincost[maxn];
bool used[maxn];
int n,m,a,b;

int main()
{
    while(cin>> n >> m &&(n&&m))
    {
        memset(cost,INF,sizeof(cost));
        memset(used,false,sizeof(used));
        memset(mincost,INF,sizeof(mincost));

        REP(m)
        {
            cin >> a >> b ;
            cin >>cost[a][b];
            cost[b][a] = cost[a][b];

        }
        mincost[0] = 0;
        int ans = 0;

        while(true)
        {
            int minv = -1;
            REP(n)if(!used[i] &&(minv == -1 ||mincost[i] < mincost[minv] )) minv = i;
            //cout << "v" << minv << endl;
            if(minv == -1) break;
            used[minv] = true;
            ans += mincost[minv];
            //cout<<minv<<":" << mincost[minv] << endl;
            
            REP(n) mincost[i] = min(mincost[i], cost[minv][i]);
        }
        
        cout << ans << endl;

    }

    return 0;
}

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

  
int ctoi(char c) {
	if (c == '0') {
		return 0;
	}
	else {
      return 1;
    }
}

int main() {
  string s;
  cin >> s;
  int s1, s2, s3;
  s1 = ctoi(s[0]);
  s2 = ctoi(s[1]);
  s3 = ctoi(s[2]);
  cout << s1 + s2 + s3 << endl;
  

}



Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    if (sys.env.getOrElse("TEST", "")=="1"){
 
    }else{
      val input=io.Source.stdin.getLines().mkString("\n")
      println(solve(input).toString.trim());
    }
  }
 
 
  def solve(input:String):Int ={
    val bigs = input.split("\n")(0).split(" ").map(_ .toInt)
    val mins = input.split("\n")(1).split(" ").map(_ .toInt)
    ( bigs(0) - mins(0) ) * (bigs(1) - mins(1))
  }
}

Measured memory_bytes: 27336
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<int> p(m);
	std::vector<std::vector<int>> vec(m);
	for(int i = 0; i < m; i++) {
		int k; scanf("%d", &k);
		
		while(k--) {
			int a; scanf("%d", &a);
			
			vec[i].push_back(a - 1);
		}
	}
	for(int i = 0; i < m; i++) scanf("%d", &p[i]);
	
	int ans = 0;
	for(int i = 0; i < (1 << n); i++) {
		bool f = true;
		for(int j = 0; j < m; j++) {
			int count = 0;
			for(auto v: vec[j]) if(i >> v & 1) count++;
			if(count % 2 != p[j]) {
				f = false;
				break;
			}
		}
		if(f) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

#define ll long long


int main(){
  int n;cin >> n;
  vector<int> v(n);
  for(auto&&e:v)cin >> e;
  int cnt = 0;
  for(int i = 1; i < n - 1; ++i){
    if(v[i-1] < v[i] && v[i] < v[i+1])cnt++;
    if(v[i-1] > v[i] && v[i] > v[i+1])cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int N;
    cin >> N;
    set<int> s;
    rep(i, N){
        int d;
        cin >> d;
        if(s.count(d) == 0) s.insert(d);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 3600
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,M;
    cin >> N >> M;
    vector<P> res(M);
    REP(i,M) {
        int a,b;
        cin >> a >> b;
        res[i].first = b;
        res[i].second = a;
    }
    sort(res.begin(),res.end());
    int ans = 0;
    int pre = -1;
    REP(i,M) {
        if(res[i].second >= pre) {
            ans++;
            pre = res[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}



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

void code()
{
    string s;
    cin>>s;
    ll k=0;
    ll ans=0;
    for(ll i=0;i<3;i++)
    {
        if(s[i]=='R')k++;
        else k=0;

        ans=max(ans,k);
    }
    cout<<ans<<endl;
}

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

    ll t=1;
    // cin>>t;
    while(t--)
    {
        code();
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> value(N);
  vector<int> cost(N);
  for (int i = 0; i < N; i++) {
    cin >> value.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> cost.at(i);
  }
  int values = 0;
  int costs = 0;
  for (int i = 0; i < N; i++) {
    if (cost.at(i) < value.at(i)) {
      costs += cost.at(i);
      values += value.at(i);
    }
  }
  cout << values - costs << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
food_list=[]
for i in range(N):
    data = list(map(int,input().split()))
    food_list = food_list + data[1:]
result =0
for j in range(M):
    if food_list.count(j+1) == N:
        result += 1
print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=110*2;
bool f[10001000],fl[N][N],fla[N];
int n,p[1000100],cnt,a[N],cot,from[N],nj[N],no[N];
bool match(int x)
{
    if(fla[x]) return false;
    fla[x]=true;
    for(int i=1;i<=no[0];++i)
        if(fl[x][i]&&(from[i]==0||match(from[i])))
        {
            from[i]=x;
            return true;
        }
    return false;
}
void init()
{
    for(int i=2;i<=10000500;++i)
    {
        if(!f[i]) p[++cnt]=i;
            for(int j=1;j<=cnt&&p[j]*i<=10000050;++j)
            {
                f[p[j]*i]=true;
                if(i%p[j]==0) break;
            }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    init();
    f[1]=true;
    f[2]=false;
    cin>>n;
    int t=-10,t1;
    for(int i=1;i<=n;++i)
    {
        cin>>t1;
        if(t1-t!=1) 
        {
            a[cot++]=t+1;
            a[cot++]=t1;
        }
        t=t1;
    }
    a[cot]=t1+1;
    for(int i=1;i<=cot;++i)
    {
        if(a[i]%2)
            nj[++nj[0]]=a[i];
        else
            no[++no[0]]=a[i];
    }
    for(int i=1;i<=nj[0];++i)
        for(int j=1;j<=no[0];++j)
            fl[i][j]=!f[abs(nj[i]-no[j])];
    int ans=0;
    for(int i=1;i<=nj[0];++i)
    {
        memset(fla,false,sizeof(fla));
        if(match(i)) ans++;
    }
    cout<< ans+(nj[0]-ans)/2*2+(no[0]-ans)/2*2+(nj[0]-ans)%2*3 <<endl;
    return 0;
}

Measured memory_bytes: 13952
#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

L = reduce((lambda x, y: x // gcd(x, y) * y), A)

res = 0

MOD = 10**9+7

for a in A:
  res += L//a

print(res%MOD)


Measured memory_bytes: 6100
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>

const int MAXN = 100000;
const int MAXA = 15;
const int INF = 0x3f3f3f3f;

int N;
int A[MAXN + 5];
int Cnt[MAXA + 5];

int Dp[(1 << (MAXA + 1)) + 5];

int Dfs(int S) {
	if (Dp[S] != INF)
		return Dp[S];
	for (int i = 1; i <= MAXA; i++)
		if ((S >> i) & 1)
			for (int j = i + 1; j <= MAXA; j++)
				if (((S >> j) & 1))
					Dp[S] = std::min(Dp[S], Dfs(S ^ (1 << i) ^ (1 << j) ^ (1 << (i ^ j))) + 1 + ((S >> (i ^ j)) & 1));
	return Dp[S];
}

int main() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		int u, v, w; scanf("%d%d%d", &u, &v, &w);
		A[u + 1] ^= w, A[v + 1] ^= w;
	}
	for (int i = 1; i <= N; i++)
		Cnt[A[i]]++;
	int Ans = 0, S = 0;
	for (int i = 1; i <= MAXA; i++) {
		Ans += Cnt[i] / 2;
		Cnt[i] %= 2;
		if (Cnt[i])
			S |= (1 << i);
	}
	memset(Dp, 0x3f, sizeof Dp);
	Dp[0] = 0;
	printf("%d", Dfs(S) + Ans);
	return 0;
}


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

using namespace std;
using ll = long long;

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

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

  vector<int> ans(n + 1);

  for (ll x = 1; x * x <= n; ++x) {
    for (ll y = 1; y * y <= n; ++y) {
      for (ll z = 1; z * z <= n; ++z) {
        ll w = x * x + y * y + z * z + x * y + y * z + z * x;
        if (w > n) continue;
        ++ans[w];
      }
    }
  }

  for (int i = 1; i <= n; ++i) cout << ans[i] << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int a,b,c,d,k; cin >> a >> b >> c >> d >> k;

    int res = 0;
    while(a != c) {
        res += 60;
        a++;
    }

    while(b > d) {
        res--; b--;
    }

    while(b < d) {
        res++; b++;
    }

    cout << max(0,res-k) << "\n";

}


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

LL n, m, ans;

void f(LL a, LL b) {
    // if(!b) return ;
    // cout << a << ' ' << b << " add :" << 2LL * (a / b) * b << '\n';
    if(a % b == 0) {
        ans += 2LL * (a / b) * b - b;
        return ;
    }
    else ans += 2LL * (a / b) * b;
    f(b, a % b);
}
int main() {
    scanf("%lld%lld", &n, &m);
    ans = n;
    f(max(m, n - m), min(m, n - m));
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string s;cin>>s;
  ll n=s.size();
  ll count=0;

  rep(i,n-1){
    if(s[i]!=s[i+1])count++;
  }
  out(count);



  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<queue>
using namespace std;

const int maxn=1000010;
int next[10010];
char P[maxn],T[maxn];
/*
* next[]的含义：x[i-next[i]...i-1]=x[0...next[i]-1]
* next[i]为满足x[i-z...i-1]=x[0...z-1]的最大z值（就是x的自身匹配）
*/
void kmp_pre(char x[])
{
    int i=0,j,m=strlen(x);
    j=next[0]=-1;
    while(i<m)
    {
        while(-1!=j && x[i]!=x[j])j=next[j];
        next[++i]=++j;
    }
}
/*
* kmpNext[]的意思：next'[i]=next[next[...[next[i]]]] (直到next'[i]<0或者
x[next'[i]]!=x[i])
* 这样的预处理可以快一些
*/
void preKMP(char x[],int m,int kmpNext[])
{
    int i,j;
    j=kmpNext[0]=-1;
    i=0;
    while(i<m)
    {
        while(-1!=j && x[i]!=x[j])j=kmpNext[j];
        if(x[++i]==x[++j])
            kmpNext[i]=kmpNext[j];
        else kmpNext[i]=j;
    }
}
/*
* 返回x在y中出现的次数，可以重叠
*/

int KMP_Count(char x[],char y[])
{//x是模式串，y是主串
    int i,j,n,m;
    int ans=0;
    m=strlen(x);
    n=strlen(y);
    //preKMP(x,m,next);
    kmp_pre(x);
    i=j=0;
    while(i<n)
    {
        while(-1!=j && y[i]!=x[j])j=next[j];
        i++;j++;
        if(j>=m)
        {
            cout<<i-j<<endl;
            ans++;
            j=next[j];
        }
    }
    return ans;
}

int main()
{
    memset(next,0,sizeof next);
    scanf("%s\n%s",T,P);
    KMP_Count(P,T);
    return 0;
}



Measured memory_bytes: 4284
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}
        static void myerr(Object t){System.err.println(t);}
        static String getStr(){return sc.next();}
        static int getInt(){return sc.nextInt();}
        static Long getLong(){return sc.nextLong();}
        static boolean isNext(){return sc.hasNext();}
        public static void main(String[] args){
  long N = getLong();
          long A = getLong();
          long B = getLong();
  
  
  long output = 0;
  if((A - B) % 2 == 0){
     myout((B-A)/2);
     }else{
     if(A-1 < N - B){
        output = A;
       B = B - A;
       A = 1;
       output += (B-A)/2;
        }else{
       output = N-B+1;
       A = A + (N-B+1);
          B = N;
       output += (B-A)/2;
        }
       myout(output);
     }
        }
        //便利メソッド追加枠ここから

        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e6;

ll a[MAXN];

int main()
{
	faster();
	ll a, b;
	cin >> a >> b;
	if(a > 0)
		cout << "Positive\n";
	else if(a <= 0 && b >= 0)
	{
		cout << "Zero\n";
	}
	else
	{
		if((b - a + 1) % 2)
			cout << "Negative\n";
		else
			cout << "Positive\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a, b, c, n, i[1000], j[1000], k[1000], r[1000], e;
	int v[1000] = { 0 };
	while (1) {
		cin >> a >> b >> c;
		if (a == 0 && b == 0 && c == 0) return 0;
		cin >> n;
		for (e = 1; e <= a + b + c; e++) {
			v[e] = 2;
		}
		for (e = 0; e < n; e++) {
			cin >> i[e] >> j[e] >> k[e] >> r[e];
			if (r[e] == 1) {
				v[i[e]] = 1;
				v[j[e]] = 1;
				v[k[e]] = 1;
			}
		}
		for (e = 0; e < n; e++) {
			if (r[e] == 0) {
				if (v[i[e]] == 1 && v[j[e]] == 1) {
					v[k[e]] = 0;
				}
				else if (v[i[e]] == 1 && v[k[e]] == 1) {
					v[j[e]] = 0;
				}
				else if (v[j[e]] == 1 && v[k[e]] == 1) {
					v[i[e]] = 0;
				}
			}
		}
		for (e = 1; e <= a + b + c; e++) {
			cout << v[e] << endl;
		}
	}
	return 0;
}

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

int main()
{
	typedef set<string> set_t;
	set_t A;
	string S,T;
	int n;
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> S >> T;
		if (S == "insert")
		{
			A.insert(T);
		}
		else
		{
			if (A.count(T))
			{
				cout << "yes" << endl;
			}
			else
			{
				cout << "no" << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 32628
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

#define mod 998244353
 
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int, int> mp;
    
    rep(i,n){
        mp[a[i]]++;
    }
    
    int ans = 0;
    for(auto i : mp){
        if(i.first <= i.second){
            ans += i.second - i.first;
        }
        else{
            ans += i.second;
        }
    }
    cout << ans << endl;

}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vz;
typedef vector<vz> vvz;
typedef pair<ll, ll> pll;
#define sz(x) ll((x).size())
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(ll i=(a); i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=1e9+7;
const ll N=1e6+10;

ll gcd(ll a, ll b)
{
	ll m=min(a, b), M=max(a, b);
	if(m==0) return M;
	return gcd(m, M%m);
}

vector<ll> spf(N+1, 1);

void sieve(){
	for(ll i=2; i<N+1; i+=2) spf[i]=2;
	for(ll i=3; i<N+1; i+=2){
		spf[i]=i;
	}
	for(ll i=3; i*i<N+1; i+=2){
		if(spf[i]!=i) continue;
		for(ll j=i*i; j<N+1; j+=i){
			if(spf[j]==j) spf[j]=i;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\input1.txt", "r", stdin);
	freopen("C:\\Users\\ASISH\\Desktop\\coding\\output1.txt", "w", stdout);
#endif

	sieve();

	ll n;
	cin>>n;
	vll a(n), F(N);
	fo(i, n) cin>>a[i];
	int flag=0;
	fo(i, n){
		if(a[i]!=1 && F[a[i]]){
			flag=1;
			break;
		}
		ll x=a[i];
		vll f;
		while(x!=1){
			f.pb(spf[x]);
			if(spf[x]!=1 && F[spf[x]]){
				flag=1;
				break;
			}
			x = x / spf[x];
		}
		if(flag) break;
		fo(j, sz(f)){
			if(f[j]!=1) F[f[j]]=1;
		}
	}
	if(flag==0){
		on("pairwise coprime");
		return 0;
	}
	vll gcdn(n);
	gcdn[0]=a[0];
	fo(i, n-1){
		gcdn[i+1] = gcd(gcdn[i], a[i+1]);
	}
	if(gcdn[n-1]==1){
		on("setwise coprime");
		return 0;
	}
	on("not coprime");

	cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 34576
<?php
// D
fscanf(STDIN, '%d', $n);
$prime_fac = primeFactorization($n);
$ans = 0;
foreach ($prime_fac as $c) {
    $cnt = $t = 0;
    for ($i = 1; $i <= $c; $i++) {
        $t += $i;
        if ($t <= $c) $cnt++;
        else break;
    }
    $ans += $cnt;
}
echo $ans;

/**
 * 素数列挙（エラトステネスのふるい）
 * $maxまでの整数のうち素数のみを格納した配列を返す
 */
function primesArr($max)
{
    $is_prime = isPrimeArr($max);
    $res = [];
    for ($i = 1; $i <= $max; $i++) {
        if ($is_prime[$i]) $res[] = $i;
    }
    return $res;
}

/**
 * 素数判定（エラトステネスのふるい）
 * $maxまでの整数が素数かどうかboolを格納した配列を返す
 */
function isPrimeArr($max)
{
    $arr = array_fill(0, $max + 1, true);
    $arr[0]  = $arr[1] = false;
    $rmax = (int) floor(sqrt($max));
    for ($i = 2; $i <= $rmax; $i++) {
        for ($j = 2 * $i; $j <= $max; $j += $i) {
            $arr[$j] = false;
        }
    }
    return $arr;
}

// 素因数分解（エラトステネスのふるい）
// インデックスに素数、値に数を格納した配列を返す
// （1は素数ではないので含まない）
function primeFactorization($n)
{
    $res = [];
    if ($n === 1) return $res;

    $primes = primesArr((int) sqrt($n) + 1);

    foreach ($primes as $prime) {
        while ($n % $prime === 0) {
            if (isset($res[$prime])) {
                $res[$prime]++;
            } else {
                $res[$prime] = 1;
            }
            $n /= $prime;
        }
    }

    if ($n > 1) {
        if (isset($res[$n])) {
            $res[$n]++;
        } else {
            $res[$n] = 1;
        }
    }

    return $res;
}

// 素数列挙（試し割り）
function primes($max)
{
    $arr = [];
    for ($i = 2; $i <= $max; $i++) {
        if (isPrime($i)) $arr[] = $i;
    }
    return $arr;
}

// 素数判定（試し割り）
function isPrime($n)
{
    if ($n === 1) return false;
    $rmax = (int) floor(sqrt($n));
    for ($i = 2; $i <= $rmax; $i++) {
        if ($n % $i === 0) return false;
    }
    return true;
}

// 約数列挙
function divisors($max)
{
    $arr = [];
    $rmax = (int) floor(sqrt($max));
    for ($i = 1; $i <= $rmax; $i++) {
        if ($max % $i === 0) {
            $arr[] = $i;
            $arr[] = $max / $i;
        }
    }
    sort($arr);
    return array_unique($arr);
}

Measured memory_bytes: 52340
a = list(input().split())
b = [0]
top = 0
for i in a:
  if i == '+':
    tmp = b[top] + b[top-1]
    del b[top]
    b[top-1] = tmp
    top -= 1
  elif i == '-':
    tmp = b[top-1] - b[top]
    del b[top]
    b[top-1] = tmp
    top -= 1
  elif i == '*':
    tmp = b[top] * b[top-1]
    del b[top]
    b[top-1] = tmp
    top -= 1
  else:
    b.append(int(i))
    top += 1
print(b[1])


Measured memory_bytes: 5600
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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;}

int h,w;
int a[510][510];

struct four{
	int f;
	int s;
	int t;
	int y;
};


int main(){
	cin>>h>>w;
	int n=0;
	vector<four> ans;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(a[i][j]%2==1){
				//cout<<i<<" "<<j<<" "<<i<<" "<<j+1<<endl;
				a[i][j+1]++;
				n++;
				four f1={i,j,i,j+1};
				ans.push_back(f1);
			}
		}
	}
	
	for(int i=0;i<h-1;i++){
		if(a[i][w-1]%2==1){
			//cout<<i<<" "<<w-1<<" "<<i+1<<" "<<w-1<<endl;
			a[i+1][w-1]++;
			four f1={i,w-1,i+1,w-1};
			ans.push_back(f1);
			n++;
		}
	}
	cout<<n<<endl;
	for(int i=0;i<ans.size();i++){
		cout<<ans[i].f+1<<" "<<ans[i].s+1<<" "<<ans[i].t+1<<" "<<ans[i].y+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
using namespace boost::multiprecision;

int main(){
    cpp_dec_float_100 a, b, c;
    cin >> a >> b >> c;
    cout << (sqrt(a) + sqrt(b) < sqrt(c) ? "Yes": "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#pragma warning(disable:4996)
#pragma GCC diagnostic ignored "-Wunused-result"

int main(int argc, char** argv)
{
	char	in[4096];
	char	*tmp;
	int		N, K, count;

	fgets(in, sizeof(in), stdin);
	if( in[strlen(in)-1] == '\n' ) in[strlen(in)-1] = '\0';

	tmp = strtok( in, " " );
	N = atoi( tmp );

	tmp = strtok( NULL, " " );
	K = atoi( tmp );

	count = (N - 1)/(K - 1);
	if ( (N - 1)%(K - 1) )
	{
		count++;
	}

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


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

int main() {
  int N;
  cin>>N;
  vector<int>D(N);
  for(int i=0;i<N;i++){
    cin>>D.at(i);
  }
  sort(D.begin(),D.end());
  int n=N/2;
  int ans=D.at(n)-D.at(n-1);
  cout <<ans<<endl;
}





Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
#include <stdio.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

ll solve(string N,int K){
    if(N.size()<K) return 0;
    if(K==1){
        return (N.size()-1)*9 + atoi(N.substr(0,1).c_str());
    }else if(K==2){
        int hoge = atoi(N.substr(0,1).c_str());
        ll ans = ((N.size()-1)*(N.size()-2))/2 * 81 + (hoge-1)*(N.size()-1)*9;
        Rep(i,N.size()){
            if(N[i] != '0'){
                ans += solve(N.substr(i,N.size()-i),1);
                break;
            }
        }
        return ans;
    }else{
        int hoge = atoi(N.substr(0,1).c_str());
        ll ans = ((N.size()-1)*(N.size()-2)*(N.size()-3))/6 *729 + (hoge-1)*((N.size()-1)*(N.size()-2))/2 * 81;
        Rep(i,N.size()){
            if(N[i] != '0'){
                ans += solve(N.substr(i,N.size()-i),2);
                break;
            }
        }
        return ans;
    }
}

int main(){
    string N;
    int K;
    cin>>N;
    cin>>K;
    cout<<solve(N,K);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  
  string s;
  cin >> s;
  long long ans = 0;
  long long cnt = 0;
  for(long long i=0; i<(long long)s.size(); i++){
    if(s[i] == 'W'){
      ans += i - cnt;
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main() {
    string s;
    cin >> s;
    int p_cnt = 0;
    for (char c : s) {
        if (c == 'p') {
            p_cnt++;
        }
    }
    cout << (s.size() / 2) - p_cnt << endl;
}


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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> f;
  for (int i=0; i<h; i++) {
    string l; cin >> l;
    f.push_back(l);
  }

  int ans = 0;
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (f[i][j]=='#') continue;

      vector<vector<int>> vd(h, vector<int>(w, -1));
      queue<pair<int, int>> q;
      q.push(make_pair(j, i));
      vd[i][j] = 0;
      while(!q.empty()) {
        int nx, ny;
        pair<int, int> np = q.front(); q.pop();
        nx = np.first;
        ny = np.second;
        for (int k=0; k<4; k++) {
          int tx = nx + dx[k];
          int ty = ny + dy[k];
          if (tx<0||w<=tx||ty<0||h<=ty) continue;
          if (vd[ty][tx]>=0||f[ty][tx]=='#') continue;
          q.push(make_pair(tx, ty));
          vd[ty][tx] = vd[ny][nx]+1;
          ans = max(ans, vd[ty][tx]);
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())

result = ""

words = [input() for i in range(N)]

if not len(words) == len(set(words)):
    result = "No"
    print(result)
    sys.exit()

for i in range(N-1):
    before = words[i]
    after = words[i + 1]

    if before[-1] == after[0]:
        continue

    else:
        result = "No"
        print(result)
        sys.exit()

result = "Yes"
print(result)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

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

  vector<int> A(n);
  vector<int> D(n);
  int md = 0;
  int head = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    A[i] = a;
  }

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      D[i] = k - A[n-1] + A[i];
      md = D[i];
    } else {
      D[i] = A[i] - A[i - 1];
      if (D[i] > md) {
        md = D[i];
        head = i;
      }
    }
  }

  cout << (k - md) << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
  int n,i;
  char s[110];
  scanf("%d%s",&n,s);
  if(n%2==1){
    printf("No\n");
  }
  else{
    for(i=0;i<n/2;i++)
      if(s[i]!=s[n/ 2+i]){
        printf("No\n");
        return 0;
      }
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, k, gcdv, maxv = 0, minv = 1e9 + 7;
  cin >> n >> k;
  rep(i, 0, n) {
    int a;
    cin >> a;
    chmax(maxv, a);
    chmin(minv, a);
    if (i == 0)
      gcdv = a;
    else
      gcdv = __gcd(gcdv, a);
  }

  if (k % gcdv == 0 && k >= minv && k <= maxv)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
}


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

typedef long long llong;

void solve() {
	int N; cin >> N;
	vector<llong> vx(N), vy(N), vh(N);
	int si = -1;
	rep(i, N) {
		scanf("%lld%lld%lld", &vx[i], &vy[i], &vh[i]);
		if (vh[i] > 0) si = i;
	}

	llong resx = -1, resy = -1, resh = -1;
	rep(x, 101) {
		rep(y, 101) {
			llong h = vh[si] + abs(x - vx[si]) + abs(y - vy[si]);
			bool ok = true;
			rep(i, N) {
				if (vh[i] > 0 && h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
				if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
					ok = false;
			}
			if (ok) resx = x, resy = y, resh = h;
		}
	}
	cout << resx << " " << resy << " " << resh << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

void bfs(int x, vector<bool> &check, vector<vector<int>> &gra){
    if (check.at(x)){
        return;
    }
    check.at(x) = true;
    for (int i = 0; i < gra.at(x).size(); i++){
        if (!check.at(gra.at(x).at(i))){
            bfs(gra.at(x).at(i), check, gra);
        }
    }
} 

int main() {
    int N, M, ans = 0;
    cin >> N >> M;
    vector<bool> check(N, false);
    vector<int> H(N);
    for (int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    vector<vector<int>> gra(N, vector<int>());
    for (int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        gra.at(b - 1).emplace_back(a - 1);
        gra.at(a - 1).emplace_back(b - 1);
    }
    for (int i = 0; i < N; i++){
        if (!check.at(i)){
            bool t = false;
            for (int j = 0; j < gra.at(i).size(); j++){
                if (H.at(i) > H.at(gra.at(i).at(j))){
                   check.at(gra.at(i).at(j)) = true; 
                }
                else {
                    t = true;
                }
                
            }
            if (!t){
                ans++;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 8772
#include <iostream>

int main(){
    
    int a,b,c;
    int coins = 0;
    int days = 1;
    std::cin >> a >> b >> c;
    
    while(1){
        coins += a;
        if(days % 7 == 0){
            coins += b;
        }
        
        if(coins >= c)break;
        days++;
    }
    
    std::cout << days << "\n";
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<set>
#include<queue>

using namespace std;

// typedef struct star {
//   int x;
//   int y;
// } star;
// priority_queue<pair<int, int>> pq;
set<pair<int, int>> red;
set<pair<int, int>> blue;
int N, ans=0;

bool ok(int x1, int y1, int x2, int y2){
  if((x1 < x2) && (y1 < y2)) return true;
  return false;
}

void solve(){
  pair<int, int> p;
  for(auto b : blue){
    priority_queue<pair<int, int>> pq;
    for(auto r: red){
      if(ok(r.first, r.second, b.first, b.second)){
        pq.push(make_pair(r.second, r.first));
      }
    }
    if(!pq.empty()){
      p = pq.top();
      red.erase(make_pair(p.second, p.first));
      ans++;
    }
  }
}

int main(){
  int i, x, y;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> x >> y;
    red.insert(make_pair(x, y));
  }
  for(i=0;i<N;i++){
    cin >> x >> y;
    blue.insert(make_pair(x, y));
  }
  solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//       BAAP IZ HERE           //
#include<bits/stdc++.h>
using namespace std;
#define gcd __gcd
#define lli long long int
#define jmd ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main()
{
    jmd;
    string s,t;
    cin>>s>>t;
    lli ans=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

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

    vector<vector<int>> Ns(10, vector<int>(10));

    for (int i = 1; i <= N; ++i) {
        int tail = i % 10;
        int head = i;
        while (head / 10 != 0) {
            head /= 10;
        }
        Ns[head][tail]++;
    }

    ll ans = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int k = 1; k <= 9; ++k) {
            ans += Ns[i][k] * Ns[k][i];
        }
    }

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

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

int main()
{
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	int sum = 0,s = 0;
	int a[10005];
	int n;
	for(int i=0;i<N;i++)
	{
		a[i]=i+1;
	}
	for(int i=0;i<N;i++)
	{
		sum=0;
		n=a[i];
		while(n)
		{
			sum+=n%10;
			n/=10;
		}
		if(sum>=A&&sum<=B)
			s=s+a[i];
	}
	printf("%d\n",s);
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a = 0;
    int b = 0;
    int c = 0;
    bool x = false;
    cin >> a >> b >> c;

    for (int i = 1; i <= b; ++i) {
        if (i * a % b == c)
        {
            cout << "YES";
            x = true;
            break;
        }
    }

    if (x == false){
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256