akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;

int sub(int a,int b){return (a^b)-a-b;}

int main(){
  int n;
  cin >> n;
  vector<int>a(n),sum(n+1,0);
  rep(i,n)cin >> a[i];
  int r=0,l=0;
  ll cnt=0,S=0;
  for(;l<n;l++){
    while(r<n&&sub(S,a[r])==0){
      S+=a[r];
      r++;
    }
    if(r<n&&r-l==0)r++;
    cnt+=r-l;
    S-=a[l];
  }
  cout << cnt << endl;
}



Measured memory_bytes: 1792
#!/usr/bin/python
# coding: utf-8

while True:
    h, m, s = map(int, raw_input().split())
    if h == m == s == -1:
        break

    full = 2 * 3600
    rest = full - (h * 3600 + m * 60 + s)

    h = int(rest / 3600)
    m = int((rest - h * 3600) / 60)
    s = rest - h * 3600 - m * 60 

    th = int(rest / 1200)
    tm = int((rest - th * 1200) / 20)
    ts = (rest - th * 1200 - tm * 20) * 3

    print "{:02d}:{:02d}:{:02d}".format(h, m, s)
    print "{:02d}:{:02d}:{:02d}".format(th, tm, ts)

Measured memory_bytes: 4224
from heapq import heappush, heappop

N,M = map(int,input().split())
A = list(map(int,input().split()))

hq = []
for a in A:
  heappush(hq, -a)
for i in range(M):
  price = heappop(hq)
  heappush(hq, -(-price//2))
print(-sum(hq))

Measured memory_bytes: 64792
import math

n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

for i in range(1,4):
	sum=0
	for j in range(n):
		sum+=pow(math.fabs(x[j]-y[j]),i)
	print(str(pow(sum,1/i)))

infD=-1
for i in range(n):
	infD=max(math.fabs(x[i]-y[i]),infD)
print(float(infD))



Measured memory_bytes: 5712
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long p[10001][101]={0},v[101][2];
int main(){
int i,j,n,w,l;
cin>>n>>w;
for(i=1;i<=n;i++)cin>>v[i][0]>>v[i][1];
for(i=1;i<=n;i++){
	for(j=1;j<=w;j++){
		if(j==v[i][1]){
			p[j][i]=v[i][0];
			for(l=0;l<=w-j;l++){
				if(w>=j+l)p[j+l][i]=max(p[j+l][i],p[j][i]+p[l][i-1]);
			}
			
		}
		p[j][i]=max(p[j][i],p[j][i-1]);
		p[j][i]=max(p[j][i],p[j-1][i]);
	}
}
cout<<p[w][n]<<endl;
return 0;
}


				
		

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int a, b;
  std::cin >> a >> b;
  if (a == b) {
    std::cout << "Draw" << std::endl;
  } else if (a == 1) {
    std::cout << "Alice" << std::endl;
  } else if (b == 1) {
    std::cout << "Bob" << std::endl;
  } else if (a < b) {
    std::cout << "Bob" << std::endl;
  } else {
    std::cout << "Alice" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<cstdio>
#include<cmath>
using namespace std;
const int M=1e5+5;
const long  MN=LONG_MAX;
long pos[M];
int main()
{
     int n,k;
     long ans;
     while(cin>>n>>k)
     {
           pos[0]=0;
         int s=0,bound=0,flag=0;
         for(int i=1;i<=n;++i)
         {
             scanf("%ld",&pos[i]);
             if(pos[i-1]<0&&pos[i]>=0)s=i-1;
             if(s!=0)bound++;
         }
        // cout<<s<<endl;
         if(s==0)
         {
             if(pos[1]>=0)cout<<pos[k]<<endl;
             else if(pos[1]<=0)cout<<-pos[n-k+1]<<endl;
         }
         else
         {
           //  cout<<s<<" "<<bound<<endl;
             if(bound>k)bound=k;
             bound+=s;
             ans=MN;
            // cout<<s<<" "<<bound<<endl;
             for(int i=bound;i-k+1>=1&&i>=s;--i)
             {
                 int t=i-k+1;
               // cout<<t<<" "<<i<<endl;
                 if(t>s)ans=min(ans,pos[i]);
                 else if(i==s)ans=min(ans,-pos[t]);
                 else ans=min(ans,min(pos[i]+pos[i]-pos[t],-pos[t]+pos[i]-pos[t]));
               // cout<<ans<<endl;
             }
             cout<<ans<<endl;
          }
     }

}


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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  double d,t,s;
  cin >> d >> t >> s;

  if(d/s <= t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
  
  return 0;
}



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

using namespace std;

const int N = 4 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int a[N], c[N];
int pos[2][N];
int cnt[N][2][N];
int dp[N][N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 1; i <= n + n; ++i) {
        char ch;
        cin >> ch >> a[i];
        c[i] = ch == 'W' ? 0 : 1;
    }

    return true;
}

void solve() {
    for (int i = 1; i <= n + n; ++i) {
        pos[c[i]][a[i]] = i;

        for (int j = 1; j < i; ++j)
            ++cnt[i][c[j]][a[j]];

        for (int j = n; j >= 0; --j)
            for (int k = 0; k < 2; ++k)
                cnt[i][k][j] += cnt[i][k][j + 1];
    }

    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= n; ++j)
            dp[i][j] = MOD;

    dp[0][0] = 0;

    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= n; ++j) {
            if (i + 1 <= n) {
                auto k = pos[0][i + 1];
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cnt[k][0][i + 1] + cnt[k][1][j + 1]);
            }

            if (j + 1 <= n) {
                auto k = pos[1][j + 1];
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cnt[k][0][i + 1] + cnt[k][1][j + 1]);
            }
        }

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

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 159616
n=int(input())
a=[int(x) for x in input().split()]
b=[0]
for i in range(n):
  b.append(b[i]+a[i])
c=0
for j in range(n-1):
  c+=a[j]*(b[n]-b[j+1])
  while c//(10**9+7)>0:
    c%=10**9+7
print(c)

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

int main(){
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);

	int ma = k-a.at(n-1) + a.at(0);
	rep(i, n-1) ma = max(ma, abs(a.at(i)-a.at(i+1)));

	cout << k-ma << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	long long int N, A, B;
	scanf("%lld%lld%lld", &N, &A, &B);
	long long int ans = (N - 1) * B + A - (N - 1) * A - B + 1;
	if(ans >= 0){
		printf("%lld\n", ans);
	}
	else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	double s = 0;
	for (int i = 0; i < n; i++) {
		s += 1.0 / a[i];
	}

	cout << setprecision(15) << 1 / s << endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
const int N = 3*1e5, M = 7 + 1e9;
int k, a[N];
vector<ll> lulun;
int cnt = 0;
void generate(string s){
	++ cnt;
	if(s.size() == 11)
		return;
	if( !s.empty() )
		lulun.push_back(stoll(s));
	for(char i = '0'; i<='9'; ++i){
		if(s.empty() && i != '0' )
			generate((s+i));
		if(!s.empty() && abs(s.back() - i) <= 1)
			generate((s+i));
	}
}
int main()
{
	cin >> k;
	generate("");
	sort(lulun.begin(), lulun.end());
	cout << lulun[k-1] << endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

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

	Int H, W;
	cin >> H >> W;

	vector<vector<char>> G(H, vector<char>(W));
	vector<vector<Int>> dist(H, vector<Int>(W,-1));
	queue<pair<Int, Int>> que;
	char temp;
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> temp;
			if (temp=='#') {
				dist[i][j] = 0;
				que.push(make_pair(i, j));
			}
		}
	}

	//DMP(dist);

	Int x, y, nx, ny;
	while (!que.empty()) {
		x = que.front().first;
		y = que.front().second;
		que.pop();

		for (Int i = 0; i < 4; i++) {
			nx = x + dx[i];
			ny = y + dy[i];

			if (nx<0||nx>=H) {
				continue;
			}
			if (ny<0||ny>=W) {
				continue;
			}

			if (dist[nx][ny]!=-1) {
				continue;
			}

			dist[nx][ny] = dist[x][y] + 1;
			que.push(make_pair(nx, ny));
		}
	}

	
	
	Int ans = 0;
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 25524
#include <bits/stdc++.h>
#define int long long
#define iris 998244353
using namespace std;

int arr[100010];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,i;
	string s;
	cin>>s;
	n=s.size();
	s='0'+s;
	
	if(s[1]=='0' || s[n]=='1')
	{
		cout<<"-1\n";
		return 0;
	}
	for(i=n-1;i;i--)
	{
		if(s[i]!=s[n-i])
		{
			cout<<"-1\n";
			return 0;
		}
		if(!arr[i])
		{
			arr[i]=i+1;
		}
		if(s[i]=='0')
		{
			arr[i-1]=arr[i];
		}
	}
	
	for(i=1;i<n;i++)
	{
		cout<<i<<' '<<arr[i]<<'\n';
	}
	
	return 0;
}

Measured memory_bytes: 4576
import random
D = int(input())
# type毎の満足度の下がりやすさ
c = list(map(int, input().split()))

# [d,i]の満足度
s = [[] for _ in range(D)]
for d in range(D):
    si = list(map(int, input().split()))
    s[d] = si

for d in range(D):
    print(random.randint(1,26))


Measured memory_bytes: 9736
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>

#define SIZE 101
#define INF 100000000

using namespace std;


typedef pair<int, int> Pa;

string s;
char c[100];
int inde = 0;

int func(){
	vector<int> v;
	for (int i = 0; i < s.size(); i++) {
		if (isdigit(s[inde])) {
			int k = 0;
			while (isdigit(s[inde])) {
				c[k] = s[inde];
				k++;
				inde++;
			}
			/*for (int j = 0; j < 100; j++) {
				cerr << c[k];
			}*/

			c[k] = '\0';

			v.push_back((atoi(c) + 1) / 2);

		} else if (s[inde] == '[') {
			inde++;
			v.push_back(func());

		} else if (s[inde] == ']') {
			vector<int> v2 = v;
			sort(v2.begin(), v2.end());

			int res = 0;
			for (int i = 0; i <= v.size() / 2; i++) {
				res += v2[i];
			}
			inde++;
			return (res);
		}
	}
}

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

	for (int i = 0; i < n; i++) {
		cin >> s;
		inde = 1;
		int res = func();
		cout << res << endl;
    }
}

Measured memory_bytes: 1300
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"


using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
	
public:
	vector<long long int>v;
	vector<long long int>edge;
	vector<long long int>sum;
	vector<long long int>can;
	UnionFind(int num,vector<long long int>vv) {
		num++;
		v = vv;
		parent.resize(num);
		rank.resize(num);
		edge.resize(num);
		sum.resize(num);
		can.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
		for (int i = 1; i < num; i++)sum[i] = v[i];
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v,long long int c) {
		u = Find(u);
		v = Find(v);
		if (u == v) {
			edge[u]++;
			if (c <= sum[u]) {
				can[u] = edge[u];
			}
			return;
		}
		if (rank[u] < rank[v]) {
			parent[u] = v;
			edge[v] += edge[u];
			edge[v]++;
			sum[v] += sum[u];
			can[v] += can[u];
			if (sum[v] >= c)can[v] = edge[v];
		}
		else {
			parent[v] = u;
			edge[u] += edge[v];
			edge[u]++;
			sum[u] += sum[v];
			can[u] += can[v];
			if (sum[u] >= c)can[u] = edge[u];
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

struct Edge {
	int a, b;
	long long int cost;
	bool operator <(const Edge&e)const {
		return cost < e.cost;
	}
};

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

	cin >> N >> M;
	vector<long long int>v(N + 1);
	for (int i = 1; i <= N; i++)cin >> v[i];
	vector<Edge>edge(M);
	set<Edge>se;
	for (auto &i : edge) {
		cin >> i.a >> i.b >> i.cost;
		se.insert(i);
	}
	sort(edge.begin(), edge.end());
	int ans = 0;
	UnionFind uf(N,v);
	for (int i = 0; i < M; i++) {
		uf.Unite(edge[i].a, edge[i].b, edge[i].cost);
	}
	cout << M - uf.can[uf.Find(1)] << endl;
}

Measured memory_bytes: 13568
// “Incredible change happens in your life when you decide to take control of what
// you do have power over instead of craving control over what you don't.

// Dear online judge:
//  I've read the problem, and tried to solve it.
//  Even if you don't accept my solution, you should respect my effort.
//  I hope my code compiles and gets accepted.

#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define input2d(arr, n, m) forn(i, 0, n) forn(j, 0, m) cin >> arr[i][j];
#define MOD 1000000007
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define tc    \
    ll T;     \
    cin >> T; \
    while (T--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

int32_t main()
{
    FAST;
    //tc
    {
        string s,t;
        cin>>s >> t;
        t.pop_back();
        if(s==t)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3588
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X, t;
    cin >> X >> t;
    cout << max(X - t, (ll)0) << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    ll n, a, b; cin >> n >> a >> b;
    ll ans = 0;
    if((b-a)%2==0){
        ans = (b-a)/2;
    }else{
        ans = min(a-1, n-b) + 1 + (b-a-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	var a, b int64
	if N == 1 {
		fmt.Println(1)
		return
	}
	a = 1
	b = 2
	for i := 2; i <= N; i++ {
		c := a + b
		a, b = c, a
	}
	fmt.Println(a)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) 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 *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) 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
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <sstream>
#include <iomanip>

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N, M;
  cin >> N >> M;

  vector<string> ans(M+1, "");

  //県ごとの市のデータ(年、i)
  map<int, vector<pair<int, int>>> mp;
  
  for(int i = 0; i < M; i++){
    int p, y; cin >> p >> y;
    mp[p].push_back(make_pair(y, i+1));
  }

  for(int i = 1; i <= N; i++){
    if(mp[i].size() == 0) continue;
  
    sort(mp[i].begin(), mp[i].end());
    
    ostringstream ost;
    ost << std::setw (6) << setfill('0') << i;
    string pID = ost.str();

    for(int j = 0; j < mp[i].size(); j++){
      int num = mp[i][j].first;
      int id = mp[i][j].second;

      ostringstream ost2;
      ost2 << std::setw (6) << setfill('0') << j+1;
      ans[id].append(pID);
      ans[id].append(ost2.str());
    }

  }

  for(int i = 1; i < M+1; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 17920
function Main(input) {
  input = input.split(' ')
  var A = parseInt(input[0])
  var B = parseInt(input[1])
  var K = (A + B) / 2

  if (Number.isInteger(K)) {
    console.log(K)
  } else {
    console.log('IMPOSSIBLE')
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, T, A;
  cin >> N >> T >> A;
  int H[N];
  for(int i=0; i<N; ++i) cin >> H[i];
  int ans, n;
  int d = 1e9;
  for(int i=0; i<N; ++i){
    n = abs(1000*A-(1000*T-H[i]*6));
    if (d > n){
      ans = i+1;
      d = n;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32,
        v: [u32;n]
    }
    let mut min = std::u32::MAX;
    let mut ans = 0;
    for i in v.iter() {
        if *i < min {
            min = *i;
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
<?php
// Your code here!
fscanf(STDIN,"%d %d",$a,$v);
fscanf(STDIN,"%d %d",$b,$w);
fscanf(STDIN,"%d",$t);


if($b < 0){
    $bb = -1 * $t * $w + $b;
    $aa = -1 * $t * $v + $a;
}else{
    $bb = $t * $w + $b;
    $aa = $t * $v + $a;
}

if(abs($aa) - abs($bb) >= 0){
    echo "YES";
}else{
    echo "NO";
}

Measured memory_bytes: 16044
#import<iostream>
#import<algorithm>
long long i,j,n,x,m=1000000007,s[200],d[1<<17];
main(){std::cin>>n>>x;for(i=0;i!=n;++i)std::cin>>s[i];std::sort(s,s+n);for(i=0;i<=x;++i)d[i]=i;for(i=0;i!=n;++i){for(j=x;j;--j)d[j]=(d[j]*i+d[j%s[i]])%m;}std::cout<<d[x];}

Measured memory_bytes: 1024
// 2013/12/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){			// 複数の入力に対応

		int N, M;
		cin >> N >> M;

		if(N==0 && M==0)
			break;

		int n[1001];
		for(int i=1; i<=N; i++){
			cin >> n[i];
		}

		int m[1001];
		for(int i=1; i<=M; i++){
			cin >> m[i];
		}

		int x = 1;
		int cnt = 0;

		for(int i=1; i<=M; i++){
			cnt++;

			x += m[i];
			if(x>=N)
				break;

			x += n[x];
			if(x>=N)
				break;
		}

		cout << cnt << '\n';
	}

	return 0;
}

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


int main(){

	int num;
	string direction;
	int Dice[6] = {};//{0,1,2,3,4,5}={???,S,E,W,N,???}
	int Dice_b[6] = {};
	for (int i = 0; i < 6; i++){//???????????????????????°????????£??\
		cin >> num;
		Dice[i] = num;
	}

	cin >> direction;//??????????????£??\

	for (int i = 0; direction[i]; i++){
	
		switch (direction[i]){
		
		case 'S':
			Dice_b[0] = Dice[4];
			Dice_b[1] = Dice[0];
			Dice_b[2] = Dice[2];//E
			Dice_b[3] = Dice[3];//W
			Dice_b[4] = Dice[5];
			Dice_b[5] = Dice[1];
			break;

		case 'E':
			Dice_b[0] = Dice[3];
			Dice_b[1] = Dice[1];//S
			Dice_b[2] = Dice[0];
			Dice_b[3] = Dice[5];
			Dice_b[4] = Dice[4];//N
			Dice_b[5] = Dice[2];
			break;

		case 'W':
			Dice_b[0] = Dice[2];
			Dice_b[1] = Dice[1];//S
			Dice_b[2] = Dice[5];
			Dice_b[3] = Dice[0];
			Dice_b[4] = Dice[4];//N
			Dice_b[5] = Dice[3];
			break;
		case 'N':
			Dice_b[0] = Dice[1];
			Dice_b[1] = Dice[5];
			Dice_b[2] = Dice[2];//E
			Dice_b[3] = Dice[3];//W
			Dice_b[4] = Dice[0];
			Dice_b[5] = Dice[4];
			break;		
		}//switch???

        //Dice_b????????????Dice????????????
		for (int i = 0; i < 6; i++){
			Dice[i] = Dice_b[i];
		}
	}	//??°???????????????

	cout << Dice[0] << endl;


	return 0;
}

Measured memory_bytes: 1204
# coding: utf-8
# Your code here!
q,h,s,d = map(int,input().split())
N=int(input())

x=min(q*8,h*4,s*2,d)#2Lあたりの値段 
y=min(q*4,h*2,s)
if N % 2 == 0:
    ans = x * (N//2)
else:
    ans = x * (N // 2)
    ans += y

print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <set>
#include <tuple>
#include <vector>
#define ll long long
#define inf 100000000000000000;

using namespace std;

int main () {
  ll n;
  cin >> n;
  vector<tuple<ll, ll, ll> > box;
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      ll s;
      cin >> s;
      if (i > j) {
        box.push_back(make_tuple(s, i + 1, j + 1));  
      }
    }  
  }  
  sort(box.begin(), box.end());
  /*
  for (ll i = 0; i < box.size(); i++) {
    cout << get<0>(box[i]) << " " << get<1>(box[i]) << " " << get<2>(box[i]) << endl;  
  }
  */
  ll length[n + 1][n + 1];
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= n; j++) {
      length[i][j] = inf;  
    }  
    length[i][i] = 0;
  }
  vector<ll> v;
  set<ll> e;
  for (ll p = 0; p < box.size(); p++) {
    ll canditate = get<0>(box[p]);
    ll i = get<1>(box[p]);  
    ll j = get<2>(box[p]);
    ll sub = inf;
    for (auto q : e) {
      if (sub > length[i][q] + length[q][j]) {
        sub = length[i][q] + length[q][j];  
      }  
    }  
    if (canditate > sub) {
      cout << - 1 << endl;
      return 0;  
    }
    if (sub == canditate) {
      // 何もしない．  
    }
    else {
      e.insert(i);  
      e.insert(j);
      v.push_back(canditate);  
      length[i][j] = canditate;
      length[j][i] = canditate;
      for (auto q : e) {
        for (auto r : e) {
          // e[q] ~ iに行き，
          if (length[q][r] > length[q][i] + canditate + length[j][r]) {
            length[q][r] = length[q][i] + canditate + length[j][r];  
            length[r][q] = length[q][r];
          }  
        }  
      }
    }
  }
  ll sum = 0;
  for (ll i = 0; i < v.size(); i++) {
    sum += v[i];  
  }
  cout << sum << endl;

}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
    int a,b,c,p;
    cin>>a>>b>>c;
    //ll n=(a/b);
    if(a%b>0){p=(a/b)+1;}
    else {p=a/b;}
    cout<<p*c;
}

Measured memory_bytes: 3640
n = int(input())
mod = 10 ** 9 + 7

a = 1
b = 1
c = 1

for _ in range(n):
    a = (a * 10) % mod
    b = (b * 9) % mod
    c = (c * 8) % mod
ans = (a - 2 * b + c) % mod
print(ans)


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> T th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int main(){
	Int n;
	string s;
	cin >> n >> s;
	char prev = '\0';
	Int ans = 0;
	RC(i, n){
		if(prev != s[i]) ++ans;
		prev = s[i];
	}
	cout << ans << endl;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int h, w;
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
        {
            break;
        }

        REP(i, h)
        {
            REP(j, w)
            {
                cout << "#";
            }

            cout << endl;
        }

        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3220
N = int(input()) 
A = list(map(int,input().split()))

CSUM = [0 for _ in range(N)]
CSUM[0] = A[0]
for i in range(1,N):
  CSUM[i] = CSUM[i-1] + A[i]
#print(CSUM)
def csum(i,j):
  if i == 0:
    return CSUM[j]
  else:
    return CSUM[j]-CSUM[i-1]

dp = [[0 for _ in range(N)] for _ in range(N)]

for k in range(1,N):
  for i in range(N-k):
    j = i+k
    tmp = 10**18
    for l in range(i,j):
      tmp = min(tmp,dp[i][l]+dp[l+1][j] + csum(i,j))
    dp[i][j] = tmp

print(dp[0][N-1])
#print(dp)


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9*2;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    REP(i,n)
        cin>>a[i];
    if(n%2==0)
    {
        int j=0;
        for(int i=n-1;i>=0;i-=2)
            b[j++]=a[i];
        for(int i=0;i<n;i+=2)
            b[j++]=a[i];
    }
    else
    {
        int j=0;
        for(int i=n-1;i>=0;i-=2)
            b[j++]=a[i];
        for(int i=1;i<n;i+=2)
            b[j++]=a[i];
    }
    REP(i,n)
        cout<<b[i]<<" \n"[i==n-1];
}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int):
    if (A==B and A!=C) or (A==C and A!=B) or (B==C and B!=A):
        print ("Yes")
    else:
        print ("No")
    return


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

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	int p,q, r, r1, r2, r3, result;
	scanf("%d%d%d", &p, &q, &r);
	r1 = p + q;
	r2 = r + p;
	r3 = q + r;
	result = min(r1,r2);
	result = min(result, r3);
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  
  bool can=true;
  if(A==B && B==C && C==A)
    can=false;
  if(A!=B && B!=C && C!=A)
    can=false;
  
  if(can)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<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;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int Y = nextInt();
  Y /= 1000;
  for (int a = 0; a <= N && a*10 <= Y; a++) {
    for (int b = 0; a + b <= N && a*10 + b*5 <= Y; b++) {
      int c = N - (a + b);
      int y = Y - (a*10 + b*5);
      if (c == y) {
        cout << a << " " << b << " " << c << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S  = sc.next();

        int count0=0;
        int count1=0;
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            if(c=='0') count0++;
            if(c=='1') count1++;
        }

        System.out.println(Math.min(count0,count1)*2);
    }
}


Measured memory_bytes: 25448
#include<stdio.h>
#define H 250

int main(){
  int A[H],h,i;

  scanf("%d",&h);
  for(i=1;i<=h;i++) scanf("%d",&A[i]);

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2>=1) printf("parent key = %d, ",A[i/2]);
    if(2*i<=h) printf("left key = %d, ",A[2*i]);
    if(2*i+1<=h) printf("right key = %d, ",A[2*i+1]);
    printf("\n");
  }

  return 0;

}



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

using namespace std;
int main(void){
  string s;
  string t;
  int c=0;
  
  cin>>s;
  cin>>t;
  
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      c++;
    }
  }
  
  cout<<c<<endl;
}


Measured memory_bytes: 256
using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine()) / 50;

            var count = 0;
            for (int aCount = 0; aCount <= a; aCount++)
            {
                var zanA = x - 10 * aCount;
                if (zanA < 0)
                {
                    break;
                }
                for (int bCount = 0; bCount <= b; bCount++)
                {
                    var zanB = zanA - 2 * bCount;
                    if (zanB < 0)
                    {
                        break;
                    }
                    if (zanB <= c)
                    {
                        count++;
                    }
                }
            }

            //出力
            Console.WriteLine(count.ToString());

            Console.ReadLine();
        }
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  
  vector<vector<int>> A(N, vector<int>(0, 0));
  for (int i = 0; i < M; i++ ) {
    int a,b;
    cin >> a >> b;
    A.at(a-1).push_back(b-1);
    A.at(b-1).push_back(a-1);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int judge = 0;
    if (A.at(i).size() == 0) ans++;
    else {
      for (int b : A.at(i)) {
        if (H.at(i) <= H.at(b)) {
          judge++;
          break;
        }
      }
      if (judge == 0) ans++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 8804
#include<stdio.h>
#include<math.h>
int ifcl(int p0[2],int p1[2],int p2[2],int p3[2]){
  long long x=p0[0],x0=p1[0]-x,x1=p2[0]-x,x2=p3[0]-x,x3=x2-x1,x6=x1-x0,x7=x2-x0;
  long long y=p0[1],y0=p1[1]-y,y1=p2[1]-y,y2=p3[1]-y,y3=y2-y1,y6=y1-y0,y7=y2-y0;
  long long c1=(x0*y1-y0*x1)*(x0*y2-y0*x2),c2=(x3*y6-y3*x6)*(x3*y1-y3*x1);
  long long d1=x1*x6+y1*y6,d2=x6*x7+y6*y7,d3=x2*x7+y2*y7,d4=x1*x2+y1*y2;
  if(c1==0&&c2==0)return (d1>0&&d2>0&&d3>0&&d4>0)?0:1;
  return (c1<=0&&c2<=0)?1:0;
}

int main(){
  int p[4][2],n,i;
  scanf("%d",&n);
  while(n--){
    for(i=0;i<8;i++)scanf(" %d",&p[i/2][i%2]);
    printf("%d\n",ifcl(p[0],p[1],p[2],p[3]));
  }
  return 0;
}

Measured memory_bytes: 600
n = int(input())
counter = 0
s = "TEMP"
list = []
temp = ''

while n > 0:
  s = input()
  list.append(s)
  n = n - 1

list.sort()
for item in list:
  if item == temp:
    counter = counter - 1
  counter = counter + 1
  temp = item

print(counter)

Measured memory_bytes: 23712
#include <cstdio>
#include <queue>

using namespace std;

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

const int INF = 1e9;
const int D[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};

const int H_MAX = 50;
const int W_MAX = 50;

typedef pair<int, int> P;

int H, W;
char s[H_MAX][W_MAX + 1];
int d[H_MAX][W_MAX];

int bfs() {
  queue<P> que;
  que.push(P(0, 0));
  fill(d[0], d[H], INF);
  d[0][0] = 1;
  while (!que.empty()) {
    P p = que.front(); que.pop();
    int i = p.first;
    int j = p.second;
    if (i == H - 1 && j == W - 1) break;
    REP(k, 4) {
      int i2 = i + D[k][0];
      int j2 = j + D[k][1];
      if (i2 < 0 || i2 >= H || j2 < 0 || j2 >= W) continue;
      if (s[i2][j2] == '#' || d[i2][j2] < INF) continue;
      que.push(P(i2, j2));
      d[i2][j2] = d[i][j] + 1;
    }
  }
  return d[H - 1][W - 1];
}


void solve() {
  int all = 0;
  REP(i, H) REP(j, W) if (s[i][j] == '.') all++;
  int mini = bfs();
  if (mini > all) puts("-1");
  else printf("%d\n", all - mini);
}

void input() {
  scanf("%d%d", &H, &W);
  REP(i, H) scanf("%s", s[i]);
}

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


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

int main()
{
    int W, H;
    bool flag;
    while (cin >> H >> W)
    {
        flag = true;
        if (H == 0 && W == 0)
        {
            break;
        }
        for (int row = 0; row < H; ++row)
        {
            for (int col = 0; col < W; ++col)
            {
                cout << (flag ? "#" : ".");
                flag = !flag;
            }
            cout << "\n";
            if (W % 2 == 0)
            {
                flag = !flag;
            }
        }
        cout << "\n";
    }
}


Measured memory_bytes: 3052
import java.util.Scanner;
//import java.util.Map;
//import java.util.HashMap;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int tmp;
		int count=0;
		for(int i=0;i<n;i++){
			tmp = in.nextInt();
			if(tmp%4==0)
				count+=2;
			else
				if(tmp%2==0)
					count++;
		}
		if(count>=n/2*2)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

int main() {
    int n, h; std::cin >> n >> h;
    std::vector<std::pair<int, int>> st_t(n);
    int max_a = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> st_t[i].first >> st_t[i].second;
        max_a = std::max(max_a, st_t[i].first);
    }

    std::sort(st_t.begin(), st_t.end(), [](const auto &a, const auto &b){
        return a.second> b.second;
    });

    int thr = 0;
    for (const auto& t: st_t) {
        if (t.second > max_a) {
            thr++;
            h -= t.second;
            if (h <= 0) {
                break;
            }
        } else {
            break;
        }
    }
    if (h > 0) {
        thr += (h + max_a - 1)/ max_a;
    }
    std::cout << thr << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

using namespace std;

int N,A,B;
typedef long long int ll;

const ll MOD=1000000007;

ll fast_power(ll base,ll exp){
    if (exp==0) return 1ll;

    auto temp=fast_power(base,exp/2);
    if (exp%2) return temp*temp%MOD*base%MOD;
    else return temp*temp%MOD;
}

ll inv(ll a){ return fast_power(a,MOD-2);};

ll C(ll m,ll n){
    auto limit=min(n,m-n);

    auto denom=1ll,nom=1ll;
    for(ll i=0;i<limit;i++) denom=denom*(m-i)%MOD,nom=nom*(1+i)%MOD;

    return denom*inv(nom)%MOD;
}

int main(){

    scanf("%d%d%d",&N,&A,&B);

    auto ans=fast_power(2,N);

    ans=(ans+MOD-1)%MOD;

    ans=(ans+MOD-C(N,A))%MOD;
    ans=(ans+MOD-C(N,B))%MOD;

    printf("%lld\n",ans);

    return 0;
}

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

int main() {
    int N,D,X;
    cin >> N >> D >> X;
    vector<int>A(N);
    int ans = X;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        ans++;
        ans+=(D-1)/A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int a[1111],b[1111],c[1111],d[1111],p[333],i,j,x,y,z;
 
main(){
  for(;scanf("%d%d%d",a,b,c)&&(*a+=*b+*c);){
    for(i=332;i;p[i--]=2);
    for(i=0,scanf("%d",p);i++<*p;scanf("%d%d%d%d",a+i,b+i,c+i,d+i));
    for(i=0;i++<*p;)for(j=0;j++<*p;d[j]?p[a[j]]=p[b[j]]=p[c[j]]=1:(x=p[a[j]]&1)&(y=p[b[j]]&1)?p[c[j]]=0:x&(z=p[c[j]])?p[b[j]]=0:y&z?p[a[j]]=0:0);
    for(i=0;i<*a;printf("%d\n",p[++i])); 
  }
  return 0;
}

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

typedef long long int ll;
#define pb push_back
#define mod 1000000007

int main()
{
   
   ll n,i,j,k,l,w,cnt,tmp;
   ll ans=0;
   cin>>l>>w;

   char a[l+1][w+1];

   for(i=1;i<=l;i++)
   {
        for(j=1;j<=w;j++)
        {
            cin>>a[i][j];
        }
   }


   ll up[l+2][w+2],dn[l+2][w+2],rt[l+2][w+2],lf[l+2][w+2];

   for(i=0;i<=l+1;i++)
    {
        for(j=0;j<=w+1;j++)
        {
            up[i][j]=0;
            dn[i][j]=0;
            lf[i][j]=0;
            rt[i][j]=0;
        }
    }

    //lf
    for(i=1;i<=l;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i][j]=='#')
                lf[i][j]=0;
            else
                lf[i][j]=lf[i][j-1]+1;
        }
    }

    //rt
    for(i=1;i<=l;i++)
    {
        for(j=w;j>=1;j--)
        {
            if(a[i][j]=='#')
                rt[i][j]=0;
            else
                rt[i][j]=rt[i][j+1]+1;
        }
    }

    //up
    for(i=1;i<=l;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i][j]=='#')
                up[i][j]=0;
            else
                up[i][j]=up[i-1][j]+1;
        }
    }

    //dn
    for(i=l;i>=1;i--)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i][j]=='#')
                dn[i][j]=0;
            else
                dn[i][j]=dn[i+1][j]+1;
        }
    }

    for(i=1;i<=l;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i][j]=='.')
            ans=max(ans,up[i][j]+dn[i][j]+rt[i][j]+lf[i][j]-3);
        }
    }

    cout<<ans;
}

Measured memory_bytes: 129408
S = list(input())
N = len(S)

def palindrome(string): return 0 if string==string[::-1] else 1

aaa = "".join(S)
tmp = int((N-1)/2-1)
bbb = "".join(S[0:tmp+1])
tmp = int((N+3)/2-1)
ccc = "".join(S[tmp:N])

sum = palindrome(aaa)+palindrome(bbb)+palindrome(ccc)


if sum ==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
int main()
{
	int n, m;
	cin>>n>>m;
	char mat[n][m];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>mat[i][j];
			
	int dp[n][m];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		if(mat[i][0]=='.')
			dp[i][0] = 1;
		else{
			dp[i][0] = 0;
			break;
		}
	}
	for(int i=0;i<m;i++)
	{
		if(mat[0][i]=='.')
			dp[0][i] = 1;
		else{
			dp[0][i]=0;
			break;
		}
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(mat[i][j]=='.')
				dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
			else
				dp[i][j] = 0;
		}
	}
	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			cout<<dp[i][j]<<" ";
			
		cout<<endl;
	}*/
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


inline double inp(const P &a, const P &b) {
	return (conj(a) * b).real();
}

inline double outp(const P &a, const P &b) {
	return (conj(a) * b).imag();
}

P circumc(const P &a, const P &b, const P &c) {
	return (a + b - (inp(c - b, a - c) / outp(b - a, c - b)) * (b - a) * P(0, 1)) / 2.0;
}

int main(){
	int n; cin >> n;
	while (n--) {
		double x1, y1, x2, y2, x3, y3; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		P p1(x1, y1), p2(x2, y2), p3(x3, y3);
		P c = circumc(p1, p2, p3);
		double r = abs(p1 - c);
		double x = c.real();
		double y = c.imag();
		if (fabs(x + 0.0005) < 0.001) x = 0;
		if (fabs(y + 0.0005) < 0.001) y = 0;
		printf("%.3f %.3f %.3f\n", x, y, r);
	}
	return 0;
}

Measured memory_bytes: 0