akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 1e5 + 10;
vector<P> G[N];
bitset<100> dp[N];
bool check[N];

bitset<100> rec(int v){
	if (check[v]) return dp[v];
	check[v] = 1;
	bitset<100> &res = dp[v];
	res = 1;

	for (auto e : G[v]){
		res |= rec(e.first) << e.second;
	}
	return res;
}

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


	int V, E, w;
	cin >> V >> E >> w;
	bool canzero = false;
	rep(i, E){
		int s, t, c;
		cin >> s >> t >> c;
		G[t].push_back(MP(s, c));
		if (!c) canzero = true;
	}

	bitset<100> ans;
	rep(i, V) ans |= rec(i);

	string str = ans.to_string();
	reverse(ALL(str));
	str[0] = '0' + canzero;

	for (int i = - w - 1; i >= 0; --i){
		if (str[i] == '1'){
			cout << i + w << endl;
			return 0;
		}
	}
	cout << "NA" << endl;

	return 0;
}


Measured memory_bytes: 12996
#include<stdio.h>
int main(){
    int m,d;
    scanf("%d%d",&m,&d);
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int p=j%10;
            int q=j/10;
            if(p*q==i&&p>=2&&q>=2)
                ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int main(void) {
  long long n, k;
  cin >> n >> k;
  
  vector<int> tele(n);
  for (int i = 0;i < n;i++) {
    cin >> tele[i];
    tele[i]--;
  }
  
  // 周期とoffsetを出す
  vector<int> visited(n, 0);
  int cnt = 0;
  int next_pos = 0;
  while(visited[next_pos] == 0) {
    cnt++;
    visited[next_pos] = cnt;
    next_pos = tele[next_pos];
    if (cnt == k) {
      cout << next_pos+1 << endl;
      return 0;
    }
  }
  int offset = visited[next_pos] - 1;
  int syuuki = cnt - offset;
  
  int ans = (k - offset) % syuuki;
  
  for (int i = 0;i < ans;i++) {
    next_pos = tele[next_pos];
  }
  
  cout << next_pos+1 << endl;
  
  return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
     int h,w;
     cin>>h>>w;
     int cx,cy,dx,dy;
     cin>>cx>>cy>>dx>>dy;cx--;cy--;dx--;dy--;
     string s[h];
     for(int i=0;i<h;i++)cin>>s[i];
     priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> que;
    int x[h][w];
    for(int i=0;i<h;i++)fill(x[i],x[i]+w,MOD*MOD);
    x[cx][cy]=0;
    que.push({0,{cx,cy}});
    while(!que.empty()){
        int p=que.top().first,a=que.top().second.first,b=que.top().second.second;
     
        que.pop();
        if(a==dx&&b==dy){
            cout<<p<<endl;
            return  0;
        }
        if(p>x[a][b])continue;
        if(a>0&& x[a-1][b]>x[a][b]&&s[a-1][b]=='.'){
            x[a-1][b]=x[a][b];
            que.push({x[a-1][b],{a-1,b}});
        }
        if(a<h-1&& x[a+1][b]>x[a][b]&&s[a+1][b]=='.'){
            x[a+1][b]=x[a][b];
            que.push({x[a+1][b],{a+1,b}});
        }
        if(b>0&& x[a][b-1]>x[a][b]&&s[a][b-1]=='.'){
            x[a][b-1]=x[a][b];
            que.push({x[a][b-1],{a,b-1}});
        }
        if(b<w-1&& x[a][b+1]>x[a][b]&&s[a][b+1]=='.'){
            x[a][b+1]=x[a][b];
            que.push({x[a][b+1],{a,b+1}});
        }
        for(int i=-2;i<=2;i++)for(int j=-2;j<=2;j++){
            if(a+i>=0&&a+i<h&&b+j>=0&&b+j<w&&x[a+i][b+j]>x[a][b]+1&&s[a+i][b+j]=='.'){
                x[a+i][b+j]=x[a][b]+1;
            que.push({x[a+i][b+j],{a+i,b+j}});
            }
        }
    }
   
    cout<<-1<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 13476
use std::io::*;
use std::str::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub fn readn<T: FromStr>(n: usize) -> Vec<T> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    (0..n).map(|_| read_from(&mut stdin)).collect()
}

fn main() {
    let n: i32 = read();
    let mut cnt = 0;
    for i in 1..n + 1 {
        if i % 2 == 1 {
            let d = (1..i + 1).filter(|j| i % j == 0).count();
            if d == 8 {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;

int main() {
	int H, A;
	cin >> H >> A;
	cout << ceil(H / double(A)) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
  int h;
  vector<int>hill;

  for(int i=0;i<10;i++){
    cin >> h;
    hill.push_back(h);
  }

  sort(hill.begin(),hill.end(),greater<int>());

  for(int i=0;i<3;i++)
    cout << hill[i] << endl;

  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0;i<(n);i++)
int inf = 1000000000;
ll INF = 1000000000000000000;
int n, m, a[55], b[55], w[55][55];
void reset() {
	rep(i, n) {
		rep(j, n) {
			w[i][j] = inf;
		}
	}
	rep(i, m) {
		w[a[i]][b[i]] = 1;
		w[b[i]][a[i]] = 1;
	}
}
int main() {
	cin >> n >> m;
	int ans = 0;
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		w[a[i]][b[i]] = 1;
		w[b[i]][a[i]] = 1;
	}
	rep(d, m) {
		reset();
		w[a[d]][b[d]] = inf;
		w[b[d]][a[d]] = inf;
		rep(k, n) {
			rep(i, n) {
				rep(j, n)w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
			}
		}
		rep(i, n) {
			rep(j, n) {
				if (w[i][j] == inf) {
					ans++;
					goto age;
				}
			}
		}
	age:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int Lsearch(int[],int,int);
int main(){
  int i,j,n,A[10000+1],sum=0,key;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  

  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%d",&key);
    if(Lsearch(A,n,key))sum++;
  }
  printf("%d\n",sum);
  return 0;
}

int Lsearch(int A[], int n, int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)i++;
  if(i==n)return 0;
  else return 1;
}
 

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;





int main()
{
	int n;
	int a[10000], b[10000];
	while (cin >> n,n) {
		int A = 0; 
		int B = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i] >> b[i];
		}
		for (int i = 0; i < n; i++) {
			if (a[i] > b[i]) A += a[i] + b[i];
			else if (a[i] < b[i]) B += a[i] + b[i];
			else {
				A += a[i];
				B += b[i];
			}
		}
		cout << A << " " << B << endl;
	}
}

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

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll N, K, ANS, B, C;
vector<ll> A;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> N >> K;
    A.resize(N);
    for (auto& item : A) cin >> item;
    return true;
}

void solve() {
    for (ll i = 0; i < N - 1; i++) {
        for (ll j = i + 1; j < N; j++) {
            if (A[i] > A[j]) {
                B++;
            }
        }
    }

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            if (i == j) continue;
            if (A[i] < A[j]) C++;
        }
    }

    ANS += (B * K) % MOD;
    ANS += (C * (((K - 1) * K / 2) % MOD)) % MOD;
    ANS %= MOD;
}

void output() {
    cout << ANS % MOD << endl;
}

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

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

int N;
int a[100];
int b[100];
int c[100];

signed main() {
  cin >> N;
  rep (i, N) {
    cin >> a[i];
  }
  rep (i, N) {
    cin >> b[i];
  }

  int ans = 0;
  rep (i, N) {
    chmax(ans, ans + a[i] - b[i]);
  }

  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
print(100, 100)
G = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]
for i in range(B - 1):
    G[(i // 50) * 2][(i % 50) * 2] = '#'
for i in range(A - 1):
    G[~((i // 50) * 2)][~((i % 50) * 2)] = '.'
for i in range(100):
    print(''.join(G[i]))

Measured memory_bytes: 9264
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<ll> H(N+1);
  H.at(0)=0;

  int ans=0;
  int temp_ans=0;
  for(int i=0;i<N;++i){
    cin >> H.at(i+1);
    if(H.at(i)>=H.at(i+1)){
      ++temp_ans;
    }
    else{
      ans=max(ans,temp_ans);
      temp_ans=0;
    }
  }

  ans=max(ans,temp_ans);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	int sum;
	sum = 100 * a + 10 * b + c;
	if (sum % 4 == 0)
	{
		cout << "YES"<<endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


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

const ll INF = ll(1e18)+1;

int main()
{
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> ra(n);
    rep(i,n) {
        ll x; cin >> x;
        a[i] = x; ra[i] = x;
    }
    sort(a.begin(), a.end());    //  a ... 小さい順
    sort(ra.rbegin(), ra.rend()); // ra ... 大きい順
    
    ll l = -INF; ll r = INF;
    // x = かけた数の境界線
    while(l+1 <r) {
        ll x = (l+r)/2;
        // 2つの数をかけてx未満になる数がk個未満か？
        bool ok = [&]{
            ll tot = 0;
            // ペアの内、1個を固定
            // ペアとなれる相方の数を、2分探索で調べていく.
            rep(i,n) {
                if( a[i] >= 0) {
                    // 固定した数が正の数なら、小さい順に見ていけばいい。
                    ll l = -1; ll r = n;
                    while(l+1<r) {
                        ll c =(l+r)/2;
                        if (a[c]*a[i] < x) l = c; else r = c;
                    }
                    tot += r;
                } else {
                    // 固定した数が負なら、大きい順に見ていく。
                    ll l = -1; ll r = n;
                    while(l+1<r) {
                        ll c = (l+r)/2;
                        if (ra[c]*a[i] < x) l = c; else r = c;
                    }
                    tot += r;
                }
                // カウント対象に自分自身との積が入っていれば、除いておく
                if (a[i] * a[i] < x) --tot;   
            }
            // 順序区別の重複があるので半分に
            tot /= 2;
            return tot < k;
        }();
        if (ok) l = x;
        else r = x;

    }

    cout << l << endl;

    return 0;
}

Measured memory_bytes: 3328
def main():
    n = input()
    aa = map(int, raw_input().split())
    x = 1
    y = 0
    for a in aa:
        x, y = -x, a - y
    start = y / (1 - x)
    ans = [start]
    for a in aa[:-1]:
        ans.append(a - ans[-1])
    print ' '.join(map(lambda x: str(x * 2), ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 51112
// AOJ 0271: Izua Dictionary
// 2017.10.7 bal4u@uu

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

#define M 1000000007
#define MAX 100000

long long f[MAX+3];
int ord[MAX+3];

// BIT library
int bit[MAX+3]; int n;
int sum(int i)
{
	int s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i)
{
	while (i <= n) {
		bit[i]++;
		i += i & -i;
	}
}

int main()
{
	int r, i, s, t, a;
	long long ans;

	f[0] = f[1] = 1; for (i = 2; i <= MAX; i++) f[i] = (f[i-1]*i) % M;
	
	while (scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) ord[i] = i;
		scanf("%d", &r);
		for (i = 0; i < r; i++) {
			scanf("%d%d", &s, &t);
			a = ord[s-1], ord[s-1] = ord[t-1], ord[t-1] = a;
		}
		memset(bit, 0, sizeof(bit));
		for (ans = 0, i = 0; i < n; i++) {
			a = ord[i];
			ans = (ans + (a - sum(a+1)) * f[n-i-1]) % M;
			add(a+1);
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3304
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << endl;
#else
#define DBG(X)
#define endl '\n'
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	ll n, a, b;
	cin >> n >> a >> b;

	cout << min(n * a, b) << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
using namespace std;
const int N = 2e5 + 1;
int n;
long long f[N], g[N];
int a[N];
priority_queue<pair<int, int>>h;
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n  ; i ++)
        scanf("%d", &a[i]);
    f[1] = 1;
    long long t = 0;
    for (int i = 2; i <= n ; i ++)
    {
        long long y = a[i] * -2;
        long long x = a[i - 1] * -2;
        f[i] = f[i - 1] + 1;
        int sum = 1;
        while (x > y)
        {
            while (!h.empty()  && h.top().first == -t)
            {
                sum += h.top().second;
                h.pop();
            }
            t += 1;
            f[i] += 2 * sum;
            x *= 4;
        }
        int z = 0;
        while (x <= y * 4){
            z ++;
            y *= 4;
        }
        t -= z;
        h.push(make_pair(-(t + z) ,sum));
    }
    while (!h.empty())h.pop();
    t = 0;
    for (int i = n - 1; i  ; i --)
    {
        long long y = a[i];
        long long x = a[i + 1];
        g[i] = g[i + 1];
        int sum = 1;
        while (x < y)
        {
            while (!h.empty()  && h.top().first == -t)
            {
                sum += h.top().second;
                h.pop();
            }
            t += 1;
            g[i] += 2 * sum;
            x *= 4;
        }
        int z = 0;
        while (x >= y * 4){
            z ++;
            y *= 4;
        }
        t -= z;
        h.push(make_pair(-(t+z) ,sum));
    }
    long long ans = min(g[1], f[n]);
    for (int i = 1; i < n ; i ++)
        ans = min(ans, f[i] + g[i + 1]);
    printf("%lld\n", ans);
  /*  for (int i = 1; i <= n ; i++)
        printf("%lld ", f[i]);
    printf("\n");
    for (int i = 1; i <= n ; i ++)
        printf("%lld ", g[i]);
    printf("\n");*/
    return 0;
}

Measured memory_bytes: 5872
#include "bits/stdc++.h"
using namespace std;
int Array[200005];

int main(){
    int N , i , j , length = 0;
    scanf( "%d" , &N );

    for( i = 1 ; i <= N ; ++i )
        scanf( "%d" , Array + i );

    i = j = 1;

    while( i <= N ){
        if( Array[i] == j ){
            ++j;
        }

        ++i;
    }

    length = N - ( j - 1 );
    if( length == N ) length = -1;
    printf( "%d\n" , length );
    return 0;
}

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

string txt[101]={},bf;
int kx,ky,x;

void A(){kx=0;}
void E(){kx=txt[ky].size();}
void P(){
	if(ky)ky--;
	A();
}
void N(){
	if(x-1!=ky)ky++;
	A();
}
void F(){
	if(kx!=txt[ky].size())kx++;
	else if(kx==txt[ky].size()&&x-1!=ky)N();
}
void B(){
	if(kx)kx--;
	else if(!kx&&ky){
		ky--;
		E();
	}
}
void D(){
	if(kx!=txt[ky].size()){
		txt[ky]=txt[ky].substr(0,kx)+txt[ky].substr(kx+1);
	}
	else if(kx==txt[ky].size()&&ky!=x-1){
		txt[ky]+=txt[ky+1];
		for(int i=ky+1;i<x;i++)txt[i]=txt[i+1];
		txt[x]="";
		x--;
	}
}
void K(){
	if(kx==txt[ky].size()&&x-1!=ky){
		D();
		bf="\n";
	}
	else if(kx!=txt[ky].size()){
		bf=txt[ky].substr(kx);
		txt[ky]=txt[ky].substr(0,kx);
	}
}
void Y(){
	if(bf=="\n"){
		//txt[ky+1]=txt[ky].substr(kx)+txt[ky+1];
		//txt[ky]=txt[ky].substr(0,kx);
		//if(ky+1==x)x++;
		string next = txt[ky].substr(kx);
		txt[ky]=txt[ky].substr(0,kx);
		x++;
		for(int i = x - 1; i >= ky + 2; i--)
			txt[i] = txt[i - 1];
		txt[ky + 1] = next;
		N();
	}
	else if(bf!=""){
		txt[ky]=txt[ky].substr(0,kx)+bf+txt[ky].substr(kx);
		kx+=bf.size();
	}
}

int main(){
	string s;
	kx=ky=x=0; bf="";
	while(getline(cin,s),s!="END_OF_TEXT")txt[x++]=s;
	while(cin>>s,s!="-"){
		if(s=="a")A();
		if(s=="e")E();
		if(s=="p")P();
		if(s=="n")N();
		if(s=="f")F();
		if(s=="b")B();
		if(s=="d")D();
		if(s=="k")K();
		if(s=="y")Y();
#if 0
		cerr << "ROW: " << ky << "COL: " << kx << endl;
		for(int i = 0; i < x; i++) cerr << txt[i] << endl;
#endif
	}
	for(int i=0;i<x;i++)cout<<txt[i]<<endl;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
long long cur;
bool ok;
char tmp[5];
int main(){
	cur = 1;
	ok = 0;
	for(int i = 0 ; i < 11 ; ++i){
		cout << "? " << cur << endl;
		fflush(stdout);
		cin >> tmp;
		if(tmp[0] == 'N'){
			ok = 1;
			cur /= 10;
			break;
		}
		cur *= 10;
	}
	if(!ok){
		cur = 10;
		for(int i = 0 ; i < 11 ; ++i){
			cout << "? " << cur - 1 << endl;
			fflush(stdout);
			cin >> tmp;
			if(tmp[0] == 'Y'){
				break;
			}
			cur *= 10;
		}
		cur /= 10;
	}
	else{
		long long l = cur;
		long long r = cur * 10 - 1;
		while(l < r){
			long long mid = l + r >> 1;
			cout << "? " << mid * 10 << endl;
			fflush(stdout);
			cin >> tmp;
			if(tmp[0] == 'Y'){
				r = mid;
			}
			else{
				l = mid + 1;
			}
		}
		cur = l;
	}
	cout << "! " << cur << endl;
	fflush(stdout);
}

Measured memory_bytes: 684
def main():
    n = int(input())
    pieces = list(map(lambda x: int(x), input().split()))
    m = int(input())
    operations = list(map(lambda x: int(x), input().split()))
    res = {}
    ans = []

    for i in range(2019):
        res[i] = 0

    for i in pieces:
        res[i - 1] = 1

    for i in operations:
        piece = pieces[i - 1]
        if piece >= 2019:
            continue
            
        if res[piece] == 1:
            pass
        else:
            res[piece - 1] = 0
            res[piece] = 1
            if (pieces[i - 1] + 1) < 2019:
                pieces[i - 1] += 1

    for i in range(2019):
        if res[i] == 1:
            print(i + 1)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5772
#include<stdio.h>
#define INF 1000000000
void MST(int);

int edge[101][101],v[101],d[101],sum=0,n,count;

int main(void){

  int m,a,b,i,j, cost;

  while(1){
      count=0;
      scanf("%d",&n);
      if(n==0)break;

      scanf("%d",&m);

      for(i=0;i<101;i++){
	  for(j=0;j<101;j++){
	      edge[i][j]=INF;
	    }
	}

      for(i=0;i<m;i++){
	scanf("%d,%d,%d",&a,&b,&cost);
	edge[a][b]=cost;
	edge[b][a]=cost;
	 }

      for(i=0;i<101;i++){
	d[i]=INF;
	v[i]=0;
      }

      d[0]=0;
      sum = 0;
      MST(0);

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

  return 0;
}

void MST(int u)
{
  int x=0,i;

  while(1){
    int minv=INF;

    for(i=0;i<n;i++){
      if(v[i]==0 &&  d[i]<minv){
	//d[i]=edge[x][i];
	x=i;
	minv=d[i];
      }
    }
    if(minv==INF)break;  

    v[x]=1;
    if ( x != u ) sum+=(d[x]/100-1);
    
    for(i=0;i<n;i++){
      if ( v[i] ) continue;
      d[i]=min(d[i],edge[x][i]);
    }
  }
}

int min(int x,int y)
{
  return x < y ? x : y;
 }

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t hh, ww, h, w;
  std::cin >> hh >> ww;
  std::cin >> h >> w;
  std::cout << (hh-h) * (ww - w) << std::endl;
  return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll> hash(n);
  for(i=0;i<m;i++){
    cin>>buf;
    hash[buf]=1;
  }
  vector<ll> dp(n+1);
  dp[0]=1;
  for(i=1;i<=n;i++){
    if(hash[i]!=1){
      dp[i]+=dp[i-1];
      dp[i]%=MOD;
      if(i>=2)dp[i]+=dp[i-2];
      dp[i]%=MOD;
    }
    //cout<<dp[i]<<endl;
  }
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL G[10][10];

int main(void)
{
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < 10; ++i)
		for (int j = 0; j < 10; ++j)
			cin >> G[i][j];
	for (int k = 0; k < 10; ++k)
		for (int i = 0; i < 10; ++i)
			for (int j = 0; j < 10; ++j)
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
	LL ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int a;
			cin >> a;
			if (a >= 0) {
				ans += G[a][1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;


void solve() {
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<int> sum(n+1), tum(m+1);
    sum[0] = tum[0] = 0;
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i] + (s[i]-'A'+1);
    }
    for (int i = 0; i < m; i++) {
        tum[i+1] = tum[i] + (t[i]-'A'+1);
    }

    int q; cin >> q;
    while (q--) {
        int x,y,u,v;
        cin >> x >> y >> u >> v;
        bool res = (sum[y]-sum[x-1]) % 3 == (tum[v]-tum[u-1]) % 3;
        cout << (res?"YES\n":"NO\n");
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1744
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin >> s;
    while(s[0]!='A') s.erase(0,1);
    while(s[s.size()-1]!='Z') s.erase(s.end()-1);
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 720
# A
N = int(input())
A_list = list(map(int, input().split()))

cumsum_list = list()
cumsum_dict = dict()
r = 0
for a in A_list:
    r += a
    if r not in cumsum_dict.keys():
        cumsum_dict[r] = 0
    cumsum_dict[r] += 1
    cumsum_list.append(r)
res = 0
if 0 in cumsum_dict.keys():
    res += cumsum_dict[0]
    
for i in range(N):
    r = cumsum_list[i]
    cumsum_dict[r] -= 1
    res += cumsum_dict[r]
    
print(res)

Measured memory_bytes: 39544
N, M = map(int, input().split())
E0 = []
for i in range(M):
    S, D, C = map(int, input().split())
    E0.append((C, S-1, D-1))
E0.sort()

*parent, = range(N)
def root(x):
    if x == parent[x]:
        return x
    y = parent[x] = root(parent[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px < py:
        parent[py] = px
    else:
        parent[px] = py
cnt = 0; base = None
for i in range(M):
    C, S, D = E0[i]
    if root(S) != root(D):
        unite(S, D)
        cnt += 1
        if cnt == N-1:
            base = C
ES = {}; CM = {}
for i in range(M):
    C, S, D = E0[i]
    if C <= base:
        ES.setdefault(C, set()).add((S, D))
        CM[S, D] = C
def bridge(G, N):
    result = set()
    label = [None]*N
    gen = 0
    cost = [0]*N
    def dfs(u, p):
        nonlocal gen
        res = 0
        for v in G[u]:
            if v == p:
                continue
            if label[v] is not None:
                if label[v] < label[u]:
                    cost[v] += 1
                    res += 1
            else:
                label[v] = gen; gen += 1
                r = dfs(v, u)
                if r == 0:
                    result.add((u, v) if u < v else (v, u))
                res += r
        res -= cost[u]
        return res
    for v in range(N):
        if not label[v]:
            label[v] = gen; gen += 1
            r = dfs(v, -1)
            assert r == 0, r
    return result
G = [[] for i in range(N)]
cnt = 0; ans = 0
for C in sorted(ES):
    for S, D in ES[C]:
        G[S].append(D)
        G[D].append(S)
    B = bridge(G, N)
    cnt += len(B & ES[C])
    ans += len(B & ES[C]) * C
print(cnt, ans)

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

using namespace std;

int main() {
	int n = 0;
	string str;
	cin >> n;
	cin >> str;
	string strA = str.substr(0, n/2);
	string strB = str.substr(n/2);
	if (strA == strB) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}

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

int main() {
    int n;
    cin >>n;
    vector<string> w;
    string ret = "Yes", tmp;
    char last_c;

    // first one
    cin >> tmp;
    w.push_back(tmp);
    last_c = tmp.at(tmp.size()-1);

    // main
    for (int i = 1; i < n; i++) {
        cin >> tmp;

        if ( tmp.at(0) != last_c ) {
            ret = "No";
        }

        // double check
        if ( find(w.begin(), w.end(), tmp) != w.end() ) {
            ret = "No";
        }

        // good word
        last_c = tmp.at(tmp.size()-1);
        w.push_back(tmp);
    }
    cout << ret << endl;
    return 0;
}

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

using namespace std;

int nwd(int a, int b)
{
    int c;
    while (b != 0)
    {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n, x, y;
    cin >> n >> x >> y;
    vector< vector<int> > dp(401, vector<int>(401, -1));
    for (int i = 0; i < n; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        vector< vector<int> > t(401, vector<int>(401, 1e9));
        t[a][b] = c;
        for (int j = 1; j < 401; ++j)
            for (int k = 1; k < 401; ++k)
                if (dp[j][k] != -1 && j + a < 401 && k + b < 401)
                    t[j + a][k + b] = min(t[j + a][k + b], dp[j][k] + c);
        for (int j = 1; j < 401; ++j)
            for (int k = 1; k < 401; ++k)
                if ((dp[j][k] == -1 && t[j][k] != -1) || (dp[j][k] != -1 && t[j][k] != -1 && dp[j][k] > t[j][k]))
                    dp[j][k] = t[j][k];
    }
    int odp = 1e9;
    for (int i = 1; i < 401; ++i)
        for (int j = 1; j < 401; ++j)
            if (dp[i][j] != -1 && i / nwd(i, j) == x && j / nwd(i, j) == y)
                odp = min(odp, dp[i][j]);
    if (odp != 1e9)
        cout << odp;
    else
        cout << "-1";
    return 0;
}


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

int main()
{
	int n,a[100];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	sort(a,a+n);
	int A=0,B=0;
	for(int i=n-1;i>=0;i-=2) A+=a[i];
	for(int i=n-2;i>=0;i-=2) B+=a[i];
	
	cout<<A-B<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="hi")
	{
		cout<<"Yes";
		return 0;
	}
	if(s=="hihi")
	{
		cout<<"Yes";
		return 0;
	}
	if(s=="hihihi")
	{
		cout<<"Yes";
		return 0;
	}
	if(s=="hihihihi")
	{
		cout<<"Yes";
		return 0;
	}
	if(s=="hihihihihi")
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

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

int isPrime[MAX];

void eratos() {
  isPrime[0] = isPrime[1] = true;
  for (int i = 2; i * i <= MAX - 1; i++) {
    for (int j = i + i; j < MAX; j += i) {
      isPrime[j] = false;
    }
  }
}

void init() {
  for (int i = 0; i < MAX; i++) {
    isPrime[i] = true;
  }
}

int main() {
  init();
  eratos();

  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    
    if (isPrime[n] == true) {
      cout << 0 << endl;
      continue;
    }
    int prev, next;
    for (int i = n - 1; ; i--) {
      if (isPrime[i] == true) {
	prev = i;
	break;
      }
    }
    for (int i = n + 1; ; i++) {
      if (isPrime[i] == true) {
	next = i;
	break;
      }
    }
    cout << next - prev << endl;
  }
}

Measured memory_bytes: 8052
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
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;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}




string T;

int main () {
  cin >> T;
  int n = T.size();

  Rep(i, n) {
    if (T[i] == '?') T[i] = 'D';
  }

//  int ans = 0;
//
//  Rep(i, n) {
//    if (T[i] == 'D') ans++;
//    if (i != n-1 && T[i] == 'P' && T[i+1] == 'D') ans++;
//  }
//
//  cout << ans << "\n";

  cout << T << "\n";

} 

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
LL n,data[100010],sum,mx=-1,f1=0,f2=0;
int main(void)
{
	int i,j;
	cin>>n;
	for(i=0;i<n;i++) cin>>data[i];
	sort(data,data+n);
	for(i=n-1;i>=3;i--) {
		if(data[i]==data[i-1]&&data[i]==data[i-2]&&data[i]==data[i-3]) {
			sum=data[i]*data[i];
			mx=max(mx,sum);
			break;
		}
		if(data[i]==data[i-1]&&data[i-3]==data[i-2]) {
			sum=data[i]*data[i-2];
			mx=max(mx,sum);
			break;
		}
	}		
	for(i=n-1;i>=1;i--) {
		if(data[i]==data[i-1]&&f1==0) f1=data[i];
		else if(data[i]==data[i-1]&&f2==0&&f1!=data[i]) f2=data[i];
		if(f1!=0&&f2!=0) {
			mx=max(mx,f1*f2);
			cout<<mx<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
}
	

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val N = nextInt()
    val A = Array(N) { nextInt() }
    val (first, second) = A.sortedDescending()
    val ans = IntArray(N) { if (A[it] == first) second else first }
    println(ans.joinToString("\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 59352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % 2019; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % 2019;
	if (k != 0)rip(i, k)j = j * a % 2019;
	return(j);
}
int main() {
	int n, l;
	cin >> n >> l;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	int maxx = 0;
	int k = 0;
	rip(i, n - 1) {
		maxx = max(maxx, a[i] + a[i + 1]);
		if (maxx ==a[i] + a[i + 1])k = i;
	}
	if (maxx < l)cout << "Impossible" << endl;
	else {
		k++;
		cout << "Possible" << endl;
		for (int i = 1; i < k; i++)cout << i << endl;
		for (int i = n - 1; i > k; i--)cout << i << endl;
		cout << k << endl;
	}
}

Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

func main() {
	w := readFloat64()
	h := readFloat64()
	x := readFloat64()
	y := readFloat64()

	b := 0
	if 2*x == w && 2*y == h {
		b = 1
	}
	fmt.Println(w*h/2, b)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#define ll long long
using namespace std;
int main(){
 string s;
 string t;
 ll cou=0;
 cin>>s>>t;
    for (ll i = 0; i <s.size() ; ++i) {
        if(s[i]==t[i]){ continue; }
        else{
          cou++;
        }
    }
    cout<<cou;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
ll MOD;
//ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int N;
int A[19],B[19];
bool flag=false;
int main(){
	cin>>N;
	int ans=N*N;
	rep(i,N)cin>>A[i];
	rep(i,N)cin>>B[i];
	rep(ii,(1<<N)){
		int hoge[20]={0};
      
		int temp=ii;
		int now=0;
		while(temp){
			hoge[now]=temp%2;
			temp/=2;
          	now++;
		}
	 	vi fuga[55];
		int piyo[20];
		rep(i,N){
			if(hoge[i]==0)piyo[i]=A[i];
			else piyo[i]=B[i];
			fuga[piyo[i]].pb((hoge[i]+i)%2);
		}
		bool check=true;
		int rank=0;
		for(int i=1;i<=50;i++){
			int sz=fuga[i].size();
			// rank~rank+sz-1の偶数の数==fuga[i]内の偶数の数？
			int cnt=0;
			int cnt2=(rank+sz+1)/2 - (rank+1)/2;
			rep(j,sz){
				if(fuga[i][j]==0)cnt++;
			}
			if(cnt!=cnt2){
              //cout<<cnt<<" "<<cnt2<<endl;
					check=false;
            }
			rank+=sz;
		}
		if(check){
			flag=true;
			/*rep(i,N)cout<<hoge[i];
			cout<<endl;*/
			int ans2=0;
			rep(i,N){
				for(int j=i+1;j<N;j++){
					if(piyo[i]>piyo[j])ans2++;
				}
			}
			int rank=0;
			for(int num=1;num<=50;num++){
				int nowe=0,nowo=0;
				int sz=fuga[num].size();
				int cnte=0;
				int cnto=0;
				rep(j,fuga[num].size()){
					int x=fuga[num][j];
					if(x==0){
						cnte++;
						int want=cnte-1;
						if(rank%2==1)want+=1;
						ans2+=max(0,want-cnto);
					}else{
						cnto++;
						int want=cnto-1;
						if(rank%2==0)want+=1;
						ans2+=max(0,want-cnte);
					}
				
				}
				rank+=sz;
			}
			ans=min(ans,ans2);
		}


	}
	if(flag){
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int hour1, hour2, min1, min2, t, wake = 0, sleep = 0;
	scanf("%d %d %d %d %d", &hour1, &min1, &hour2, &min2, &t);
	
	wake = (hour1 * 60) + min1;
	sleep = (hour2 * 60) + min2;
	
	if((sleep - wake) > t) {
		printf("%d", sleep - wake - t);
	} else {
		printf("0");
	}
		
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >>a>>b;
  int h;
  char w ='A';
  vector<vector<string>> s(a,vector<string>(b));
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin >> s.at(i).at(j);
      if( s.at(i).at(j)=="snuke"){
        h= i+1;
        w +=j;
      }
    }
  }
  cout << w<<h;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n;
	cin >> n;
	int arr[n] = {0};
	arr[0] = 0;
	int tmp, prev, diff=0;
	cin >> prev;
	REP(i, 1, n){
		cin >> tmp;
		if(tmp > prev) arr[i] = 1;
		else if(tmp < prev) arr[i] = -1;
		else arr[i] = 0;
		
		if(diff == 0) diff = arr[i];
		prev = tmp;
	}
	int ans = 0;
	REP(i, 1, n){
		if(diff == 0)diff=arr[i];
		else if(diff != arr[i] && arr[i] != 0){
			diff = arr[i+(i==n-1?0:1)];
			++ans;
		}
	}
	cout << ans+1;
	

}


Measured memory_bytes: 640
K = int(input(""))

import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)

num_range = [int(x) for x in range(1, K+1)]

val = 0

for a in num_range:
    for b in num_range:
        for c in num_range:
            val = val + gcd(a, b, c)

print(val)

Measured memory_bytes: 69428
/*
Author- Aasav Badera
Time- Sat Sep 19 17:16:21 2020
*/
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma") 
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL  
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc      
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n' 
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];


int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
    	string s;
    	cin >> s;
    	if(s[sz(s) - 1] == 's')s += "es";
    	else s += 's';
    	cout << s;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

Measured memory_bytes: 3624