akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)
static const int TMAX = 50;
static const int PMAX = 10;

class Team{
public:
  int nsolved, p;
  int T[PMAX];
  int TR[PMAX];
  int id;
  Team(){}
  Team(int id):id(id){
    rep(i, PMAX) T[i] = TR[i] = 0;
    nsolved = p = 0;
  }

  bool operator < ( const Team &t) const{
    if ( nsolved == t.nsolved ){
      if ( p == t.p ){
	return id < t.id;
      } else return p < t.p;
    } else return nsolved > t.nsolved;
  }
};
int T, P, R;

void simulate(){
  Team TM[TMAX];
  int tid, pid, tim;
  string mes;
  rep(i, T) TM[i] = Team(i+1);
  rep(i, R){
    cin >> tid >> pid >> tim >> mes;
    tid--; pid--;
    if ( mes == "CORRECT" ){
      if ( TM[tid].T[pid] == 0 ){
	TM[tid].T[pid] = tim; 
	TM[tid].p += tim + 1200*TM[tid].TR[pid];
	TM[tid].nsolved++;
      }
    } else {
      TM[tid].TR[pid]++;
    }
  }
  sort(TM, TM+T);
  rep(i, T){
    cout << TM[i].id << " " << TM[i].nsolved << " " << TM[i].p << endl;
  }

}

main(){
  while(1){
    cin >> T >> P >> R;
    if ( T == 0 ) break;
    simulate();
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	int five = 0;
	int sev = 0;
	if(a==5)
		five++;
	else if(a==7)
		sev++;
	
	if(b==5)
		five++;
	else if(b==7)
		sev++;
	
	if(c==5)
		five++;
	else if (c==7)
		sev++;
		
	if(five== 2 && sev == 1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
		
	return 0;
	
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = list(map(int, input().split()))

B = [A[0]]
for i in range(N-1):
    B.append(A[i] + A[i+1])
B.append(A[-1])

ans = 0
for i in range(N+1):
    if B[i] > x:
        a = B[i] - x
        ans += a
        B[i] -= a
        if i < N:
            B[i+1] -= a
print(ans)

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

int main(){
    long int trip,sui,tou,total,flag;
    while(1){
        total = 0;
        flag = 0;
        cin >> trip;
        if(trip == 0){
            break;
        }
        for(int i=0;i<12;i++){
            cin >> sui >> tou;
            total += sui - tou;
            if(total >= trip && flag == 0){
                cout << i+1 << endl;
                flag = 1;
            }
        }
        if(flag == 0){
            cout << "NA" << endl;
        }
    }
}

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

int main()
{
	string N;
	cin >> N;
	
	bool flag = false;
	
	rep( i, 3 ) {
		if( N.at(i) == '7' ){
			flag = true ;
		}
	}
	
	cout << ((flag)?"Yes":"No") <<endl ;
}	

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









const int N=2010;
int n,k,k2,s[N][N],x,y,dx,dy,res;
char c,c2;


void f(int j,int inc)
{
	s[0][j]+=inc;
	s[dx+1][j]-=inc;
	s[dx+k+1][j]+=inc;
}

void f2(int j,int inc)
{
	s[dx+1][j]+=inc;
	s[dx+k+1][j]-=inc;
}




void solve()
{
	cin>>n>>k;
	k2=2*k;
	for(int i=0;i<=k2+1;i++)for(int j=0;j<=k2+1;j++)s[i][j]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y>>c;
		dx=x%k2;
		dy=y%k2;
		if(dx<k)
		{
			if(dy<k)c2='W';
			else c2='B';
		}
		else
		{
			if(dy<k)c2='B';
			else c2='W';
		}
		if(dy>=k)dy-=k;
		if(dx>=k)dx-=k;
		if(c==c2)
		{
			f(0,1);
			f(dy+1,-1);
			f(dy+k+1,1);
			f2(dy+1,1);
			f2(dy+k+1,-1);
		}
		else
		{
			f2(0,1);
			f2(dy+1,-1);
			f2(dy+k+1,1);
			f(dy+1,1);
			f(dy+k+1,-1);
		}
	}
	for(int j=0;j<k2;j++)
	{
		for(int i=1;i<k2;i++)s[i][j]+=s[i-1][j];
	}
	res=0;
	for(int i=0;i<k2;i++)
	{
		res=max(res,s[i][0]);
		for(int j=1;j<k2;j++)
		{
			s[i][j]+=s[i][j-1];
			res=max(res,s[i][j]);
		}
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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

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

  int cnt_E = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'E') cnt_E++;
  }

  int left_W = 0, right_E = cnt_E;
  int ans = 1000000;
  for (int i = 0; i < N; i++) {
    int num = left_W;
    if (S[i] == 'E') {
      num += right_E - 1;
      right_E--;
    } else {
      num += right_E;
      left_W++;
    }
    ans = min(ans, num);
  }

  cout << ans << endl;
}

Measured memory_bytes: 900
#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()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;cin >> n >> k;
    vi snuke(n);
    rep(i,k){
        int d;cin >> d;
        rep(j,d){
            int a;cin >> a;
            snuke[a-1] = 1;
        }
    }
    cout << n - accumulate(ALL(snuke),0) << endl;
    return 0;
}

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


public class Main {
	static boolean[] isPrime = new boolean[1000000];
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n;
		fill_isPrime();
		while(sc.hasNext()){
			System.out.println(theNumberOfPrime(sc.nextInt()));
		}
	}
	private static int theNumberOfPrime(int n){
		int count=0;
		for(int i=1;i<=n;i++){
			if(isPrime[i]) count++;
		}
		return count;
	}
	private static void fill_isPrime(){
		Arrays.fill(isPrime, true);
		isPrime[1]=false;
		isPrime[2]=true;
		for(int i=1;i<=999999;i++){
			if(isPrime[i]){
				for(int j=i*2;j<=999999;j=j+i){
					isPrime[j] = false;
				}
			}
		}
	}
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int H, W, D;
  cin >> H >> W >> D;
  vector<vint> A(H, vint(W));
  vector<Pi> inv(H*W+1);
  rep(i, H) rep(j, W) {
    cin >> A[i][j];
    inv[A[i][j]] = Pi(i, j);
  }
  vector<int> dp(H*W+1, 0);
  reps(i, 1, H*W+1) {
    if(i+D <= H*W) dp[i+D] += dp[i]+llabs(inv[i+D].first-inv[i].first)+llabs(inv[i+D].second-inv[i].second);
  }
  int Q;
  cin >> Q;
  rep(i, Q) {
    int l, r;
    cin >> l >> r;
    cout << dp[r]-dp[l] << endl;
  }

  return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;
  for (int i=0; i<N; i++) {
    if (S[i]!=S[K-1]) {
      S[i]='*';
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 3600
#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 repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    rep(i,N) cin >> x[i] >> y[i];
    int a[] = {0,1,2,3,4,5,6,7};
    double ans = 0;
    do{
        rep(i,N-1){
            ans += sqrt((x[a[i]]-x[a[i+1]])*(x[a[i]]-x[a[i+1]])+(y[a[i]]-y[a[i+1]])*(y[a[i]]-y[a[i+1]]));
        }
    }while(next_permutation(a,a+N));
    
    rep1(i,N) ans /= i;
    
    pr(ans);
}

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

void solve(){
  string s; int n; cin >> n >> s;
  for(long long int i = 0; i < s.length(); i++){
    int x;
    if(s[i] + n > 90) x = n - 26;
    else x = n;
    cout << (char)(s[i] + x);
  }
  cout << endl;
  return;
}

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


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

using namespace std;

int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	int n, result = 0;
	cin >> n;
	while (n--) {
	int a, b;
		cin >> a >> b;
		result += b- a + 1;
	}
	cout << result;
	return 0;
}

Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$A = explode(' ',trim(fgets(STDIN)));
$max = 0;
$min = 1000000000;

for($i = 0; $i < $N; $i++) {
  if($A["$i"] > $max) {
    $max = $A[$i];
  }
  if($A["$i"] < $min) {
    $min = $A[$i];
  }
}

$ans = $max - $min;
echo "$ans\n";

?>


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

int main() {
    int A, B;
    cin >> A >> B;

    std::vector<int> v{1, 2, 3};
    v.erase(std::remove(v.begin(), v.end(), A), v.end());
    v.erase(std::remove(v.begin(), v.end(), B), v.end());
    cout << v[0] << endl;
    return 0;
}


Measured memory_bytes: 256
use std::collections::BinaryHeap;

fn main() {
    let mut first = String::new();
    std::io::stdin().read_line(&mut first).ok();
    let mut it = first.trim().split_whitespace();
    let n:u32 = it.next().unwrap().parse().unwrap();
    let m:u32 = it.next().unwrap().parse().unwrap();
    let mut a_line = String::new();
    std::io::stdin().read_line(&mut a_line).ok();
    let mut a_heap:BinaryHeap<u64> = a_line.trim().split_whitespace().map(|a| -> u64 {a.parse().unwrap()}).collect();
    let mut b_vec:Vec<(u64,u64)> = vec!();
    for _ in 0..m {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        let mut it = line.trim().split_whitespace();
        let b:u64 = it.next().unwrap().parse().unwrap();
        let c:u64 = it.next().unwrap().parse().unwrap();
        b_vec.push((b,c));
    }
    b_vec.sort_by_key(|n| {n.1});
    b_vec.reverse();
    let mut pushed:u32 = 0;
    for b_c in b_vec.iter() {
        pushed = pushed + b_c.0 as u32;
        for _ in 0..b_c.0 {
            a_heap.push(b_c.1);
        }
        if pushed > n{
            break;
        }
    }
    let mut result:u64 = 0;
    for _ in 0..n {
        result  = result + a_heap.pop().unwrap();
    }
    println!("{}",result);
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, b; cin >> a >> b;
  cout << max(a - 2 * b, 0) << '\n';
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
from math import factorial

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, a, b = na()

def pow(a,n,p=mod):
    bi=str(format(n,"b"))
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res
def comb(a, b, p=mod):
    res = 1
    pres = 1
    for i in range(b):
        res = (res*(a-i))%p
        pres = (pres*(i+1))%p
    return res*pow(pres, p-2, p) % p
print((pow(2, n) - 1 - comb(n, a) - comb(n, b))%mod)

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if(i!=s.size()-1)
            cout << s[i];
        else{
            if(s[i]=='s')
                cout << s[i] << "es";
            else
                cout << s[i] << 's';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int isPrime(int num){
  int counter = 0;
  for(int i=1;i<=sqrt(num);i++){
    if(num%i == 0){
      counter++;
    }
    if(counter==2){
      break;
    }
  }
  if(counter==1){
    return 1;
  }else{
    return 0;
  }
}

int main(){
  int N;
  vector<int> vec;
  cin >> N;
  int counter = 0;
  int num = 2;

  while(counter<=N){
    if(isPrime(num)&&num%10==1){
      vec.push_back(num);
      counter++;
    }
    num++;
  }

  for(int i=0;i<N;i++){
    cout << vec[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  std::vector<ll> A(N), S(N);
  for(int i=0;i<N;i++) {
    std::cin >> A[i];
    S[i] = (i==0?0:S[i-1]) + A[i];
  }
  int left = 0;
  vvl ans = vv(N, 8, 0, ll);

  for(int i=0;i<N;i++){
    while(S[left] < S[i] - S[left]){
      left++;
    }
    ans[i][0] = S[left], ans[i][1] = S[i] - S[left];
    ans[i][2] = (left==0?0:S[left-1]), ans[i][3] = S[i] - (left==0?0:S[left-1]);
  }

  int right = 0;
  for(int i=0;i<N;i++){
    while(S[right] - S[i] < S[N-1] - S[right]){
      right++;
    }
    ans[i][4] = S[right] - S[i], ans[i][5] = S[N-1] - S[right];
    ans[i][6] = S[right-1] - S[i], ans[i][7] = S[N-1] - S[right-1];
    if(ans[i][6]<0) ans[i][6] = ans[i][7] = 0;
  }
  /*
  for(int i=0;i<N;i++) {
    for(int j=0;j<8;j++) std::cout << ans[i][j] << " ";
    std::cout << '\n';
  }
  */
  ll ANS = 10000000000000007;
  for(int i=0;i<N;i++){
    ll a = min({ans[i][0], ans[i][1], ans[i][4], ans[i][5]});
    ll b = min({ans[i][0], ans[i][1], ans[i][6], ans[i][7]});
    ll c = min({ans[i][2], ans[i][3], ans[i][4], ans[i][5]});
    ll d = min({ans[i][2], ans[i][3], ans[i][6], ans[i][7]});
    ll aa = max({ans[i][0], ans[i][1], ans[i][4], ans[i][5]});
    ll bb = max({ans[i][0], ans[i][1], ans[i][6], ans[i][7]});
    ll cc = max({ans[i][2], ans[i][3], ans[i][4], ans[i][5]});
    ll dd = max({ans[i][2], ans[i][3], ans[i][6], ans[i][7]});
    ANS = min({aa-a, bb-b, cc-c, dd-d, ANS});
  }
  std::cout << ANS << '\n';
  return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
 
 
 
int main()
{
	int n, m;
cin >> n >> m;
	cout << (n-1)*(m-1) << endl;
	return 0;
}


Measured memory_bytes: 256
function main(int) {
	const chars = int.toString().split('');
	const head = chars[0];
	const tail = chars[3];
	const isGood =
		(chars[1] == head && chars[2] == head) ||
		(chars[1] == tail && chars[2] == tail);
	console.log(isGood ? 'Yes' : 'No');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S;
  cin >> S;
  if (S <= "2019/04/30") {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=500100;
char str[maxn];
int l[maxn],r[maxn];
int Max(int x,int y){
	return x>y?x:y;
}
int main(){
//	freopen("A.in","r",stdin);
	scanf("%s",str+1);
	int n=strlen(str+1);
	for(int i=1;i<=n;i++){
		if(str[i]=='<')
			l[i]=l[i-1]+1;
		else
			l[i]=0;
	}
	for(int i=n;i>=1;i--){
		if(str[i]=='>')
			r[i-1]=r[i]+1;
		else
			r[i-1]=0;
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
		ans+=Max(l[i],r[i]);
	printf("%lld\n",ans);
	return 0;
}


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

#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MOD = 1e9+7;

ll a, b, cnt=0, n, mx=-1;

int main(){
  // freopen("input.txt", "r", stdin); 
  // freopen("output.txt", "w", stdout);
  cin.sync_with_stdio(0); cin.tie();
  cin.exceptions(cin.failbit);

  cin >> n;
  rep(i, 1, n){
    cin >> a >> b;
    if(a==b){
      cnt++;
      mx=max(cnt, mx);
    }
    else cnt=0;
  }
  cout << (mx>=3? "Yes":"No");
}

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


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


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            string gh = Console.ReadLine();
            if (gh == null) { break; }
            double u = double.Parse(gh);
            double y = u * u / (double)19.6;
            double kainogo = 5 + y;
            if (kainogo % 5 == 0) { Console.WriteLine(kainogo / 5); }
            else { Console.WriteLine((int)(kainogo / 5) + 1); }
        }
    }
}

Measured memory_bytes: 9280
def cutter(nums, idx):
    if len(nums) - idx <= 2:
        return len(nums)
    
    for i in xrange(idx+1, len(nums)):
        if int(nums[i]) != int(nums[i-1]):
            pos = i
            flag = int(nums[i]) > int(nums[i-1])  # is asc?
            # print flag
            break
    else:
        return len(nums)

    for i in xrange(pos, len(nums)):

        if flag:
            if int(nums[i]) < int(nums[i-1]):
                return i
        else:
            if int(nums[i]) > int(nums[i-1]):
                return i
    return len(nums)


n = int(raw_input())
idx = 0
arr = raw_input().split()
if n < 2:
    print n
else:
    count = 0
    while idx < n:
        # print arr[idx:]
        count += 1
        idx = cutter(arr, idx)

    print count

Measured memory_bytes: 41056
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int count=0;
    int curr=i;
    while(curr>0){
      curr/=10;
      count++;
    }
    if(count%2==1) ans++;
  }
  cout<<ans;
  return 0;
}


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

using namespace std;

int n,m;
int d[200001];
int t[200001];

int main() {
  cin >> n;
  for(int i = 0; i < n; i++) cin >> d[i];
  cin >> m;
  for(int i = 0; i < m; i++) cin >> t[i];
  sort(d,d+n);
  sort(t,t+m);

  bool ok = true;

  int k = 0;
  for(int i = 0; i < m; i++) {
    while(true) {
      if(t[i] == d[k]) {k++; break;}
      else if(t[i] > d[k]) k++;
      else { ok = false; break; }
    }
    if(!ok) break;
  }

  if(ok) cout << "YES" <<endl;
  else cout << "NO" <<endl;
}
  


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int N;
    cin >> N;
    vector<int> x(N);
    double m = 0;
    REP(i, N) {
        cin >> x[i];
        m += x[i];
    }
    m /= (double)N;
    vector<int> y;
    y.push_back(ceil(m-1));
    y.push_back(ceil(m));
    y.push_back(floor(m));
    y.push_back(floor(m+1));
    ll tmp = 1e10;
    REP(i, 4){
        ll sum = 0;
        REP(j, N){
            sum += (y[i] - x[j]) * (y[i] - x[j]);
        }
    tmp = min(tmp, sum);
    }

    cout << tmp << endl;


    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int a[3],k,ans,ma;
	cin>>a[0]>>a[1]>>a[2]>>k;
	sort(a,a+3);
	for(int i=1;i<=k;i++) a[2]*=2;
	ans=a[0]+a[1]+a[2];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];
int cal[10];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    bool judge = false;

    int bi = 1;

    for(int i=2;i<=n;i++){
        judge = false;
        for(int j=2;j*j<=i;j++)
            if(!(i%j))judge = true;

        if(!judge){
            bi = 1;
            sum = 0;
            for(int j=0;;j++){
                bi = bi*i;
                if(bi>n)break;
                sum+=(n/bi);
            }
            if(sum>=2)cal[0]++;
            if(sum>=4)cal[1]++;
            if(sum>=14)cal[2]++;
            if(sum>=24)cal[3]++;
            if(sum>=74)cal[4]++;
        }
    }

    int ans = 0;

    ans+=cal[4];
    if(cal[3])ans+=(cal[3]*(cal[0]-1));
    if(cal[2])ans+=(cal[2]*(cal[1]-1));
    if(cal[1]>=2)ans+=(cal[1]*(cal[1]-1)/2*(cal[0]-2));

    cout<<ans<<"\n";

    return 0;
}


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

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

/*
R..........L
各マスについて、RL の境界にたどり着いて、偶奇に応じてどちらに
つくか決まる

たとえば
RRL
なら
0番目はLにたどり着くまで2回、そこから偶数回移動するので2に終着
1番目はLまで1回、そこから偶数回 1に終着

R側は切り上げ、L側は商

*/
int main() {
    string S;
    cin >> S;
    vector<int> res(S.length(),0);
    for (int i = 0; i < S.length()-1; i++) {
        if (S[i] == 'R') {
            int cnt = 0;
            while (i < S.length()-1 && S[i] != 'L') {
                cnt++;
                i++;
            }
            res[i] += cnt / 2;
            res[i-1] += (cnt + 1) / 2;
        }
    }
    for (int i = S.length()-1; i > 0; i--) {
        if (S[i] == 'L') {
            int cnt = 0;
            while (i > 0 && S[i] != 'R') {
                cnt++;
                i--;
            }
            res[i] += cnt / 2;
            res[i+1] += (cnt + 1) / 2;
        }
    }
    for (int i = 0; i < S.length(); i++) {
        cout << res[i] << " ";
    }
    cout << endl;




}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100
#define INF (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dijkstra();


int n,N[MAX][MAX];


int main(){
  int i,j,r,k,t,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){

      N[i][j] = INF;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&t);
      N[u][v]=t;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int i,x,minv,a[MAX],color[MAX];
  for(i=0;i<n;i++){
    a[i]=INF;

    color[i]=WHITE;
  }
  a[0] = 0;
  color[0]=GRAY;
while(1){
    minv = INF;
    x = -1;
    for(i=0;i<n;i++){
      if(minv > a[i] && color[i] != BLACK){
        x=i;
        minv = a[i];
      }
    }
    if(x == -1){
      break;
    }
    color[x] = BLACK;
    int v;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && N[x][v] != INF){
        if(a[v] > a[x] + N[x][v]){
          a[v] =a[x] + N[x][v];

          color[v]=GRAY;
        }

      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n",i,(a[i] == INF ? -1 : a[i]));
  }
}




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

int n; // 変数
string s;

int main() {
// input
    cin >> n;
    cin >> s;
// solve
    ll r = 0, g = 0 , b = 0;
    rep(i, n) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'G') g++;
        else if (s[i] == 'B') b++;
    }
    ll ans = r * g * b;
    rep(i, n) {
        rep(j, n) {
            if (j <= i) continue;
            int k = 2 * j - i;
            if (k <= j or k >= n) continue;
            if (s[i] != s[j] and s[j] != s[k] and s[k] != s[i]) ans--;
        }
    }
// output
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;


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

  int n; cin >> n;
  int a[22], b[22], c[22];
  REP(i,n) cin >> a[i], --a[i];
  REP(i,n) cin >> b[i];
  REP(i,n) cin >> c[i];

  long ans = 0;
  REP(i,n) {
    ans += b[a[i]];
    if(i < n-1 && a[i+1] == a[i] + 1) 
      ans += c[a[i]];
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	int n,k;
    long min=10000000000;
    cin >> n >> k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p.at(i);
    }
    sort(p.begin(),p.end());
    for(int i=k-1;i<n;i++){
        if(min>p.at(i)-p.at(i+1-k)) min=p.at(i)-p.at(i+1-k);
    }
    cout << min;
}

Measured memory_bytes: 768
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
        int maxCoin;
        //aとbの大きさを判別する
      	if(a == b){
        	maxCoin = a + b;
        }else if(a > b){
        	maxCoin = a + (a-1);
        }else{
        	maxCoin = b + (b-1);
        }
      //出力
      System.out.println(maxCoin);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
#define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int neg = 0;
    for (int i = 0; i < N; i++) {
        int _a; cin >> _a;
        if (_a < 0) neg++;
        A[i] = _a;
    }

    int mini = -1;
    if (neg % 2 != 0) {
        int minA = 0;
        for (int i = 0; i < N; i++) {
            if (mini == -1 || minA * minA > A[i] * A[i]) {
                minA = A[i];
                mini = i;
            }
        }
    }

    int sumB = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] < 0) {
            A[i] *= -1;
        }
        if (mini == i && A[i] > 0) {
            A[i] *= -1;
        }
        sumB += A[i];
    }
    cout << sumB << endl;
    return 0;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var S = Read();
            var num = new List<int>();
            var chk = S[0];
            var cnt = 1;
            var idx = 1;
            while (idx < N)
            {
                if (chk == S[idx])
                {
                    cnt++;
                }
                else
                {
                    num.Add(cnt);
                    chk = S[idx];
                    cnt = 1;
                }
                idx++;
            }
            num.Add(cnt);

            if (num.Count() < K * 2 + 1)
            {
                Console.WriteLine(N);
                return;
            }

            var sum = new int[num.Count() + 1];
            for (int i = 0; i < num.Count(); i++)
            {
                sum[i + 1] = sum[i] + num[i];
            }

            var ans = 0;
            if (S[0] == '0')
            {
                ans = sum[K * 2];
                idx = 2;
            }
            else
            {
                idx = 1;
            }
            while (true)
            {
                if (idx + K * 2 >= sum.Count())
                {
                    var tmp = sum[sum.Count() - 1] - sum[idx - 1];
                    if (tmp > ans) ans = tmp;
                    break;
                }
                else
                {
                    var tmp = sum[idx + K * 2] - sum[idx - 1];
                    if (tmp > ans) ans = tmp;
                }
                idx += 2;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 14304
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, t;
	cin >> n >> t;
	vector<int> v(n);
	int dif = 0, mi;
	for(int i = 0; i < n; i++) {
		cin >> v[i];
		if(i == 0) mi = v[i];
		else {
			dif = max(dif, v[i] - mi);
			mi = min(v[i], mi);
		}
	}
	set<int> st;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(st.count(v[i] - dif)) ans++;
		st.insert(v[i]);
	}
	cout << ans << endl;
	return 0;	
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 3005, M = 998244353;

void add(int &w, int u) {
    w += u;
    if (w >= M) w -= M;
}

int n, S;
int a[N];
int dp[N];

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

    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    
    int ans = 0;
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = S - a[i]; j >= 1; j--) {
            add(dp[j + a[i]], dp[j]);
            if (j + a[i] == S) {
                add(ans, (long long)dp[j] * (n - i + 1) % M);
            }
        }
        add(dp[a[i]], i);
        if (a[i] == S) {
            add(ans, (long long)i * (n - i + 1) % M);
        }
    }
    
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n, a, b;
  scanf("%d", &n);

  if(n == 1){
	printf("Hello World\n");
  }else {
	scanf("%d\n%d", &a, &b);
	printf("%d\n", a + b);
  }

  return 0;
}

Measured memory_bytes: 128
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e2+5;

int a[3];

int main(){
    cin >> a[0] >> a[1] >> a[2];
    sort(a , a + 3);
    if(a[0] == a[1]){
        cout << a[2];
    } else {
        cout << a[0];
    }
}





Measured memory_bytes: 256
import copy
length, capacity = map(int, input().split(" "))
nap = []
for _ in range(length):
    v, w = map(int, input().split(" "))
    nap.append([v, w])
dp = [0 for n in range(capacity + 1)]

for i, (v, w) in enumerate(nap):
    new_dp = dp[::]
    if w <= capacity:
        new_dp[w] = max(v, dp[w])
    for j, now_v in enumerate(dp):
        if now_v and j + w <= capacity:
            new_dp[j + w] = max(dp[j + w], now_v + v)
    dp = new_dp
answer = 0
for v in dp:
    answer = max(answer, v)
print(answer)



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

int selectionSort(int A[], int N){
    int minj, count=0;
    for(int i=0; i <= N-1; i++){
        minj= i;
        for(int j=i; j <= N-1; j++){
            if (A[j] < A[minj]) minj = j;
        }
        swap(A[i], A[minj]);
        if (i != minj) count++;
    }
    return count;
}

int main(){
    int N, count;
    cin >> N;
    int A[100];
    for(int i=0; i<N; i++) cin >> A[i];
    count = selectionSort(A, N);
    for(int i=0; i<N-1; i++){
        cout << A[i] << " ";
    }
    cout << A[N-1] << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int Alice = 0, Bob = 0;
  
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  
  sort(A.begin(), A.end());
  
  for (int i = N-1; i >= 0; ){
  	Alice += A.at(i);
    if(i-1 >= 0)
  		Bob += A.at(i-1);
    i = i-2;
    }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 3628
// 解き直し.
// https://img.atcoder.jp/abc161/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define all(x) x.begin(), x.end()

// 与えられた正の整数のすべての約数を抽出.
// @param X: 約数を抽出したい正の整数.
// @return ret: すべての約数(※2以上).
vector<LL> div(LL X){
    vector<LL> ret;
    for(LL d = 2; d * d <= X; d++){
        if(X % d == 0){
            ret.pb(d);
            if(d * d != X) ret.pb(X / d);
        }
    }
    // hand_03 で WA版のため, ロジック修正.
    // ret.pb(X);
    if(X > 1) ret.pb(X);
    sort(all(ret));
    return ret;
}

int main(){
    
    // 1. 入力情報.
    LL N;
    scanf("%lld", &N);
    
    // 2. 解説通り.
    // 2-1. N - 1 の 約数 を 計算.
    vector<LL> v1 = div(N - 1);
    
    // 2-2. N の 約数 を 計算.
    vector<LL> v2 = div(N);
    
    // 2-3. 割り算を一度も行わない.
    LL ans = v1.size();
    
    // 2-4. 割り算を一度以上行う場合.
    for(auto &k : v2){
        LL n = N;
        while(n % k == 0) n /= k;
        if(n % k == 1) ans++;
    }
    
    // 3. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

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

bool f(int x){
  int keta = 0;
  while (x){
    keta++;
    x /= 10;
  }
  return keta%2 == 1;
}
int main() {
  int n, ans;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (f(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



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

        vector<ll> x(N);
        vector<ll> y(N);
        for(ll i=0;i<N;i++)cin>>x[i]>>y[i];
        vector<ll> W(N),K(N);

        for(ll i=0;i<N;i++){
            W[i]=x[i]+y[i];
            K[i]=x[i]-y[i];
        }
        sort(ALL(W));
        sort(ALL(K));
        W.front();
        cout<<max(W.back()-W.front(),K.back()-K.front())<<endl;







    }

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

int main(){
    int n;
    cin >> n;
    string s[n];
    set<string>S;
    int count = 0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        S.insert(s[i]);
    }
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 25504
def k(x):
  x=int(x)
  if x%2==0:
    if (x%3==0 or x%5==0):
      return 1
    return 0
  return 1
n=int(input());l=list(map(k,input().split()))
if sum(l)==n:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#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 m, n;
  while (cin >> m >> n  && m+n) {
    bitset<11234567> bit;
    for (int64 i = m; ; i++) {
      if (bit[i] == 0) {
        n--;
        if (n < 0) {
          cout << i << endl;
          break;
        }
        for (int64 j = 2*i; j < 11234567; j += i) {
          bit[j] = 1;
        }
      }
    }
  }
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,m=0,a;
  cin>>n>>t;
  for(int i=0;i<t;i++){
    cin>>a;
    m=max(a,m);
  }
  int nm=n-m;
  if(m-nm-1<=0){
    cout<<0<<endl;
  }else{
    cout<<m-nm-1<<endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	lint a, b, c, k; cin >> a >> b >> c >> k;
	if (k % 2)co(b - a);
	else co(a - b);
	gc();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <list>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 100000007;
using Graph = vector<vector<int>>;

vector<bool> seen;

void dfs(const Graph &G, int v){
    seen[v] = true;

    for(auto next_v : G[v]){
        if(seen[next_v]) continue;
        dfs(G, next_v);
    }

}

int main(){
    ll N,M;
    cin >> N >> M;
    Graph G(N);
    REP(i,M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int count = 0;
    seen.assign(N, false);
    REP(v,N){   
        if(seen[v]) continue;
        dfs(G,v);
        ++count;
    }
    count -= 1;
    cout << count << endl;

}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  string s;
  if ((a % 2 == 1 && b <= a / 2 + 1) || (a % 2 == 0 && b <= a / 2)) s = "YES";
  else s = "NO";

  cout << s << endl;
}


Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
$a = [];
$cnt = 0;

for ($i=0; $i<$N; $i++) {
    array_push($a, array_map('intval', explode(' ', fgets(STDIN))));
}

foreach ($a as $i) {
    if ($cnt==0) {
        if ($i[0]!==$i[1]+$i[2]){
            break;
        }
    } else {
        $sec = $i[0]-$a[$cnt-1][0];
        $point = abs(($i[1]+$i[2])-($a[$cnt-1][1]+$a[$cnt-1][2]));
        if (($sec%2!==$point%2)or($sec<$point)) {
            break;
        }
    }

    $cnt ++;
}

echo $cnt==count($a) ? 'Yes': 'No';

Measured memory_bytes: 45940
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
#define int long long
using namespace std;

struct Edge {
  int dst, id;
  Edge(const int dst = 0, const int id = 0) : dst(dst), id(id) {}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

string itos(int i) {
  ostringstream os;
  os << setfill('0') << setw(3) << i;
  return os.str();
}

int compose(int p, int q) { // 置換の合成
  string s = itos(p), t = itos(q), r = "   ";
  for (int i = 0; i < 3; i++) r[i] = t[s[i] - '0'];
  return stoi(r);
}

int prms[] = {12, 21, 102, 120, 201, 210};

signed main() {
  int n;
  cin >> n;
  vector<int> prm(n);
  for (int i = 0; i < n; i++) { // 各あみだくじを置換に変換
    int w;
    cin >> w;
    vector<int> q(w);
    for (int j = 0; j < w; j++) cin >> q[j];
    string v = "012";
    for (int j = w - 1; j >= 0; j--) swap(v[q[j]], v[q[j] + 1]);
    prm[i] = stoi(v);
  }

  Graph g(300); // 頂点を置換, 辺を置換とするグラフ
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 6; j++) {
      int u = prms[j], v = compose(prms[j], prm[i]);
      g[u].emplace_back(v, i);
    }
  }

  // ここから恒等置換から恒等置換への閉路を検出
  vector<bool> used(300, false);
  queue<pair<int, int>> q; // 頂点, 使用した置換(あみだくじ)をbitで持つ
  q.emplace(12, 0);
  bool cycle = false;
  while (q.size()) {
    int v, b;
    tie(v, b) = q.front();
    q.pop();
    if (used[v]) continue;
    used[v] = true;
    for (auto &e : g[v]) {
      if ((b >> e.id) & 1LL) continue;
      if (e.dst == 12) cycle = true;
      q.emplace(e.dst, b | (1LL << e.id));
    }
  }

  cout << (cycle ? "yes" : "no") << endl;
}



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

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

  for (int i = 0, s = S.length(); i < s; i++) {
    for (int j = i + 1; j < s; j++) {
      if(S[i] == S[j]) {
        cout << "no" << endl;
        return 0;
      }
    }
  }

  cout << "yes" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;
int main(){
    int n;  cin >> n;
    cout << 3*n*n;
    
    

    return 0;
}




Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h,w,m = inpl()
yd = []
for i in range(h):
    yd.append([i,0])
xd = []
for i in range(w):
    xd.append([i,0])
se = set()
def ind(i,j):
    return i*w + j
for _ in range(m):
    a,b = inpl()
    yd[a-1][1] += 1
    xd[b-1][1] += 1
    se.add((a-1,b-1))
yd.sort(key = lambda x:x[1], reverse = True)
xd.sort(key = lambda x:x[1], reverse = True)
ymax = yd[0][1]
yl = []
for i,x in yd:
    if x != ymax: break
    yl.append(i)
xmax = xd[0][1]
xl = []
for i,x in xd:
    if x != xmax: break
    xl.append(i)
res = ymax + xmax - 1
# print(yl,xl,res)
for i in yl:
    for j in xl:
        if not (i,j) in se:
            res += 1
            print(res)
            quit()
print(res)

Measured memory_bytes: 226884
#!/usr/bin/env python3
import sys


def solve(X: int):
    happiness = 0
    gohyaku_maisuu, modulo = divmod(X, 500)
    happiness += gohyaku_maisuu * 1000
    happiness += (modulo // 5) * 5
    return happiness


def main():
    X = int(sys.stdin.readline().strip())  # type: int
    print(solve(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N,T = map(int,input().split())

x = [[int(i) for i in input().split()] for i in range(N)]

m = x[0][0]

for i in range(N):
	if x[i][1]<T+1:
		m = min(m,x[i][0])
t=x[0][1]

for i in range(N):
	t=min(t,x[i][1])

if t<T+1:
	print(m)
else:
	print("TLE")
	
	

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main() 
{
  int n;
  cin >> n;
  if (n == 1){
    cout << "Hello World" << endl;
    return 0;
  }else {
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a=n/100000000+n%100000000/10000000+n%10000000/1000000+n%1000000/100000+n%100000/10000+n%10000/1000+n%1000/100+n%100/10+n%10;
	if(n%a==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256