akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int N, A[100001], B;
long long sum = 0;
int main() {
  	scanf("%d",&N);
  	for (int i = 0; i <= N; i++) scanf("%d",&A[i]);
  	for (int i = 0; i < N; i++) {
		scanf("%d",&B);
      	int x = min(A[i],B);
      	A[i] -= x;
      	B -= x;
        sum += x + min(A[i+1],B);
      	A[i+1] -= min(A[i+1],B);
    }
  	printf("%lld\n",sum);
}

Measured memory_bytes: 640
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(1, N + 1):
    t[i], x[i], y[i] = map(int, input().split())

for i in range(1, N + 1):
    t_dif = t[i] - t[i - 1]
    dict = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    #print(t_dif, dict)
    if t_dif < dict or t_dif % 2 != dict % 2:
        print("No")
        break
else:
    print("Yes")



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m, sum = 0;
	cin >> n >> m;
	vector<int> a(n);
	rep (i, n) {
	  cin >> a[i];
	  sum += a[i];
	}
	int cnt = 0;
	rep (i, n) {
	  cnt += (a[i] * 4 * m >= sum);
	}
	cout << (cnt >= m ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
ll ans = 0;
string s;
ll fact(ll n)
{
    ll sum = 0;
    for (ll i = n; i > 0; i--)
    {
        sum += i;
    }
    return sum;
}
int main()
{

    cin >> s;
    ll j, l, r;
    // cout << "length: " << s.length() << endl;
    for (ll i = 0; i < s.length(); i++)
    {
        j = i;
        l = 0;
        r = 0;
        while (s[j] == '<')
        {
            r++;
            j++;
        }
        while (s[j] == '>')
        {
            l++;
            j++;
        }
        // cout << l << "," << r << endl;
        if (l > r)
        {
            ans += fact(l);
            ans += fact(r - 1);
        }
        else
        {
            ans += fact(l - 1);
            ans += fact(r);
        }
        // cout << ans << endl;
        i += (l + r) - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4240
//
// Created by Kiran Chavhan on 19/09/2020.
//

#include<bits/stdc++.h>

#define int long long
#define MOD 1000000007
#define sort(a) sort(a.begin(),a.end())
#define endl '\n'

using namespace std;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<n;i++){
    cnt+=(n/i);
    if(n%i==0)cnt--;
    }
    cout<<cnt;
}

Measured memory_bytes: 3688
import java.io.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String input = br.readLine();
			String[] numbers = input.split(" ");
			Integer a = Integer.parseInt(numbers[0]);
			Integer b = Integer.parseInt(numbers[1]);
			if(a == 0 && b == 0){
				break;
			}
			for(int i=1; i <= a; i++){
				String line = "";
				for(int j=1; j <= b; j++){
					if(i%2 == 1){
						if(j%2 == 1){
							line += "#";
						}
						else{
							line += ".";
						}
					}
					else{
						if(j%2 == 1){
							line += ".";
						}
						else{
							line += "#";
						}
					}
				}
				System.out.println(line);
			}
			System.out.println("");
		}

	}

}

Measured memory_bytes: 52560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  map<string, set<int> > sakuin;
  string word;
  int page;
  map<string, set<int> >::iterator it;
  set<int>::iterator it2;
  while(cin>>word){
    cin>>page;
    if((it=sakuin.find(word))!=sakuin.end()){
      (*it).second.insert(page);
    }else{
      set<int> tmp;
      tmp.insert(page);
      sakuin[word]=tmp;
    }
  }
  for(it=sakuin.begin();it!=sakuin.end();it++){
    cout<<(*it).first<<endl;
    for(it2=(*it).second.begin();it2!=(*it).second.end();it2++){
      if(it2!=(*it).second.begin()){
        printf(" ");
      }
      printf("%d",(*it2));
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll N=500001;
int n,q,c[N],l[N],r[N],a[N],b[N],ans[N];
vector<pair<int,int> > x[N];

void add(int x,int v){
  for(int i=x;i<=n;i+=i&(-i))
    b[i]+=v;
}

int sum(int x){
  int v=0;
  for(int i=x;i>0;i-=i&(-i))v+=b[i];
  return v;
}

int main(){
  ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
  cin>>n>>q;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=q;i++){
    cin>>l[i]>>r[i];
    x[r[i]].emplace_back(l[i],i);
  }
  for(int i=1;i<=n;i++){
    if(a[c[i]])add(a[c[i]],-1);
    a[c[i]]=i;
    add(i,1);
    for(auto [d,e]:x[i])ans[e]=sum(i)-sum(d-1);
  }
  for(int i=1;i<=q;i++)cout<<ans[i]<<endl;
  return 0;
}

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

using namespace std;
#define Vi vector<int>
#define FOR(i,n) for(int i=0;i<n;i++)
#define MAX_SIZE 100001

int main(){
  long n,k;
  cin>>n>>k;
  vector<long> v(MAX_SIZE,0),tmpa(n),tmpb(n);
  FOR(i,n)
    cin>>tmpa[i]>>tmpb[i];
  FOR(i,n)
    v[tmpa[i]]+=tmpb[i];
  for(int i=1;i<MAX_SIZE;i++){
    k-=v[i];
    if(k<=0){
      cout<<i<<endl;
      break;
    }
  }
}

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

int main() {
  int n;
  int a[210];
  
  cin >> n;
  for(int i=0;i<n;i++) cin >> a[i];
  
  int cnt=0;
  
  while(true) {
    bool exist_odd = false;
    for(int i=0;i<n;i++) {
      if(a[i]%2 != 0) exist_odd=true;
    }
    
    if(exist_odd) break;
    
    for(int i=0;i<n;i++) {
      a[i] /= 2; 
    }
    
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int a,b,c;
      //string s;
      cin >> a >> b >> c;
      //cin >> s;
      //if((a+b)%2==1)cout << 1 + (a+b)/2 << endl;
      //else cout << (a+b)/2 << endl;
      a = a-b;
      while(true){
        if((a-c)<0){break;}
        else a = a-c;
      }
      cout << a << endl;
      return 0;
    }

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

using namespace std;

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> arr(n);
	int el;
	for (int i = 0; i < n; i++) {
		cin >> el;
		arr[i] = el;
	}
	sort(arr.begin(), arr.end());
	//reverse(arr.begin(), arr.end());
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (arr[i] > x) { x = 0; break; }
		cnt++;
		x -= arr[i];
	}
	if (x > 0) cnt--;
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;

int n, a;
vector<pii> x;

int main(){
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> a;
		x.emplace_back(i, a);
	}
	sort(x.begin(), x.end(), [](pii& u, pii& v){return u.second < v.second;});
	for (auto& e: x){
		printf("%d ", e.first);
	}
	printf("\n");
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<ll> node;
 
public:
    SegmentTree() {
        int sz = 200050;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, ll val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1] , node[2*x+2]);
        }
    }
    // hannkaikukann 
    ll getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        ll vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};


int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    int h[200100];
    ll a[200100];
    SegmentTree seg;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        ll maxi = seg.getmax(1, h[i]);
        seg.update(h[i], maxi + a[i]);
    }
    cout << seg.getmax(1, n + 1) << endl;
    return 0;
}


Measured memory_bytes: 6656
s = input()
l = []
cnt = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] =="C" or s[i] == "G" or s[i] == "T":
        cnt += 1
        #print(i, cnt)
        if i == len(s) - 1:
            l.append(cnt)
            
        
        
        
    elif i != "A" or i !="C" or i != "G" or i != "T":
        l.append(cnt)
        cnt = 0
        #print("y")
print(max(l))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    string A, B;
    cin >> A >> B;
    ll size_A,size_B;
    size_A = A.size();
    size_B = B.size();
    if(size_A != size_B){
        if(size_A > size_B){
            cout << "GREATER" << endl;
        }
        else{
            cout << "LESS" << endl;
        }
    }
    else{
        for(ll i=0;i<size_A;i++){
            if(A[i]!=B[i]){
                if(A[i]>B[i]){
                    cout << "GREATER" << endl;
                    break;
                }
                else{
                    cout << "LESS" << endl;
                    break;
                }
            }
            if((i==size_A-1)&&A[i]==B[i]){
                cout << "EQUAL" << endl;
            }
        }
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

#define MOD (int)(1e9+7)

typedef long long ll;

long long mod_pow(long long x, long long n, int p)
{
	if (n == 0)return 1;
	if (n == 1)return x % p;

	long long y = mod_pow(x, n / 2, p);

	if (n % 2 == 0)return (y * y) % p;
	else return (x * ((y * y) % p)) % p;
}

int main() {
	int N;cin>>N;
	vector<ll>A(N);
	for(int i=0;i<N;i++)cin>>A[i];

	vector<ll>ruiseki(N+1);
	for(int i=1;i<=N;i++)
	{
		ruiseki[i] = ruiseki[i-1] + A[i-1]%MOD;
		ruiseki[i] %= MOD;
	}

	vector<vector<ll>>cnt0(64, vector<ll>(N+1));
	vector<vector<ll>>cnt1(64, vector<ll>(N+1));

	for (int j = 0; j < 63; j++)
	{
		for (int i = 1; i <= N; i++)
		{	
			cnt0[j][i] = cnt0[j][i-1] + ((A[i-1]&(1ll<<j))==0);
			cnt1[j][i] = cnt1[j][i-1] + ((A[i-1]&(1ll<<j))!=0);
		}
	}

	ll ans = 0;
	for(int i=1;i<N;i++)
	{
		ll temp = ruiseki[N] - ruiseki[i] + MOD;
		temp %= MOD;
		for (int j = 0; j < 63; j++)
		{
			bool flag = (A[i-1] & (1ll<<j)) != 0;

			if(flag == false)continue;

			ll b = mod_pow(2, j, MOD);
			temp += (((cnt0[j][N]-cnt0[j][i]) - (cnt1[j][N] - cnt1[j][i]))*b)%MOD;
			temp %= MOD;
		}

		ans += (temp+MOD)%MOD;
		ans %= MOD;
	}

	cout<<ans<<endl;
	

	return 0;
}

Measured memory_bytes: 307288
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys
import itertools

import numpy as np

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

a,b,h=map(int, read().split())
print(h*(b+a)//2)


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> vec(H);
  
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    cout << "#" << vec.at(i) << "#" << endl;
  }
  
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  
  cout << endl;
}

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;
using P =pair<int,int>;

int main(){
    int n,ans;
    cin >> n ;
    if(n%2==1){
        cout << n/2+1 << endl;

    }
    else{
        cout << n/2 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  cin >> N;
  ll K;
  cin >> K;
  vector<ll> A(N);
  cin >> A;
  auto dp = vect(61, vect(2, -LLINF));
  vector<ll> cnt(60, 0ll);
  for (int i = 0; i < 60; i++) {
    for (int j = 0; j < N; j++) {
      if ((A[j] >> i) & 1) cnt[i]++;
    }
  }
  dp[0][1] = 0ll;
  for (int i = 0; i < 60; i++) {
    for (int j = 0; j < 2; j++) {
      if (dp[i][j] == -LLINF) continue;
      ll bit = (1LL << (59 - i));
      // use 0
      if (j == 1 && (bit & K) == 0) {
        chmax(dp[i + 1][1], dp[i][j] + bit * cnt[59 - i]);
      } else {
        chmax(dp[i + 1][0], dp[i][j] + bit * cnt[59 - i]);
      }
      // use 1
      if (j == 1 && (bit & K) == 0) continue;
      if (j == 1) {
        chmax(dp[i + 1][1], dp[i][j] + bit * ((ll)N - cnt[59 - i]));
      } else {
        chmax(dp[i + 1][0], dp[i][j] + bit * ((ll)N - cnt[59 - i]));
      }
    }
  }
  cout << max(dp[60][0], dp[60][1]) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }

int d[100001];

int main(){
  cin.tie(0); ios::sync_with_stdio(false);
    
  int n,m; cin>>n>>m; vector<Vi> ed(n,Vi{}); int h[n]={};
  for (int j = 0; j < m; j++){
    int x,y; cin>>x>>y; ed[x-1].push_back(y-1); h[y-1]++;
  }
  stack<int> st; for (int i = 0; i < n; i++)if(!h[i])st.push(i);
  Vi po={};
  while(st.size()){
    int i=st.top(); st.pop();
    po.push_back(i);
    for (auto p: ed[i]){
      h[p]--;
      if(!h[p])st.push(p);
    }
  }
  for (auto i:po){
    for (int j = 0; j < ed[i].size(); j++){
      chmax(d[ed[i][j]],d[i]+1);
    }
  }
  cout<<*max_element(d,d+n)<<'\n';
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
#define name "b"

using namespace std;

const int maxn = 310;
int n;
string maze[maxn];

int q[maxn * maxn], classBfs[maxn];
int top, bot;
void nhap(){
    cin >> n;
    for (int i = 0; i < n;i++){
        cin >> maze[i];
    }
}

int bfs(int i){
    int countn = 1;
    memset(classBfs, 0, sizeof(classBfs));
    classBfs[i] = countn;
    q[1] = i;
    top = bot = 1;
    while(bot <= top){
        int topClass = top;
        countn++;
        while (bot <= topClass){
            int u = q[bot];
            //cout << u << "\n";
            for (int i = 0; i < n; i++){
                if (maze[u][i] == '1' && classBfs[i] == 0){
                    q[++top] = i;
                    classBfs[i] = countn;
                }
            }
            bot++;
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (maze[i][j] == '0')continue;
            if (classBfs[i] == classBfs[j] - 1 || classBfs[i] - 1 == classBfs[j]){
                continue;
            }
            else return -1;
        }
    }
    return countn - 1;
}

void xuli(){
    int res = -1;
    for (int i = 0; i < n; i++){
        res = max(res, bfs(i));
       // cout << i << " " << bfs(i)<< "\n";
    }
    cout << res;
}

int main(){
  //  freopen(name".inp", "r", stdin);
  //  freopen(name".out", "w", stdout);
    nhap();
    xuli();
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint ans = 1;
    int n;
    cin >> n;

    vector<llint> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
        if(a.at(in)==0) {
            cout << 0 << endl;
            return 0;
        }
    }

    for(int in=0;in<n;in++) {
        if(a.at(in)>1000000000000000000/ans) { 
            cout << -1 << endl;
            return 0;
        }
        ans *= a.at(in);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
# 初期入力
from statistics import mean, median,variance,stdev
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
A = list(map(int, input().split()))
monney =[-1]*N
kabu_med =median(A)
kabu_num =[-1]*N

#初日
if A[0] < A[1]:
    kabu_num[0]   = 0     +1000 //A[0]
    monney[0]     = 1000  -kabu_num[0] *A[0]
elif A[0] >= A[1]:
    kabu_num[0]   = 0
    monney[0]     = 1000
#2日目～ラス前
for i in range(1,N-1):
    if A[i-1] >= A[i] < A[i+1]:
        kabu_num_today =monney[i-1] //A[i]
        kabu_num[i]   = kabu_num[i-1]   +kabu_num_today
        monney[i]     = monney[i-1]     -kabu_num_today *A[i]
    elif A[i-1] <= A[i] > A[i+1]:
        kabu_num_today =kabu_num[i-1]
        kabu_num[i]   = 0
        monney[i]     = monney[i-1]     +kabu_num_today *A[i]
    elif A[i-1] <= A[i] <= A[i+1]:
        kabu_num[i]   = kabu_num[i-1]
        monney[i]     = monney[i-1]
    elif A[i-1] >= A[i] >= A[i+1]:
        kabu_num[i]   = kabu_num[i-1]
        monney[i]     = monney[i-1]

#最終日
monney[N-1] =monney[N-2]     +kabu_num[N-2] *A[N-1]

print(monney[-1])

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

int ans=0;

int devide(int a){
  int sum=0;
  while(a%2==0){
    a/=2;
    sum++;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin >> a[i];

  rep(i,n)ans+=devide(a[i]);
  cout << ans << endl;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    while(1){
        ll n,m; cin >> n >> m;
        if(n==0 && m==0) break;
        vl a(n);
        vl sums;
        sums.push_back(0);
        rep(i,n) {
            cin >> a[i];
            sums.push_back(a[i]);
        }
        rep(i,n){
            REP(j,i,n){
                sums.push_back(a[i]+a[j]);
            }
        }
        sort(all(sums));
        ll ans = 0;
        for(auto i : sums){
            auto itr = upper_bound(all(sums), m-i);
            if(itr == sums.begin()) continue;
            itr--;
            ans = max(ans, i+*itr);
        }
        cout << ans << endl;
        sums.clear();
    }
}



Measured memory_bytes: 10748
#include <stdio.h>
#define N 100000
#define Q 50000

int main(){

  int S[N],T[Q];
  int i,n,q;
  int left,right,mid,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(S[mid]>T[i]){
        right=mid;
      }
      else if(S[mid]<T[i]){
        left=mid+1;
      }
      else if(S[mid]==T[i]){
          count++;
          break;
        }
      else{
        left=mid+1;
      }
      }
    }

  printf("%d\n",count);

  return 0;
  }

Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout<<endl;
#define P pair<int, int>
#define prique priority_queue<P, vector<P>, greater<P>>
struct edge { int to, cost; };
using namespace std;
template<typename T> void unsort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}

int n, m;
int cnt[114514];
int ans = 0;
signed main() {
	cin >> n >> m;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		l--;
		cnt[l] ++;
		cnt[r] --;
	}
	rep(i, n) cnt[i + 1] += cnt[i];
	rep(i, n) {
		if (cnt[i] == m) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
import java.util.*;

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

        List<Double> list = new ArrayList<Double>();

        for (int i = 0; i < n; i++) {
            int v = sc.nextInt();
            list.add(new Double(v+""));
        }
        Collections.sort(list);

        double result = list.get(0);
        for(int i = 1; i < list.size() ; i++){
            Double v2 = list.get(i);
            result = (result + v2) / 2.0;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string s;
  cin >> s ;
  if(s.size() > 2){
    cout << s.at(0) << s.size() - 2 << s.at(s.size()-1) << endl;
  }
  else cout << s << endl;
}

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


int main(){

  char symbol[100];
  int  num[99],x=0;

  while(scanf("%s",symbol)!=EOF){
  if(symbol[0]=='+'){
    num[x-2]=num[x-2]+num[x-1];
    x--;
  }
  else if(symbol[0]=='-'){
    num[x-2]=num[x-2]-num[x-1];
    x--;
  }
  else if(symbol[0]=='*'){
    num[x-2]=num[x-2]*num[x-1];
    x--;
  }
  else{

    num[x]=atoi(symbol);
    x++;
  }
  }
  printf("%d\n",num[0]);

  return 0;
}
 

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

ll a,w,t,r;

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


Measured memory_bytes: 3632
n, t = map(int, input().rstrip().split())
ss = [[int(i) for i in input().split()] for i in range(n)]

ans = 1000
flg = True

for s in ss:
    if int(s[1]) <= t:
        if s[0] < ans:
            ans = s[0]
        flg = False

if flg:
    print("TLE")
else:
    print(ans)


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

int main(){
  int n;
  scanf("%d",&n);

  int count = 0;
  for(int i = 1; i <= n; i++){
    if((isOdd(i)%2) == 0) count++;
  }
  
  printf("%d",count);
}

int isOdd(int n){
  int ketasu = 1;
  while(n != 0){
    n = n / 10;
    ketasu++;
  }
  return ketasu;
}

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

int main()
{
    string n;
    cin>>n;
    int f=0;
	for(int i=0;i<n.length();i++){
    if(n[i]=='7'){
       f=1;}

	}
	if(f==1){
        cout<<"Yes\n";

	}
	else{
        cout<<"No\n";
	}
}


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

#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    auto calc = [&](int x){
        int cut = 0;
        for (int i=0;i<N;i++){
            cut += (A[i]%x == 0) ? (A[i]/x - 1) : (A[i]/x);
        }
        return cut;
    };
    int upper = 1e9+1;
    int lower = 0;
    while (upper - lower > 1){
        int mid = (upper+lower)/2;
        if (calc(mid) > K) lower = mid;
        else upper = mid;
    }
    int length = upper;
    cout << upper << "\n";
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=2*100005;
int n;int a[mx],pos[mx];
int main(){
	/*freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);*/  
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> n;
	//rep(i,mx)rep(j,mx)dp[i][j]=-1;
	if(n==1){cout << 0 << endl;return 0;}	
	rep(i,n){
		cin >> a[i];
		pos[a[i]]=i;
	}	
	int res=1,ans=n;
	for(int i=2;i<=n;++i){
		if(pos[i]>pos[i-1])++res;
		else res=1;
		ans=min(ans,n-res);
	}
	cout << ans << endl;
}
	

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
string s;
cin>>s;
int start=-1,end=-1;
FOR(i,0,s.size()-1){
    if(s[i]=='Z')end=i;
    else if(s[i]=='A'&&start==-1)start=i;
}
cout<<end-start+1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}


const int a_max = int(1e6 + 5);

vector<bool> IsPrime;

vector<pair<llong,llong>> factoring(llong n){
    vector<pair<llong,llong>> ans;
    if( n== 1){
        ans.push_back( make_pair(1,1));
        return ans;
    }
    llong i=1;
    while(1){
        i+=1;
        if( i * i > n) break;
        pair<llong,llong> tmp;
        tmp.first=i;
        tmp.second=0;
        while(1){
            if(n%i != 0) break;
            n/=i;
            tmp.second+=1;
        }
        if(tmp.second!=0) ans.push_back(tmp);
    }
    if(n!=1) ans.push_back( make_pair(llong(n),llong(1)));
    return ans;

}
signed main(){
    int a,b;
    cin >> a >> b;
    
    if(a == 1 or b == 1){
        cout << 1 << endl;
        return 0;
    }

    auto fac1 = factoring(a);
    auto fac2 = factoring(b);
    map<int,int> M;

    itrfor(itr,fac1){
        M[itr->fi] ++;
    }
    itrfor(itr,fac2){
        M[itr->fi] ++;
    }

    int cnt = 1;
    itrfor(itr,M){
        if(itr->se == 2) cnt ++;
    }
    cout << cnt << endl;




}

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

tree_heights = []

for i in range(N):
    height = int(input())
    tree_heights.append(height)
    
tree_heights = sorted(tree_heights)

ans = 10**9

for i in range(N-K+1):
   diff = tree_heights[i+K-1] - tree_heights[i]
   
   if diff < ans:
       ans = diff
      
print(ans)

Measured memory_bytes: 14156
import math

def check_even_number(N, M):
    if N <= 1:
        combination_N = 0
    else:
        combination_N = math.factorial(N) // (math.factorial(N - 2) * math.factorial(2))

    if M <= 1:
        combination_M = 0
    else:
        combination_M = math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
        
    return combination_N + combination_M


if __name__ == "__main__":
    N, M = map(int, input().split())
    print(check_even_number(N, M))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//以上テンプレ
int main(){
    ll N;
    cin>>N;
    string S;
    cin>>S;
    map<char,int> RGB;
    rep(i,N){
        RGB[S.at(i)]++;
    }
    ll r=RGB['R'];
    ll g=RGB['G'];
    ll b=RGB['B'];
    ll Ans=r*g*b;
    rep(i,N){
        rep2(j,i+1,N){
            ll k=j*2-i;
            if(k<N&&S.at(k)!=S.at(j)&&S.at(k)!=S.at(i)&&S.at(j)!=S.at(i)){
                Ans--;
            }
        }
    }
    cout<<Ans<<endl;
    }


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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}



int main()
{
  int n;
  cin >> n;
  set<string>ss;
  for(int i = 0; i < n ; i++)
  {
    string s;
    cin >> s;
    ss.insert(s);
  }
  cout << ss.size() << endl;
  return 0;
}

Measured memory_bytes: 19264
a, b, c, d, e, f = map(int, input().split())

water_dp = [True] + [False for _ in range(100)]
suger_dp = [True] + [False for _ in range(f + 100)]

for i in range(0, 31):
    water_dp[i+a] = water_dp[i+a] or water_dp[i]
    water_dp[i+b] = water_dp[i+b] or water_dp[i]

for i in range(0, f+1):
    suger_dp[i+c] = suger_dp[i+c] or suger_dp[i]
    suger_dp[i+d] = suger_dp[i+d] or suger_dp[i]

ans = (0, 0, 0)

for i in range(1, 31):
    if not water_dp[i]:
        continue
    suger = 0
    for j in range(0, f):
        if suger_dp[j] and i*100 + j <= f and j <= e * i:
            suger = j
    if suger * 100 / (i*100 + suger) > ans[2]:
        ans = (i, suger, suger * 100 / (i*100 + suger))

if ans[0] != 0:
    print(ans[0]*100 + ans[1], ans[1])
else:
    print(100 * a, 0)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    for (int j=0; j<n; j++) {
        int on,off;
        cin>>on>>off;
        if(on<6){
            if(on<off){
                for(int i=on;i<off;i++)cout<<i<<" ";
                cout<<off<<endl;
            }else{
                for(int i=on;i>off;i--)cout<<i<<" ";
                cout<<off<<endl;
            }
        }else{
            if(off>5){
                if(on<off){
                    for(int i=on;i<off;i++)cout<<i<<" ";
                    cout<<off<<endl;
                }else{
                    for(int i=on;i<10;i++)cout<<i<<" ";
                    for(int i=5;i>0;i--)cout<<i<<" ";
                    for(int i=0;i<off;i++)cout<<i<<" ";
                    cout<<off<<endl;
                }
            }else{
                for(int i=on;i<10;i++)cout<<i<<" ";
                for(int i=5;i>off;i--)cout<<i<<" ";
                cout<<off<<endl;
            }
        }
    }
}


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

struct UnionFind {
    vector<int> data; int group;
    UnionFind(int N) : data(N, -1), group(N) {}
    void init(int N) {
        data.assign(N, -1);
        group = N;
    }
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y){
            data[x] += data[y];
            data[y] = x;
            --group;
        }
    }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]);}
    bool same(int a, int b) { return root(a) == root(b);}
};

typedef pair<int, int> pint;
typedef complex<double> P;
typedef tuple<double, int, int> Edge;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    vector<P> piles(N);
    for(auto& p : piles) {
        double x, y;
        cin >> x >> y;
        p = P(x, y);
    }
    vector<Edge> edges(M);
    double sum = 0.0;
    for(auto& e : edges) {
        int p, q;
        cin >> p >> q;
        --p; --q;
        double dist = abs(piles[p] - piles[q]);
        e = Edge(dist, p, q);
        sum += dist;
    }
    sort(edges.rbegin(), edges.rend());
    UnionFind uf(N);
    double ans = 0.0;
    for(const auto& e : edges) {
        double dist; int u, v;
        tie(dist, u, v) = e;
        if(uf.same(u, v) == false) {
            uf.unite(u, v);
            ans += dist;
        }
    }
    ans = sum - ans;
    cout << fixed << setprecision(3) << ans << endl;
    return 0;
}

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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

bool is_prime(int x) {
        if (x == 1) return false;
        for (int i = 2; i * i <= x; i ++) {
                if (x % i == 0) return false;
        }
        return true;
}

struct edge {
        int to, cap, rev;
};
bool used[101010];
vector<edge> g[101010];
static const int INF = 0x3f3f3f3f;
void add_edge(int from, int to, int cap) {
        g[from].push_back((edge) { to, cap, (int)g[to].size() });
        g[to].push_back((edge) { from, 0, (int)g[from].size() - 1 });
}
int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < g[v].size(); i ++) {
                edge& e = g[v][i];
                if (!used[e.to] && e.cap > 0) {
                        int d = dfs(e.to, t, min(f, e.cap));
                        if (d > 0) {
                                e.cap -= d;
                                g[e.to][e.rev].cap += d;
                                return  d;
                        }
                }
        }
        return 0;
}
int MaxFlow(int s, int t) {
        int flow = 0;
        while (true) {
                memset(used, false, sizeof(used));
                int f = dfs(s, t, INF);
                if (f == 0) return flow;
                flow += f;
        }
}

vector<int> even, odd;

void push(int x) {
        if (x & 1) odd.push_back(x);
        else even.push_back(x);
}

int main() {
        int n;
        cin >> n;
        vector<int> x(n);
        for (int i = 0; i < n; i ++) cin >> x[i];
        for (int i = 0; i < n; i ++) {
                if (i == 0 || x[i] - 1 != x[i - 1]) push(x[i]);
                if (i == n - 1 || x[i] + 1 != x[i + 1]) push(x[i] + 1);
        }
        int o = odd.size(), e = even.size();
        int s = 0, t = o + e + 1;
        for (int i = 0; i < o; i ++) add_edge(s, i + 1, 1);
        for (int i = 0; i < e; i ++) add_edge(i + o + 1, t, 1);
        for (int i = 0; i < o; i ++) {
                for (int j = 0; j < e; j ++) {
                        int d = abs(odd[i] - even[j]);
                        if ((d & 1) && is_prime(d)) add_edge(i + 1, j + o + 1, 1);
                }
        }
        int k = MaxFlow(s, t);
        int ans = k + ((e - k) / 2 + (o - k) / 2) * 2 + ((o - k) % 2) * 3;
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 2944
def main():
    n = int(input())
    txy = [list(map(int, input().split())) for _ in range(n)]
    
    pre_x, pre_y, pre_t = 0, 0, 0
    for t, x, y in txy:
        d = abs(pre_x - x) + abs(pre_y - y)
        if t - pre_t >= d and (t - pre_t) % 2 == d % 2:
            pre_x,  pre_y, pre_t = x, y, t
        else:
            print('No')
            break
        pre_x,  pre_y, pre_t = x, y, t
    else:
        print('Yes')
        
        
if __name__ == '__main__':
    main()

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

int main(){
  string n;
  cin >> n;
  for(int i=0;i<2;i++){
    if(n[i]=='9'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

ll h,w;
int main(){
    cin >> h >> w;
    if(h == 1 or w == 1)cout << 1 << endl;
    else {
        cout << (h*w+1)/2 << endl;
    }
}

Measured memory_bytes: 256
package main

import "fmt"

const MAX = 10000000001

func abs(n int) int {
	if n < 0 {
		return -n
	} else {
		return n
	}
}

func min(a []int) int {
	n := len(a)
	min := MAX
	for i:=0; i<n; i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func main() {
	var N int
	var sum int
	fmt.Scan(&N)
	a := make([]int, N)
	for i:=0; i<N; i++ {
		fmt.Scan(&a[i])
		sum += a[i]
	}
	sun := sum - a[0]
	ara := a[0]
	
	t := abs(sun-ara)
	sa := make([]int, 1)
	sa[0] = t
	for i:=1; i<N-1; i++ {
		sun -= a[i]
		ara += a[i]
		sa = append(sa, abs(sun-ara))
	}
	fmt.Println(min(sa))
}


Measured memory_bytes: 9088
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(M), B(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i];
		--A[i], --B[i];
	}
	vector<vector<int> > G(N);
	for (int i = 0; i < M; ++i) {
		G[A[i]].push_back(B[i]);
	}
	priority_queue<pair<int, int> > que;
	int cur = -1, ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j : G[i]) {
			que.push(make_pair(-j, i));
		}
		while (!que.empty() && que.top().second <= cur) {
			que.pop();
		}
		if (!que.empty()) {
			int u = -que.top().first;
			if (u == i + 1) {
				cur = u - 1;
				++ans;
				que.pop();
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7164
#include<cstdio>
int main(){
    int a,b,add,sub,mul;
    scanf("%d%d",&a,&b);
    add=a+b;
    sub=a-b;
    mul=a*b;
    if(add<sub)printf("%d",(sub<mul)?mul:sub);
    else printf("%d",(add<mul)?mul:add);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

const int dx[4] = {  0, 1, 0, -1 };
const int dy[4] = { -1, 0, 1,  0 };
const int INF = (int)(2e+9);

int H, W, K;
int sy, sx, gy, gx;
vector<string> S;
vector<vi> d;

void input_init(void) {
	cin >> H >> W >> K;
	cin >> sy >> sx >> gy >> gx;
	S.resize(H + 2);
	S[0] = S[H + 1] = string(W + 2, '@');
	for (int j = 1; j <= H; ++j) {
		string str;
		cin >> str;
		S[j] = "@" + str + "@";
	}
	d.resize(H + 2, vi(W + 2, INF));
}

int bfs() {
	queue<pi> que;
	que.push(make_pair(sx, sy));
	d[sy][sx] = 0;
	while (que.size()) {
		pi p = que.front();
		que.pop();
		if (p.first == gx && p.second == gy)
			break;
		for (int i = 0; i < 4; ++i) {
			for (int k = 1; k <= K; ++k) {
				int nx = p.first + dx[i] * k;
				int ny = p.second + dy[i] * k;
				if (S[ny][nx] == '@')
					break;
				if (d[ny][nx] <= d[p.second][p.first])
					break;
				if (d[ny][nx] > d[p.second][p.first] + 1) {
					que.push(make_pair(nx, ny));
					d[ny][nx] = d[p.second][p.first] + 1;
				}
			}
		}
	}
	return d[gy][gx];
}

int main(void) {
	input_init();
	int ans = bfs();
	if (ans == INF)
		ans = -1;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 21980
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}
fn main() {
    let n: usize;
    input!(n);

    let ans = n * 800 - 200 * (n / 15);
    println!("{}", ans);
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	s := 1
	ans := 0
	for i := 0; i < n; i++ {
		tmp := sc.NextInt()
		if tmp == s {
			s++
		} else {
			ans++
		}
	}
	if s == 1 && ans == n {
		fmt.Printf("%v\n", -1)
		return
	}
	if ans == n {
		fmt.Printf("%+v\n", ans) // output for debug
		return
	}
	fmt.Printf("%+v\n", ans) // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long
#define pb push_back


using namespace std;


int main() {
  char i;
  cin >> i;
  if(i >= 'a' && i <= 'z')
    cout << 'a';
  else
    cout << 'A';
  //cout << "Hello world";
}


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

int main(void){
	int n,k;
	while(cin>>n>>k,n||k){
		vector<int> c(n);
		for(int i=0;i<n;++i)cin>>c[i];
		int max_m=0;
		for(int i=0;i<n-k+1;++i){
			int x=1;
			for(int j=0;j<k;++j)x*=c[i+j];
			max_m=max(max_m,x);
		}
		int max_n=0;
		for(int i=0;i<n;++i){
			for(int j=0;j<i;++j){
				swap(c[i],c[j]);
					for(int p=0;p<n-k+1;++p){
						int x=1;
						for(int q=0;q<k;++q)x*=c[p+q];
						max_n=max(max_n,x);
					}
				swap(c[i],c[j]);
			}
		}
		if(max_m<=max_n)cout<<(max_n-max_m)<<endl;
		else cout<<"NO GAME"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196