akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

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

    vector<vector<int>> vec(M);
    for (int i = 0; i < M; i++) {
        int k; cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; j++) {
            cin >> vec[i][j];
            vec[i][j]--;
        }
    }

    vector<int> p(M);
    for (int i = 0; i < M; i++) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << N); i++) {
        bool ok = true;
        for (int j = 0; j < M; j++) {
            int c = 0;
            for (int id: vec[j]) {
                if ((i >> id) & 1) {
                    c++;
                }
            }
            c %= 2;
            if (c != p[j]) {
                ok = false;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char T[55],P[55],ans[55];


int main(){

	scanf("%s",T);
	scanf("%s",P);

	int len_T,len_P;

	for(len_T = 0; T[len_T] != '\0'; len_T++);
	for(len_P = 0; P[len_P] != '\0'; len_P++);

	bool FLG;

	//既に含まれているか調べる
	for(int loc = 0; loc+len_P <= len_T; loc++){

		FLG = true;

		for(int i = 0; i < len_P; i++){
			if(T[loc+i] == '?' || T[loc+i] != P[i]){
				FLG = false;
				break;
			}
		}
		if(FLG){
			for(int i = 0; i < len_T; i++){ //辞書順最小にする
				if(T[i] == '?'){
					T[i] = 'a';
				}
			}
			printf("%s\n",T);

			return 0;
		}
	}

	for(int loc = len_T-len_P; loc >= 0; loc--){ //★辞書順最小にするために、部分文字列はなるべく後にしたい

		FLG = true;
		for(int i = 0; i < len_P; i++){
			if(T[loc+i] != '?' && T[loc+i] != P[i]){
				FLG = false;
				break;
			}
		}

		if(!FLG){ //locを始点にできない場合

			if(T[loc+len_P-1] == '?'){
				T[loc+len_P-1] = 'a';
			}
			continue;
		}

		for(int i = 0; i < len_P; i++){
			T[loc+i] = P[i];
		}
		for(int i = 0 ; i < loc; i++){
			if(T[i] == '?'){
				T[i] = 'a';
			}
		}

		printf("%s\n",T);
		return 0;
	}

	printf("UNRESTORABLE\n");

	return 0;
}


Measured memory_bytes: 256
def check(A):
    for i in A:
       if i.count("x") == 3:
           return True
    for n in range(3):
        if A[0][n] == "x" and A[1][n] == "x" and  A[2][n] == "x":
            return True
    if A[0][0] == "x" and A[1][1] == "x" and A[2][2] == "x":
        return True
    if A[0][2] == "x" and A[1][1] == "x" and A[2][0] == "x":
        return True
    
    return False
    
        
        
                
     

A = []
for _ in range(3):
    A.append([int(i) for i in input().split(" ")])
N = int(input())
b = [int(input()) for _ in range(N)] 



for i in b:
    for a in A:
        if i in a:
            index = a.index(i)
            a[index] = "x"

if check(A):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# C - H and V
def main():
    H, W, K = map(int, input().split())
    C = [input().rstrip() for _ in range(H)]
    res = 0
    for bit in range(1 << (H + W)):
        cnt_black = sum(
            C[i][j] == "#" and not (bit >> i) & 1 and not (bit >> (j + H)) & 1
            for i in range(H)
            for j in range(W)
        )
        if cnt_black == K:
            res += 1
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	string s1,s2,s3;
	cin >> s1 >> s2;
	cin >> a >> b;
	cin >> s3;
	if(s1==s3) cout << a-1 << " " << b << endl;
	else if(s2==s3) cout << a << " " << b-1 << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll k, t;
  cin >> k >> t;
  ll ma = 0;
  for (int i = 0; i < t; i++) {
    ll a;
    cin >> a;

    if (a > ma) {
      ma = a;
    }
  }

  ll otrs = k - ma;

  ll ans = max(0ll, ma - otrs - 1);

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
import sys

def solve(n, d):
    d = sorted(d)
    return d[n/2] - d[n/2 - 1]


if __name__ == '__main__':

    n = sys.stdin.readline().strip()
    d = map(int, sys.stdin.readline().strip().split(" "))
    print solve(int(n), d)

Measured memory_bytes: 11280
#include<iostream>
#include<vector>
#include<set>
#include<unordered_map>
#include<algorithm>
#include<iterator>
using namespace std;

int main(){
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }
    long r = 0;
    int c = 0;
    long m = A.at(0);
    for(int i=1; i<N; i++){
        if(m > A.at(i)){
            m = A.at(i);
        }else{
            int t =  A.at(i) - m;
            if(t > r){
                r = t;
                c = 1;
            }else if(t == r){
                c++;
            }
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, k;
  cin >> n >> k;
  uin(k, n);
  vector<int> a(n);
  for (int &x : a) cin >> x;
  sort(ALL(a));
  reverse(ALL(a));
  i64 ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i >= k) ans += a[i];
  }
  kek(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int A = 1e6, BASE = 998244353;

long long power(long long x, long long y)
{
  if (!y)
    return 1;
  long long res = power(x, y >> 1);
  res = res * res % BASE;
  if (y & 1)
    res = res * x % BASE;
  return res;
}

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

  int n, x;
  cin >> n;
  vector<long long> a(A + 1, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> x;
    a[x]++;
  }

  vector<long long> sumPair(A + 1, 0);
  for (int i = 1; i <= A; i++)
  {
    long long sum = 0;
    for (int j = i; j <= A; j += i)
      if (a[j])
      {
        sumPair[i] += sum * a[j] % BASE * j + (a[j] - 1) * a[j] / 2 * j % BASE * j;
        sumPair[i] %= BASE;
        sum = (sum + a[j] * j) % BASE;
      }
  }

  for (int i = A / 2; i; i--)
    for (int j = i * 2; j <= A; j += i)
      sumPair[i] = (sumPair[i] - sumPair[j] + BASE) % BASE;

  long long ans = 0;
  for (int i = 1; i <= A; i++)
    if (sumPair[i])
      ans = (ans + sumPair[i] * power(i, BASE - 2)) % BASE;
  cout << ans << endl;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, m;
vi e[MN];
int deg[MN];
int vis[MN];

void sat(int cn, int p){
    //cout << "doing " << cn << " " << p << "\n";
    vis[cn] = true;
    for(auto nn : e[cn]) if(nn != p){
        if(vis[nn]){
            if(cn < nn){
                cout << cn << " " << nn << "\n";
                ++deg[cn];
            }
        } else{
            sat(nn, cn);
        }
    }
    if(cn == 1) return;

    //cout << "resolving " << cn << " " << p << "\n";

    if(deg[cn] % 2 == 1){
        cout << cn << " " << p << "\n";
        ++deg[cn];
    } else{
        cout << p << " " << cn << "\n";
        ++deg[p];
    }
}

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

    cin >> n >> m;
    F0R(_, m){
        int a, b;
        cin >> a >> b;
        e[a].pb(b);
        e[b].pb(a);
    }
    if(m % 2 == 1){
        cout << "-1\n";
        return 0;
    }

    sat(1, 0);

    return 0;
}


Measured memory_bytes: 15488
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

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

int main(){

ll N,K;
cin>>N>>K;
cout<<K*(ll)powl(K-1,N-1)<<endl;


return 0;
}

Measured memory_bytes: 3592
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        s: chars,
    }
    let mut cnt = s.len();
    let mut pair_flag = false;
    let mut cur = 1;
    while cur < s.len() {
        if pair_flag {
            pair_flag = false;
            cur += 1;
            continue;
        }
        if s[cur - 1] == s[cur] {
            cur += 2;
            cnt -= 1;
            pair_flag = true;
        } else {
            cur += 1;
            //cnt -= 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4476
#include<iostream>
#include<string>
using namespace std;
string s[10]={"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "};
int main(){
	string d;
	int c[5];
	bool first=true;
	while(cin>>d){
		if(!first)cout<<endl;
		first=false;
		for(int i=0;i<5;i++)c[i]=0;
		for(int i=0;i<d.size();i++)c[5-d.size()+i]=d[i]-'0';
		for(int i=0;i<8;i++){for(int j=0;j<5;j++)cout<<s[c[j]][i];cout<<endl;}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=510;
int a[maxn] , b[maxn] , c[maxn];
int main()
{
    int n;
    while (~scanf("%d", &n)){
        for (int i=1; i<n; i++)  scanf("%d%d%d", &a[i], &b[i], &c[i]);

        for (int i=1; i<n; i++){
            int temp = a[i] + b[i];
            for (int j=i+1; j<n; j++){
                if (temp < b[j]){
                    temp = b[j] + a[j];
                }
                else {
                    int t = (temp - b[j]) % c[j];
                    if (t == 0)  temp += a[j];
                    else temp += a[j] + (c[j] - t);
                }
            }
            printf("%d\n", temp);
        }
        puts("0");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 2000000

int Heap,A[N];

void maxHeapify(int i){
  int left,right,L,tmp;
  left = 2 * i;
  right = 2 * i + 1;

  if(left <= Heap && A[left] > A[i]){
    L = left;
  }
  else {
    L = i;
  }
  if(right <= Heap && A[right] > A[L]){
    L = right;
  }

  if(L != i){
    tmp = A[i];
    A[i] = A[L];
    A[L] = tmp;
    maxHeapify(L);
  }
}

int main(){
  int i;
  scanf("%d",&Heap);
  for(i=1; i<=Heap; i++){
    scanf("%d",&A[i]);
  }
  for(i=Heap/2; i>=1; i--){
    maxHeapify(i);
  }
  for(i=1; i<=Heap; i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3636
#!/usr/bin/env python3


def main():
    a,v = map(int,input().split())
    b,w = map(int,input().split())
    t = int(input())

    if w >= v:
        print("NO")
    elif abs(b-a)/(v-w) <= t:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

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

// bool evenNumberOfOnesInBinary(int number){
//     int count = 0;
//     while(number>0){
//         if(number%2!=0) count++;
//         number = number/2;
//     }
//     return count%2==0;
// }

bool evenNumberOfOnesInBinary(long long int x)
{
    long long int y = x ^ (x >> 1);
    y = y ^ (y >> 2);
    y = y ^ (y >> 4);
    y = y ^ (y >> 8);
    y = y ^ (y >> 16);
   if (y & 1)
        return false;
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    unsigned long long int N, A, B; cin>>N>>A>>B;
    
    unsigned long long int remaining = N%(A+B);
    if(remaining>A) remaining = A;
    unsigned long long int time = N/(A+B);
    time = time*A;
    cout<<time+remaining<<endl;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", max(0, a - b));
	
	Please AC;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h> 
#include<string>
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define IN insert
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define NL cout<<endl
#define ll long long int
#define ld long double
#define vl vector<ll>
#define sl set<ll>
#define ml map<ll,ll>
#define sc set<char>
#define li list<ll>
#define vp vector<pair<ll, ll> >
#define vs vector<string>
#define ss set<string>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define REPIT(it,a) for(auto it=a.begin();it!=a.end();it++)
#define DB(x) cout<<"Debug "<<x<<endl
#define N (ll)100004
#define mod (ll)1000000007
using namespace std;
ll a[N],b[N],c[N];
int main()
{

ios::sync_with_stdio(0);
cin.tie(0);
ll n;
cin>>n;
ll dp[n][3],a[n][3];
REP(i,0,n){
  REP(j,0,3)
   cin>>a[i][j];
}
dp[0][0]=a[0][0];
dp[0][1]=a[0][1];
dp[0][2]=a[0][2];
REP(i,1,n){
	REP(j,0,3){
		if(j==0)
		  dp[i][j]=max(dp[i-1][1]+a[i][j],dp[i-1][2]+a[i][j]);
		if(j==1)
		  dp[i][j]=max(dp[i-1][0]+a[i][j],dp[i-1][2]+a[i][j]);
		if(j==2)
		  dp[i][j]=max(dp[i-1][1]+a[i][j],dp[i-1][0]+a[i][j]);
	}
}
cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
#define N 10000
int PN(int);
int main(){
  int i;
  int n,hako[N];
  int count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&hako[i]);
  }
  for(i=0;i<n;i++){
    if(PN(hako[i])==1) count++;
      
  }
  printf("%d\n",count);
  return 0;
}

int PN (int a){
  int i=3;
  if(a==2) return 1;
  if(a%2==0) return 0;
  while(i<=sqrt(a)){
    if(a%i==0) return 0;
    i = i+2;
  }
  return 1;
}



Measured memory_bytes: 2084
H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]

ans = []
for i in range(H):
    if i % 2 == 0:
        start = 0
        end = W
        direction = 1
    else:
        start = W-1
        end = -1
        direction = -1
    for j in range(start, end, direction):    
        if A[i][j] % 2 == 0:
            continue
        else:
            if i % 2 == 0 and j < W-1:
                ans.append((i, j, i, j+1))
                A[i][j] -= 1
                A[i][j+1] += 1
            elif i % 2 == 0 and j == W-1 and i < H-1:
                ans.append((i, j, i+1, j))
                A[i][j] -= 1
                A[i+1][j] += 1
            elif i % 2 == 1 and j > 0:
                ans.append((i, j, i, j-1))
                A[i][j] -= 1
                A[i][j-1] += 1
            elif i % 2 == 1 and j == 0 and i < H-1:
                ans.append((i, j, i+1, j))
                A[i][j] -= 1
                A[i+1][j] += 1

# print(A)
print(len(ans))
for y,x,y2,x2 in ans:
    print(y+1,x+1,y2+1,x2+1)


Measured memory_bytes: 72156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000
using namespace std;
typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main()
{
    int k;
    cin >> k;
    int cnt = 0;
    for (int i = 1; i <= k; i += 2)
    {
        for (int j = 2; j <= k; j += 2)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

int n;
pair< pair<int, int>, int> p[1002];

bool cmp(pair< pair<int, int>, int> x, pair< pair<int, int>, int> y) {
	return x.X.X+x.X.Y < y.X.X+y.X.Y;
}

ll dp[20002];

int main () {

	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i].X.X >> p[i].X.Y >> p[i].Y;
	sort(p, p + n, cmp);
	
	ll maxi = 0;
	for (int i = 0; i < n; i++) {
		for (int j = p[i].X.Y; j >= 0; j--) {
			dp[j+p[i].X.X] = max(dp[j+p[i].X.X], dp[j]+p[i].Y);
		
			maxi = max(maxi, dp[j+p[i].X.X]);
		}
	}
	
	cout << maxi;

	return 0;
}

Measured memory_bytes: 3732
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int MAXN=int(1e4);
int n,m,p;
int A[MAXN],B[MAXN],C[MAXN];
struct node {
    int to,w;
};
vector<node>G[MAXN];
vector<int>W[MAXN];
bool f[MAXN];
int Dist[MAXN],cnt[MAXN];
bool flag[MAXN],vis[MAXN];
int SPFA(int S,int T){
    queue<int> Q;
    memset(Dist,0x3f,sizeof Dist);
    Dist[S]=0;
    Q.push(S),vis[S]=1,cnt[S]=1;
    while(!Q.empty()){
        int u=Q.front();vis[u]=0;Q.pop();
        for(int i=0;i<int(G[u].size());i++){
            int v=G[u][i].to,w=G[u][i].w;
            if(!flag[v])
                continue;
            if(Dist[v]>Dist[u]+w){
                Dist[v]=Dist[u]+w;
                if(!vis[v]){
                    Q.push(v);
                    vis[v]=1;
                    cnt[v]++;
                    if(cnt[v]>n)
                        return -1;
                }
            }
        }
    }
    return max(-Dist[T],0);
}
void Bfs() {
    queue<int>Q;
    Q.push(n);flag[n]=1;
    while(!Q.empty()) {
        int u=Q.front();
        Q.pop();
        for(int i=0;i<W[u].size();i++) {
            int v=W[u][i];
            if(flag[v]) continue;
            flag[v]=1;
            Q.push(v);
        }
    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&p);
    for(int i=1;i<=m;i++) {
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        G[u].push_back((node){v,p-w});
        W[v].push_back(u);
    }
    Bfs();
    printf("%d",SPFA(1,n));
}


Measured memory_bytes: 1024
function Main(input) {
		input = input.split(" ");
		const num1 = parseInt(input[0], 10);
		const num2 = parseInt(input[1], 10);
		console.log( ( 0 < num1 && num1 < 10) &&  ( 0 < num2 && num2 < 10)  ?  num1 * num2 : -1);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void){
    
    int i, N, rank;
    cin >> N;

    vector<tuple<string, int, int>> tp(N);

    for (i=0;i<N; i++){
        cin >> get<0>(tp.at(i)) >> get<1>(tp.at(i));
    }

    for (i=0;i<N; i++){
        get<1>(tp.at(i)) = 100 - get<1>(tp.at(i));  // ソートできるように点数の大小関係を逆転させる
        get<2>(tp.at(i)) = i+1;                     // ページ番号出力用
    }

    sort(tp.begin(), tp.end());                     // ソート

    for (i=0; i<N; i++){
        cout << get<2>(tp.at(i)) << endl;
    }
    
    return 0;
}

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

using namespace std;

int main()
{
	int n, a, b, c, d;
	string r;
	cin>>n;
	a = b = c = d = 0;
	while (n --)
	{
		cin>>r;
		if (r == "AC") a ++;
		else if (r == "WA") b ++;
		else if (r == "TLE") c ++;
		else d ++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl; 
	return 0;
}

Measured memory_bytes: 3620
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 2e5+5, MOD = 998244353;
int t,n,m,k,x,y;

v32 adj[LIM];
v32 nodes_with_col[LIM]; 
int cnt[LIM],col[LIM];
int tim;
int ans[LIM];
int extim[LIM];

void dfs(int node,int par){
	cnt[node]=1;
	extim[node]=++tim;
	for(auto v : adj[node]){
		if(v!=par){
			dfs(v,node);
			int w=cnt[v];
			while(nodes_with_col[col[node]].size() && extim[nodes_with_col[col[node]].back()]>=extim[node]){
				w-=cnt[nodes_with_col[col[node]].back()];
				nodes_with_col[col[node]].pop_back();
			}
			cnt[node]+=cnt[v];
			ans[col[node]]+=(w*(w+1))/2;
		}
	}
	nodes_with_col[col[node]].pb(node);
}

int32_t main()
{
	IOS;
	cin>>n;
	forsn(i,1,n+1) cin>>col[i];
	forn(i,n-1){
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(1,0);
	forsn(i,1,n+1){
		int w=n;
		while(nodes_with_col[i].size()){
			w-=cnt[nodes_with_col[i].back()];
			nodes_with_col[i].pop_back();
		}
		ans[i]+=(w*(w+1))/2;
		cout<<(n*(n+1))/2 - ans[i]<<ln;
	}
}


Measured memory_bytes: 45112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define lwb lower_bound
#define upb upper_bound
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int K;
    cin>>K;
    string s="";
    rep(i, K){
        s+="ACL";
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3600
a,b,c = map(int,input().split())
k = int(input())
while(a >= b):
  if k == 0:
    break
  else:
    b *= 2
    k -= 1
while(b >= c and k >= 1):
  if k == 0:
    break
  else:
    c *= 2
    k -= 1
if a < b < c:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9128
import sys, math
from functools import lru_cache
from collections import deque

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A, B = i2(N)
    
    cnt = 0
    for i in range(N-1, -1, -1):
        cnt += math.ceil((A[i]+cnt)/B[i])*B[i]-(A[i]+cnt)

    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36140
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int n,m,a,b;
vi v[10];
bool flag[10]={};
int dfs(int now,int depth){	
	if(flag[now])return 0;	
	if(depth==n)return 1;	
	flag[now]=true;			
	int ans=0;	
	for(auto vv:v[now])ans+=dfs(vv,depth+1);
	flag[now]=false;
	return ans;
}

int main(){
	cin>>n>>m;
	rep(i,0,m){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	print(dfs(1,1));
}

Measured memory_bytes: 256
def main():
    b = input()
    array = ['A','C','G','T']
    if b == array[0]:
        print(array[3])
    if b == array[1]:
        print(array[2])
    if b == array[2]:
        print(array[1])
    if b == array[3]:
        print(array[0])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

template <class M, class N>
common_type_t<M, N> gcd(M a, N b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

template <class M, class N>
common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

int main(int argc, const char *argv[]) {
  long long a, b;
  cin >> a >> b;
  cout << lcm(a, b) << '\n';
  return 0;
}

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

using namespace std;
#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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    ll N;
    cin >> N;
    vector<ll> P(N);
    vector<pair<ll, ll>> Q(N);
    rep(i, N)
    {
        cin >> P[i];
        Q[i] = make_pair(P[i], i);
    }

    sort(Q.rbegin(), Q.rend());

    set<ll> st;

    ll ans = 0;

    rep(j, N)
    {
        ll p = Q[j].first;
        ll i = Q[j].second;

        st.insert(i);
        if (j == 0) {
            continue;
        }

        auto i_it = st.lower_bound(i);
        auto b1_it = next(i_it, 1);
        auto b2_it = next(i_it, 2);
        auto a1_it = prev(i_it, 1);
        auto a2_it = prev(i_it, 2);

        ll b1, b2, a1, a2;
        if (b1_it == st.end()) {
            b1 = N;
        } else {
            b1 = *b1_it;
        }

        if (b2_it == st.end() || b1 == N) {
            b2 = N;
        } else {
            b2 = *b2_it;
        }

        if (i_it == st.begin()) {
            a1 = -1;
        } else {
            a1 = *a1_it;
        }

        if (a1_it == st.begin() || a1 == -1) {
            a2 = -1;
        } else {
            a2 = *a2_it;
        }

        ans += ((a1 - a2) * (b1 - i) + (i - a1) * (b2 - b1)) * p;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10308
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; ++i) // マクロ
using namespace std; // stdの省略
using pii = pair<int, int>; // pairの略記
using ll = long long; // long longの略記


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

   int A;
   vector<int> a(n);
   rep(i,n-1) {
       cin >> A;
       A--;
       a[A]++;
   }

   rep(i,n) cout << a[i] << endl;
   
   return 0;
}

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

#include <string>
template <typename List>
void split(const std::string& s, const std::string& delim, List& result)
{
    result.clear();
    using string = std::string;
    string::size_type pos = 0;
    while(pos != string::npos )
    {
        string::size_type p = s.find(delim, pos);
        if(p == string::npos)
        {
            result.push_back(s.substr(pos));
            break;
        }
        else {
            result.push_back(s.substr(pos, p - pos));
        }
        pos = p + delim.size();
    }
}

int main(){
    string s;
    std::cin >> s;
    s += 'a';
    s = 'a' + s;
    int64_t ans = 0;
    std::vector<string> result;
    split(s, "><", result);
    int64_t res_size = result.size();
    //cout<< res_size <<endl;
    for (int i = 0; i < res_size; i++) {
        string frac = result[i];
        int64_t ln = std::count(frac.cbegin(), frac.cend(), '>') + 1;
        int64_t rn = std::count(frac.cbegin(), frac.cend(), '<') + 1;
        if (i == 0) {
            rn -= 1;
        }
        if (i == res_size - 1) {
            ln -= 1;
        }
        int64_t maxval = max({ln,rn});
        int64_t minval = min({ln,rn});
        int64_t s_sum = 0;
        for (int j = 0; j < maxval+1; j++) {
            //cout<< j <<endl;
            s_sum += j;
        }
        for (int j = 0; j < minval; j++) {
            //cout<< j <<endl;
            s_sum += j;
        }
        ans += s_sum;
        //cout<< frac <<endl;
    }
    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 6164
class UnionFindVerSize():
    def __init__(self, N):
        self._parent = [n for n in range(0, N)]
        self._size = [1] * N

    def find_root(self, x):
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x])
        return self._parent[x]

    def unite(self, x, y):
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans


N = int(input())
mati = []
Y = [-1 for i in range(N)]
for i in range(N):
    x,y = map(int,input().split())
    mati.append((x-1,y-1,i))
    Y[y-1] = i
mati.sort()


uf = UnionFindVerSize(N)

left = [(-1,-1)] + [(Y[i],i) for i in range(N-1)]
right = [(Y[i+1],i+1) for i in range(N-1)] + [(-1,N)]

Max = -1

for x,y,i in mati[::-1]:
    res,idx = left[y]
    if res!=-1:
        uf.unite(i,res)
        right[idx] = right[y]
    res,yyy = right[y]
    if res!=-1:
        left[yyy] = left[y]
        if yyy<Max:
            uf.unite(res,i)

    Max = max(Max,y)

for i in range(N):
    print(uf.get_size(i))

Measured memory_bytes: 151900
/**
 * Title: C - Many Requirements
 * Url: https://atcoder.jp/contests/abc165/tasks/abc165_c
 * 
 * a1~aN までの配列を全パターン試す
 * O(M^N)
 * クエリのON/OFFを全通り試す
 * o(2^M)
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int N, Q, M;
const int MAX_N = 10;
const int MAX_M = 10;
const int MAX_Q = 50;
int a[MAX_Q+1], b[MAX_Q+1], c[MAX_Q+1], d[MAX_Q+1];
int A[MAX_N+1];
int ans = 0;

void debug() {
    for(auto ai:A) {
        cout << ai << " ";
    }
    cout << endl;
    return;
}

void dfs(int depth, int x) {
    if(depth==N+1) {
        // debug();
        int tmp_ans = 0;
        for(int i=0; i<Q; i++) {
            if(A[b[i]]-A[a[i]]==c[i]) {
                tmp_ans += d[i];
            }
        }
        ans = max(ans, tmp_ans);
        return;
    } else {
        for(int i=x; i<=M; i++) {
            A[depth] = i;
            dfs(depth+1, i);
        }
    }
}

int main() {
    cin >> N >> M >> Q;
    for(int i=0; i<Q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
    dfs(1, 1);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n, K;
    cin >> n >> K;

    vector<int> hoge(n, false);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;

        for (int i = 0; i < d; i++) {
            int a;
            cin >> a;
            --a;
            hoge[a] = true;
        }
    }

    int ans = n;
    for (int i = 0; i < n; i++) {
        ans -= hoge[i];
    }
    cout << ans << newl;
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n;
    cin >> n;
    vector<long long> a(n,0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long b = a[0];
    long long stools = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b) {
            stools += b - a[i];
        }
        if (a[i] > b) {
            b = a[i];
        }
    }
    cout << stools;
}


Measured memory_bytes: 4748
a = int(input())
s = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
l = s.split(',')
print(l[a-1])

Measured memory_bytes: 2940
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#include <iostream>
 
int main(void)
{
    std::string S, T;
    std::cin >> S >> T;

    int64_t count = 0;
    for (int64_t i = 0; i < S.size(); ++i) {
        if (S.at(i) == T.at(i)) count++;
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=305,mod=1e9+7;
int n,m,a[N<<1],b[N<<1],f[2][N][N];
void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}
int main(){
	scanf("%d",&n);
	rep (i,1,2*n) scanf("%d",&a[i]);
	for (int i=1;i<=2*n;i+=2){
		if (~a[i]&&~a[i+1]){b[a[i]]=b[a[i+1]]=-1; continue;}
		if (a[i]==-1&&a[i+1]==-1){++m; continue;}
		if (~a[i]) b[a[i]]=1;
		if (~a[i+1]) b[a[i+1]]=1;
	}
	int t,tmp; f[t=0][0][0]=1;
	rep (i,1,2*n) if (~b[i]){
		t^=1; memset(f[t],0,sizeof(f[t]));
		rep (j,0,n) rep (k,0,n)
			if (tmp=f[t^1][j][k])
				if (b[i]){
					if (j) upd(f[t][j-1][k],(ll)tmp*j%mod);
					upd(f[t][j][k+1],tmp);
				} else{
					if (k) upd(f[t][j][k-1],tmp);
					upd(f[t][j+1][k],tmp);
					upd(f[t][j][k+1],tmp);
				}
	}
	int ans=f[t][0][0];
	rep (i,1,m) ans=(ll)ans*i%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.14159265358979323846264338)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD (1000000007ll)
using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    long long d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3648
cnt = gets.to_i
ss = []
cnt.times do |i|
	ss = gets.to_s.split(" ").map(&:to_i)
	if(ss[0]*ss[0]+ss[1]*ss[1]-ss[2]*ss[2]==0 or ss[0]*ss[0]-ss[1]*ss[1]+ss[2]*ss[2]==0 or -ss[0]*ss[0]+ss[1]*ss[1]+ss[2]*ss[2]==0) then
		puts "YES"
	else
		puts "NO"
	end
end

Measured memory_bytes: 8764
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


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

    int n; cin >> n;
    std::vector<int> a(n); rep(i,n) cin >> a[i];

    std::unordered_set<int> s; rep(i,n) s.emplace(a[i]);

    if(s.size() == a.size()) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}

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

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

  int a = n / (2 * d + 1);
  int b = n % (2 * d + 1);

  if (b == 0) {
    cout << a << endl;
  }
  else {
    cout << a + 1 << endl;
  }
}


Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}


int main(int argc, char *argv[]) {
  ll N, K;
  cin >> N >> K;
  if (2 * K > N + 1) {
    cout << -1 << endl;
  } else if (N % 2 == 1) {
    vector<int> cs(N);
    ll S = (N + 1) / 2;
    REP(i, S) {
      cout << K + 2 * N - 1 - i << " " << K + N - 1 - (N - S) - i << " " << K + 3 * N - 1 - 2 * i << endl;
    }
    REP(i, N - S) {
      cout << K + N - 1 - i << " " << K + 2 * N - 1 - S - i << " " << K + 3 * N - 2 - 2 * i << endl;
    }
  } else {
    ll S = N / 2;
    REP(i, S) {
      cout << K + 2 * N - 1 - i << " "
           << K + N - 1 - (N - S - 1) - i
           << " " << K + 3 * N - 1 - 2 * i << endl;
    }
    REP(i, S - 1) {
      cout << K + N - 1 - i << " " << K + 2 * N - 1 - S - i << " " << K + 3 * N - 2 - 2 * i << endl;
    }
    cout << K << " " << K + N << " " << K + 2 * N << endl;
  }
}


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

using namespace std;


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

  vector<int> E(N), W(N);
  S[0] == 'E' ? E[0]++ : W[0]++;
  for (int i = 1; i < N; ++i) {
    E[i] = E[i - 1] + (S[i] == 'E' ? 1: 0);
    W[i] = W[i - 1] + (S[i] == 'W' ? 1: 0);    
  }

  int ans = INT_MAX;
  for (int i = 0; i < N; ++i) {
    ans = min(ans, W[i - 1] + (E[N-1] - E[i]));
  }

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



Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const int MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

ll n;
multiset<pair<ll,ll> > s;

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(0); 
	cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	rep(i,0,n) {
		int a, b;
		cin >> a >> b;
		s.insert(mp(b, a));
	}
	
	ll time = 0;
	ll limit = 0;
	for(auto it = s.begin(); it != s.end(); ++it) {
		time += it->S;
		limit = max(limit, it->F);
		if(time > limit) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 12800
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF_L = 1e17+7;
const long long INF_I = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s,t;
	cin >> s >> t;
		
	for(int i=s.size()-t.size();i>=0;i--){
		for(int j=0;j<t.size();j++){
			if(s[i+j]!='?' && s[i+j]!=t[j]){
				break;
			}else if(s[i+j]==t[j] || s[i+j]=='?'){
				bool ok=true;
				for(int k=0;k<t.size();k++){
					if(s[i+k]=='?' || s[i+k]==t[k]){
						continue;
					}else if(s[i+k]!=t[k]){
						ok=false;
					   break;
					}
				}
				if(ok){
					for(int k=0;k<t.size();k++){
						s[i+k]=t[k];
					}
					for(int i=0;i<s.size();i++){
						if(s[i]=='?'){
							s[i]='a';
						}
					}
					cout << s << endl;
					return 0;
				}
			}
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
string S,T;
  cin>>S>>T;
  int A,B;
  cin>>A>>B;
  string U;
  cin>>U;
  if(S==U){cout<<A-1<<" "<<B<<endl;}
  else{if(T==U){cout<<A<<" "<<B-1<<endl;}
      else{cout<<A<<" "<<B<<endl;}}
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define ld long double
#define endl "\n"
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

lli dp[110][100010];
const lli INF = 1e18;

int main()
{
    //fastIO();
    lli n, W; cin>>n>>W;
    vector< pair<lli,lli> > nums(n);
    for(auto &x: nums) cin>>x.first>>x.second;

    forn(i,0,105) forn(j,0,100005) dp[i][j] = INF;

    forn(i,0,n+1) dp[i][0] = 0;
    for(int i = 0; i<n; i++)
    {
        pair<lli,lli> bolsa = nums[i];
        for(int v = 0; v<=100005; v++)
        {
            dp[i+1][v] = min(dp[i][v], dp[i+1][v]);
            dp[i+1][v+bolsa.second] = min(dp[i][v] + bolsa.first, dp[i+1][v+bolsa.second]);   
        }
    }

    // El mejor de todos los dp[n][i]
    lli ans = 0;

    for(int i = 0; i<=100001; i++)
    {
        if(dp[n][i] <= W)
        {
            ans = i;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 85644