akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;
using namespace std;


int main() {
    ll n;
    cin>>n;
    string name="";
    while(n){
        --n;
        name += 'a'+n%26;
        n /= 26;
    }
    reverse(rng(name));
    cout<<name<<endl;
    

    return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> L(N, 0);
    for(auto& l:L){
        cin >> l;
    }

    sort(L.rbegin(), L.rend());

    int ans = 0;
    for (int i = 0; i < K; ++i)
    {
        ans += L[i];
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  int N;
  int cnt=0;
  int des,cur;
  cin >> N;
  vector<int> b(N);
  for(int i = 0;i<N;i++)cin>>b.at(i);
  // for(int i = 1; i<100;i++){
  //   int des = b.at(i);
  //   cnt+=1;
  //   b.at(i) =0;
  //   b.at(des)
  //   if(des == 2)break;
  // }
  cur = 0;
  while(true){
    if(des == 1)break;
    des = b.at(cur) -1;
    b.at(cur) = 0;
    if(b.at(des) == 0){
      cnt = -1;
      break;
    }
    cur = des;
    cnt+=1;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(200000)
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
g = A[0]
for i in range(1,N):
    g = gcd(g,A[i])
if K > max(A):
    print("IMPOSSIBLE")
    exit()
if K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 86360
import math
N = int(input())

ans = 0

if N % 2 != 0 or N == 0:
    pass
else:
    max_pow_five = int(math.log(N, 5))
    for i in range(1, max_pow_five + 1):
        ans += N // ((5 ** i) * 2)

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    string t;
    cin>>t;
    int ans = 0;
    rep(i,t.size()){
        if(t[i] == '?')t[i] = 'D';
    }
    cout<<t<<endl;

    return 0;
}


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

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

using namespace std;

typedef long long ll;

vector<string> split(string &str,char delim)
{
	vector<string> res;
	size_t current = 0,found;
	while((found = str.find_first_of(delim,current)) != string::npos)
	{
		res.push_back(string(str,current,found  - current));
		current = found + 1;
	}
	res.push_back(string(str,current,str.size() - current));
	return res;
}
int main()
{
	int n,m;
	while(cin >> n && n)
	{
		map<string,ll> ma;
		
		rep(i,n)
		{
			string s;
			ll temp;
			cin >> s >> temp;
			ma[s] = temp;
		}

		cin >> m;
		vector<vector<string> > v(m);
		
		rep(i,m)
		{
			string s1;
			ll t;
			cin >> s1 >> t;
			
			v[i].push_back(s1);

			rep(j,t)
			{
				cin >> s1;
				v[i].push_back(s1);
			}
		}
		
		rep(i,m)
		{
			rep(j,m)
			{
				ll t = 0;
				REP(k,1,v[j].size())
				{
					t += ma[v[j][k]];
				}
				ma[v[j][0]] = min(ma[v[j][0]],t);
			}
		}
		
		string ans;
		cin >> ans;

		cout << ma[ans] << endl;
	}
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> S(H, vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> S[i][j];
        }
    }
    int res=INF;
    for(int bits=0; bits<(1<<(H-1)); bits++){
        int sum=__builtin_popcount(bits);
        vi cnt(sum+1, 0);
        int ng=0;
        for(int i=0; i<W; i++){
            int id=0;
            for(int j=0; j<H; j++){
                if(S[j][i] == '1'){
                    cnt[id]++;
                }
                if(bits>>j & 1){
                    id++;
                }
            }
            bool ok=true;
            for(int j=0; j<(int)cnt.size(); j++){
                if(cnt[j] > K){
                    ok=false;
                }
            }
            if(ok) ng=0;
            else{
                for(int j=0; j<(int)cnt.size(); j++){
                    cnt[j]=0;
                }
                i--;
                sum++;
                ng++;
            }
            if(ng == 2){
                sum=INF;
                break;
            }
        }
        res=min(res, sum);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, l; cin >> n >> l;
    int tot = 0;
    int mini = MOD;
    rep(i, n)
    {
        int ap = l + i;
        tot += ap;
        ap = abs(ap - 0);
        mini = min(mini, ap);
    }
    cout << abs(abs(tot - 0) - abs(mini - 0)) * (tot / (abs(tot - 0) == 0 ? 1 : abs(tot - 0))) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}



signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,n)cnt += s[i] == 'R';
    if(cnt*2 > n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "-10 5 -4" ].parse.expand.solve == 19 );
	assert( [ "5", "10 -4 -8 -11 3" ].parse.expand.solve == 30 );
	assert( [ "11", "-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000" ].parse.expand.solve == 10000000000 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}
auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto mc = 0L;
	auto m = long.max;
	auto ans = 0L;
	foreach( ref a; as )
	{
		mc += ( a <= 0 );		// マイナスorゼロの個数を集計
		a = a.abs;				// 絶対値に変換
		m = min( m, a );		// 絶対値が一番小さいやつを検索
		ans += a;				// 絶対値の合計を計算
	}
	
	// マイナスorゼロが偶数個だったら全部プラスにできる
	// マイナスorゼロが奇数個だったら絶対値が一番小さいやつをマイナス、残りをプラスにする
	if( mc % 2 == 1 ) ans -= m * 2;
	
	return ans;
}


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

int main(){
    int N;cin>>N;
    int array[N];
    int dp[N]={1000};
    for(int i=0;i<N;i++)cin>>array[i];
    dp[0]=array[0];
    for(int i=1;i<N;i++){
        if(array[i]<array[i-1])dp[i]=dp[i-1];
        else dp[i]=dp[i-1]+array[i]-array[i-1];
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
using namespace std;
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
//
//bool prime[n];
//vector<int> v;
//void sieve(){
//    prime[0]=prime[1]=1;
//    for(int i=2;i*i<=n;i++){
//        if(prime[i]==0){
//            for(ll j = i*i;j<=n;j+=i){
//                prime[j]=true;
//            }
//        }
//    }
//    for(int i=2;i<=n;i++){
//        if(prime[i]==0)v.push_back(i);
//    }
//}
//
//bool ispalindrome(string s){
//
//    for(int i=0,j=s.size()-1;i<s.size();i++,j--){
//        if(s[i]!=s[j])
//            return false;
//    }
//    return true;
//}


int main(){
   int n,k,ans;
        cin>>n>>k;
    if(n>=10)cout<< k <<endl;
    else {
        ans = k + (100*(10-n));
            cout<< ans <<endl;
    }
    return accepted;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}

const LLI inf = 1e18;

template <typename T> class Dinic{
private:
  vector<vector<pair<int,T>>> graph;
  int size, s, t;
  vector<vector<T>> cap;
  vector<int> level;
  
  bool buildLevel(){
    fill(ALL(level), 0);
    level[s] = 1;
    deque<int> deq = {s};
    while(!deq.empty()){
      int cur = deq.front(); deq.pop_front();
      REP(i,size)
	if(level[i]==0 && cap[cur][i]>0){
	  level[i] = level[cur] + 1;
	  deq.push_back(i);
	}
    }
    return level[t] != 0;
  }
  void dfs(vector<int> &path, T &flow){
    if(path.empty()) return;
    int cur = path.back();
    if(cur == t){
      T f = inf;
      FOR(i,1,path.size()) f = min(f, cap[path[i-1]][path[i]]);
      FOR(i,1,path.size()){
	cap[path[i-1]][path[i]] -= f;
	cap[path[i]][path[i-1]] += f;
      }
      flow += f;
    }else{
      REP(i,size){
	if(cap[cur][i]>0 && level[i]>level[cur]){
	  path.push_back(i);
	  dfs(path, flow);
	  path.pop_back();
	}
      }
    }
  }
  T augment(){
    T f = 0;
    vector<int> path = {s};
    dfs(path, f);
    return f;
  }
  T loop(){
    T f = 0;
    while(buildLevel()) f += augment();
    return f;
  }

public:
  Dinic(vector<vector<pair<int,T>>> &_graph): graph(_graph), size(graph.size()) {}

  T query(int _s, int _t){
    cap = vector<vector<T>>(size, vector<T>(size, 0));
    level = vector<int>(size, 0);

    REP(i,size)
      for(auto &p : graph[i]){
	int j = p.first;
	T d = p.second;
	cap[i][j] += d;
      }

    s = _s;
    t = _t;
      
    return loop();
  }
};


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

  int n; cin >> n;
  vector<LLI> a(n);
  REP(i,n) cin >> a[i];

  vector<vector<pair<int,LLI>>> graph(n+2);

  int s = 0, t = n+1;

  REP(i,n){
    if(a[i] <= 0)
      graph[s].push_back(make_pair(i+1,-a[i]));
    else
      graph[i+1].push_back(make_pair(t,a[i]));
  }

  FORE(i,1,n)
    FORE(j,i+1,n)
      if(j % i == 0)
	graph[i].push_back(make_pair(j,inf));


  Dinic<LLI> dinic(graph);

  LLI sum = 0;
  REP(i,n) sum += max(0LL, a[i]);
  

  cout << sum - dinic.query(s,t) << endl;

  
  return 0;
}


Measured memory_bytes: 384
// ABC154 E - Almost Everywhere Zero
// 問題URL
// https://atcoder.jp/contests/abc154/tasks/abc154_e

#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>

using namespace std;

int main()
{
  string S;

  cin >> S;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long 

/////////////

signed main()
{
  
    int n;
    cin>>n;
    int a[n];
    int s=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        s+=a[i];
        a[i]*=n;
    }
    int m=abs(s-a[0]),po=0;
    for(int i=1;i<n;++i)
    {
        if(abs(s-a[i])<m)
        {
            po=i;
            m=abs(s-a[i]);
        }
    }
    cout<<po;
}

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

int main() {

	long long  X;
	cin >> X;

	long long risoku = 100.0;
	int kikan = 0;
	while (1) {
		risoku = floor(risoku * 1.01);
		//cout << risoku << endl;
		kikan++;
		if (X <= risoku) {
			break;
		}
	}

	cout << kikan << endl;


}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    if (i * j == n)
                    {
                        WriteLine("Yes");
                        return;
                    }
                }
            }
            WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	//Number of items available and max capacity of Knapsack
	int items, capacity;
	cin >> items >> capacity;

	//Store the value sum for each combination of items with weight w
	long long dp[capacity+1];
	//set all dp values to zero in order to compare max value
	memset(dp,0,sizeof dp);

	//read every weight and value of item
	int weight, value;	
	for (int i = 0; i < items; ++i)
	{
		cin >> weight >> value;
		//cw is the current weight inside the knapsack
		for (int cw = capacity - weight;cw>=0;cw--){
			//Check max value between (don't put item, put item)
			//Then memoize current answer
			dp[cw + weight] = max(dp[cw + weight], dp[cw] + value);
		}
	}
	//Set answer to zero in order to compare max value
	long long answer = 0;
	//Loop through dp to get max possible value
	for (int i=0; i<=capacity; ++i)
	{
		answer = max(answer,dp[i]);
	}
	//Print max possible sum of values
	cout << answer << endl;

}

Measured memory_bytes: 4372
fun main() {
  val (total, _) = readLine()!!.split(' ').map { it.toInt() }
  val sum = readLine()!!.split(' ').map { it.toInt() }.sum()
  val rest = total-sum
  val o = if (rest >= 0) {
    rest
  } else {
    -1
  }
  println(o)
}

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

int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  vector<char> answer;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') {
      if (answer.size()) answer.pop_back();
    } else {
      answer.push_back(s[i]);
    }
  }
  for (auto c : answer) cout << c;
  cout << endl;
  return 0;
}


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

long long int gcd(long long int a, long long int b)
{
	if (a < b){
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	if (b == 0) return a;

	long long int c = a % b;
	while (c != 0){
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}

int main()
{
	int N = 0;
	std::cin >> N;

	std::vector<long long int> A(N + 1, 0);
	std::vector<long long int> M(N, 0);
	for (int i = 0; i < N; i++)
	{
		std::cin >> A[i + 1];
	}

	std::vector<long long int> L(N + 2, 0);
	std::vector<long long int> R(N + 2, 0);
	L[0] = 0;
	R[N + 1] = 0;
	for (int i = 1; i < N + 1; i++)
	{
		L[i] = gcd(L[i - 1], A[i]);
		R[(N + 1) -i] = gcd(R[(N + 1)- (i - 1)], A[(N + 1) - i]);
	}

	for (int i = 1; i < N + 1; i++) M[i - 1] = gcd(L[i - 1], R[i + 1]);
	std::sort(M.begin(), M.end(), std::greater<long long int>());

	std::cout << M[0] << std::endl;

	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void){
	int H,A;
  scanf("%d%d",&H,&A);
  int cnt=0;
  
  if(H>=1&&H<=10000&&A>=1&&A<=10000){
    while(H>0){
      H-=A;
      cnt++;
    }

    printf("%d\n",cnt);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
    // input
    auto n = std::size_t(0);
    std::cin >> n;

    auto input_vec = [&n]() {
        auto v = std::vector<std::uint64_t>();
        v.reserve(n);
        for (auto i_ = std::size_t(0); i_ < n; ++i_) {
            auto l = 0;
            std::cin >> l;
            v.emplace_back(l);
        }

        std::sort(v.begin(), v.end());

        return v;
    };

    const auto a = input_vec();
    const auto b = input_vec();
    const auto c = input_vec();

    auto counter = std::uint64_t(0);
    for (const auto& middle : b) {
        auto upper_bound_itr = std::lower_bound(a.begin(), a.end(), middle);
        const auto upper_candidate = std::distance(a.begin(), upper_bound_itr);

        auto lower_bound_itr = std::upper_bound(c.begin(), c.end(), middle);
        const auto lower_candidate = std::distance(lower_bound_itr, c.end());

        counter += static_cast<std::uint64_t>(upper_candidate * lower_candidate);
    }

    std::cout << counter << std::endl;

    return 0;
}

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

using namespace std;

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

int n;
string s;

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

    return true;
}

bool yymm(const string& s) {
    int x = (s[2] - '0') * 10 + s[3] - '0';
    return 1 <= x && x <= 12;
}

bool mmyy(const string& s) {
    int x = (s[0] - '0') * 10 + s[1] - '0';
    return 1 <= x && x <= 12;
}

void solve() {
    if (yymm(s) && !mmyy(s))
        cout << "YYMM\n";
    else if (!yymm(s) && mmyy(s))
        cout << "MMYY\n";
    else if (yymm(s) && mmyy(s))
        cout << "AMBIGUOUS\n";
    else
        cout << "NA\n";
}

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

    while (read())
        solve();

    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int main()
{
    string S;
    cin >> S;

    S[3] = '8';

    cout << S << endl;   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>
#define L(_i,_N) for(int _i=0;_i<_N;_i++)
#define C(_Dis) cout<<_Dis<<endl;

using namespace std;

typedef long long int lli;

int main() {
	int Loan = 100000;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		Loan *= 1.05;
		if (Loan % 1000 != 0) {
			Loan -= Loan % 1000;
			Loan += 1000;
		}
	}
	C(Loan);
	return 0;
}

Measured memory_bytes: 3008
a=[[],[],[]]

for i in range(3):
    a[i] = list(map(int, input().split()))

n = int(input())

for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0

y0 = (a[0][0] == a[0][1] == a[0][2])
y1 = (a[1][0] == a[1][1] == a[1][2])
y2 = (a[2][0] == a[2][1] == a[2][2])

t0 = (a[0][0] == a[1][0] == a[2][0])
t1 = (a[0][1] == a[1][1] == a[2][1])
t2 = (a[0][2] == a[1][2] == a[2][2])

n1 = (a[0][0] == a[1][1] == a[2][2])
n2 = (a[0][2] == a[1][1] == a[2][0])

if y0 or y1 or y2 or t0 or t1 or t2 or n1 or n2:
    print('Yes')
else :
    print('No')


Measured memory_bytes: 3064
N = int(input())
b = list(map(int,input().split()))
i = N-1
jun = []
while i > -1:
    if b[i] == i+1:
        del b[i]
        jun.append(i+1)
        i = len(b)-1
    else:
        i -= 1
if len(b) != 0:
    print(-1)
else:
    for j in jun[::-1]:
        print(j)

Measured memory_bytes: 63612
#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 argc, const char * argv[]) {



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

    char a;
    cin>>a;
    if(islower(a))
        cout<<'a'<<endl;
    else
    {
        cout<<'A'<<endl;
    }
    

    return 0;
}


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

int main() {
    
    int n, x;
    cin >> n;
    
    long long sum = 0;
    int min = 1000001;
    int max = -1000001;
    
    for (int i = 0; i < n; i++) {
        cin >> x;
        sum += x;
        
        if (x < min) {
            min = x;
        }
        
        if (x > max) {
            max = x;
        }
    }
    
    cout << min << " " << max << " " << sum << endl;
    
    
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1001001001;

int main() {
  string s;
  cin >> s;
  int n = 0;
  for (char c : s) {
    n += c - '0';
  }
  string ans = n % 9 == 0 ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

vector<pair<string, string>> rules;
string s;
string g;
map<string, int> mp;

string getReplacedString(string t, pair<string, string> p) {
    string a, b;
    tie(a, b) = p;

    // cout << t << " " << a << " " << b << endl;

    int i = 0;
    while (i <= (int)t.size() - (int)a.size()) {
        // cout << t << " " << i << " " << t.substr(i, a.size()) << endl;
        if (t.substr(i, a.size()) == a) {
            t.replace(i, a.size(), b);
            i += b.size();
        } else {
            i++;
        }
    }

    return t;
}

int bfs() {
    mp.clear();
    queue<pair<string, int>> que;
    que.push(make_pair(s, 0));

    while (!que.empty()) {
        string t;
        int c;
        tie(t, c) = que.front(); que.pop();
        if (t == g) break;

        for (const auto &p : rules) {
            string nt = getReplacedString(t, p);
            if (!mp.count(nt) && nt.size() <= g.size()) {
                mp[nt] = c + 1;
                que.push(make_pair(nt, c + 1));
            }
        }
    }

    return (mp.count(g) ? mp[g] : -1);
}

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

    int n;
    int t = 0;
    while (cin >> n, n) {
        rules.clear();
        rep(i, n) {
            string a, b;
            cin >> a >> b;
            rules.emplace_back(a, b);
        }
        cin >> s;
        cin >> g;

        cout << bfs() << endl;
    }
}

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

int main()
{
    long long int  m, n, ans, drink = 0;
    cin >> n >> m;
    vector<long long int> a(n), b(n);
    for(int i = 0;i < n;i++){
        cin >> a[i] >> b[i];
    }
    vector<pair<long long int, long long int>> shop(n);
    for(int i = 0;i < n;i++){
        shop[i] = make_pair(a[i], b[i]);
    }

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

    ans = 0;
    for(int i = 0;i < n;i++){
        drink += shop[i].second;
        if(drink < m){
            ans += shop[i].first * shop[i].second;
        }
        else{
            drink -= shop[i].second;
            ans += shop[i].first * (m - drink);

            break;
        }
    }

    cout << ans;

    return 0;

}


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


int main(){
	string S;
	cin >> S;
	int i;
	string res;
	for (i = 0; i < 26;i++) {
		int j;
		for (j = 0;j < S.size();j++) {
			if ((int)S.at(j) == (int)'a' + i) break;
		}
		if (j == S.size()) {
			res += (char)((int)'a' + i);
			break;
		}
		if (i == 25) res += "None";
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;


int main()
{
    int N, Q, l, r;
    cin >> N >> Q;
    vector<int> num(N);
    string S;
    cin >> S;
    for(int i=0;i<N-1;i++){
        if(S[i] == 'A' && S[i+1] == 'C'){
            num[i+1] = num[i]+1;
        }
        else{
            num[i+1] = num[i];
        }
    }

    for(int i=0;i<Q;i++){
        cin >> l >> r;
        --l;
        --r;
        cout << num[r] - num[l] << endl;
    }
}


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

#define pb emplace_back
#define fi first
#define se second
#define m_p make_pair
#define vi vector<int>
#define pi pair<int, int>
#define mem(a,b) memset(a,b,sizeof(a))
#define el cout<<endl
#define sz(a) (int)a.size()
const int mod = (int)1e9+7;
typedef long long int ll;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = (int)1e5+5;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	string s[n+1];
	for(int i=0;i<n;i++){
		cin>>s[i];
		sort(s[i].begin(), s[i].end());
	}	
	sort(s,s+n);
	ll cnt=1, ans=0;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			cnt++;
		}
		else{
			ans += (cnt*(cnt-1))/2;
			cnt=1;
		}
	}
	if(s[n-1]==s[n-2]){
		ans += (cnt*(cnt-1))/2;
	}
	cout<<ans<<endl;
}

ll power(ll a,ll b, ll md=mod){
	ll r=1;
	while(b){
		if(b%2) 
			r=(r*a)%md;
		a=(a*a)%md;
		b>>=1;
	}
	return r;
}

Measured memory_bytes: 6720
N = int(input())
SUM = 0
map = [0] * 100001
for i in [int(i) for i in input().split()]:
  SUM += i
  map[i] += 1

Q = int(input())
for i in range(Q):
  [b,c] = [int(i) for i in input().split()]
  SUM += (c-b)*map[b]
  print(SUM)
  map[c] += map[b]
  map[b] = 0

Measured memory_bytes: 21224
def is_ok(a, b):
    d = abs(b[1]- a[1]) + abs(b[2] - a[2]) - (b[0] - a[0])
    if d <= 0 and d % 2 == 0:
        return True
    else:
        return False

N = int(input())
L = [[] for i in range(N + 1)]

L[0] = [0, 0, 0]
for i in range(1, N + 1):
    L[i] = list(map(int, input().split()))

ans = 'Yes'
for i in range(N):
    if not is_ok(L[i], L[i + 1]):
        ans = 'No'
        # print(i)

print(ans)


Measured memory_bytes: 27288
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    lli h,w;cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<endl;
        return 0;
    }
    lli res=h*w/2;
    if((h*w)%2==1)res++;
    cout<<res<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		//System.setIn(new FileInputStream("./input.txt"));
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(br.ready()){
			int[] a = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			int s = a[0] + a[1];
			for(int i = 0; i < 14; ++i) {
				s /= 10;
				if(s == 0){
					System.out.println(i+1);
					break;
				}
						
			}
		}

	}

}

Measured memory_bytes: 31132
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll mod = (ll) 1e9+7;

using namespace std;

int main()
{
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  string s1, s2;
  cin >> s1 >> s2;
  ll c = 0;
  for(ll i = 0; i < 3; i++) {
    if(s1[i] == s2[i]) c++;
  }
  cout << c << endl;
  return 0;
}


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

int main()
{
  int n;
  cin>>n;
  if(n%10==3)
    cout<<"bon";
  else if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon";
  else
    cout<<"hon";
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	scanf("%d", &S);
	h=S/3600;
	m=S%3600/60;
	s=S%3600%60/1;
	printf("%d:%d:%d\n", h,m,s);
	return 0;
}

Measured memory_bytes: 592
n = int(input())
t = input().split()
t = list(map(int,t))
m = int(input())
p = []
x = []
for i in range(m):
    tmp = input().split()
    p.append(int(tmp[0]))
    x.append(int(tmp[1]))

for i in range(m):
    arr = list()
    for j in range(n):
        if p[i] == j+1:
            arr.append(x[i])
        else:
            arr.append(t[j])
    print(sum(arr))


Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        double P [] = new double[N];
        double max = 0,now =0;
        for(int i=0;i<N;i++){
            int num = sc.nextInt();
            double sum = 0;
            for(int j=1;j<=num;j++) sum+=j;
            sum/=num;
            P[i] = sum;
            if(i<K) {
                max+=sum;
                now+=sum;
            }
            else{
                now = now -P[i-K]+P[i];
                if(now>max) max=now;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 65116
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000000LL;
const int MAX_N = 100005;

int n;
ll h[MAX_N];
ll dp[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];

	for (int i = 1; i < n; i++)
		dp[i] = INF;
	for (int i = 0; i < n - 1; i++)
	{
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		if (i + 2 < n)
			dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}

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

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <limits>
#define rep(it, ifrom, ito) for (auto it = ifrom; it != ito; ++it)

using namespace std;

int main(int argc, char* argv[]) {
    int N, T, A;
    scanf("%d %d %d", &N, &T, &A);
    vector<int> Hs;
    rep(i, 0, N) {
        int tmp;
        scanf("%d", &tmp);
        Hs.push_back(tmp);
    }

    int best_diff = std::numeric_limits<int>::max();
    int best_i = 0;
    rep(i, 0, N) {
        int diff = std::abs((T * 1000 - Hs[i] * 6) - (A * 1000));
        if (diff < best_diff) {
            best_diff = diff;
            best_i = i;
        }
    }
    std::printf("%d\n", best_i + 1);

    return 0;
}


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

using namespace std;

#define ar array
#define ll long long

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

ll n, x, m, ps[MAX_N], used[MAX_N];

void solve() {
    cin >> n >> x >> m;
    int idx = 1;
    ll y = x;
    while (idx <= n && !used[y]) {
        ps[idx] = ps[idx - 1] + y;
        used[y] = idx++;
        y = y * y % m;
    }
    // detect no cycle
    if (idx == n + 1) {
        cout << ps[n] << "\n";
        // cout << "No cycle\n";
        return;
    }
    // detect cycle
    // range of cycle [used[y]..idx - 1]
    ll len = idx - used[y];
    ll rng = ps[idx - 1] -  ps[used[y] - 1];
    ll last = (n - used[y] + 1) - (n - used[y] + 1) / len * len;
    ll sum_last = ps[used[y] - 1 + last] - ps[used[y] - 1];
    ll ans = ps[used[y] - 1] + (n - used[y] + 1) / len * rng + sum_last;
    cout << ans << "\n";
    // cout << used[y] << " " << idx << " " << "\n";
    // cout << ps[used[y] - 1] << " " << (n - used[y] + 1) / len * rng << " " << ps[last] << "\n";
    // cout << rng << "\n";
    // cout << ps[idx - 1] -  ps[used[y]] << " " << ps[idx - 1] -  ps[used[y] - 1] << "\n";
    // cout << y << "\n";

    // 492443256176507
    // 492443244981950
    
    // for (int i = 1; i <= 30; i++) cout << ps[i] << " ";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int dp[51][51][105];

int main(){
	fast_io();
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	cu(i,0,n){
		cin >> v[i];
		dp[i][i][0] = 0;
		dp[i][i][1] = v[i];
		dp[i][i][2] = 0; 
	}
	cu(l,1,n){
		cu(i,0,n-l){
			int r = i + l;
			fu(j,1,k){
				int & cur = dp[i][r][j];
				int * left = dp[i+1][r];
				int * right  = dp[i][r-1];
				gmax(cur, v[i] + left[j-1]);
				gmax(cur, v[r] + right[j-1]);
				if(j > 1){
					gmax(cur, left[j-2]);
					gmax(cur, right[j-2]);
				}
			}
		}
	}
	int ans = 0;
	fu(i,0,k){
		gmax(ans, dp[0][n-1][i]);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 110;
int n,W;
int w,v;
void max_self(ll  &a,ll b){
  a = max(a,b);
}
int main(){
	scanf("%d%d",&n,&W);
  	vector<ll> dp(W+1);
  	for(int day=0;day<n;++day){
      ll w,v;
      cin>>w>>v;
      for(int wa = W-w;wa>=0;--wa)
        max_self(dp[wa+w],dp[wa]+v);
    }
    ll ans = 0;
  	for(int i=0;i<W+1;++i)max_self(ans,dp[i]);
  	cout<<ans<<endl;
  	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

double dist(vector<ll> a, vector<ll> b) {
  ll c = 0;
  for (ll i = 0; i < a.size(); i++) c+=(a[i]-b[i])*(a[i]-b[i]);
  return sqrt(c);
}

int main() {
  ll N,D, ans=0;
  cin >> N >> D;
  vector<ll> vec(D);
  vector<vector<ll>> mat(N,vec);
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < D; j++) cin >> (mat[i])[j];
  }
  
  for (ll i = 0; i < N-1; i++) {
  	vector<ll> v1 = mat[i];
    for (ll j = i+1; j < N; j++) {
      vector<ll> v2 = mat[j];
      double d = dist(v1,v2);
      int d_int = round(d);
      if (abs(d-d_int) < 1e-8) ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

map<string, int> q;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    q[s]++;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    q[s]--;
  }
  int ans = 0;
  for (auto p : q)
    ans = max(ans, p.second);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>

#define EPS 1e-10;

struct POINT_DOUBLE {
  double x;
  double y;
};

struct VECTOR_DOUBLE {
  double x;
  double y;

  VECTOR_DOUBLE(const POINT_DOUBLE& pt1, const POINT_DOUBLE& pt2) {
    x = pt2.x - pt1.x;
    y = pt2.y - pt1.y;
  }

  double Angle() const {
    return atan(y / x);
  }
};

std::istream& operator >> (std::istream& is, POINT_DOUBLE& p)
{
  is >> p.x >> p.y;
  return is;
}

static bool IsParallel(const VECTOR_DOUBLE& vec1, const VECTOR_DOUBLE& vec2)
{
  return std::abs(vec1.Angle() - vec2.Angle()) < EPS;
}

int main(void)
{
  int n;
  std::cin >> n;

  for (int i = 0; i < n; i++) {
    POINT_DOUBLE pt1, pt2, pt3, pt4;
    std::cin >> pt1 >> pt2 >> pt3 >> pt4;

    VECTOR_DOUBLE vec1(pt1, pt2);
    VECTOR_DOUBLE vec2(pt3, pt4);

    std::cout << (IsParallel(vec1, vec2) ? "YES" : "NO") << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3372
#include<iostream>
using namespace std;
string s[8];
bool m[8][8];
main()
{
	while(cin>>s[0])
	{
		for(int i=1;i<8;i++)cin>>s[i];
		for(int i=0;i<8;i++)for(int j=0;j<8;j++)m[i][j]=0;
		for(int i=0;i<8;i++)for(int j=0;j<8;j++)if(s[i][j]=='1')m[i][j]=1;
		for(int i=0;i<7;i++)for(int j=0;j<7;j++)
			if(m[i][j]&&m[i+1][j]&&m[i][j+1]&&m[i+1][j+1])cout<<'A'<<endl;
		for(int i=0;i<5;i++)for(int j=0;j<8;j++)
			if(m[i][j]&&m[i+1][j]&&m[i+2][j]&&m[i+3][j])cout<<'B'<<endl;
		for(int i=0;i<8;i++)for(int j=0;j<5;j++)
			if(m[i][j]&&m[i][j+1]&&m[i][j+2]&&m[i][j+3])cout<<'C'<<endl;
		for(int i=0;i<6;i++)for(int j=0;j<7;j++)
			if(m[i][j+1]&&m[i+1][j]&&m[i+1][j+1]&&m[i+2][j])cout<<'D'<<endl;
		for(int i=0;i<7;i++)for(int j=0;j<6;j++)
			if(m[i][j]&&m[i][j+1]&&m[i+1][j+1]&&m[i+1][j+2])cout<<'E'<<endl;
		for(int i=0;i<6;i++)for(int j=0;j<7;j++)
			if(m[i][j]&&m[i+1][j]&&m[i+1][j+1]&&m[i+2][j+1])cout<<'F'<<endl;
		for(int i=0;i<7;i++)for(int j=0;j<6;j++)
			if(m[i+1][j]&&m[i+1][j+1]&&m[i][j+1]&&m[i][j+2])cout<<'G'<<endl;
	}
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	int n;
    cin >> n;
    vector<int> d(n); 
    rep(i,n){
      cin >>d[i];
    }
    sort(d.begin(),d.end());
    d.erase(unique(d.begin(),d.end()),d.end());
    cout << d.size() << endl;
    return 0;
  } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ull = unsigned long long;
 
#define NL '\n'
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x, y) scanf("%d%d",&x, &y)
#define sll(x, y) scanf("%lld%lld",&x, &y)
 
#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define mdx ((l+r)>>1)
#define ldx ((idx<<1))
#define rdx ((idx<<1)|1)
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define sqr(x)  ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define file_err(); freopen("serr.txt", "w", stderr);
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

template<class T> T setbit(T n, T pos){n=n|(1<<pos); return n;}
template<class T> T checkbit(T n, T pos){n=n&(1<<pos); return n;}
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return ((a / gcd(a,b) ) * b);}




int main(){
	_fastIO();
	int n, arr[101];
	cin >> n;
	rep(i, 0, n){
		cin >> arr[i];
	}
	sort(arr, arr + n);
	rep(i, 1, n-1) arr[i] += arr[i-1];
	if(arr[n-2] > arr[n-1]) cout << "Yes";
	else cout << "No";
}




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

using namespace std;

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

    int c[p][p];
    for (int i = 0; i < p; i++) {
        c[i][0] = c[i][i] = 1;
        for (int j = 1; j < i; j++) {
            c[i][j] = (c[i-1][j-1] + c[i-1][j]) % p;
        }
    }

    int b[p];
    memset(b, 0, sizeof(b));
    for (int i = 0; i < p; i++) {
        int a;
        cin >> a;
        if (a == 1) {
            b[0] = (b[0] + 1) % p;
            int neg = p - 1;
            int t = 1;
            for (int j = p - 1; j >= 0; j--) {
                b[j] = (b[j] + neg * t % p * c[p-1][j]) % p;
                neg = p - neg;
                t = t * i % p;
            }
        }
    }

    for (int i = 0; i < p; i++) {
        cout << b[i] << (i == p - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 35456
n,m=map(int,input().split())
k=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

answer = 0
switch = []
for i in range(2 ** n):
    _switch = [0] * n
    for j in range(n):

        if i >> j & 1 :
            _switch[j]  = 1
    switch.append(_switch)

for i in range(2 ** n):
    flag = True
    for j in range(m):
        light = 0
        for _k  in k[j][1:]:
            light += switch[i][_k - 1]

        if light % 2 != p[j]:
            flag = False

    if flag:
        answer += 1

print(answer)

Measured memory_bytes: 9248
from sys import stdin
import itertools
input = stdin.readline

n,m=map(int,input().split())
ks=[list(map(int, input().split())) for _ in range(m)]
p=list(map(int,input().split()))

sw=[]
for bits in itertools.product([0,1], repeat=n):
    sw.append(list(bits))

anscnt=0
for i in range(2**n):
    ans=True
    for j in range(m):
        count=0
        for k in range(1,ks[j][0]+1):
            count+=sw[i][ks[j][k]-1]

        if count%2!=p[j]:
            ans=False
    if ans:
        anscnt+=1

print(anscnt)


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
    int x1, y1, x2, y2 = 0;
    cin >> x1 >> y1 >> x2 >> y2;
    int x = x2;
    int y = y2;
    int dx = x2 - x1;
    int dy = y2 - y1;

    REP(i, 2)
    {
        swap(dx,dy);
        dx = -dx;
        x += dx;
        y += dy;
        cout << x << " " << y << endl;
    }

    return 0;
}

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++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int getint() {
	char C;
	while (!isdigit(C = getchar()));
	int A = C - '0';
	while (isdigit(C = getchar())) A = A * 10 + C - '0';
	return A;
}

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


	int N = getint();
	ll D = getint();
	ll kotae = (N - 1) * D;
	int A[200001];
	ll C[200001];
	C[0] = 1e18;
	rep1(i, N) {
		A[i] = getint();
		kotae += A[i];
		C[i] = min(C[i - 1] + D, (ll)A[i]);
	}
	ll mae = 1e18;
	for (int i = N - 1; i > 1; i--) {
		mae = min(mae + D, (ll)A[i + 1]);
		ll kari = min(mae, C[i - 1]) + D;
		kotae += min((ll)A[i], kari);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X;
  cin >> X;
  FOR(x,X,2*X) {
    bool found = true;
    FOR(y,2,sqrt(X)) {
      if (x % y == 0) {
        found = false;
        break;
      }
    }
    if (found) {
      cout << x << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256