akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static int[] Accumulate(IList<int> a) { var s = new int[a.Count + 1]; for (var i = 0; i < a.Count; i++) s[i + 1] = s[i] + a[i]; return s; }
	const int MOD = 1000000007;
	public K()
	{
		var N = G[0];
		var A = G;
		var sum = Accumulate(A, 0, (a, b) => a ^ b);
		var zero = Accumulate(sum.Select(t => t == 0 ? 1 : 0).ToList());
		Func<IList<int>, int[]> getZero = l => MakeArray(l.Count - 1, i => zero[l[i + 1]] - zero[l[i]]);
		var dic = Indexes(sum);
		if (sum[N] != 0) WriteLine(DP(getZero(dic[sum[N]])).Last());
		else
		{
			var ans = Pow(2, zero[N + 1] - 2, MOD);
			foreach (var t in dic) if (t.Key != 0) ans = (ans + DP(getZero(t.Value)).Sum()) % MOD;
			WriteLine(ans % MOD);
		}
	}
	static Dictionary<int, List<int>> Indexes(IList<int> x)
	{
		var dic = new Dictionary<int, List<int>>();
		for (var i = 0; i < x.Count; i++)
		{
			if (!dic.ContainsKey(x[i])) dic[x[i]] = new List<int>();
			dic[x[i]].Add(i);
		}
		return dic;
	}
	static long[] DP(IList<int> zs)
	{
		var L = zs.Count;
		var dp = new long[L + 1];
		dp[0] = 1;
		var sum = 1L;
		for (var j = 0; j < L; j++)
		{
			dp[j + 1] = (dp[j] + zs[j] * sum % MOD) % MOD;
			sum = (sum + dp[j + 1]) % MOD;
		}
		return dp;
	}
	public static long Pow(long a, long b, long mod)
	{
		long p = 1L, x = a;
		while (b > 0)
		{
			if ((b & 1L) == 1L) p = p * x % mod;
			b >>= 1;
			x = x * x % mod;
		}
		return p;
	}
}


Measured memory_bytes: 73348
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> g(n);
  V<> deg(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v, --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
    ++deg[u];
    ++deg[v];
  }
  V<> d(n);
  auto dfs = [&](const auto& dfs, int v, int p) -> void {
    for (int w : g[v]) if (w != p) {
      d[w] = d[v] + 1;
      dfs(dfs, w, v);
    }
  };
  d[0] = 0;
  dfs(dfs, 0, -1);
  int x = max_element(begin(d), end(d)) - begin(d);
  d[x] = 0;
  dfs(dfs, x, -1);
  int y = max_element(begin(d), end(d)) - begin(d);
  V<> prev(n);
  auto ndfs = [&](const auto& ndfs, int v, int p) -> void {
    prev[v] = p;
    if (v == y) return;
    for (int w : g[v]) if (w != p) {
      ndfs(ndfs, w, v);
    }
  };
  ndfs(ndfs, x, -1);
  V<> vs;
  while (true) {
    vs.push_back(y);
    if (y == x) break;
    y = prev[y];
  }
  int m = vs.size();
  {
    V<> lr;
    for (int v : vs) lr.push_back(deg[v]);
    auto rl = lr;
    reverse(begin(rl), end(rl));
    if (lr > rl) {
      reverse(begin(vs), end(vs));
    }
  }
  V<bool> b(n);
  for (int v : vs) b[v] = true;
  for (int v = 0; v < n; ++v) if (!b[v] and deg[v] >= 2) {
    return cout << -1 << '\n', 0;
  }
  for (int i = 1; i < m - 1; ++i) --deg[vs[i]];
  V<> res;
  int t = 1;
  for (int v : vs) {
    deque<int> deq;
    for (int _ = 0; _ < deg[v]; ++_) {
      deq.push_back(t++);
    }
    deq.push_back(deq[0]);
    deq.pop_front();
    res.insert(end(res), begin(deq), end(deq));
  }
  for (int i = 0; i < n; ++i) {
    cout << res[i] << " \n"[i == n - 1];
  }
}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}

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

int main() {
  use_cio();
  int n, m;
  cin >> n >> m;
  int lo = 1, hi = n;
  rep(i, m) {
    int l, r;
    cin >> l >> r;
    lo = max(l, lo);
    hi = min(hi, r);
  }
  if (lo > hi)
    cout << 0;
  else
    cout << hi - lo + 1;
}


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

#define FOR(i, a, b) for(int i=a; i<b; i++)
typedef long long ll;
typedef vector<int> vi;

bool **grid;
int *dp[21];
int n, c=1000000007;

int find(int x, int l){
    if(x==n){
        return 1;
    }
    if(dp[x][l]>=0)
        return dp[x][l];
    int ans=0;
    FOR(i, 0, n){
        if(grid[x][i] && (l&(1<<i))==0){
            ans=(ans+find(x+1, l|(1<<i)))%c;
        }
    }
    dp[x][l]=ans;
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin>>n;
    grid= new bool*[n];
    FOR(i, 0, n){
        grid[i]= new bool[n];
        FOR(j, 0, n){
            cin>>grid[i][j];
        }
        dp[i]=new int[1<<21];
        memset(dp[i], -1, sizeof(int)*(1<<21));
    }
    cout<<find(0, 0);
    return 0;
}

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

int main() {
  int N, a, i, cnt = 0, m = 0;
  cin >> N;
  for(i = 0; i < N; i++) {
    cin >> a;
    if(a == 0) {
      m = max(m, cnt);
      cnt = 0;
    }else{
      cnt++;
    }
  }
  m = max(m, cnt);
  cout << m + 1 << endl;
  return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    string s;
    cin>>s;
    if(n%2)cout<<"No";
    else{bool ok=1;
        f(i,0,n/2){
            if(s[i]!=s[i+n/2]){ok=0;break;}
        }
        if(ok)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}   

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// 10:43
int main(){
	std::ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	if(N%K==0){
		cout << 0;
	}else{
		cout << N-K;
	}
}

 


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

const int mod = 1e9+7;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	vector<int> dp(k+1), v(n);
	for (int i=0; i<n; ++i){
		cin >> v[i];
	}
	dp[0] = 1;
	for (int i=0; i<n; ++i){
		vector<int> psum(k+1);
		psum[0] = dp[0];
		for (int j=1; j<=k; ++j){
			psum[j] = dp[j];
			psum[j] += psum[j-1];
			psum[j] %= mod;
		}
		for (int j=0; j<=k; ++j){
			int sum = psum[j];
			if (j-v[i]-1 >= 0) sum -= psum[j-v[i]-1];
			dp[j] = sum%mod;
		}
	}
	int ans = dp[k];
	cout << (ans+mod)%mod << '\n';
	return 0;
}


Measured memory_bytes: 4760
#include<stdio.h>
#define MAX 131072
typedef struct _task{
    char name[11];
    int time;
} task;
task Q[MAX];
int head, tail;
void initialize();
void enq(task);
task deq();
int isFull();
int isEmpty();
int main(void){
    int i, q, N, time_passed = 0;
    task t;
    scanf("%d %d", &N, &q);
    for(i = 0; i < N; i++){
        scanf("%s %d", t.name, &t.time);
        enq(t);
    }
    while(!(isEmpty())){
        t =deq();
        if(t.time <= q){
            time_passed += t.time;
            printf("%s %d\n", t.name, time_passed);
        } else {
            t.time -= q;
            time_passed += q;
            enq(t);
        }
    }

    return 0;
}
void initialize(){
    head = 0;
    tail = 0;
    return;
}
int isFull(){
    return (head + 1) % MAX == tail;
}
int isEmpty(){
    return head == tail;
}
void enq(task data){
    if(isFull()){
        printf("queue.overflow");
        return;
    }
    Q[head] = data;
    if(head == MAX - 1){
        head = 0;
    } else head++;
    return;
}
task deq(){
    task error_return; 
    task t;   

    if(isEmpty()){
        printf("queue.nodata");
        return error_return;
    }
    t = Q[tail];
    if(tail == MAX - 1){
        tail = 0;
    } else tail++;
    return t;
}



Measured memory_bytes: 3900
let m = 1000000007
let ( +^ ) x y = (x + y) mod m

module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let as_ =
    IntSet.of_list @@
    Array.to_list @@
    Array.init m @@ fun _ ->
      Scanf.scanf "%d\n" @@ fun a -> a in
  let dp = Array.make (n + 1) 0 in
  dp.(0) <- 1;
  dp.(1) <- if IntSet.mem 1 as_ then 0 else 1;
  for i = 2 to n do
    dp.(i) <-
      if IntSet.mem i as_
      then 0
      else dp.(i - 1) +^ dp.(i - 2)
  done;
  Printf.printf "%d\n" @@ dp.(n)

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

using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0 ;i < n ;i++)
        cin >> a[i];

    if (n&1) {
        cout << 0;
        return 0;
    }

    sort(a.begin() , a.end());

    cout << a[n / 2] - a[n / 2 - 1];
}

Measured memory_bytes: 640
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int D;
	cin >> D;
	cout << "Christmas";
	for (int i = 0; i < 25 - D; i++) {
		cout << " Eve";
	}
	cout << endl;

	return(0);
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void Dump(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void PushBack(T& v) {
    auto x = 0;
    cin >> x;
    v.push_back(x);
}

template<class T>
void RandomAccess(const T& v) {
    auto x = 0;
    cin >> x;
    cout << v[x] << endl;
}

template<class T>
void PopBack(T& v) {
    v.pop_back();
}

int main() {
    ll p;
    cin >> p;

    list<ll> li;
    auto     iter = li.begin();
    REP(i, p) {
        int query;
        cin >> query;
        if (query == 0) {
            int x;
            cin >> x;
            li.insert(iter, x);
            --iter;
        } else if (query == 1) {
            int d;
            cin >> d;
            advance(iter, d);
        } else if (query == 2) {
            iter = li.erase(iter);
        } else cout << "Error: query is not correct\n";
    }

    Dump(li);
    return 0;
}



Measured memory_bytes: 18636
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

long long  abssum(int n,int a[],int b)
{
  long long sum=0;
  for(int i=0;i<n;i++){
    if(a[i]>b){
      sum+=(a[i]-b);
    }else{
      sum+=(b-a[i]);
    }
  }
  return sum;
}
int main()
{
  int n;
  cin>>n;
  int a[200100];
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]-=i+1;
  }
  sort(a,a+n);

  long long ans=abssum(n,a,a[n/2]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
#define PI 3.1415926535897932
using namespace std;
typedef long long ll;

const ll MOD=1000000007;

ll powmod(ll x, ll y){
	ll res=1;
	rep(i,y){
		res=res*x%MOD;
	}
	return res;
}

int main(){
	long long N;
	cin>>N;

	long long ans = powmod(10,N) - powmod(9,N)-powmod(9,N) + powmod(8,N);
	ans%=MOD;
	ans=(ans+MOD)%MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 3472
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

ll D;
ll c[26+1];
ll s[365+1][26+1];

ll last[365+1];

int main(){
    cin>>D;
    repn(i,26) cin>>c[i];
    repn(i,D) repn(j,26) cin>>s[i][j];

    //ll v=0;
    repn(d,D){
        ll maxi=0;
        ll k=0;
        repn(i,26){
            if(maxi<=s[d][i]){
                maxi=s[d][i];
                k=i;
            }
        }
        k=rand()%26+1;
        //cout<<idx<<':'<<maxi<<endl;
        //v+=maxi;
        //last[k]=d;
        //repn(i,26) v-=c[i]*(d-last[i]);
        cout<<k<<endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll n;
    cin >> n;

    pair<ll, ll> p[n];
    rep(i,n)
    {
    	ll a,b;
    	cin >> a >> b;
    	p[i] = mp(b,a);
    }

    sort(p,p+n);

    ll time = 0;
    rep(i,n)
    {
    	time = time + p[i].ss;
    	if(time>p[i].ff)
    	{
    		cout << "No" << endl;
    		return 0;
    	}
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;
int main(){
    Int l,r;
    cin >> l >> r;
	Int ans = 1e9;
	if(l+2018 <= r){
		ans = 0;
	}else{
		for(Int i=l; i<r; ++i)
			for(Int j=i+1; j<=r; ++j)
				ans = min(ans, i*j%2019);
	}
	cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    char c;
    scanf("%c", &c);

    if(c == 'A')
        puts("T");
    if(c == 'C')
        puts("G");
    if(c == 'T')
        puts("A");
    if(c == 'G')
        puts("C");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k;
	cin >> n >> k;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];

	bool valid = true;

	for (i = k; i < n; i++) {
		if (a[i] <= a[i - k]) cout << "No\n";
		else cout << "Yes\n";
	}

	return 0;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
ll s;

ll f(ll n){
  if(n%2==0) return n/2;
  else return 3*n+1;
}
int main(){
  cin >> s;
  map<ll,ll> m;
  m[s] = 1;
  ll prev = s;
  FOR(i,2,1000001){
    prev = f(prev);
    if(m[prev] > 0){
      cout << i << endl;
      return 0;
    }
    m[prev]++;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
lis = list(map(int,input().split()))
num = 0
for i in range(n-1):
    num = lis[i] * 2 - num
x = (lis[-1] * 2-num) // 2

ans = [str(x)]

for i in range(n-1):
    ans.append(str(lis[i]*2-int(ans[-1])))
print(" ".join(ans))

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int k, a, b; cin >> k >> a >> b;
  for (int i = a; i <= b; i++){
    if (i % k == 0) return cout << "OK", 0;
  }
  cout << "NG";
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n, k;
  cin >> n >> k;

  int h[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  vector<int> dp(n + 10, INF);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  cout << dp[n - 1] << endl;

  return 0;
}

Measured memory_bytes: 1024
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
int main()
{
    int a, b, c, d, sum=0;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if(a>b)
    {
        sum=b*c+((a-b)*d);
    }
    else if(a<=b)
    {
        sum=a*c;
    }
    printf("%d", sum);
}


Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int h1,h2;
    int m1,m2;
    int k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h = h2-h1;
    int m;
    if(m1>m2){
        h--;
        m = 60-m1+m2;
    }else{
        m = m2-m1;
    }
    cerr << h << "\t" << m << endl;
    cout << h*60+m-k << endl;
    return 0;
}


Measured memory_bytes: 3624
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    H, W = in_nn()
    _ = in_n()
    a = in_nl()
    a = [(i + 1, t) for i, t in enumerate(a)]

    ans = [[0 for _ in range(W)] for _ in range(H)]

    for y in range(H):
        for x in range(W):
            if y % 2 == 1:
                x = W - x - 1
            c, num = a[-1]
            ans[y][x] = c
            if num - 1 == 0:
                a.pop(-1)
            else:
                a[-1] = (c, num - 1)

    for s in ans:
        print(' '.join(map(str, s)))


if __name__ == '__main__':
    main()


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

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

  string X; cin >> X;
  string ans = "Yes";
  if (X == "AAA" || X == "BBB") ans = "No";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
# include <iostream>

int main() {
    int five = 0;
    int seven = 0;

    for (int i = 0; i < 3; i++) {
        int v;
        std::cin >> v;
        if (v == 5) {
            five++;
        } else if (v == 7) {
            seven++;
        } else {
            std::cout << "NO";
        }
    }

    if (five == 2 && seven == 1) std::cout << "YES";
    else std::cout << "NO";
}


Measured memory_bytes: 3596
//Name: Long Distance Taxi
//Level:
//Category:
//Note:

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <array>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define TIMES(i,n) for(int i = 0; i < (n); ++i)

typedef long long LL;
const LL INF = 3000LL*200*2000;

struct Dict {
    map<string,int> dict;

    int get(const string &str) {
        if(dict.count(str)) return dict[str];
        const int idx = dict.size();
        return dict[str] = idx;
    }
};

map<int,LL> search_path(int from, map<int,vector<pair<int,LL>>> &graph) {
    priority_queue<pair<LL,int>> q;
    map<int,LL> memo;
    q.push(make_pair(0, from));
    memo[from] = 0;
    while(!q.empty()) {
        const LL cost = -q.top().first;
        const int cur = q.top().second;
        q.pop();
        if(memo[cur] < cost) continue;
        for(const auto &edge : graph[cur]) {
            const LL nc = cost + edge.second;
            if(memo.count(edge.first) == 0 || memo[edge.first] > nc) {
                memo[edge.first] = nc;
                q.push(make_pair(-nc, edge.first));
            }
        }
    }
    return memo;
}

bool solve() {
    int N, M, C;
    cin >> N >> M >> C;
    if(!N && !M && !C) return false;

    Dict dict;
    string Sn, Dn;
    cin >> Sn >> Dn;
    const int S = dict.get(Sn);
    const int D = dict.get(Dn);

    map<int,vector<pair<int,LL>>> graph;
    TIMES(_, N) {
        string s, t;
        LL d;
        cin >> s >> t >> d;
        const int si = dict.get(s);
        const int ti = dict.get(t);
        graph[si].push_back(make_pair(ti, d));
        graph[ti].push_back(make_pair(si, d));
    }
    vector<int> stations;
    TIMES(_, M) {
        string s;
        cin >> s;
        stations.push_back(dict.get(s));
    }
    stations.push_back(S);
    stations.push_back(D);
    map<int,vector<pair<int,LL>>> min_graph;
    for(int from : stations) {
        map<int,LL> res = search_path(from, graph);
        for(int i : stations) {
            if(res.count(i) && res[i] <= C*10) {
                min_graph[from].push_back(make_pair(i, res[i]));
                //cout << from << ' ' << i << ' ' << res[i] << endl;
            }
        }
    }

    map<int,LL> res = search_path(S, min_graph);
    LL ans = -1;
    if(res.count(D)) {
        ans = res[D];
    }
    cout << ans << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 5140
#include<stdio.h>

int main(){
    int H, W;
    int mas[100][100];
    char s[100];
    int i,j,k;
    int ans = 0, sum;

    for(i=0; i<100; i++){
        for(j=0; j<100; j++){
            mas[i][j] == 0;
        }
    }

    scanf("%d %d", &H, &W);

    for(i=0; i<H; i++){
        scanf("%s", &s);
        for(j=0; j<W; j++){
            if(s[j] == '#'){
                mas[i+1][j+1] = 1;
            }
            //printf("%d ",mas[i+1][j+1]);
        }
        //printf("\n");
    }

    for(i=1; i<=H; i++){
        for(j=1; j<=W; j++){
            if(mas[i][j] == 1){
                sum = mas[i-1][j] + mas[i+1][j] 
                      + mas[i][j-1] + mas[i][j+1];
                if(sum == 0){
                    ans =1;
                }
            }
        }
    }

    if(ans == 0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
constexpr ll INF=1000000011;
constexpr ll LINF = 1001002003004005006ll;
vector<vector<ll>> dp; // グラフの距離を格納した2次元配列（隣接行列）
                      // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）
ll nex[1000][1000];  //  i から j への最短経路における i の1つ後の点　経路復元

void WF(ll N){      // nは頂点数
    // 経路復元の初期化
    rep(i,N){
        rep(j,N){
            nex[i][j]=j;
        }
    }
    rep(k,N){           // 経由する頂点
        rep(i,N){       // 開始頂点
            if(dp[i][k]==LINF){
                continue;
            }
            rep(j,N){   // 終端 
                if(dp[k][j]==LINF){
                    continue;
                }
                if(dp[i][j]>dp[i][k]+dp[k][j]){
                    dp[i][j] = min (dp[i][j],dp[i][k]+dp[k][j]);
                    nex[i][j] = nex[i][k];
                }
            }
        }
    } 
}

void way_of_WF(ll s,ll g){ //  経路復元の出力　s->gの最短経路
    ll cur;  
    for (cur = s; cur != g; cur = nex[cur][g]){
        cout << cur << " ";
    }
    cout << g << endl;
}

bool negative(ll N){  //負の閉路が存在するなら１を返す
    rep(i,N){
        if(dp[i][i]<0){
            return 1;
        }
    }
    return 0;
}

int main(){
    ll N,M,X,Y,L;
    cin >> N;
    dp = vector<vector<ll>> (N,vector<ll>(N,LINF));
    rep(i,N){
        dp[i][i]=0;
    }
    cin >> M ;
    rep(i,M){
        cin >> X >> Y >> L;
        dp[X][Y]=L;
    }

    WF(N);

    if(negative(N)){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    
    rep(i,N){
        rep(j,N){
            if(dp[i][j]==LINF){
                cout << "INF";
            }
            else{
                cout << dp[i][j];
            }
            if(j!=N-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3692
import java.util.Scanner;

class Main {
	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);
				
		int n, ap, bp, a;
		String str, str2;
		int str3, str4;
		String str5, sub, sub2;
		
		
		str = scan.next();
		n = scan.nextInt();
		for(int i = 0; i < n; i++){

			str2 = scan.next();
			str3 = scan.nextInt();
			str4 = scan.nextInt();
			
			if(str2.equals("print")){
				if(str4 < str.length() - 1) {
					sub = str.substring(str3, str4 + 1);
				} else {
					sub = str.substring(str3);
				}
				
				System.out.println(sub);
				
			} else if(str2.equals("reverse")){
				if(str3 != 0) {
					sub = str.substring(0, str3);
				} else {
					sub = "";
				}
				if(str4 < str.length() - 1) {
					sub2 = str.substring(str4 + 1);
				} else {
					sub2 = "";
				}
				
				String sub3 = str.substring(str3, str4 + 1) ;
				
				StringBuffer sb = new StringBuffer(sub3);
				str = sub + sb.reverse().toString() + sub2;
				
			} else if(str2.equals("replace")) {
				sub = str.substring(0, str3);
				
				if(str4 < str.length() - 1) {
					sub2 = str.substring(str4 + 1);
				} else {
					sub2 = "";
				}
				
				str5 = scan.next();
				str = sub + str5 + sub2;
			}
		}
	}
	
}

Measured memory_bytes: 29884
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		int a[3];
		for(int i=0;i<3;i++)
			cin>>a[i];
		sort(a,a+3);
		if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w, x;
    cin >> h >> w >> x;
    char c[h][w];
    rep(i, 0, h) {
        rep(j ,0, w) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    rep(i, 0, (1 << h)) {
        rep(j, 0, (1 << w)) {
            int cnt = 0;
            rep(k, 0, h) {
                rep(l, 0, w) {
                    if (i & (1 << k)) continue;
                    if (j & (1 << l)) continue;
                    if (c[k][l] == '#') cnt++;
                }
            }
            if (cnt == x) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
from datetime import datetime as dt


d0 = dt.strptime("2 0 0",'%H %M %S')

while True:
    s = raw_input()
    if s == "-1 -1 -1":
        exit()
    d = dt.strptime(s,'%H %M %S')
    sec = (d0-d).seconds
    print '{:02}:{:02}:{:02}'.format(sec // 3600, sec % 3600 // 60, sec % 60)
    sec *= 3
    print '{:02}:{:02}:{:02}'.format(sec // 3600, sec % 3600 // 60, sec % 60)

Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define Cr7 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    Cr7
    string s;
    cin>>s;
    if(s=="ABC")    cout<<"ARC"<<endl;
    else            cout<<"ABC"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }
  SegmentTree(const vector<T> &v, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  // k 番目の要素を a に変更
  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  // k 番目の要素を取得
  T get(int k) { return dat[k + N - 1]; }

  // 区間 [l, r) の和を取得
  T query(int l, int r)
  {
    T vl = unit, vr = unit;
    for (l += (N - 1), r += (N - 1); l < r; l >>= 1, r >>= 1)
    {
      if ((l & 1) == 0)
        vl = func(vl, dat[l]);
      if ((r & 1) == 0)
        vr = func(vr, dat[--r]);
    }
    return func(vl, vr);
  }
};
int main(){
ll n,q;
cin >> n >> q;
ll bigg = pow(2,31)-1LL;
auto minimum = [](ll a, ll b) { return min(a, b); };
SegmentTree<ll> sgt(n, minimum, bigg);
for (ll i = 0; i < q;i++){
    ll s,t,u;
    cin >> s >> t >> u;
    if (s == 0) {
        sgt.update(t, u);
    } else {
        cout << sgt.query(t,u+1)<< endl;
    }
}
}


Measured memory_bytes: 4932
#include<iomanip>
#include<algorithm>

// from iostream
#include<iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::flush;
using std::endl;
// from vector
#include<vector>
using std::vector;
// from queue
#include<queue>
using std::deque;
using std::priority_queue;
// from tuple
using std::tuple;
using std::get;
using std::tie;
using std::make_tuple;
using std::forward_as_tuple;
// from string
#include<string>
using std::string;


// type definitions
typedef signed long long INT;
typedef tuple<INT,INT> TII;
typedef tuple<INT,INT,INT> TIII;
typedef tuple<double,double> TDD;
typedef tuple<double,double,double> TDDD;
typedef vector<INT>  VI;
typedef vector<TII>  VII;
typedef vector<TIII> VIII;
typedef vector<double> VD;
typedef vector<TDD>    VDD;
typedef vector<TDDD>   VDDD;

// macros
#define rep(i,n) for( INT i = 0 ; i <  n ; ++i )
#define REP(i,n) for( INT i = 1 ; i <= n ; ++i )
#define ALL(a) (a).begin(),(a).end()


// main

// begin global variables
// end global varieble;

int main(){
  std::ios::sync_with_stdio(false);
  // begin main
  INT N;
  cin >> N;

  VI a(N);
  rep(i,N) cin  >> a[i];
  std::sort(ALL(a));
  cout << a[N-1] - a[0] << endl;
  // end main
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		long dog = Long.parseLong(br.readLine());
		String res = "";
		
		while(dog-- > 0) {
			res = (char)('a' + (dog%26)) + res;
			dog /= 26;
		}
		
		bw.write(res + "\n");
		bw.flush();
	}

}

Measured memory_bytes: 37416
//#pragma warning disable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

public class Test
{
    public static void Main()
    {
        var line1 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = line1[0];
        var A = line1[1];
        var B = line1[2];

        var X = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        long sum = 0;

        for (int i = 0; i < N - 1; i++)
        {
            sum += Math.Min(B, A * (X[i + 1] - X[i]));
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 22880
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{
    int a,b,ans=0;
    scanf("%d %d",&a,&b);

    for(int i=1;i<1500;i++)
    {
        int c=i*0.08;
        int d=i*0.1;
        if(c==a&&d==b)
        {
            ans=i;
            break;
        }
    }

    if(ans>0)
    {
        printf("%d\n",ans);
    }
    else
    {
        printf("-1\n");
    }
    
    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<ll>a(n),sum(n+1);
    rep(i, 0, n){
        cin >> a[i]; 
    }
    rep(i, 0, n){
        sum[i+1] = sum[i]+a[i];
        sum[i+1] %= mod;
    }
    ll ans = 0;
    rep(i, 0, n){
        ans += (a[i]*((sum[n]+mod-sum[i+1])%mod))%mod;
        ans %= mod;
    }
    //rep(i, 0, n+1)cout << sum[i] << endl;
    cout << ans%mod << endl;
}

Measured memory_bytes: 6420
n = int(input())
comments = {}

for i in range(1, n+1):
    ni = int(input())
    comments[i] = [tuple(map(int, input().split())) for _ in range(ni)]

nhonests = [0]

for ibin in (format(i, "b") for i in range(2**n, 2**(n+1))):
    ni_lie, ni = 0, 1
    
    while (not ni_lie) and ni < n+1:        
        for ci in comments[ni]:            
            if int(ibin[ni]) and ci[1] ^ int(ibin[ci[0]]):
                ni_lie += 1
            ### print(ibin, ni, int(ibin[ni]), end=" ") ###
            ### print((ci[0], ci[1]), ci[0], int(ibin[ci[0]]), end=" ") ###
            ### print((ni_lie,)) ###
            
        ni += 1
        
    if not ni_lie:
        nhonests.append(ibin.count("1") - 1)
        ### print(ibin) ###
        
print(max(nhonests))

Measured memory_bytes: 3444
n,m=map(int,input().split())
if n == 1 and m == 1:
  print(1)
elif n <= 2 and m <= 2:
  print(0)
elif n == 1:
  print(m-2)
elif m == 1:
  print(n-2)
else:
  print((n-2)*(m-2))

Measured memory_bytes: 3060
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#

def main():
    n, m, q = MII()
    query = [MII() for _ in range(q)]

    def calc_point(lst):
        sumv = 0
        for a, b, c, d in query:
            if lst[b-1] - lst[a-1] == c:
                sumv += d
        return sumv

    def dfs(lst):
        if len(lst) == n:
            return calc_point(lst)
        point = 0
        last_elm = lst[-1]
        for i in range(last_elm, m+1):
            point = max(point, dfs(lst+[i]))
        return point

    print(dfs([1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
#include <stdio.h>
int main(void){
	int H,W;
	int i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0&&W == 0)break;
		
		for(i = 0;i < H;i++){
			for(j = 0;j < W;j++){
				if(i == 0){
					printf("#");
				}else if(i+1 == H){
					printf("#");
				}else{
					if(j == 0 || j+1 == W){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 572
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int[] res = new int[n];

        for(int i=1; i<=n-1; i++) {
            for(int j=i+1; j<=n; j++) {
                int d = j - i;
                d = Math.min(d, Math.abs(i-x) + Math.abs(j-y) + 1);
                d = Math.min(d, Math.abs(i-y) + Math.abs(j-y));
                d = Math.min(d, Math.abs(i-x) + Math.abs(j-x));
                res[d]++;
            }
        }



        for(int i=1; i<n; i++) {
            System.out.println(res[i]);
        }

    }


}

Measured memory_bytes: 24148
//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    int a;
    cin >> a;
    cout << !a << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int n = s.length();
  vector<string> v{""};
  string tmp = "";
  REP(i, n) {
    tmp += s[i];
    if (v.back() != tmp) {
      v.emplace_back(tmp);
      tmp = "";
    }
  }
  cout << v.size() - 1 << '\n';
  return 0;
}


Measured memory_bytes: 11016
n, m = map(int, input().split())
info = [tuple(map(int, input().split())) for _ in range(m)]
# print(info)
num = [-1] * n
answer = ''
ok = True
for si, ci in info:
    # print(si, ci)
    if num[si-1] == -1:
        num[si-1] = ci
    if num[si-1] != ci:
        ok = False
    if num[0] == 0 and n != 1:
        ok = False


if ok:
    for i in range(n):
        # print(n)
        if num[i] == -1 and i == 0:
            if n == 1:
                answer += '0'
            else:
                answer += '1'
        elif num[i] == -1 and i != 0:
            answer += '0'
        else:
            answer += str(num[i])
    print(answer)
else:
    print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main()
{   
    int A, B;
    cin >> A >> B;
    if((A+B)%3==0){
        cout << "Possible" << endl;
    }
    else if(A%3==0 || B%3==0){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int menor, medio, maior, a,b,c;

	
	scanf("%d", &a);

	scanf("%d", &b);
	
	scanf("%d", &c);
	
	if(a == b && c > a){
		menor = a;
		medio = b;
		maior = c;
	}
	
	
	if(a == c && b > a){
		menor = a;
		medio = c;
		maior = b;
	}
	
	
	if(b == c && a > b){
		menor = b;
		medio = c;
		maior = a;
	}
	
	
	if(a < b && a < c){
		menor = a;
		
		if(b < c){
			medio = b;
			maior = c;
		}
			
		if(c < b){
			medio = c;
			maior = b;
		}
		
		if(c == b){
			medio = c;
			maior = b;
		}
		
	}
		
	if(b < a && b < c){
		menor = b;
		
		if(a < c){
			medio = a;
			maior = c;
		}
			
		if(c < a){
			medio = c;
			maior = a;
		}
		
		if(c == a){
			medio = b;
			maior = a;
		}
		
	}
		
	if (c < a && c < b){
		menor = c;
		
		if(a < b){
			medio = a;
			maior = b;
		}
			
		if(b < a){
			medio = b;
			maior = a;
		}
		
		if(b == a){
			medio = b;
			maior = a;
		}
	}
	
	printf("%d %d %d\n", menor, medio, maior);
	
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main(){
  int N;
  cin >> N;
  if (N == 1){
    cout << "Hello World" << endl;
  }
  else if (N == 2){
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
  }
}

Measured memory_bytes: 256
import sys
import math
import bisect

def solve(A):
    for a in A:
        if a * 2 == sum(A):
            return True
    return False
 
def main():
    A = list(map(int, input().split()))
    if solve(A):
        print('Yes')
    else:
        print('No')
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
from collections import deque


def bfs(h, w, visited, ss):
    visited[0][0] = 0
    queue = deque([])
    queue.append([0, 0])
    while queue:
        y, x = queue.popleft()
        if y == h-1 and x == w-1:
            return visited[y][x]
        for i, j in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            xn, yn = x+i, y+j
            if xn < 0 or yn < 0 or xn >= w or yn >= h:
                continue
            if visited[yn][xn] == -1 and ss[yn][xn] != "#":
                visited[yn][xn] = visited[y][x] + 1
                queue.append([yn, xn])
    return -1


def main():
    h, w = map(int, input().split())
    ss = [input() for _ in range(h)]
    visited = [[-1 for _ in range(w)] for _ in range(h)]
    c = 0
    for s in ss:
        c += s.count("#")

    min_route = bfs(h, w, visited, ss)
    if min_route == -1:
        print(min_route)
    else:
        print(h*w - c - min_route - 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>



int main() {
  long i, j, k, num, A, B, C;
  scanf("%ld %ld %ld", &A, &B, &C);
  printf("%ld %ld %ld", C, A, B);
  return 0;
}


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

const int MOD = 1e9+7;
const int MAX = 1e6+10;
const int INF = 0x3fffffff;

char s[MAX];

int main(){
	while(scanf("%s",s)!=EOF){
		int len = strlen(s);
		int num=1;
		for(int i=1;i<len;i++){
			if(s[i]!=s[i-1])	num++;
		}
		printf("%d\n",num-1);
	}
	return 0;
}

Measured memory_bytes: 384