akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    vector<int> freq(m);
    rep(i,0,n)
    {
        int k;
        cin >> k;
        rep(j,0,k)
        {
            int x;
            cin >> x;
            --x;
            freq[x]++;
        }
    }
    int ans = 0;
    rep(i,0,m)
        ans += freq[i] == n;
    cout << ans;
    return  0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  unsigned long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string key = "MARCH";
map<char, ll> mob;
ll ans;

void fun(int pos, int cnt, ll now) {
    if (cnt == 3) {
        ans += now;
        return;
    }
    if (pos == key.size()) {
        if (cnt == 3) ans += now;
        return;
    }
    fun(pos + 1, cnt, now);
    fun(pos + 1, cnt + 1, now * mob[key[pos]]);
}

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mob[s[0]]++;
    }
    fun(0, 0, 1);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
#include <cstdint>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
#define mod 1000000007
typedef long long ll;

unsigned gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}


ll comb(int n, int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int compare_char(const void* left, const void* right) {
	char *left_char = (char *)left;
	char *right_char = (char *)right;

	return strcmp(left_char, right_char);
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	ll i, j, k, l, m, n, len, a, b, c;
	ll B, C, D, N, M, K,num_R,num_G,num_B;
	ll sum = 0, sum_B = 0, sum_C = 0, max, min, count=0, W;
	ll **dp;
	char S[200000];
	int ans;

	
	cin >> N >> M;

	vector<int> A(N);

	for (i = 0; i < N; i++){
		cin >> A[i];
		sum += A[i];
	}

	for (i = 0; i < N; i++){
		if (A[i] * 4 * M >= sum){
			count++;
		}

	}
	if (count >= M)
	cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;


}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    rep(i,0,5){
        int x; cin>>x;
        if(x==0){
            cout<<i+1<<endl;
            return 0;
        }
    }

    
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

unsigned GetDigit(unsigned num)
{
  return log10(num);
}

int main() {
  int N;
  cin >> N;
  int  cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (GetDigit(i) % 2 == 0) cnt++;
  }
  
  cout << cnt << endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double


int32_t main()
{
	IOS
	int n;cin>>n;
	vector<float>A(n+5);
	for(int i=1;i<=n;i++)cin>>A[i];
	vector<float>dp(n+5);
	//dp[i] probability of making i heads
	
	//base case using one coin
	dp[0]=1-A[1];
	dp[1]=A[1];
	
	for(int i=2;i<=n;i++)
	{
		vector<float>dp2(n+5);
		for(int j=0;j<=n;j++)
		{
			dp2[j]+=dp[j]*(1-A[i]);
			dp2[j+1]+=dp[j]*A[i];
		}
		dp=dp2;
	}
	
	float ans=0;
	for(int i=0;i<=n;i++)
	{
		if( i > n-i )ans+=dp[i];
	}
	cout << fixed << setprecision(20) << ans <<endl;
	
	
				
		
}
			
	
	
	
	
	

	

	

	
		


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int bingo[4][4];
	FOR(i, 1, 3) {
		FOR(j, 1, 3) {
			cin >> bingo[i][j];
		}
	}
	int n;
	cin >> n;
	FOR(k, 1, n) {
		int b;
		cin >> b;
		FOR(i, 1, 3) {
			FOR(j, 1, 3) {
				if (bingo[i][j] == b) {
					bingo[i][j] = -1;
				}
			}
		}
	}

	bool flag=false;
	FOR(i, 1, 3) {
		if (bingo[i][1] == -1 && bingo[i][2] == -1 && bingo[i][3] == -1) {
			flag = true;
		}
	}
	FOR(j, 1, 3) {
		if (bingo[1][j] == -1 && bingo[2][j] == -1 && bingo[3][j] == -1) {
			flag = true;
		}
	}
	if (bingo[1][1] == -1 && bingo[2][2] == -1 && bingo[3][3] == -1) {
		flag = true;
	}
	if (bingo[1][3] == -1 && bingo[2][2] == -1 && bingo[3][1] == -1) {
		flag = true;
	}
	if (flag) {
		ps(Yes);
	}
	else {
		ps(No)
	}
	return(0);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n, m, i, j;
	cin >> n >> m;
	int A[100][100], b[100], c[100] = {0};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> A[i][j];
		}
	}
	for (j = 0; j < m; j++) {
		cin >> b[j];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			c[i] = c[i] + A[i][j] * b[j];
		}
	}
	for (i = 0; i < n; i++)
		cout << c[i] << endl;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli a, b, c;
int main() {
  cin >> a >> b >> c;
  cout << min(b/a, c) << '\n';
  return 0;
}


Measured memory_bytes: 256
import numpy as np

N=int(input())
A=np.array(list(map(int, input().split())))
S=sum(A)-A[0]
X=A[0]
ans=abs(S-X)
for i in range(1,N-1):
  X+=A[i]
  S-=A[i]
  ans=min(ans,abs(S-X))
print(ans)

Measured memory_bytes: 49972
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        String a = nextString();
        String b = nextString();

        String aa = "";
        String bb = "";
        
        for (int i = 0; i < Integer.parseInt(b); i++) {
            aa += a;
        }
        for (int i = 0; i < Integer.parseInt(a); i++) {
            bb += b;
        }

        String ans = Integer.parseInt(a) < Integer.parseInt(b) ? aa : bb;
        System.out.println(ans);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }

    public static double nextDouble() throws Exception {
        return Double.parseDouble(nextString());
    }
}

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

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        int ipt;
        cin >> ipt;
        a[i] = ipt - (i + 1);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    if (n % 2 == 1)
    {
        ans = a[n / 2];
    }
    else
    {
        ans = (a[(n / 2) - 1] + a[n / 2]) / 2;
    }
    ll total = 0;
    rep(i, n)
    {
        total += abs(a[i] - ans);
    }
    cout << total << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int X;
    cin >> X;
    if (X == 7){
        cout << "YES" << endl;
    } else if (X == 5){
        cout << "YES" << endl;
    } else if (X == 3){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int N;
  cin >> N;
  vector<long> A(N);
  vector<long> B(N);
  rep(i, 0, N) {
    cin >> A[i] >> B[i];
  }

  long n = 0;
  for (int i = N - 1; i > -1; --i) {
    if ((A[i] + n) % B[i] == 0) continue;
    n += B[i] - (A[i] + n) % B[i];
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 1792
import numpy as np

H, W = map(int, input().split())

maze01 = np.array([[int(x=='.') for x in input()] for _ in range(H)]) 

u = np.zeros((H, W), dtype=np.int32)
d = np.zeros((H, W), dtype=np.int32)
r = np.zeros((H, W), dtype=np.int32)
l= np.zeros((H, W), dtype=np.int32)


u[0] = maze01[0]
d[H - 1] = maze01[H - 1]
for hh in range(1,H):
    u[hh] = u[hh-1] + maze01[hh]
    u[hh] *= maze01[hh]
    d[H - hh - 1] = d[H - hh] + maze01[H - hh - 1]
    d[H - hh - 1] *= maze01[H - hh - 1]

l[:, 0] = maze01[:, 0]
r[:, W - 1] = maze01[:, W - 1]
for ww in range(1, W):
    l[:, ww] = l[:, ww -1] + maze01[:, ww]
    l[:, ww] *= maze01[:, ww]
    r[:, W - ww -1] = r[:, W - ww] + maze01[:, W - ww - 1]
    r[:, W - ww -1] *= maze01[:, W - ww - 1]

cnt = r + l + u + d - 3

print(max([max(cnt[i]) for i in range(H)]))


Measured memory_bytes: 153512
n = int(input())

maxNum = 0
maxcount = 0
tugi = 0
ls = [0]*n
for i in range(n):
    o = int(input())
    maxNum = max(maxNum,o)
    ls[i] = o
for i in range(n):
    if ls[i] == maxNum:
        maxcount+=1
    else:
        tugi = max(tugi,ls[i])
if maxcount > 1:
    for i in range(n):
        print(maxNum)
else:
    for i in range(n):
        if ls[i] == maxNum:
            print(tugi)
        else:
            print(maxNum)


Measured memory_bytes: 58556
from sys import stdin
N, M = (int(i) for i in input().split())
AB = [[int(i) for i in input().split()] for i in range(N)]

AB = sorted(AB)
#total = 0
money = 0
for i in range(N):
    m = min(AB[i][1], M)
    money += AB[i][0]*m
    M = M - m
    if M == 0:
        break

print(money)



Measured memory_bytes: 22384
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    map<string, int> mp;
    int N, M;
    cin >> N;
    vector<string>S(N,"");
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        mp[S[i]]++;
    }
    cin >> M;
    vector<string>T(M,"");
    for (int i = 0; i < M; i++) {
        cin >> T[i];
        mp[T[i]]--;
    }
    
    int ans = 0;
    for (auto i : mp) {
        ans = max(ans ,i.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N,K = input().split(" ")
N   = int(N)
K   = int(K)

str =input()

if str[K-1]=='A':
    out = str[0:K-1] + 'a' + str[K : N]
if str[K-1]=='B':
    out = str[0:K-1] + 'b' + str[K : N]
if str[K-1]=='C':
    out =str[0:K-1] + 'c' + str[K : N]

print(out)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  char str[100];
  scanf("%s",str);
  if(str[0] =='S'){
    printf("Cloudy");
  }else if(str[0] == 'C'){
    printf("Rainy");
  }else{
    printf("Sunny");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    // 入力受け取り, 入次数も管理する
string s;
    cin >> s;
int flag=0;
for(int i=0;i<(int)(s.length());i++){
if(i%2==1){
if(!(s[i]=='L' || s[i]=='U' || s[i]=='D'))flag=1;
}else{
if(!(s[i]=='R' || s[i]=='U' || s[i]=='D'))flag=1;

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






}


Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use std::collections::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        h:usize,
        w:usize,
        m:usize,
        b:[(usize,usize);m],
    }

    let mut line = vec![0; h];
    let mut row = vec![0; w];
    // let mut bomb = vec![vec![0; w]; h];
    // let mut bs = BTreeSet::new();

    for &(i, j) in &b {
        // bomb[i - 1][j - 1] = 1;
        line[i - 1] += 1;
        row[j - 1] += 1;
        // bs.insert((i - 1, j - 1));
    }

    // for i in 0..h {
    //     let mut acc = 0;
    //     for j in 0..w {
    //         acc += bomb[i][j];
    //     }
    //     line[i] = acc;
    // }
    //
    // for i in 0..w {
    //     let mut acc = 0;
    //     for j in 0..h {
    //         acc += bomb[j][i];
    //     }
    //     row[i] = acc;
    // }

    let line_max = line.iter().max().unwrap();
    let lines = line
        .iter()
        .enumerate()
        .filter(|(_index, score)| *score == line_max)
        .map(|(index, _score)| index)
        .collect_vec();

    let row_max = row.iter().max().unwrap();
    let rows = row
        .iter()
        .enumerate()
        .filter(|(_, s)| *s == row_max)
        .map(|(i, _)| i)
        .collect_vec();

    let p = lines.len() * rows.len();
    // eprintln!("p: {:?}", p);
    let mut ps = 0;

    for &(i, j) in &b {
        if line[i - 1] == *line_max && row[j - 1] == *row_max {
            ps += 1;
        }
    }
    // eprintln!("ps: {:?}", ps);

    let a = if p == ps { 1 } else { 0 };

    println!("{}", line_max + row_max - a);
}


Measured memory_bytes: 17744
N,A,B,C,D=map(int,input().split())
b=[D+D,C+C,D-C]
b2=[D,C,-C,-D]
def solve(s,e,b,n):
    while True:
        if abs(e-s)>b[0]*n//2:
            return False
        if b[2]*n//2>=abs(e-s) or b[1]*n//2<=abs(e-s)<=b[0]*n//2:
            return True
        n-=2
        if n<0:
            return False
        if s+b[0]<e:
            s+=b[0]
        elif s+b[1]<=e:
            s=e
        elif s<e:
            s+=b[1]
        elif s-b[0]>e:
            s-=b[0]
        elif s-b[1]>=e:
            s=e
        else:
            s-=b[1]
if N%2==0:
    for d in b2:
        a=solve(A,B+d,b,N-2)
        if a==True:
            break
else:
    a=solve(A,B,b,N-1)
print(['NO','YES'][a])

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

using ll = long long;
const ll MOD = 1e9 + 7;
struct nCr_queries {
	private:
	ll N, p;
	vector<ll> fact, ifact, inv;
	ll inverse(const ll& x) {
		if(x == 1) return 1;
		return ((p - p/x) * (inv[p % x] % p)) % p;
	}
	public:
	nCr_queries(ll N,ll p) {
		this->N = N;
		this->p = p;
		fact.resize(N + 1);
		ifact.resize(N + 1);
		inv.resize(N + 1);
		fact[0] = ifact[0] = 1;
		for(int i = 1; i < fact.size(); ++i) {
			fact[i] = fact[i-1] * i % p;
			inv[i] = inverse(i);
			ifact[i] = ifact[i-1] * inv[i] % p;
		}
	}

	ll query(ll n, ll r) {
 		return (fact[n] * ifact[r])%p * ifact[n-r] % p;
	}
};

int main() {
	nCr_queries q(2 * (ll)1e5, (ll)1e9 + 7);
	int r, c, n;
	cin >> r >> c >> n;
	vector<pair<int, int>> v(n);
	vector<ll> dp(n + 1);
	for(auto& i: v) cin >> i.first >> i.second;
	v.push_back({r, c});
	sort(begin(v), end(v));
	for(int i = 0; i <= n; ++i) {
		ll ans = q.query(v[i].first + v[i].second - 2, v[i].second - 1);
		for(int j = 0; j < i; ++j) {
			if(v[j].second > v[i].second) continue;
			ll temp = dp[j] * q.query(v[i].first + v[i].second - v[j].first - v[j].second, v[i].second - v[j].second);
			temp %= MOD;
			ans -= temp;
			while(ans < 0) ans += MOD;
			ans %= MOD;
		}
		dp[i] = ans;
	}
	cout << dp[n];
	return 0;
}
		


Measured memory_bytes: 5120
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

bool check(string& s) {
    static int let['z' - 'a' + 1];
    memset(let, 0, sizeof let);

    for (char c : s) {
        let[c - 'a']++;
        if (let[c - 'a'] * 2 > size(s)) {
            return true;
        }
    }
    return false;
}

void solve() {
    string s;
    cin >> s;

    for (int i = 0; i < size(s); ++i) {
        for (int j = i + 1; j < size(s) && j - i + 1 < 4; ++j) {
            string t = s.substr(i, j - i + 1);
            if (check(t)) {
                cout << i + 1 << " " << j + 1 << "\n";
                return;
            }
        }
    }
    cout << "-1 -1\n";
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3736
#include<stdio.h>

#define N 100000

int main(){
    int i,j,n,p,r,x,y,A[N];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    p=0;
    r=n;
    x=A[r-1];
    i=p-1;
    
    for(j=0;j<r-1;j++){
        if(A[j]<=x){
            i=i+1;
            y=A[i];
            A[i]=A[j];
            A[j]=y;
        }
    }
    y=A[i+1];
    A[i+1]=A[r-1];
    A[r-1]=y;
    
    for(j=0;j<=i;j++){
        printf("%d",A[j]);
        if(j!=i+1){
            printf(" ");
        }
    }
    printf("[%d]",A[j]);
    printf(" ");
    for(i=j+1;i<n;i++){
        printf("%d",A[i]);
        if(i+1!=n){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2248
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <cmath>
#include <string.h>
#include <assert.h>
#include <stack>
#include <sstream>
#include <map>
#include <set>
#define FRE freopen("c:\\users\\sky123\\desktop\\input.txt","r",stdin)
#define FF freopen("output.txt", "w", stdout)
#define PI 3.1415926535897932384626433832795028
#define ee 2.7182818284590452354
#define pi acos(-1.0)
#define eps 1e-5
#define M 50
#define Inf 0x80000000
#define LL __int64
#define inf 100000000
using namespace std;

int main()
{
	int n,i,a,b,c;
	double l,d,m,lok,dok,mok;
	while(scanf("%d",&n),n)
	{
		l=0;
		d=0;
		m=0;
		lok=0;
		dok=0;
		mok=0;
		for(i=0;i<n;i++)
		{
			scanf("%d%*c%d%d",&a,&b,&c);
			if(a>=11&&a<15)
			{
				l++;
				if(c<b)
					c+=60;
				if(c-b<=8)
					lok++;
			}
			else if(a>=18&&a<21)
			{
				d++;
				if(c<b)
					c+=60;
				if(c-b<=8)
					dok++;
			}
			else if((a>=21&&a<=24)||(a>=0&&a<2))
			{
				m++;
				if(c<b)
					c+=60;
				if(c-b<=8)
					mok++;
			}
		}
		printf("lunch ");
		if(l==0)
			printf("no guest\n");
		else
			printf("%d\n",(int)((lok/l)*100));
		printf("dinner ");
		if(d==0)
			printf("no guest\n");
		else
			printf("%d\n",(int)((dok/d)*100));
		printf("midnight ");
		if(m==0)
			printf("no guest\n");
		else
			printf("%d\n",(int)((mok/m)*100));
	}
	return 0;
}

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

int calc_sat(int D, int N, vector<int> c, vector<vector<int>> s, vector<int> t) {
	vector<int> last(N,-1);
	int sat = 0;  // 満足度
	rep(d,D) {
		last[t[d]] = d;
		sat += s[d][t[d]];
		rep(i,N) {
			sat -= c[i] * (d-last[i]);
		}
	}
	return sat;
}

int main() {
	clock_t start = clock();

	int D;
	cin >> D;
	const int N = 26; // コンテストの種類
	vector<int> c(N);
	rep(i,N) cin >> c[i];
	vector<vector<int>> s(D, vector<int>(N));
	rep(i,D) rep(j,N) cin >> s[i][j];

	vector<int> t(D); // 開催するコンテスト

	int c_max = 0; // c[i]が最も大きいコンテスト
	rep(i,N) if (c[c_max]<c[i]) c_max = i;

	// 初期解
	rep(i,D) {
		t[i] = rand() % 26;
	}

	int sat = calc_sat(D, N, c, s, t);

	// 改善
	double e_time;
	e_time = (double)(clock() - start) / CLOCKS_PER_SEC;
	while(e_time <= 1.95) {
		int new_d, new_q;
		new_d = rand() % D;
		new_q = rand() % N;
		int old = t[new_d];
		t[new_d] = new_q;
		int new_sat = calc_sat(D, N, c, s, t);
		if (new_sat > sat) {
			sat = new_sat;
		}
		else {
			t[new_d] = old;
		}
		e_time = (double)(clock() - start) / CLOCKS_PER_SEC; 
	}


	// 出力
	rep(i,D) {
		printf("%d\n", t[i]+1);
	}

	return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int INF = 1e9 + 5;

int n, cnt;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		if (x & 1) ++cnt;
	}
	if (cnt & 1) {
		cout << "NO\n";
	}
	else {
		cout << "YES\n";
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 256
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input

def gauss(a):
	if not a or len(a)==0: return None
	n=len(a)
	for i in range(n):
		if a[i][i]==0:
			for j in range(i+1,n):
				if a[j][i]!=0:
					for k in range(i,n+1): a[i][k]+=a[j][k]
					break
			else:
				return None
		for j in range(n):
			if i!=j:
				r = Fraction(a[j][i],a[i][i])
				for k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r
	for i in range(n):
		x=Fraction(a[i][i],1)
		for j in range(len(a[i])):
			a[i][j] /= x
	return a

uaz=list(map(int,raw_input().split()))
enemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]
b0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
sol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))
print('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')

Measured memory_bytes: 14776
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=110;
int n;
VI e[N];

bool vis[N];
pair<int,LL> go( VI v, int lv, LL z ) {
    for ( int i:v ) vis[i]=1;
    int d=0;
    for ( int i:v ) {
        int c=0;
        for ( int j:e[i] ) if ( !vis[j] ) c++;
        chkmax(d,c);
    }
    VI nv;
    LL nz=0;
    for ( int i:v ) {
        int c=0;
        for ( int j:e[i] ) if ( !vis[j] ) {
            c++;
            nv.PB(j);
        }
        nz+=d-c;
    }
    nz+=z*d;
    if ( nv.empty() ) return {lv,SZ(v)+z};
    else return go(nv,lv+1,nz);
}

void main() {
    R(n);
    REP(i,n-1) {
        int a,b;
        R(a,b);
        e[a].PB(b);
        e[b].PB(a);
    }
    pair<int,LL> ans={INT_MAX,LLONG_MAX};
    REP1(i,1,n) {
        memset(vis,0,sizeof(vis));
        auto now=go({i},1,0);
        chkmin(ans,now);
    }
    REP1(i,1,n) {
        for ( int j:e[i] ) {
            memset(vis,0,sizeof(vis));
            auto now=go({i,j},1,0);
            dump(i,j,now);
            chkmin(ans,now);
        }
    }
    W(ans.first,ans.second);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


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

int main()
{

	int A;
	int B;
	int C;
	cin >> A;
	cin >> B;
	cin >> C;
	if (A == 5 && B == 5 && C ==7|| A== 5 && B== 7 && C == 5||A == 7 && B== 5 && C== 5)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}


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

using namespace std;

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

  int result = 0;
  for (int i = 0; i < 1000; ++i) {
    div_t d = div(i, 10);
    size_t j = S.find_first_of(d.rem + '0');
    if (string::npos == j) continue;
    d = div(d.quot, 10);
    j = S.find_first_of(d.rem + '0', j + 1);
    if (string::npos == j) continue;
    d = div(d.quot, 10);
    j = S.find_first_of(d.rem + '0', j + 1);
    if (string::npos == j) continue;
    ++result;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

bool PalinCheck(string s) {
	bool ret = true;
	int size = (int)s.size();
	for (int i = 0; i < size / 2; ++i) {
		if (s[i] != s[size - i - 1]) {
			ret = false;
			break;
		}
	}
	return ret;
}

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

	for (int i = n; i >= 0; i--) {
		if (PalinCheck(to_string(i))) {
			can.pb(i); break;
		}
	}
	for (int i = n + 1; true; i++) {
		if (PalinCheck(to_string(i))) {
			can.pb(i); break;
		}
	}

	int ans = 0, mi = inf;
	for (auto aa : can) {
		if (mi > abs(aa - n)) {
			ans = aa;
			mi = abs(aa - n);
		}
	}
	Cout(ans);
}


Measured memory_bytes: 3280
#include <iostream>
using namespace std;
int main(void){
   string s;
   cin >> s;
   int a = 0;
   for(int i = 0;i < s.size();i++){
         if(s[i] == 'A'){
               a = i;
               break;
         }
   }
   int z = s.size();
   for(int i = s.size() - 1;i >= 0;i--){
         if(s[i] == 'Z'){
               z = i;
               break;
         }
   }
   cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){

char c1[3],c2[3];
rep(i,3)cin >> c1[i];
rep(i,3)cin >> c2[i];
reverse(c2,c2+3);
rep(i,3){
    if(c1[i]!=c2[i]){
        cout << "NO"<<endl;
        return 0;
    }
}
cout << "YES" << endl;
return 0;
}





Measured memory_bytes: 256
N,K = map(int,raw_input().split())
src = map(int,raw_input().split())

def gcd(a,b):
  a,b = max(a,b),min(a,b)
  if b == 0:
    return a
  return gcd(b, a%b)

def solve():
  if N == 1: return src[0] == K
  mx = max(src)
  if K > mx: return False
  g = src[0]
  for i in range(1,N):
    g = gcd(g, src[i])
    if g == 1:
      return True
  return K % g == 0

print ('POSSIBLE' if solve() else 'IMPOSSIBLE')

Measured memory_bytes: 11320
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 2e5+5;
const int M = 1e9+7;
#define pi acos(-1)
#define INF 1e10
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
LL dp[N][2],a[N];
int main()
{
	int n;sd(n);
	for(int i=1;i<=n;++i) sld(a[i]);
	dp[1][0] = dp[1][1] = 0;//注意对于1位置选i/2个元素其实是0个元素,所以1位置不用选择元素
	dp[2][0] = a[1],dp[2][1] = a[2];
	for(int i=3;i<=n;++i)
	{
		if(i&1)
		{
			dp[i][0] = max(dp[i-1][0],max(dp[i-1][1],dp[i-3][0]+a[i-2]));
			dp[i][1] = max(max(dp[i-2][0],dp[i-2][1]),max(dp[i-3][0],dp[i-3][1]))+a[i];
		}
		else 
		{
			dp[i][0] = dp[i-2][0]+a[i-1];
			dp[i][1] = max(dp[i-1][0],max(dp[i-2][0],dp[i-2][1]))+a[i];
		}
	}
	plr(max(dp[n][0],dp[n][1]));
	//system("pause");
	return 0;
}

Measured memory_bytes: 8512
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i  = (a); i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  	int n,memo = 0,cnt = 0;
  	cin >> n;
  	int a[n];
  	rep(i,0,n){
      cnt = 0;
      cin >> a[i];
    }
  
  	while(1){
      rep(i,0,n){
        if(a[i] % 2 != 0){
			cout << memo << endl;
          	return 0;
        }
        else{
          a[i] /= 2;
        }
      }
      memo++;
    }
  
  	cout << memo << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

class Drink{
public:
    ll b, a;
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    vector<Drink> d(n);
    ll sum = 0;
    rep(i, n){
        cin >> a[i] >> b[i];
        Drink c;
        c.b = b[i];
        c.a = a[i];
        d[i] = c;
    }
    sort(d.begin(), d.end(), [](Drink d, Drink e){ return d.a < e.a; });
    //for_each(d.begin(), d.end(), [](Drink d){ cout << d.a << endl; });
    ll ret = 0;
    repi(i, d){
        ret += min(m, (*i).b) * (*i).a;
        m -= (*i).b;
        if(m <= 0){
            break;
        }
    }
    cout << ret << endl;
    //for_each(d.begin(), d.end(), [](Drink d){ cout << d.a << " " << d.b << endl; });
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,x=0;cin>>A>>B>>C;
  if(A==B&&B==C&&A%2==0)cout<<"-1"<<endl;
  else{
    while(A%2==0&&B%2==0&&C%2==0){
      x++;int a=A,b=B,c=C;
      A=(b+c)/2,B=(c+a)/2,C=(a+b)/2;
    }
    cout<<x<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
	int a, b ,c;
	int max, min, total;
	
	
	scanf("%d %d %d", &a, &b, &c);
	
	total = a + b +c;
	
	if(a > b && a > c)
	{
		max = a;
	}
	else if(b > a && b > c)
	{
	    max = b;
    }
	else 
	{
        max = c;
	}
	
	if(a < b && a < c)
	{
		min = a;
	}
	else if(b < a && b < c)
	{
		min = b;
	}
	else
	{
		min = c;
	}
	printf("%d %d %d\n", min, (total - min - max), max);
	
	return 0;

} 



Measured memory_bytes: 2752
import sys
def input():
    return sys.stdin.readline()[:-1]

N,K,Q = map(int,input().split(' '))
dp = [K]*N
for i in range(Q):
    ind = int(input())-1
    dp[ind] += 1
for i in range(N):
    if dp[i]-Q>0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 6604
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6+5;
int main() {
    long long n,m;
    cin>>n>>m;
    long long extra = 0;
    if(1LL*2*n<=m){
        long long rem = m-(1LL*2*n);
        extra = rem/4;
    }
    cout<<min(n,m/2)+extra<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
if(b==0) return a;
if(a < b) return GCD(b, a);
unsigned r;
while ((r=a%b)) {
a = b;
b = r;
}
return b;
}

int main() {
    int A,B,C,ans;
    cin >> A>> B >> C;
    int count;
    count = B/A;
    if(count>C){
        ans = C;
    }else{
        ans =count;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
if (b - a )% 2 == 0:
  print((b-a)//2)
else:
  small = min(n-a,b-1)
  smal = min(a+(b-a-1)//2, n-b+1+(b-a-1)//2)
  print(min(small, smal))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
long long gcd(long long a, long long b);
long long lcd(long long a, long long b);
int main(){
    int n; cin >> n;
    long long ans ; cin >> ans;
    for(int i = 1; i < n; i++){
        long long t; cin >> t;
        if(ans > t) ans = lcd(ans, t);
        else ans = lcd(t, ans);
    }
    cout << ans << endl;
}

long long gcd(long long a, long long b){
    if(b == 0) return a;
    else return gcd(b, a%b); 
}

long long lcd(long long a, long long b){
    long long w = a/gcd(a,b);
    return w*b;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in",,"r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}
pair<int,int> ans1,ans2,ans3,ans4;
#define mp make_pair
int n,v[100010],ap[100010],ans,flag[100010];
int main(){
	n=gi();
	for(int i=1;i<=n;i++)v[i]=gi();
	for(int i=1;i<=n;i+=2)ap[v[i]]++;
	for(int i=1;i<=n;i+=2){
		if(flag[v[i]])continue;
		if(ap[v[i]]>ans1.first){ans2=ans1;ans1=mp(ap[v[i]],v[i]);}
		else if(ap[v[i]]>ans2.first)ans2=mp(ap[v[i]],v[i]);
		flag[v[i]]=1;
	}
	for(int i=1;i<=100000;i++){ap[i]=0;flag[i]=0;}
	for(int i=2;i<=n;i+=2)ap[v[i]]++;
	for(int i=2;i<=n;i+=2){
		if(flag[v[i]])continue;
		if(ap[v[i]]>ans3.first){ans4=ans3;ans3=mp(ap[v[i]],v[i]);}
		else if(ap[v[i]]>ans4.first)ans4=mp(ap[v[i]],v[i]);
		flag[v[i]]=1;
	}
	if(ans1.second!=ans3.second)ans=n-ans1.first-ans3.first;
	else ans=n-max(ans1.first+ans4.first,ans2.first+ans3.first);
	printf("%d\n",ans);
	return 0;
}
#undef mp


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecll a(n);
  REPe(e, a) { cin >> e; }
  ll sum = 0;
  vecll b;
  int c = 0;
  REP(i, n) {
    ll x;
    cin >> x;
    a[i] -= x;
    if (a[i] < 0) {
      sum += abs(a[i]);
      c++;
    } else if (a[i] > 0) {
      b.push_back(a[i]);
    }
  }
  sort(all(b), greater<ll>());
  // if (sum == 0) {
  //   cout << 0 << endl;
  //   return 0;
  // }
  // cout << sum << endl;
  // REPe(e, b) { cout << e << endl; }
  int i = 0;
  ll tmp = 0;
  while (tmp < sum && i < (int)b.size()) {
    tmp += b[i];
    i++;
  }
  i += c;
  if (tmp < sum) {
    i = -1;
  }
  cout << i << endl;
}
//////////////////////////////////////////////


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

int gcd2(int x, int y) {
    if (x % y == 0) {
        return y;
    }
    return gcd2(y, x % y);
}

int gcd(int a, int b, int c) {
    return gcd2(gcd2(a, b), c);
}

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

    int K; cin >> K;
    int ans = 0;
    REPS(i, 1, K) REPS(j, 1, K) REPS(k, 1, K) ans += gcd(i, j, k);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
   int n,i,j,k,a[20],b[20],c[20],s;
 
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&a[i]);
   for (i=0;i<n;i++) scanf("%d",&b[i]);
   for (i=0;i<n-1;i++) scanf("%d",&c[i]);
   k=-9;
   for (s=i=0;i<n;i++) {
      j=a[i]-1;
      s+=b[j];
      if (j==k+1) s+=c[k];
      k=j;
   }
   printf("%d",s);
   return 0;
}


Measured memory_bytes: 128
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            int l = int.Parse(str[2]);

            int[,] a = GetData(n, m);
            int[,] b = GetData(m, l);
            string[,] c = new string[n, l];

            for (int rowA = 0; rowA < n; rowA++) 
            { 
                for (int colB = 0; colB < l; colB++)
                {
                    long sum = 0;
                    for (int rowB = 0; rowB < m; rowB++)
                    {
                        sum += b[rowB, colB] * a[rowA, rowB];
                        //Console.WriteLine(string.Format("{0} * {1}", b[rowB, colB], a[rowA, rowB]));
                    }

                    c[rowA, colB] = sum.ToString();
                }
            }

            for (int row = 0; row < n; row++)
            {
                for (int col = 0; col < l - 1; col++)
                {
                    Console.Write(c[row, col] + " ");
                }

                Console.WriteLine(c[row, l - 1]);
            }
        }

        static int[,] GetData(int a, int b)
        {
            int[,] data = new int[a, b];

            for (int i = 0; i < a; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                for (int j = 0; j < b; j++)
                {
                    data[i, j] = int.Parse(str[j]);
                }
            }

            return data;
        }
    }
}

Measured memory_bytes: 10236