akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int n,x,y; cin>>n>>x>>y;
    vector <tuple<int,int,int>> data(n);
    rep(i,n) {int a,b,c; cin>>a>>b>>c; data[i] = make_tuple(a,b,c);}
    vector<vector<vector<int>>> dp (50, vector<vector<int>>(510, vector<int>(510, INF)));
    dp[0][0][0] = 0;
    rep(i,n){
            for(int k=0;k<=400;k++){
                for(int l=0;l<=400;l++){
                    if(dp[i][k][l] == INF) continue;
                    chmin(dp[i+1][get<0>(data[i]) + k][get<1>(data[i]) + l],dp[i][k][l] + get<2>(data[i]));
                    chmin(dp[i+1][k][l],dp[i][k][l]);
                }
            }
    }
    int ans = INF;
    int multiply = 2;
    int nowx=x, nowy=y;
    while(nowx<=409&&nowy<=409){
        rep(i,n+5) {chmin(ans, dp[i][nowx][nowy]); }
        nowx = x*multiply, nowy = y*multiply;
        multiply++;
    }
    if(ans == INF) cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 104960
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
L = [[False, 0] for i in range(N)]
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == "WA":
        if not L[p - 1][0]:
            L[p-1][1] += 1
    elif S == "AC":
        if not L[p - 1][0]:
            L[p-1][0] = True

AC = 0
PN = 0
for i in range(N):
    if L[i][0]:
        AC += 1
        PN += L[i][1]
print(AC, PN)


Measured memory_bytes: 17828
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<string>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
using namespace std;

signed main() {
	int a, b; cin >> a >> b;
	vector<int>c;
	for (int d = 0; d < a; d++) {
		int e; cin >> e;
		c.push_back(e);
	}
	sort(c.begin(), c.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < b; i++) {
		ans += c[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int H;
  int A;
  int P;
  int Y;
  scanf("%d",&H);
  scanf("%d",&A);
  P=H/A;
  Y=H%A;
  if(Y!=0){
    P=P+1;
  }
  printf("%d",P);
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        X: i64,
        A: i64,
        B: i64,
    }
    if A>=B{
        println!("delicious");
    }else if B-A <= X{
        println!("safe");
    }else{
        println!("dangerous");
    }
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

const int MOD = 1e9 + 7;
inline int mod (int a, int m = MOD) { return (a % m + m) % m; }

int modfact(int n){
    int a = 1;
    rep(i,n) a = a * (i+1) % MOD;
    return a;
}

signed main(){
    int n, m;
    cin >> n >> m;
    
    if(abs(n - m) <= 1){
        int ans = modfact(n);
        ans = mod(ans * modfact(m));
        ans = mod(ans * (abs(n-m) ? 1 : 2));
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}

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

#define llint long long int

using namespace std;

int main(){
    int N, K;

    cin >> N >> K;

    vector<int> p(N);

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

    for(int i = 0; i < K - 1; i ++){
        sum += p[i];
    }
    llint max = 0;

    for(int i = K - 1; i < N; i ++){
        sum += p[i];

        if(sum > max){
            max = sum;
        }
        sum -= p[i - K + 1];
    }
    cout << fixed;
    cout << setprecision(1) << 0.5 * (max + K) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int n, p[500], cnt=0, i=0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> p[i];
    }
    for(i=0;i<n;i++){
        if(p[i]!=(i+1)) cnt++;
    }

    if(cnt<=2) cout << "YES" <<endl;
    else cout << "NO" <<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int t = scan.nextInt();
		int show =x-t;
		if(show<=0) {
			show=0;
		}
		System.out.println(show);
	}

}


Measured memory_bytes: 23760
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=1,r=1e9,m;
    int ans=1e9;
    while(r>=l)
    {
        m=(l+r)/2;
        int cnt=0;
        for(int i=0;i<n;i++)
        {
            int z=a[i]+m-1;
            z=z/m;
            z--;
            cnt+=z;
        }
        if(cnt<=k)
        {
            ans=m;
            r=m-1;
        }
        else
            l=m+1;
        
    }
    cout<<ans<<endl;
    
    
    
}

int32_t main()
{
    IOS;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        
        solve();
    }
    return 0;
}


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

/* constant */

#define MAX_C	(15)
#define MAX_D	(30)
#define MAX_W	(50)
#define MAX_X	(5)

/* typedef */

/* global variables */

static int es[MAX_C][MAX_D];
static int fs[MAX_C][MAX_D];
static int dp[MAX_D + 1][MAX_W + 1][MAX_X + 1];

/* subroutines */

/* main */

int main(int argc, char **argv) {
  int c, d, i, j, k, r, w, x;
  int dp0, dp1, dpijk, j0, j1, r1;
  int max_dp, dpdjk;
  
  for (;;) {
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &w);
    scanf("%d", &x);

    if ((c | d | w | x) == 0) break;

    for (i = 0; i < c; i++)
      for (j = 0; j < d; j++)
	scanf("%d", &(es[i][j]));

    for (i = 0; i < c; i++)
      for (j = 0; j < d; j++)
	scanf("%d", &(fs[i][j]));

    for (i = 0; i <= d; i++)
      for (j = 0; j <= w; j++)
	for (k = 0; k <= x; k++)
	  dp[i][j][k] = -1;
    dp[0][0][0] = 0;

    for (i = 0; i < d; i++)
      for (j = 0; j <= w; j++)
	for (k = 0; k <= x; k++) {
	  dpijk = dp[i][j][k];
	  if (dpijk < 0) continue;

	  if (dp[i + 1][j][k] < dpijk) dp[i + 1][j][k] = dpijk;

	  for (r = 0; r < c; r++) {
	    if (es[r][i] == 0) continue;
	    j0 = j + fs[r][i];
	    if (j0 <= w) {
	      dp0 = dpijk + es[r][i];
	      if (dp[i + 1][j0][k] < dp0) dp[i + 1][j0][k] = dp0;

	      if (k == x) continue;

	      dp1 = dp0;
	      j1 = j0;

	      for (r1 = r + 1; r1 < c; r1++) {
		if (es[r1][i] == 0) break;
		dp1 += es[r1][i];
		j1 += fs[r1][i];
		if (j1 > w) break;
		if (dp[i + 1][j1][k + 1] < dp1) dp[i + 1][j1][k + 1] = dp1;
	      }

	      dp1 = dp0;
	      j1 = j0;

	      for (r1 = r - 1; r1 >= 0; r1--) {
		if (es[r1][i] == 0) break;
		dp1 += es[r1][i];
		j1 += fs[r1][i];
		if (j1 > w) break;
		if (dp[i + 1][j1][k + 1] < dp1) dp[i + 1][j1][k + 1] = dp1;
	      }
	    }
	  }
	}

    max_dp = 0;
    for (j = 0; j <= w; j++)
      for (k = 0; k <= x; k++) {
	dpdjk = dp[d][j][k];
	if (max_dp < dpdjk) max_dp = dpdjk;
      }

    printf("%d\n", max_dp);
  }

  return 0;
}

Measured memory_bytes: 640
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define S second
#define F first
using namespace std;

const ll N = 2e5 + 5, M = 1e6 + 5;

int arr[N], B[N], C[N];
set<pair<int, int> > ss;
vector<pair<int, int> > v;

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0 ; i < n ; i++) scanf("%d", arr + i);
    sort(arr, arr + n);
    for(int i = 0 ; i < n ; i++)
    {
        if(v.empty()) v.emplace_back(arr[i], 1);
        else if(arr[i] == v.back().F) v[v.size() - 1].S++;
        else v.emplace_back(arr[i], 1);
    }
    for(int i = 0 ; i < m ; i++) scanf("%d%d", B + i, C + i);
    for(auto i:v) ss.emplace(i);
    for(int i = 0 ; i < m ; i++)
    {
        int c = B[i];
        while(c > 0)
        {
            auto it = ss.begin();
            if(it->F < C[i])
            {
                int mn = min(c, it->S);
                c -= mn;
                if(mn == it->S) ss.erase(it);
                else
                {
                    int val = it->F, freq = it->S - mn;
                    ss.erase(it);
                    ss.emplace(val, freq);
                }
                auto search = ss.lower_bound({C[i], 0});
                if(search == ss.end() or search->F > C[i]) ss.emplace(C[i], mn);
                else
                {
                    int val = search->F, freq = search->S + mn;
                    ss.erase(search);
                    ss.emplace(val, freq);
                }
            }
            else break;
        }
    }
    ll sum = 0;
    for(auto i:ss) sum += 1LL * i.F * i.S;
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 9848
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int a;
	cin >> a;
	int b;
	cin >> b;

	string s1,s2;
	for (int i = 0; i < b; i++)
		s1.append(to_string(a));

	for (int i = 0; i < a; i++)
		s2.append(to_string(b));

	if (s1 > s2)
		cout << s2;
	else
		cout << s1;
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("03")
#pragma GCC target("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
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<string> vs;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define sz(x) (ll)(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 ins insert
#define nl "\n"
 
const int mod=10e7+7;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vi a(n);
	for(int i=0;i<n;i++) {
		cin >> a[i];
	}
	if(n%2==1) {
		for(int i=n-1;i>=0;i-=2) {
			cout << a[i] << " ";
		}
		for(int i=1;i<n;i+=2) {
			cout << a[i] << " ";
		}
		return 0;
	}
	for(int i=n-1;i>=0;i-=2) {
		cout << a[i] << " ";
	}
	for(int i=0;i<n;i+=2) {
		cout << a[i] << " ";
	}
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int main(){
  char s[200000];
  cin >> s;
  int c=0;
  int n=strlen(s);
  for(int i=0;i<n;i++){
    if(s[i]=='0')c++;
  }
  cout << 2*min(c,n-c);
}


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

using namespace std;
	long long n;int m;
long long yu[200100];
long long sum[200100];
int pos[200100];
int hs = -1;
int he = -1;
int main(){
	scanf("%lld%lld%d",&n,&yu[1],&m);//printf("~~~\n"); 
	for(int i = 0;i<=m;i++){
		pos[i]=-1;
	}
	pos[yu[1]]=1;sum[1] = yu[1];
	for(int i = 2;i <= m+1;i++){
		yu[i] = yu[i-1]*yu[i-1]%m;
		if(pos[yu[i]]==-1){
			pos[yu[i]]=i;
		} else {
			if(hs == -1) {
				hs = pos[yu[i]];
				he = i-1;
			} else {
				
			}
		}
		sum[i]=sum[i-1]+yu[i];
	}
	if(n<=m+1){
		printf("%lld\n",sum[n]);
		return 0;
	}
	
	long long ans = 0;
	
//	printf("%d  %d %d~%d\n",hs,he,yu[hs],yu[he+1]);
	ans = sum[hs-1];
	n-=hs-1;
	ans+=(n/(he-hs+1))*(sum[he]-sum[hs-1]);
	ans+=sum[hs-1+(n%(he-hs+1))]-sum[hs-1];
	printf("%lld\n",ans);
}

Measured memory_bytes: 5712
#include <stdio.h>
#include <string.h>

int main(){
  char palavra[101];
  scanf("%s", palavra);
  int cont = 0;

  int n = strlen(palavra);
  int x = n/2;
  --n;

  for(int i = 0; i < x; ++i){
    if(palavra[i] != palavra[n]){
      ++cont;
    }
    --n;
  }
  printf("%d\n", cont);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>

using ll = long long;
using namespace std;

const int MOD = 1e9+7;

int main() {
    string s,t,u = "A",v;
    bool g = false;
    cin >> s >> t;
    for(int i = s.length() - t.length(); i >= 0; i--) {
        bool match = true;
        for (int j = 0; j < t.length(); j++) {
            if (s[i + j] != t[j] && s[i + j] != '?') {
                match = false;
                break;
            }
        }
        if (match) {
            for(int k = 0; k < t.length(); k++)
            {
                s[i + k] = t[k];
            }
            for(int j = 0; j < s.length(); j++)
            {
                if (s[j] == '?') s[j] = 'a';
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int c[3][3];
    for(int i=0;i<3;i++)cin >> c[i][0] >> c[i][1] >> c[i][2];

    int diff[2];
    diff[0] = c[0][0] - c[0][1];
    diff[1] = c[0][1] - c[0][2];
    for(int i=1;i<3;i++){
        if(c[i][0]-c[i][1]!=diff[0]){
            cout << "No" << endl;
            return 0;
        }
        if(c[i][1]-c[i][2]!=diff[1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

B = [A[0]]
for i in range(N):
    if A[i]%A[0] != 0:
        B.append(A[i]%A[0])
B = set(B)
#B = sorted(B,reverse = False) 

#import math
import fractions
from functools import reduce

def gcd_list(numbers):
    #return reduce(math.gcd, numbers)
    return reduce(fractions.gcd, numbers)

print(gcd_list(B))

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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


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

    ll n;

    cin >> n;

    map<string,ll> a;

    for(ll i=0; i<n; i++){
        string key;
        cin >> key;
        a[key] = 0;
    }

    cout << a.size() << endl;

    return 0;
}

Measured memory_bytes: 19216
/*
 * main.cpp
 *
 *  Created on: 2020/04/09
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

int main(){
	int X, Y, Z;
	cin >> X >> Y >> Z;

	for(int i = 0;;i++){
		int lim_length = (Y + Z) * i + Z;
		if(lim_length > X){
			cout << i-1 << endl;
			break;
		}
	}

	return 0;
}




Measured memory_bytes: 256
#include<cstdio>

#define  N 1000005

using namespace std;

int a[N],vis[N],i,n;
int main()
{
       scanf("%d",&n);
       for (i=1;i<=n;++i) scanf("%d",&a[i]);
       for (i=n;i>=1;i-=2) vis[i]=1,printf("%d ",a[i]);
       for (i=1;i<=n;++i) if (!vis[i]) printf("%d ",a[i]);
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<P,P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

//-----------------------------------------------------------------------------

string s,t="AKIHABARA";

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

	cin>>s;
	if(s[0]!='A') s.insert(0,"A");
	if(s.size()>=4&&s[4]!='A') s.insert(4,"A");
	if(s.size()>=6&&s[6]!='A') s.insert(6,"A");
	if(s.size()>=8&&s[8]!='A') s.insert(8,"A");

	if(s==t) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = INT_MAX;
  for (int i = 0; i <= S.size() - T.size(); i++) {
    int tmp = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S.at(i + j) != T.at(j)) tmp++;
    }
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
//const int mod = 1e9+9;
/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
*void exEuclid(int a, int b){
	if(b==0){x = 1; y=0; d=a; return ;}
	exEuclid(b, a%b);
	int x1=y;
	int y1=x-(a/b)*y;
	x=x1; 100000
	y=y1;
} 
* */
//===========================================================//
int n;
const int nx = 1e5+5;
int ac[nx][3];
int dp[3][nx];
int go(int a, int i){
	if(i == n) return 0;
	if(dp[a][i] != -1) return dp[a][i];
	int& ans = dp[a][i];
	
	if(a==0){
		ans=max(ans, go(1, i+1)+ac[i][0]);
		ans=max(ans, go(2, i+1)+ac[i][0]);
	}
	if(a==1){
		ans=max(ans, go(0, i+1)+ac[i][1]);
		ans=max(ans, go(2, i+1)+ac[i][1]);
	}
	if(a==2){
		ans=max(ans, go(0, i+1)+ac[i][2]);
		ans=max(ans, go(1, i+1)+ac[i][2]);
	}
	
	return ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>ac[i][0]>>ac[i][1]>>ac[i][2];
	memset(dp, -1, sizeof dp);
	cout<<max(go(0,0),max(go(1,0),go(2,0)))<<"\n";
	return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>

int main(){
  int c,i,j,l,m[4],n;
  while(scanf("%d\n",&n),n!=0){
    c=0;
    if(n%1111>0){
      while(n!=6174){
        for(i=0;i<3;i++){ m[i]=n%10; n=n/10; }
        m[3]=n;

        for(i=0;i<3;i++){
          for(j=i;j<4;j++){
            if(m[i]>m[j]){l=m[i];m[i]=m[j];m[j]=l;}
          }
        }
        n=(m[3]-m[0])*999+(m[2]-m[1])*90;
        c++;
      }
      printf("%d\n",c);
    } else {
      printf("NA\n");
    }
  }
  return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

template< class Abel > struct UnionFind {
  vector< int > par;
  vector< int > rank;
  vector< Abel > diff_weight;
  
  UnionFind(int n = 1, Abel SUM_UNITY = 0) {
    init(n, SUM_UNITY);
  }

  void init(int n = 1, Abel SUM_UNITY = 0) {
    par.resize(n); rank.resize(n), diff_weight.resize(n);
    for(int i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      diff_weight[i] = SUM_UNITY;
    }
  }
  
  int root(int x) {
    if (par[x] == x) return x;
    // 累積和をとる
    int r = root(par[x]);
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = r;
  }

  Abel weight(int x) {
    // 経路圧縮をする
    root(x);
    return diff_weight[x];
  }

  Abel diff(int x, int y) {
    return weight(y) - weight(x);
  }

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

  // weight(x) - weight(y) = wとなるようにmerge
  bool merge(int x, int y, Abel w) {
    // xとyそれぞれについてrootとの重み付き補正
    w += weight(x); w -= weight(y);
    x = root(x); y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if (rank[x] == rank[y]) {
      ++rank[x];
    }
    par[y] = x;

    // xがyの和になるので、xとyの差分をdiff_weight[y]に記録
    diff_weight[y] = w;
    return true;
  }

  // templateですよ！！！
  
};

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

  CIN(N, Q);
  UnionFind< int > uf(N + 1);

  REP(qi, Q) {
    CIN(c);
    if (c == 0) {
      CIN(x, y, w);
      // merge
      uf.merge(x, y, w);
    } else {
      // judge
      CIN(x, y);
      if (!uf.issame(x, y)) {
	cout << "?" << endl;
      } else {
	cout << uf.diff(x, y) << endl;
      }
    }
  }
  
  return 0;
}




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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w; cin >> h >> w;
    string g[h];

    int dist[h][w]; memset(dist, -1, sizeof dist);
    queue<ii> q;
    FOR(i,0,h-1){
        cin >> g[i];
        FOR(j,0,w-1){
            if (g[i][j] == '#') q.emplace(ii(i,j)), dist[i][j] = 0;
        }
    }

    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, 1, 0, -1};
    int ans = 0;
    while (!q.empty()) {
        int y = q.front().fi, x = q.front().sc; q.pop();
        ans = max(ans, dist[y][x]);

        FOR(i,0,3){
            int ny = y + dy[i], nx = x + dx[i];
            if (ny >= 0 && ny < h && nx >= 0 && nx < w && dist[ny][nx] == -1){
                dist[ny][nx] = dist[y][x] + 1;
                q.emplace(ny, nx);
            }
        }
    }
    cout << ans << '\n';
}



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

using namespace std;
typedef long long ll;

int n; 

void rec(vector<vector<int>>& v, vector<int> value, int digit) {

    if (digit == n) {
        v.push_back(value);
        return;
    }

    value.push_back(-1);
    for (int i = 1; i <= n ; i++) {
        bool t = true;
        for (int j = 0; j < digit; j++) {
            t &= (value[j] != i) ;
        }
        if (!t) continue;
        value[digit] = i;
        rec(v, value, digit+1);
    }
}


int main() {
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }

    vector<vector<int>> v(0, vector<int>());
    rec(v, {}, 0);
    int a, b;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] == p) a = i;
        if (v[i] == q) b = i;
    }
    cout << abs(a-b) << endl;
}







Measured memory_bytes: 3256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,k;
    cin >> n >> k;
    bool a[n];
    REP(i,n) a[i]=true;
    REP(i,k){
        int d;
        cin >> d;
        REP(j,d){
            int t;
            cin >> t;
            a[t-1]=false;
        }
    }
    int cnt=0;
    REP(i,n) if(a[i]) cnt++;
    cout << cnt;
    return 0;
}

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

int a[1000];
int main(){
    memset(a, 0, sizeof(a));
    string s;
    cin >> s;
    for(register int i = 0; i < 4; ++i){
        ++a[s[i]];
    }
    for(register int i = 0; i < 4; ++i){
        if(a[s[i]] != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  int n;
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin >> a.at(i).at(j);
    }
  }
  cin >> n;
  int b;
  for (int i=0; i<n; i++) {
    cin >> b;
    for (int j=0; j<3; j++) {
      for (int k=0; k<3; k++) {
        if (a.at(j).at(k) == b) {
          a.at(j).at(k) = 0;
          break;
        }
      }
    }
  }
  bool flag = false;
  for (int i=0; i<3; i++) {
    if (a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0) flag = true;
    else if (a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0) flag = true;
  }
  if (a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0) flag = true;
  if (a.at(0).at(2) == 0 && a.at(1).at(1) == 0 && a.at(2).at(0) == 0) flag = true;
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int a,b;
    int d;
    int r;
    double f;
    
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = double(a) / double(b);
    cout << d << " " << r << " "; 
    printf("%.8lf\n", f);
    return 0;
}

Measured memory_bytes: 3224
main :: IO ()
main = do
   interact solve
solve :: String -> String
solve i =
  case compare a b of
    LT -> "a < b\n"
    EQ -> "a == b\n"
    GT -> "a > b\n"
  where a = (read $ (words i) !! 0) :: Int
        b = (read $ (words i) !! 1) :: Int

Measured memory_bytes: 3572
import java.util.Scanner;
public class Main {

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

		int a = scan.nextInt();
		int b = scan.nextInt();

		System.out.println(a*b);

	}

}

Measured memory_bytes: 35872
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define sys system("PAUSE")
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, m, ans = 1;
signed main() {
	cin >> n >> m;
	for (int i = m / n;; i--) {
		if (m%i == 0) {
			cout << i << endl;
			sys;
			return 0;
		}
	}
	sys;
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef unsigned long long ull;
const ull INF = ull(1e+18);

void mul(string s, ull& ans, bool& flag)
{
    ull k = 1, tmp=ans;
    ans = 0;
    for(int i=s.size()-1;i>=0;--i)
    {
        ans += (s[i] - '0') * k * tmp;
        if(ans > INF)
        {
            ans = 0;
            flag = true;
            break;
        }
        k *= 10;
    }
}

int main()
{
    int n;
    cin >> n;
    vector<string> array(n);
    for(int i=0;i<n;++i) cin >> array[i];
    ull ans = 1;
    bool flag = true;
    for(int i=0;i<n;++i)
    {
        if(array[i] == "0")
        {
            flag = false;
            break;
        }
    }
    if(flag){
        flag = false;
        for(int i=0;i<n;++i) {
            mul(array[i], ans, flag);
            if(ans == 0) break;
        }
        if(flag) cout << -1 << endl;
        else cout << ans << endl;
    }
    else{
        cout << 0 << endl;
    }
}



Measured memory_bytes: 11176
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int long long
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


const int nax = 1e5 + 5;
const int INF = 1e15;
int dp[105][nax];
int w[105], v[105];
int N, W;

void input() {
	cin >> N >> W;
	FOR (i, 1, N) {
		cin >> w[i] >> v[i];
	}

	FOR (i, 0, 104) {
		FOR (j, 0, nax - 1) {
			dp[i][j] = -1;
		}
	}
}

int calc(int i, int j) {
	if (i <= 0 && j > 0) return INF;
	if (i <= 0) return 0;
	if (j <= 0) return 0;

	if (dp[i][j] != -1) return dp[i][j];

	int ret = INF;

	ret = min(calc(i - 1, j), ret);
	ret = min(calc(i - 1, j - v[i]) + w[i], ret);

	return (dp[i][j] = ret);
}

void solve() {
	for (int j = nax - 1; j >= 0; --j) {
		if (calc(N, j) <= W) {
			cout << j;
			return;
		}
	}
}

signed main() {
#ifdef _DEBUG
	// freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

Measured memory_bytes: 82304
n,c,k=map(int,input().split())
t=[int(input()) for _ in [0]*n]
t.sort()
t=t+[0]
b=1
h=0
d=t[0]
for i in range(n):
  if(h<c and t[i]-d<=k):
    h+=1
  else:
    b+=1
    h=1
    d=t[i]
print(b)

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

MOD = 2019  # type: int


def solve(L: int, R: int):
    list_lr_mod = []
    ans = 2018

    if R - L >= 2018:
        print(0)
        return

    for i, x in enumerate(range(L, R + 1)):
        xmod = x % MOD
        if xmod == 0:
            print(0)
            return
        else:
            list_lr_mod.append(xmod)


    for i in range(len(list_lr_mod) - 1):
        for j in range(i + 1, len(list_lr_mod)):
            tmp = list_lr_mod[i] * list_lr_mod[j]
            ans = min(ans, tmp % MOD)

    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n, x_l = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)
tmp = (x + [x_l]).sort
diff = 1_000_000_000
(0..(tmp.length - 2)).each do |i|
  d = (tmp[i] - tmp[i + 1]).abs
  diff = d if d < diff
end

(0..diff).each do |i|
  a = diff - i
  r = x_l % a
  if x.all? { |e| e % a == r }
    puts a
    break
  end
end

Measured memory_bytes: 11776
#include <iostream>
#include <string>
long sc(long long x, long long y) {
	if (x < y) {
		int z = x;
		x = y;
		y = z;
	}
	if (x%y==0) return(y);
	return(sc(y, x%y));
}
using namespace std;
int main()
{	
	long long n, m,a,b,c;
	string s,t;
	cin >> n;
	cin >> m;
	getline(cin, s);
	getline(cin, s);
	getline(cin, t);
	c = sc(n,m);
	a = m / c;
	b = n / c;
	for (long long i = 0; i < n; i++) {
		if ((i*a) % b == 0) {
			if (s[i] != t[(i*a) / b]) {
				cout << -1;
				return 0;
			}
		}
	}
  	a=a*n;
	cout << a;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
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; }

int main()
{
  string str;
  int Q;
  cin >> str >> Q;

  string front;
  string back;
  bool is_re = false;
  for (int i = 1; i <= Q; ++i) {
    int j = Q - i;
    int t;
    cin >> t;
    if (t == 1) {
      is_re = !is_re;
    } else {
      int f; char c;
      cin >> f >> c;

      if (f == 1 && !is_re || f == 2 && is_re) {
        front.push_back(c);
      } else {
        back.push_back(c);
      }
    }
  }

  if (is_re) {
    reverse(str.begin(), str.end());
    reverse(back.begin(), back.end());
    cout << back + str + front << endl;
  } else {
    reverse(front.begin(), front.end());
    cout << front + str + back << endl;
  }

  return 0;
}


Measured memory_bytes: 1348
#include<stdio.h>
#include<string.h>

int main(){
  int n ,ans[100], agari, i, j, ap, bp;
  char a[1000], b[1000];
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%s%s", a, b);
    if(strlen(a) > 80 || strlen(b) > 80){
      puts("overflow");
      continue;
    }
    ap = strlen(a) - 1;
    bp = strlen(b) - 1;
    j = 0;
    agari = 0;
    while(ap >= 0 || bp >= 0){
      ans[j] = agari;
      if(ap >= 0)ans[j] += a[ap] - '0';
      if(bp >= 0)ans[j] += b[bp] - '0';
      agari = ans[j] / 10;
      ans[j] %= 10;
      j++;
      ap--;
      bp--;

    }
    if(agari == 1)ans[j] = 1;
    else j--;
    if(j >= 80){
      puts("overflow");
      continue;
    }
    for(;j >= 0;j--){
      printf("%d", ans[j]);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < m; j++) {
      if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < abs(a[i] - c[ans]) + abs(b[i] - d[ans])) ans = j;
    }
    cout << ans+1 << endl;
  }
}


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

using namespace std;

class Timer {
    clock_t start;
    string name;
public:
    Timer() {name = "";start = clock();}
    Timer(string s){name = s;start = clock();}
    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
};

#define sq(a) ((a) * (a))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl
#define setbitj(n, j) (n |= (1 << (j)))
#define isbitjOn(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)
#define safeMod(a, m) ((((a)%(m))+(m))%(m))/*handling negative sign of remainder*/

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const double EPS = 1e-9;
const int INF = 0x7fffffff;
const double PI = acos(-1.0);
const int MAX = 100005;
const int MOD = 1000000007;
const int precision = 10;

inline bool isEq(double a, double b){return abs(a - b) < EPS;}
inline bool isEq(double a, double b, double eps){return abs(a - b) < eps;}
inline double toRad(double deg){return deg*PI/180;}
inline double toDeg(double rad){return rad*180/PI;}

//#define isValid(a, b) (a >= 0 && a < b)
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};
typedef complex<double> Point;
typedef complex<double> Vector;

int main(int argc, char* argv[])
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    int x, y;
    cin >> x >> y;
    Point A(x, y);
    cin >> x >> y;
    Point B(x, y);

    Vector AB = B-A;
    AB = AB*polar(1.0, PI/2);
    Point D = A + AB;

    Vector BA = A-B;
    BA = BA*polar(1.0, -PI/2);
    Point C = B + AB;
    cout << fixed << setprecision(0) << C.real() << " " << C.imag() << " " << D.real() << " " << D.imag() << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)

V_MAX = int(1e05)+1


def main():
    # sys.stdin = open("sample.txt")
    N, W = Scanner.map_int()
    V = [Scanner.map_int() for i in range(N)]
    dp = [[INF for _ in range(V_MAX)] for _ in range(N+1)]
    dp[0][0] = 0

    for i in range(N):
        for j in range(V_MAX):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j - V[i][1]] + V[i][0])
    ans = 0
    for i in range(V_MAX):
        if dp[N][i] <= W:
            ans = i
    print(ans)
    return


if __name__ == "__main__":
    main()


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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
	if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void  solve()
{
	string a,b;
	cin>>a>>b;
	int r,bb;
	cin>>r>>bb;
	string s;
	cin>>s;
	//cout<<r<<" "<<bb<<endl;
	if(s==a)r--;
	else bb--;
	cout<<r<<" "<<bb<<endl;
}


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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int x;
    string str;

    vector<int> vOperand;

    while (cin >> str) {
        if (str == "+") {
            if ((int)vOperand.size() >= 2) {
                int& a1 = vOperand.back();
                vOperand.pop_back();
                int& a2 = vOperand.back();
                vOperand.pop_back();

                vOperand.push_back(a2+a1);
            }
        }
        else if (str == "-") {
            if ((int)vOperand.size() >= 2) {
                int& a1 = vOperand.back();
                vOperand.pop_back();
                int& a2 = vOperand.back();
                vOperand.pop_back();

                vOperand.push_back(a2 - a1);
            }
        }
        else if (str == "*") {
            if ((int)vOperand.size() >= 2) {
                int& a1 = vOperand.back();
                vOperand.pop_back();
                int& a2 = vOperand.back();
                vOperand.pop_back();

                vOperand.push_back(a2 * a1);
            }
        }
        else {
            x = atoi(str.c_str());
            vOperand.push_back(x);
        }
    }

    if (!vOperand.empty()) {
        cout << vOperand.at(0) << endl;
    }

    return 0;
}


Measured memory_bytes: 3216
using namespace std;

#include <iostream>
#include <vector>
#include <cmath>

typedef long long ll;

int N, M;
bool edge[50][50];
bool reach[50];
int cnt;

void dfs(int node) {
  cnt++;
  reach[node] = true;
  for (int i = 0; i < N; i++) {
    if (edge[node][i] && !reach[i]) {
      dfs(i);
    }
  }
}

int main() {
  cin >> N >> M;
  memset(edge, 0, sizeof(edge));
  memset(reach, 0, sizeof(reach));
  vector<pair<int, int>> P(M);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    edge[x-1][y-1] = true;
    edge[y-1][x-1] = true;
    P[i] = make_pair(x-1, y-1);
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int x = P[i].first, y = P[i].second;
    edge[x][y] = false;
    edge[y][x] = false;
    memset(reach, 0, sizeof(reach));
    cnt = 0;
    dfs(0);
    if (cnt < N) ans++;
    
    edge[x][y] = true;
    edge[y][x] = true;
  }
  
  cout << ans << endl;
  return 0;
  
  
}

Measured memory_bytes: 256