akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

int main() {
	ll n, m;
	cin >> n >> m;
	if (n % 2 == 1) {
		ll a = n / 2;
		ll b = a + 1;
		for (ll i = 0; i < m; ++i) {
			cout << a - i << " " << b + i << endl;
		}
	} else {
		ll a = 1;
		ll b = n - 1;
		rep(i,m){
			if(i == (n/2 - 1)/2){
				b--;
			}
			cout << a + i << " " << b - i << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 3616
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int H = scan.nextInt();
		int W = scan.nextInt();
		int h = scan.nextInt();
		int w = scan.nextInt();

		int totalCount = H * W;

		int rowBlack = W * h;

		int colBlack = w * (H - h);

		System.out.println(totalCount - rowBlack - colBlack);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 23380
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include<iostream>
#include<fstream>

using namespace std;

const int N = 5e5 + 5;
const int inf = N;

int n, k, cnt;
int a[N];
int ans[N];
int ind[N];
int fen[N * 4];
bool mark[N];
priority_queue<int> s;

void add(int ind, int val) 
{
	for (fen[ind += n] = val; ind >>= 1;)
	{
		fen[ind] = max(fen[ind << 1], fen[ind << 1 | 1]);
	}
}

int get(int l, int r) 
{
	l = max(l, 0);
	r = min(r, n);
	int ans = 0;
	for (l += n, r += n; l < r; l >>= 1, r >>= 1) 
	{
		if (l & 1)
		{
			ans = max(ans, fen[l++]);
		}
		if (r & 1)
		{
			ans = max(ans, fen[--r]);
		}
	}
	return ans;
}

void isval(int x) 
{
	int mx = get(x * k, x * k + k);
	if (mx == -inf)
	{
		return;
	}
	int me = ind[mx];
	if (a[me] >= get(me - k + 1, me + k) && mark[me] == false) 
	{
		mark[me] = true;
		s.push(me);
	}
}

int main() 
{
	cin >> n >> k;
	for (int i = 0; i < n; i++) 
	{
		cin >> a[i];
		ind[a[i]] = i;
		add(i, a[i]);
	}
	cnt = (n + k - 1) / k;
	for (int i = 0; i < cnt; i++)
	{
		isval(i);
	}
	for (int i = n; i; i--) 
	{
		int x = s.top();
		s.pop();
		ans[x] = i;
		add(x, -inf);
		x /= k;
		if (x)
		{
			isval(x - 1);
		}
		isval(x);
		if (x + 1 < cnt)
		{
			isval(x + 1);
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << ans[i] << ' ';
	}
}



Measured memory_bytes: 17776
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int S = in.nextInt();
        int W = in.nextInt();
        if(S > W){
            System.out.print("safe");
        }
        else{
            System.out.print("unsafe");
        }
        

    }

}

Measured memory_bytes: 35768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		sc.close();

		if(n>=400&&n<=599) {
			System.out.println(8);
		} else if(n>=600&&n<=799) {
			System.out.println(7);
		} else if(n>=800&&n<=999) {
			System.out.println(6);
		} else if(n>=1000&&n<=1199) {
			System.out.println(5);
		} else if(n>=1200&&n<=1399) {
			System.out.println(4);
		} else if(n>=1400&&n<=1599) {
			System.out.println(3);
		} else if(n>=1600&&n<=1799) {
			System.out.println(2);
		} else if(n>=1800&&n<=1999) {
			System.out.println(1);
	}
	}
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define double long double

int n,a[110];

bool check(int s){
	int now=0;
	for(int i=0;i<n;i++){
		now+=a[i];
		if(now-s<0)return false;
		now-=s;
	}
	return true;
}

void input(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	return;
}

void solve(){
	for(int j=100;j>=1;j--){
		if(check(j)){
			cout<<j<<endl;
			return;
		}
	}
	return;
}

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


Measured memory_bytes: 3096
s=input()
t=input()
a=len(s)
b=len(t)
dp=[[0]*(b+1) for i in range(a+1)]
for j in range(1,a+1):
    for i in range(1,b+1):
        if s[j-1]==t[i-1]:
            dp[j][i]=dp[j-1][i-1]+1
        else:
            dp[j][i]=max(dp[j-1][i],dp[j][i-1])


N=dp[a][b]
y=a
x=b
#L=[]
H=[]
while N>0:
    if dp[y][x-1]-dp[y][x]==0:
        x-=1
        continue
    if dp[y-1][x]-dp[y][x]==0:
        y-=1
        continue
    #L.append((t[x-1],x-1))
    H.append(t[x-1])
    N-=1
    y-=1
    x-=1
print(''.join(H[::-1]))

Measured memory_bytes: 113116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a, b, c;
	cin >> a >> b >> c;
	if((a == b && a != c) || (a == c && a != b) || (b == c && a != b)){
		print("Yes")
	}
	else{
		print("No")
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

INF = float('inf')
N = int(input())
*A, = map(int, input().split())
cumsum = list(accumulate([0] + A))
dp = [[INF] * (N+1) for _ in range(N+1)]
for i in range(N): dp[i][i+1] = 0
for l in range(2, N+1):
    for i in range(N-l+1):
        j = i + l
        dp[i][j] = min([dp[i][k] + dp[k][j] for k in range(i+1, j)]) + (cumsum[j] - cumsum[i])
print(dp[0][N])

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> s.at(i).at(j);
  bool ok = true;
  rep(i, h) {
    rep(j, w) {
      if (s.at(i).at(j) == '.') {
        continue;
      }
      bool bn = false; // 隣接するマスに黒がある
      rep(k, 4) {
        int nh = i + dy.at(k);
        int nw = j + dx.at(k);
        if (nh >= 0 && nh < h && nw >= 0 && nw < w) {
          if (s.at(nh).at(nw) == '#') {
            bn = true;
            break;
          }
        }
      }
      if (!bn) {
        ok = false;
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;

int n, m;
int adjmat[111][111];
int parent[111][111];
bool path[111][111];
int a, b, c;
int ans;

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

   for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
         adjmat[i][j] = 1000000000;
         parent[i][j] = i;
         path[i][j] = false;
      }
   }

   for (int i = 0; i < m; i++) {
      cin >> a >> b >> c;
      adjmat[a][b] = c;
      adjmat[b][a] = c;
      path[a][b] = true;
      path[b][a] = true;
   }

   for (int k = 1; k <= n; k++) {
      for (int i = 1; i <= n; i++) {
         for (int j = 1; j <= n; j++) {
            if (adjmat[i][k] + adjmat[k][j] < adjmat[i][j]) {
               adjmat[i][j] = adjmat[i][k] + adjmat[k][j];
               parent[i][j] = parent[k][j];
            }
         }
      }
   }

   for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
         path[j][parent[i][j]] = false;
         path[parent[i][j]][j] = false;
      }
   }

   for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
         if (path[i][j]) ans++;
      }
   }

   cout << ans/2 << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
#define INF 1e9 + 7
#define cae cout << ans << endl;
#define cye cout << "Yes" << endl;
#define cne cout << "No" << endl;
#define r0 return 0;
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
signed main() {
    int n, m;
    int ans = 0;
    cin >> n >> m;
    int a[1234] = {0};
    rep(i, n) {
        cin >> a[i];
        ans += a[i];
    }
    sort(a, a + n, greater<>());
    rep(i, m) {
        if ((double)ans / (4 * m) > a[i]) {
            cne
            r0
        }
    }
    cye
    r0
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const int nax = 5005;
ll a[nax];
vector<vector<ll>> dp;
ll INIT = 1e18L + 5;

ll recurse(int st, int en){
    if(st > en) return 0ll;
    ll &z = dp[st][en];

    if(z != INIT) return z;
    ll lt = recurse(st + 1, en);
    ll rt = recurse(st, en - 1);
    return z = max(a[st] - lt, a[en] - rt);
}


void solve(){
    int n;
    cin>>n;
    dp.resize(n, vector<ll>(n, INIT));
    fr(i, n) cin>>a[i];
    ll diff = recurse(0, n-1);   /// X - Y
    cout<<diff;
}

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

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

    return 0;
}



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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    if n % 2 != 0 {
        println!("No");
        return;
    }

    for i in 0..n / 2 {
        if s[i] != s[i + n / 2] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

int main() {
  int N,n;
  cin>>N;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    n+=r-l+1;
  }
  cout<<n<<endl;
}

Measured memory_bytes: 256
a,b=map(int, input().split()) 
box1 =[1,3,5,7,8,10,12]
box2 =[4,6,9,11]
if a==b==2:
    print("Yes")
elif a in box1 and b in box1:
    print("Yes")
elif a in box2 and b in box2:
    print("Yes")
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    S.erase(S.size()-1,1);
    int N = S.size();
    bool flag = true;
    for(int i = 0; i < N; i++){
        if(S.size() == 2){
            if(S[0] == S[1]){
                cout << 2 << endl;
                return 0;
            }
        }
        flag = true;
        if(S.size()%2 == 1){
            S.erase(S.size()-1, 1);
            continue;
        }
        else{
            for(int j = 0; j < S.size()/2; j++){
                if(S[j] != S[S.size()/2+j]){
                    flag = false;
                    S.erase(S.size()-1, 1);
                }
            }
            if(flag == true){
                cout << S.size() << endl;
                return 0;
            }
        }
        
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    set<ll> s;

    rp(i,n){ cin >> a[i]; s.insert(a[i]);}

    cout << sz(s)<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
import sys
# recieve |V| and |E|
V, E = map(int, input().split())
es = [[] for i in range(V)]

for i in range(E):

	# recieve edges
	a, b, c = map(int, input().split())
	a, b = a-1, b-1
	es[a].append((b,c))
	es[b].append((a,c))

# recieve frequencies
F  = list(map(int,input().split()))

T = int(input())

# recieve info
for i in range(T):

	# the number of new order
	Nnew = int(input())
	for j in range(Nnew):
		new_id, dst = map(int, input().split())
	
	# the number of items transfered into the car at time t.
	Nput = int(input())
	for j in range(Nput):
		put_id = int(input())

	# insert your code here to get more meaningful output
	# you have to output a command here
	print(-1)

	vardict = input()
	if vardict == 'NG':
		sys.exit()

	# the number of orders that have been delivered at time t.
	Nachive = int(input())
	for j in range(Nachive):
		achive_id = int(input())
for i in range(100):
    print(-1)

Measured memory_bytes: 54660
#include <bits/stdc++.h>
#define maxn 200001
#define maxa 1000005
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second
#define rep(i, n) for(ll i = 0; i < n; i++)

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}
ll ceil(ll a, ll b){if((a%b) != 0) return a/b+1; return a/b;}
void flaged(bool flag){
    if(flag) cout << "Yes\n";
    else cout << "No\n";
}
ll power(ll a, ll b = MOD-2){
    if(b == 0) return 1;
    ll r = power(a, b/2);
    r = (r*r)%MOD;
    if(b%2 == 1) r = (r*a)%MOD;
    return r;
}

void solve(){
    ll m, n; cin >> m >> n;
    ll s = 0;
    rep(i, n){
        ll x; cin >> x; s+=x;
    }
    flaged(s>=m);
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();
		for (int i=0;i<10;i++) {
			x = r*x-D;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 35720
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int n;

  cin>>n;

  cout<<"ABC"<<n<<endl;
  
  return 0;

}




Measured memory_bytes: 256
def solve():
    N, Y = map(int, input().split())
    
    upper1 = Y // 10000
    if upper1 > N:
        print(-1, -1, -1)
        return None
    for i in range(upper1 + 1):
        rest = Y - 10000 * i
        upper2 = rest // 5000
        if upper2 > N - i:
            continue
        for j in range(upper2 + 1):
            k = N - i - j
            if 1000 * k == rest - 5000 * j:
                print(i, j, k)
                return None
    else:
        print(-1, -1, -1)

solve()

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

const int N=100000+10;

int _r;char _c;

int read()
{
	while(!isdigit(_c=getchar()));
	_r=_c-48;
	while(isdigit(_c=getchar()))
		_r=_r*10-48+_c;
	return _r;
}

int n,d[N],rt,dp[N];
int fir[N],nxt[N<<1],to[N<<1],tote;

void dfs(int u,int fa=rt)
{
	int i,v,fl(1);
	for(i=fir[u];i;i=nxt[i])if((v=to[i])!=fa)
	{
		dfs(v,u);
		if(!dp[v])
		{
			if(fl)
				fl=0;
			else
				++dp[u];
		}
		else
			dp[u]+=dp[v];
	}
}

int main()
{
	n=read();
	int i,u,v;
	for(i=1;i<n;++i)
	{
		u=read()+1;v=read()+1;
		to[++tote]=v;nxt[tote]=fir[u];fir[u]=tote;
		to[++tote]=u;nxt[tote]=fir[v];fir[v]=tote;
		++d[u];++d[v];
	}
	for(i=1;i<=n&&!rt;++i)if(d[i]>2)
		rt=i;
	if(!rt)
		printf("1");
	else
	{
		dfs(rt);
		printf("%d",dp[rt]);
	}
	return 0;
}


Measured memory_bytes: 6400
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)


def solve(N, t):
    d1 = array2(N, 0)
    d2 = array2(N, 0)

    t  = [(x[0]-1, x[1], x[2]) for x in t]
    t1 = [(x[0], x[1] - x[2]) for x in t if x[1] >= x[2]]
    t2 = [(N - 2 - x[0], x[2] - x[1]) for x in t if x[1] < x[2] and N - 2 - x[0] >= 0]

    ans = sum([min(x[1], x[2]) for x in t])
    
    for k, dt in t1:
        d1[k].append(dt)

    S = []

    for i in range(N):
        for dt in d1[i]:
            insort(S, dt)

        if len(S) > i:
            S = S[len(S)-i-1:]

    #print("d1: ", d1, " S: ", S)

    ans += sum(S)

    for k, dt in t2:
        d2[k].append(dt)

    S = []
    for i in range(N):
        for dt in d2[i]:
            insort(S, dt)

        if len(S) > i:        
            S = S[len(S)-i-1:]

    #print("d2: ", d2, " S: ", S)
    ans += sum(S)
    print(ans)

T = n1()

for _ in range(T):
    N = n1()
    t = nm(N)
    solve(N, t)

Measured memory_bytes: 276648
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

using namespace std;
int n,m,x;
int mat[20][20];
int costs[20];
int ans=INT_MAX;
void func(int i,vector<int> knowledge,int cost)
{
  if(i==n)
  {
    for(int j=0;j<m;j++)
      if(knowledge[j]<x)
        return;
      ans=min(ans,cost);
      return;
  }

  func(i+1,knowledge,cost);
  cost+=costs[i];
  for(int j=0;j<m;j++)
  {
    knowledge[j]+=mat[i][j];

  }
  func(i+1,knowledge,cost);


}
void solve()
{
  
  cin>>n>>m>>x;
  
  for(int i=0;i<n;i++)
  {
    cin>>costs[i];
    for(int j=0;j<m;j++)
      cin>>mat[i][j];
  }
  vector<int> v(m);
  func(0,v,0);
  if(ans!=INT_MAX)
  cout<<ans<<endl;
else
  cout<<-1<<endl;






}
signed main()

{
  FAST_IO;
  int t = 1;

  

  while(t--)
  {
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3664
package main

import (
    "fmt"
)

const ZERO byte = 48
const ONE byte = 49

// main 124-c
func main() {
    var s string
    fmt.Scan(&s)

    var h1 = ZERO
    var h2 = ONE
    var c1, c2 = 0, 0

    for i := 0; i < len(s); i++ {
        if s[i] == h1 {
            c1++
        }
        if s[i] == h2 {
            c2++
        }

        h1, h2 = h2, h1
    }

    if c1 > c2 {
        fmt.Println(c2)
    } else {
        fmt.Println(c1)
    }

}



Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
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 All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<ll> A(N);
    vector<ll> X(N);
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    }
    ll tmp = 0;
    rep(i,N){
        if(i%2==1)tmp+=A[i];
    }
    tmp*=2;
    X[0]=sum-=tmp;
    for(int i=1;i<N;i++){
        X[i]=2*(A[i-1]-X[i-1]/2);
    }
    rep(i,N)cout << X[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2944
N, K = map(int, input().split())
hn = [int(input()) for _ in range(N)]
hn.sort()

s = [0] * N
for i in range(1, N):
    s[i] = s[i-1] + (hn[i] - hn[i-1])
m = min(s[i+K-1] - s[i] for i in range(0, N-K+1))

print(m)

Measured memory_bytes: 10960
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, Q;
  std::cin >> N >> Q;
  std::string S;
  std::cin >> S;

  std::vector<i64> source(N, 0);
  for (i64 i = 1; i < N; ++i) {
    if (S[i - 1] == 'A' && S[i] == 'C') ++source[i];
  }
  std::vector<i64> cumsum({0});
  cumsum.reserve(N + 1);
  std::partial_sum(source.begin(), source.end(), std::back_inserter(cumsum));

  for (i64 i = 0; i < Q; ++i) {
    i64 l_i, r_i;
    std::cin >> l_i >> r_i;
    --l_i;
    --r_i;
    if (l_i > 0 && S[l_i - 1] == 'A' && S[l_i] == 'C') ++l_i;
    if (r_i < N - 1 && S[r_i] == 'A' && S[r_i + 1] == 'C') --r_i;
    std::cout << cumsum[r_i + 1] - cumsum[l_i] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 2688
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)

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


def dfs(v, parent, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to == parent:
            continue
        dfs(to, v, d + cost)


depth = defaultdict(int)
tree = defaultdict(list)
n = int(input())
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append((b, c))
    tree[b].append((a, c))

q, k = map(int, input().split())
k -= 1

dfs(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(depth[x] + depth[y])


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

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

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

struct UnionFind {
        vector<int> par, rank, Size;
        UnionFind(int n = 1) {
            init(n);
        }

        void init(int n = 1) {
            par.resize(n + 1);
            rank.resize(n + 1);
            Size.resize(n + 1);
            for(int i = 0; i <= n; i++) {
                par[i] = i;
                rank[i] = 0;
                Size[i] = 1;
            }
        }

    int root(int x) {
        if(par[x] == x) return x;
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

        bool issame(int x, int y) {
            x = root(x);
            y = root(y);
            return x == y;
        }

        bool merge(int x, int y) {
            x = root(x);
            y = root(y);
            if(x == y) return false;
            Size[x] += Size[y];
            par[y] = x;
            return true;
        }
    };

const ll mod = 1e9 + 7;
ll N, M;
ll a[5050];
ll Prev[5050], Next[5050];
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    UnionFind uni(2 * N);
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            if(a[i] > a[j]) {
                uni.merge(i , j + N);
                uni.merge(i + N, j);
            }
        }
    }
    for(int i = 0; i < N; i++) {
        //cerr << i << " " << uni.root(i) << " " << uni.root(i + N) << endl;
        if(uni.issame(i, i + N)) {
            cout << 0 << endl;
            return 0;
        }
    }
    Prev[0] = 1;
    for(int i = 0; i < N; i++) {
        if(uni.root(i) != i and uni.root(i) != i + N) continue;
        for(int i = 0; i <= N; i++) Next[i] = 0;
        ll x[2] = {0, 0};
        for(int j = 0; j < N; j++) {
            if(uni.issame(i, j)) x[0]++;
            if(uni.issame(i, j + N)) x[1]++;
        }
        //cerr << x[0] << " " << x[1] << endl;
        for(int index = 0; index < 2; index++) {
            for(int before = 0; before < N; before++) {
                if(before + x[index] <= N) {
                    Next[before + x[index]] += Prev[before];
                    Next[before + x[index]] %= mod;
                }
            }
        }
        swap(Prev, Next);
    }
    ll ans = 0;
    for(ll i = N - M; i <= M; i++) {
        ans += Prev[i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */
int ceil(int a, int b){
    if(a % b == 0) return a /b;
    else return a /b + 1;
}

struct Union_Find{
    vector<int> par;
    vector<int> rank;

    Union_Find(int n){
        for(int i = 0; i < n; i++){
            par.push_back(i);
            rank.push_back(0);
        }
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    void merge(int x, int y){
        x = root(x);
        y = root(y);

        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

};


signed main(){

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

    Union_Find uf = Union_Find(13);

    uf.merge(1,3);
    uf.merge(1,5);
    uf.merge(1,7);
    uf.merge(1,8);
    uf.merge(1,10);
    uf.merge(1,12);

    uf.merge(4, 6);
    uf.merge(4, 9);
    uf.merge(4, 11);

    if(uf.same(input(), input())){
        print("Yes");
    }else{
        print("No");
    }

    
    




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		if(n <= 111) System.out.println(111);
		else if(n <= 222)System.out.println(222);
		else if(n <= 333)System.out.println(333);
		else if(n <= 444)System.out.println(444);
		else if(n <= 555)System.out.println(555);
		else if(n <= 666)System.out.println(666);
		else if(n <= 777)System.out.println(777);
		else if(n <= 888)System.out.println(888);
		else if(n <= 999)System.out.println(999);
										
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
float PHI = 1.6180339;
//const float  PI_F=3.14159265358979f;
#define MAX 100000 
#define endl "\n"    
//typedef long long float;
#define int long long
//#define float unsigned long long
  


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << fixed << setprecision(7);

    int r;
    cin>>r;
    int s=r*r;
    cout<<s<<endl;

}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    string s;
    cin >> s;

    int cnt[30] = {0};
    rep(i, s.size()) ++ cnt[(int)(s[i]) - 97];

    bool flag = true;
    rep(i, 30){
        flag = cnt[i] % 2 == 0 && flag;
    }

    outYes(flag);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a, b, c, d;

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b * d))) << '\n';

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
typedef long long ll;

int n,k;
string s,t;
int h[200005];

int main() {
  cin >> n >> k;
  rep(i,n) cin >> h[i];
  sort(h,h+n);
  ll ans=0;
  rep(i,n-k) ans+=h[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
N=int(input())
A=[int(a) for a in input().split()]
X=[A[i-1]+i for i in range(1,N+1)]
Y=[-A[j-1]+j for j in range(1,N+1)]
cnt={}
for x in X:
    cnt[x]=[0,0]
for y in Y:
    cnt[y]=[0,0]
for x in X:
    cnt[x][0]+=1
for y in Y:
    cnt[y][1]+=1
ans=0
for key in cnt:
    p,q=cnt[key]
    ans+=p*q
print(ans)

Measured memory_bytes: 93372
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B;cin>>A>>B;
  cout<<(A-1)*(B-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
a, b, h, k = map(int, input().split())
kakudo_h = (0.5 * 60 * h) + (0.5 * k)
kakudo_k = 6 * k
ans = 0
ans2 = 0
kakudo = 0

if abs(kakudo_k-kakudo_h) == 180 or abs(kakudo_h-kakudo_k) == 180:
  ans = a + b
elif kakudo_h == kakudo_k:
  ans = abs(b - a)
elif kakudo_h > kakudo_k:
  if kakudo_h - kakudo_k > 180:
    kakudo = 360 - (kakudo_h - kakudo_k)
    ans2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo))
    ans = ans2 ** 0.5
  else:
    kakudo = kakudo_h - kakudo_k
    ans2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo))
    ans = ans2 ** 0.5
elif kakudo_h < kakudo_k:
  if kakudo_k - kakudo_h > 180:
    kakudo = 360 - (kakudo_k - kakudo_h)
    ans2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo))
    ans = ans2 ** 0.5
  else:
    kakudo = kakudo_k - kakudo_h
    ans2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo))
    ans = ans2 ** 0.5

print(float(ans))

Measured memory_bytes: 9584
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  string s, t="keyence";
  bool ans=false;
  cin >> s;
  for(int i=0;i<t.length();i++){
    string a="", b="";
    for(int j=0;j<i;j++)a=a+t[j];
    for(int j=i;j<t.length();j++)b=b+t[j];
    if(i==0){
      if(s.find(b)!=-1&&(s.find(b)==0||s.find(b)==s.length()-7))ans=true;
    }
    else{
      if(s.find(a)==0&&s.rfind(b)==s.length()-7+i)ans=true;
    }
  }
  if(ans)puts("YES");
  else puts("NO");

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <fstream>
#include <bitset>
#include <cassert>
using namespace std;
 
//#define int long long
#define double long double
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pb push_back
#define debug(x) cerr << #x << ": " << x << '\n';
#define ppoint(p) cout << #p << ' ' << p.x << ' ' << p.y << '\n';
#define fi first
#define se second
#define FOR(i, n) for (int i = 0; i < n; ++i)
//typedef long long ll;
typedef pair<int, int> pii;
 
template<typename T1, typename T2> inline bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template<typename T1, typename T2> inline bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };
 
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int N = 3e6 + 10;
int a = 3e6;
int cnt[N];

signed main() {
	fast();
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string tmp;
	cin >> tmp;
	if (tmp == s) a--;
	else b--;
	cout << a << ' ' << b << '\n';
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n,m,t;
    cin>>n>>m>>t;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    
    int ans = 0;
    ans+=a[0]-m;
    ans+=max(0,t-m-a[a.size()-1]);
    rep(i,a.size()-1){
        if(a[i+1]-a[i]>2*m)ans+=a[i+1]-a[i]-2*m;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#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, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a == b and b == c)cout << "No" << endl;
	else if (a == b)cout << "Yes" << endl;
	else if (a == c)cout << "Yes" << endl;
	else if (b == c)cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
    
using namespace std;
            
    #define ll long long
    #define do long double
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define inf LONG_LONG_MAX
    #define mod 998244353
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


void solve()
{
	ll n,m,i,j,k;
	cin>>n;
	if(n&1)
	cout<<0;
	else
	{
		ll x=5,ans=0;
		while(n/x>0)
		{
			ll c=n/x;
			ans+=(c/2);
			x*=5;
		}
		cout<<ans;
	}

	
}



int main()
{
    FAST
    ll n,m,i,j;
    ll q;
    q=1;

    while(q--)
    	solve();
	

}

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

using namespace std;

int main(){
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  long double d = A * A + B * B;
  d -= 2 * A * B * cos(2 * M_PI * (H / 12 + M / (60 * 12) - M / 60));
  d = sqrt(d);
  
  cout << fixed << setprecision(10) << d << endl;
  
  return 0;
}

Measured memory_bytes: 4168
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;

	return 0;
}

Measured memory_bytes: 3504
#include<iostream>
#include<iomanip> // 出力桁数の調整
using namespace std;

// Problem https://atcoder.jp/contests/abc126/tasks/abc126_c
// Reference http://drken1215.hatenablog.com/entry/2019/05/19/224500_2 桁数の調整
// https://img.atcoder.jp/abc126/editorial.pdf 処理そのものの単純化

int main(void){
    double answer;
    long long N,K;
    answer = 0.0;
    cin >> N >> K ;
    for(long long j=1 ; j <= N ; j++)
    {
        double tmp;
        long long nowC;
        tmp = 1.0/N;
        nowC = j;
        while(nowC<K){
            nowC = nowC * 2;
            tmp = tmp / 2.0;
        }
        answer = answer+tmp;
    }
        
    cout << fixed << setprecision(10) << answer << endl;
    return 0;
}



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

int main()
{
	int N;
	int p[15]={};
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
		cin >> p[i];
	
	sort(p,p+N);
	p[N-1]/=2;
	for(int i=0;i<N;i++)
		ans+=p[i];
	cout << ans << endl;
	return 0;
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL mod = MOD)
{
    if(n < 0) a = fp(a, mod - 2, mod), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % mod) if(n & 1) res = res * a % mod; return res;
}

struct Mint
{
    LL x;
    Mint() {}
    Mint(int _x): x(_x) {}
    Mint(LL _x): x(_x) {}
    Mint operator - () const{
        return Mint(MOD - x);
    }
    Mint operator + (const Mint &rhs) const{
        LL res = x + rhs.x; if(res >= MOD) res -= MOD; return Mint(res);
    }
    Mint operator - (const Mint &rhs) const{
        LL res = x - rhs.x; if(res < 0) res += MOD; return Mint(res);
    }
    Mint operator * (const Mint &rhs) const{
        return Mint(x * rhs.x % MOD);
    }
    Mint operator / (const Mint &rhs) const{
        return Mint(x * fp(rhs.x, -1) % MOD);
    }
    friend ostream& operator << (ostream &out, const Mint &rhs){
        return out << rhs.x;
    }
    friend istream& operator >> (istream &in, Mint &rhs){
        return in >> rhs.x;
    }
};

int n, m;
char s[111][111];
int dp[111][111];

void work()
{
    cin >>n >>m;
    for(int i = 1; i <= n; i++) cin >>(s[i] + 1);

    memset(dp, 0x3f, sizeof(dp));
    dp[1][1] = s[1][1] == '#';

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(i + j != 2)
                dp[i][j] = min(dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'), dp[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));

    cout <<dp[n][m] <<endl;
}


int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

yon=0
ni=0
flag=False
ki=0
# やりかたは 1.2の倍数をセットにして除去 2.余りものを4の横に配置
for a in A:
    if a%4==0:
        yon+=1
    elif a%2==0:
        ni+=1
        flag=True
    else:
        ki+=1

if flag:
    if (ki+1)-yon<=1:
        print("Yes")
    else:
        print("No")
else:
    if (ki-yon)<=1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252