akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
  int N, a[100000], count = 0;
  cin >> N;
  for(int i = 1; i<N+1; i++){
    cin >> a[i];
  }

  for(int i = 1;;){
    if(a[i] == 2){
      count++;
      cout << count << endl;
      return 0;
    }
    else{
      count++;
      i = a[i];
    }

    if(count == N){
      cout << -1 << endl;
      return 0;
    }
  }


  return 0;
}

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

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

template <typename T>
class fenwick_tree {
public:
    fenwick_tree(int n_) : n(n_), dat(n_) {}

    void add(int i, T val) {
        for(; i < n; i |= i + 1) {
            dat[i] += val;
        }
    }

    ll sum(int i) const {
        T res = 0;
        for(; i >= 0; i = (i & (i + 1)) - 1) {
            res += dat[i];
        }
        return res;
    }
    T sum(int l, int r) const {
        return sum(r - 1) - sum(l - 1);
    }

private:
    const int n;
    vector<T> dat;
};

pair<ld, ll> decomp(ld val) {
    int cnt = 0;
    while(val >= 10.0) {
        cnt += 1;
        val /= 10;
    }
    return make_pair(val, cnt);
}

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

    int n, m; cin >> n >> m;
    vector<ll> a(n), b(m);
    for(auto& x : a) cin >> x;
    for(auto& x : b) cin >> x;

    fenwick_tree<ll> sum_b(m + 1);
    vector<pair<ld, int>> bs(m);
    for(int i = 0; i < m; ++i) {
        auto p = decomp(b[i]);
        sum_b.add(i, p.second + 1);
        bs[i] = make_pair(p.first, i);
    }
    sort(bs.begin(), bs.end());

    vector<ll> sum(n + 1);
    vector<pair<ld, ll>> aval(n);
    for(int i = 0; i < n; ++i) {
        auto p = decomp(a[i]);
        aval[i] = p;
        sum[i + 1] = sum[i] + p.second * m + sum_b.sum(0, m);
        sum[i + 1] += bs.end() - lower_bound(bs.begin(), bs.end(), make_pair(10.0L / p.first, -1));
    }
    reverse(bs.begin(), bs.end());

    int q; cin >> q;
    vector<ll> d(q), aidx(q);
    string ans(q, ' ');
    for(int i = 0; i < q; ++i) {
        cin >> d[i];
        int lb = 0, ub = n + 1;
        while(ub - lb > 1) {
            const int mid = (ub + lb) / 2;
            (sum[mid] >= d[i] ? ub : lb) = mid;
        }
        if(ub == n + 1) {
            ans[i] = 'x';
        } else {
            aidx[i] = lb;
        }
    }
    vector<int> qord(q);
    iota(qord.begin(), qord.end(), 0);
    sort(qord.begin(), qord.end(), [&] (int i, int j) { return aval[aidx[i]].first < aval[aidx[j]].first; });

    int b_it = 0;
    for(auto const qi : qord) {
        if(ans[qi] == 'x') continue;
        const int ai = aidx[qi];
        while(b_it < m && bs[b_it].first * aval[ai].first >= 10.0L) {
            sum_b.add(bs[b_it++].second, 1);
        }
        ll lb = 0, ub = m;
        while(ub - lb > 1) {
            const int mid = (lb + ub) / 2;
            const ll s = sum[ai] + sum_b.sum(0, mid) + aval[ai].second * mid;
            (s >= d[qi] ? ub : lb) = mid;
        }
        const ll offset = d[qi] - (sum[ai] + sum_b.sum(0, lb) + aval[ai].second * lb);
        ans[qi] = to_string(a[ai] * b[lb])[offset - 1];
    }

    cout << ans << endl;
}



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

int main() {
int N, x;
cin >> N >> x;
vector<int>a(N);
for(int &x : a)
{
  cin >> x;
}
int64_t sum = accumulate(a.begin(), a.end(), 0LL);
if(x==sum) cout << N << endl;
if(x>sum) cout << N-1 << endl;
if(x<sum)
{
  sort(a.begin(), a.end());
  int cnt=0;
  for (int i = 0; i < N; i++)
  {
    x-=a[i];
    if(x<0) break;
    cnt++;
  }
  
  cout << cnt << endl;
}

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const double EPS=1e-10;
 
typedef int Weight;
//typedef
//------------------------------------------
 
typedef int Weight;
//typedef
//------------------------------------------
 
 
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int sum=A+B;
    cout<<min(C,A+B+1)+B<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;


int main()
{
  lint n;
  cin >> n;
  std::vector<string> s(n);
  REP(i,n) cin >> s[i];

  // 辞書順ソート
  sort(ALL(s));
  //重複を飛ばして数える
  lint cnt = 0;
  REP(i,n-1){
    if(s[i] != s[i+1]) cnt++;
  }

  cout << cnt+1 << "\n";
  return 0;
}


Measured memory_bytes: 9508
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,a="No";cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if (s.substr(i,2)=="AC"){
      a="Yes";
      break;
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int>A(6);
  vector<int>B(4,0);
  for (int i = 0; i < 6; i++) {
    cin >> A.at(i);
    B.at(A.at(i)-1)++;
  }
  sort(B.begin(), B.end());
  if (B.at(0) == 1 && B.at(3) == 2){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}
  
    

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
//#define pw (ll)pow 
#define MAX 1000005
#define MOD (ll)1e9+7
#define ii(x,y) if(n<=y && n>=x)
using namespace std;

int wt(int n)	{
	int z;
	ii(1,2) z=1;
	ii(3,5) z=2;
	ii(6,9) z=3;
	ii(10,14) z=4;
	ii(15,20) z=5;
	ii(21,27) z=6;
	ii(28,35) z=7;
	ii(36,44) z=8;
	ii(45,54) z=9;
	return z;
}

bool prime[MAX];
vector<ll> prs;

void sieve()	{
	prime[1]=true;
	int x=sqrt(MAX);
	for(int i=2; i<x; i++)	{
		for(int j=i*i; j<MAX; j+=i)	prime[j]=true;
	}
	for(int i=1; i<MAX; i++)	{
		if(!prime[i]) prs.push_back(i);
	}
}

int main()	
{
	sieve();
	//for(auto p:prs) cout << p << " ";
	//cout << endl;
	ll n;
	cin >> n;
	ll N=n;
	map<ll,ll> s;
	for (auto p:prs)	{
		//cout << p << " ";
		ll c=0;
		while(n%p==0)	{
			c++;
			n/=p;
		}
		//cout << c << endl;
		if(c>0)	{
			if(s.find(p)!=s.end())	s[p]=c;
		else s.insert({p,c});
		}
		if(n<p)	break;
		if(n<MAX && !prime[n])	s.insert({n,1});
	}
	if(n!=1)	s.insert({n,1});
	ll c=0;
	for(auto p:s)	{
		//cout << p.first << " " << p.second << endl;
		c+=wt(p.second);
	}
	if(N==1)	cout << 0 << endl;
	else	cout << c << endl;
	return 0;
}

Measured memory_bytes: 5108
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if (a < b){
		puts("a < b");
	}
	else if(a > b){
		puts("a > b");
	}
	else {
		puts("a == b");
	}
	
	return (0);
}

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

int main() {
  // ここにプログラムを追記
  int N;
  cin >> N;
  string tmp;
  int cnt[4] = {0,0,0,0};
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(tmp == "AC") cnt[0]++;
    if(tmp == "WA") cnt[1]++;
    if(tmp == "TLE") cnt[2]++;
    if(tmp == "RE") cnt[3]++;
  }
  cout << "AC x " << cnt[0] << endl;
  cout << "WA x " << cnt[1] << endl;
  cout << "TLE x " << cnt[2] << endl;
  cout << "RE x " << cnt[3] << endl;
}


Measured memory_bytes: 3628
function Main(input){
	input = input.split(" ").map(a=>~~a);
  return input[0] + 1 - input[1];
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
4 2
`);

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e5 + 2 ;
int cnt ; 
bool vis[N] ; 
int n ;

int main () {
	cin >> n ;
	for (int i = 1 ; i <= n ; i ++) {int k ; cin >> k ; if (vis[k]) cnt ++ ; else vis[k] = 1 ; }
    if (cnt % 2 == 1) cnt ++ ;
    cout << n - cnt << endl ;
	return 0 ;
}

Measured memory_bytes: 3712
//????????????????????¢?????¨????????????????????????????????????

#include<stdio.h>

int main()
{

	int W,H,x,y,r;

	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if(y+r>H || y-r<0){
			printf("No\n");
		}else if(x+r>W || x-r<0){
			printf("No\n");
		}else{
			printf("Yes\n");
		}
	return 0;
}
			

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class a, int N, class T>
void fillArray(a(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int a[10005], b[10005];
vector<int> g[10005];
ll in[10005];
ll c[10005];
int nc = 0;
ll d[10005];
void dfs(int pos) {
    if (d[pos] != 0) return;
    d[pos] = c[nc++];
    vector<pair<ll, int>> v;
    rep(i, g[pos].size()) v.emplace_back(in[g[pos][i]], g[pos][i]);
    all(sort, v, greater<>());
    rep(i, g[pos].size()) dfs(v[i].second);
}

void solve() {
    cin >> n;
    rep(i, n - 1) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        g[a[i]].push_back(b[i]); g[b[i]].push_back(a[i]);
        ++in[a[i]]; ++in[b[i]];
    }
    rep(i, n) cin >> c[i];
    sort(c, c + n, greater<>());
    int r = 0;
    ll ma = 0;
    rep(i, n) if (ma < in[i]) { ma = in[i]; r = i; }
    dfs(r);
    ll m = 0;
    rep(i, n - 1) m += min(d[a[i]], d[b[i]]);
    cout << m << endn;
    rep(i, n) cout << d[i] << " ";
    cout << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
const int INF = 1e18;

signed main(){
    int m, keta = 0, sum = 0; cin >> m;
    REP(i,m){
        int d, c; cin >> d >> c;
        keta += c;
        sum += d*c;
    }
    int ans = (sum-1)/9 + keta - 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vpii E(1e5, pair<int, int>());
	vpii O(1e5, pair<int, int>());
	for (int i = 0; i < 1e5; i++)
	{
		E[i].second = i+1;
		O[i].second = i+1;
	}
	for (int i = 0; i < n; i++)
	{
		int v;
		cin >> v;
		i % 2 == 0 ? E[v-1].first++ : O[v-1].first++;
	}

	sort(rall(E));
	sort(rall(O));
	int ans;
	if (E[0].second == O[0].second)
	{
		if (E[1].first > O[1].first)
			ans = (n/2 - E[1].first) + (n/2 - O[0].first);
		else
			ans = (n/2 - E[0].first) + (n/2 - O[1].first);
	}
	else
		ans = (n / 2 - E[0].first) + (n / 2 - O[0].first);
	cout << ans << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int N,M,ans(0);
vector <int> connect[8];
int passed[8]={0},node(0);

int dfs(int n){
  passed[n]=1;
  node++;
  if (node==N) ans+=1;
  for (int i(0);i<connect[n].size();i++){
    if (passed[connect[n][i]]==0) dfs(connect[n][i]); // is not still path
  }
  passed[n]=0;
  node--;
  return 0;
}

int check(int n){
  passed[n]=1;
  node++;
  if(node==N){
    ans++;
  }
  for(int i=0;i<connect[n].size();i++){
    if(passed[connect[n][i]]==0){
      check(connect[n][i]);
    }
  }
  passed[n]=0;
  node--;
  return 0;
}

// int main() {
// 	cin>>N>>M;
// 	for (int i(0);i<N;i++) {
//     int a,b;
//     cin>>a>>b;
//     connect[b-1].push_back(a-1);
//     connect[a-1].push_back(b-1);
//   }
//   // dfs(0);
//   check(0);
//   cout<<ans<<endl;
//   return 0;
// }
int main(){
  
  cin>>N>>M;
  for(int i=0;i<M;i++){
		int a,b;
    cin>>a>>b;
    connect[a-1].push_back(b-1);
    connect[b-1].push_back(a-1);
  }
  check(0);
  cout<<ans<<endl;
  
 
  return 0;
}


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

const int N=500005; 

using namespace std;

int n,m,mark,p[N],qq[N],deg[N];
pair<int,int> q[N];

struct edge{
	int u,v,nxt; 
}e[N<<1]; int adj[N],tail; 

void addedge(int u,int v){ e[++tail]=(edge){u,v,adj[u]}; adj[u]=tail; }

set<int> s; 
set<int>::iterator it; 
priority_queue< int, vector<int>, greater<int> > pq; 

bool cmp(pair<int,int> a, pair<int,int> b){ return a.first>b.first; }

int main(){
	int x,y; 
	scanf("%d%d",&n,&m); 
	for(int i=1; i<=n; ++i) scanf("%d",&p[i]);  
	for(int i=1; i<=n; ++i) qq[p[i]]=q[p[i]].first=i, q[p[i]].second=p[i]; 
	tail=0; for(int i=1; i<=n; ++i) adj[i]=-1; 
	sort(q+1,q+n+1); s.clear(); 
	for(int i=1; i<=n; ++i){
		if(i-m>=1) s.erase(q[i-m].second);
		it=s.upper_bound(q[i].second);
		if(it!=s.end()) addedge(q[i].first,qq[*it]), ++deg[qq[*it]]; 
 		s.insert(q[i].second); 
	}
	sort(q+1,q+n+1,cmp); s.clear(); 
	for(int i=1; i<=n; ++i){
		if(i-m>=1) s.erase(q[i-m].second);
		it=s.upper_bound(q[i].second);
		if(it!=s.end()) addedge(q[i].first,qq[*it]), ++deg[qq[*it]]; 
 		s.insert(q[i].second); 
	}
	for(int i=1; i<=n; ++i) if(!deg[i]) pq.push(i); 
	for(int i=1; i<=n; ++i){
		x=pq.top(); pq.pop(); 
		p[x]=i; 
		for(int k=adj[x]; k!=-1; k=e[k].nxt){
			y=e[k].v; 
			--deg[y]; 
			if(!deg[y]) pq.push(y); 
		}
	} 
	for(int i=1; i<=n; ++i) printf("%d\n",p[i]); 
	return 0; 
}

Measured memory_bytes: 50432
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val x = sc.nextInt()
    val y = sc.nextInt()
    for (i in 0..x) {
        val j = x - i
        if (2 * i + 4 * j == y) {
            println("Yes")
            return
        }
    }
    println("No")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34460
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
const int maxn = 1e4+100;
struct City {
    int to,len,va;
};
struct Spend {
    int len,va;
}sp[maxn];

vector <City> ve[maxn];
int n,m;
bool vis[maxn];

void init() {
    for(int i=1;i<=n;i++) {
        sp[i].va = sp[i].len = 0x7f7f7f7f;
        ve[i].clear();
    }

    City temp;
    for(int i=0;i<m;i++) {
        int a,b,len,va;
        scanf("%d%d%d%d",&a,&b,&len,&va);
        temp.to = b,temp.len = len,temp.va = va;
        ve[a].push_back(temp);
        temp.to = a;
        ve[b].push_back(temp);
    }
}

void spfa() {
    sp[1].len = sp[1].va = 0;
    queue <int> qu;
    qu.push(1);
    while(!qu.empty()) {
        int now = qu.front(); qu.pop();
        vis[now] = false;
        for(int i=0;i<ve[now].size();i++) {
            City temp = ve[now][i];
            int v = temp.to;
            int d = temp.len;
            int va = temp.va;
            if(sp[v].len > sp[now].len + d) {
                sp[v].len = sp[now].len + d;
                sp[v].va =  va;
                if(!vis[v]) {
                    qu.push(v);
                    vis[v] = true;
                }
            }
            if(sp[v].len == sp[now].len + d && sp[v].va > va) {
                sp[v].va = va;
            }
        }
    }
}

void get_len() {
    int tot = 0;
    for(int i=1;i<=n;i++) {
        tot += sp[i].va;
    }
    printf("%d\n",tot);
}

int main() {
    while(scanf("%d%d",&n,&m) && n+m) {
        init();
        spfa();
        get_len();
    }
    return 0;
}


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

//int numberofPaths(int h,int w,int a,int b);

int main()
{
    ll n,i,len1,h,t,cnt=0,cnt1=0,x=1,m,flag=0,k=10,b,h1=0,h2=0,od=0,ev=0;
    double w;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>k;
	if(n>0&&k>0)
    {
        cout<<"Positive"<<endl;
    }
    else if((n>=0&&k<=0)||(n<=0&&k>=0))
    {
        cout<<"Zero"<<endl;
    }
    else{
        t=abs(n-k);
        if(t%2==0)
        {
            cout<<"Negative"<<endl;
        }
        else{
            cout<<"Positive"<<endl;
        }


    }







	return 0;
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

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

    if (n%2) cout << fixed << setprecision(6) << double((n+1)/2.0/n) << endl;
    else cout << setprecision(6) << 0.5 << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
 
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
 
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
 
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
 
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        }  
    }
 
    public static void main(String[] args) throws IOException {
 
        FastReader s= new FastReader();
 
        int n = s.nextInt();
        int m = s.nextInt();
 
        if (n > 0 && n < 10 && m > 0 && m < 10)
        	System.out.println(n*m);
        else {
        	System.out.println(-1);
        }
 
    }
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<int,int>> bridge(M,make_pair(0,0));
  for(int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    bridge.at(i) = make_pair(b,a);//bについてsort
  }

  sort(bridge.begin(),bridge.end());
  int ans = 0;
  int flag = 0;
  for(int i = 0; i < M; i++){
    if(i==0){
      flag = bridge.at(i).first - 1;
      ans++;
    }
    else{
      if(bridge.at(i).first>flag&&bridge.at(i).second<=flag)continue;
      else{
        flag = bridge.at(i).first - 1;
        ans++;
      }
    }

  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N, M := sc.i(), sc.i()
	A := sc.is(N)
	sort.Slice(A, func(i, j int) bool { return A[i] > A[j] })
	sum := 0
	for i := range A {
		sum += A[i]
	}
	if sum%(4*M) == 0 {
		sum -= 1
	}
	s := sum / (4 * M)
	if A[M-1] <= s {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}

}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 1776
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 1; i < (n); i++)
using namespace std;
using ll = long long;

int f[101];

int main() {
	
	int x, y;
	int a, b;
	int limnx=0, limny=0;
	int limdx=0, limdy=0;
	int limx, limy;
	cin >> x >> y;

	a = 1; b = 1;
	int cnt =1;
	if (x == 0 && y == 0) {
		cout << cnt << endl; return 0;
	}	
	 if(x>0)x++;
	if(y>0)y++;
	while (1) {
		limx = a + b;//2=1+1
		a = b;
		b = limx;
		limnx = limx + limdx;//limnx=2
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}

		limy = a + b;//3=1+2
		a = b;
		b = limy;
		limny = limy + limdy;
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}

		limx = a + b;//2+3;
		a = b;
		b = limx;
		limdx = -limx + limnx;//limdx=-5+2
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}

		limy = a + b;
		a = b;
		b = limy;
		limdy = -limy + limny;//-8+3
		cnt++;
		if (x >= limdx && x <= limnx) {
			if (y >= limdy && y <= limny) {
				if (cnt % 3 == 0) {
					cout << '3' << endl;
					return 0;
				}
				else {
					cout << cnt % 3 << endl;
					return 0;
				}
			}
		}
	}
	

	return 0;
}


Measured memory_bytes: 3112
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int iin = sc.nextInt();
        int ikflg = 0;
		long[] iia = new long[iin];
        for(int i=0;i<iin;i++){
          iia[i] = sc.nextLong();
          if(iia[i]%2==1){
            ikflg = 1;
            break;
          }
        }
        int iret = 0;
        for(;ikflg==0;){
          iret++;
          for(int i=0;i<iin;i++){
            iia[i] /= 2;
            if(iia[i]%2==1){
              ikflg = 1;
              break;
            }
          }
		}
		System.out.println(iret);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,l,k,s=0,x;
    cin>>n;
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=n; j++)
            {
                for(k=1; k<=n; k++)
                {
                s=s+(__gcd(i,__gcd(j,k)));
                        }

                    }

                }




        cout<<s;
}


Measured memory_bytes: 3516
#include<iostream>
#include<array>
#include<algorithm>

int main(){
	std::array<char, 20>str;
	
	for(int i=0; i<20; ++i){
		std::cin >> str[i];
	}
	
	for(int i=str.size()-1; i>=0; --i){
		std::cout << str[i];
	}
	std::cout << std::endl;
	return 0;
}

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

int n;
long long a[1000];
long long rui[1000];

long long memo[500][500];

long long dp(int l, int r){
    if(l == r) return 0;
    if(memo[l][r] != -1) return memo[l][r];

    long long ans = LLONG_MAX;
    for(int mid = l;mid < r;mid++){
        ans = min(ans, dp(l,mid)+dp(mid+1,r) + rui[r+1]-rui[l]);
    }

    return memo[l][r] = ans;
}

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

    memset(memo, -1, sizeof(memo));

    cout << dp(0, n-1) << endl;
    return 0;
}



Measured memory_bytes: 2304
def divisor(n):
    i = 1
    table = []

    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = list(set(table))

    return table


def common_divisor(a, b):
    table = []
    for i in a:
        if i in b:
            table.append(i)
    return table


def resolve():
    A, B = map(int, input().split())
    a_list = divisor(A)
    b_list = divisor(B)
    common_list = common_divisor(a_list, b_list) if len(a_list) < len(b_list) else common_divisor(b_list, a_list)
    common_list.sort()
    i = 1
    while i < len(common_list):
        j = i + 1
        while j < len(common_list):
            if common_list[j] % common_list[i] == 0:
                del common_list[j]
            else:
                j += 1
        i += 1

    print(len(common_list))
    
resolve()


Measured memory_bytes: 39920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String pattern = scan.next();
        String buf;
        int count = 0;

        while(!((buf = scan.next()).equals("END_OF_TEXT"))) {
            if (pattern.equalsIgnoreCase(buf)) count++;
        }

        System.out.println(count);
    }
}



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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> data(H+2,vector<char>(W+2,'#'));
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>data[i][j];
    }
  }
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
    cout<<data[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


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

	ll g = (X / 500) * 1000;
	X %= 500;
	g += (X / 5) * 5;

	cout << g << endl;

	return 0;
}

Measured memory_bytes: 256
//リファクタリング作業

#include<stdio.h>

int Min(int a, int b) { if (a < b) { return a; }return b; }

int fa[52][26];//その文字の文字列内登場回数
int main() {
	int N;
	char S[52];
	scanf("%d", &N);
	for (int i = 0; i < N; i++)//文字列
	{
		scanf("%s", S);
		for (int j = 0; j < strlen(S); j++)//アルファベット
		{
			fa[i][S[j] - 'a']++;
		}
	}

	for (int j = 0; j < 26; j++)//アルファベット
	{
		int cntmin = 60;//その文字は全ての文字列で最低何回登場しているのか
		int num = 0;
		for (int i = 0; i < N; i++)//文字列
		{
			if (fa[i][j] >= 1)//この文字列で登場している場合
			{
				cntmin = Min(cntmin, fa[i][j]);//その文字は全ての文字列で最低何回登場しているのか
				num++;
			}
			else //この文字列で登場していない場合
			{
				break;//この文字は対象外
			}
		}
		if (cntmin != 60 && cntmin != 0 && num == N)
		{
			for (int i = 0; i < cntmin; i++)
			{
				printf("%c", 'a' + j);
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
        int a, b;
        cin >> a >> b;

        string a_b;
        string b_a;
        for(int i = 0; i < b; i++)
        {
            a_b += to_string(a);
        }

        for(int j = 0; j < a; j++)
        {
            b_a += to_string(b);
        }
     
        if(a_b <= b_a)
        {
            cout << a_b;
        }
        else
        {
            cout << b_a;
        }
     
    }

Measured memory_bytes: 256
n, m = map(int, input().split())

a = []
b = []

for i in range(n): a.append(list(map(int, input().split())))
for i in range(m): b.append(list(map(int, input().split())))

for i in range(n):
    ans = 0
    tmp = 10**9
    for j in range(m):
        dt = abs(a[i][0]-b[j][0]) + abs(a[i][1]-b[j][1])
        if dt < tmp:
            ans = j+1
            tmp = dt
    print(ans)

Measured memory_bytes: 3064
H, W = gets.split.map(&:to_i)
as = []
H.times do |i|
    as[i] = gets.chomp
end

rs = Array.new(H){Array.new(W, '.')}
bs = Array.new(H){Array.new(W, '.')}
rs[0] = Array.new(W, '#')
bs[H-1] = Array.new(W, '#')

(1...(H-1)).each do |i|
    W.times do |j|
        if as[i][j] == '#' || j % 2 == 0
            rs[i][j] = '#'
        end
        if as[i][j] == '#' || j % 2 == 1
            bs[i][j] = '#'
        end
    end
end

H.times do |i|
    puts rs[i].join
end

puts

H.times do |i|
    puts bs[i].join
end

Measured memory_bytes: 37628
# coding: utf-8
# Your code here!

box_num = int(input())
ball_in_box_num_list = tuple([int(i), []] for i in input().split(" "))
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i - 1)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
    if b[0] == 1:
        ans_num += 1
        ans_list.append(a + 1)
        for j in b[1]:
            ball_in_box_num_list[j][0] = 1 - ball_in_box_num_list[j][0]
print(ans_num)
if ans_list != 0:
    ans_list = [str(i) for i in ans_list]
    ans_list = ans_list[::-1]
    print(" ".join(ans_list))

Measured memory_bytes: 141392
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::map<int, pair<int,int>> map;
    map[0]=make_pair(0,0);
    int N;
    while (cin>>N) {
        if (N==0) {
            break;
        }
        int n,d;
        for (int i=1;i<N;i++) {
            cin>>n>>d;
            if (d==0) {
                map[i]=make_pair(map[n].first-1,map[n].second);
            } else if (d==1) {
                map[i]=make_pair(map[n].first,map[n].second-1);
            } else if (d==2) {
                map[i]=make_pair(map[n].first+1,map[n].second);
            } else if (d==3) {
                map[i]=make_pair(map[n].first,map[n].second+1);
            }
        }
        int max_x=0,max_y=0,min_x=1000,min_y=1000;
        for (int i=0;i<N;i++) {
            max_x=max(max_x,map[i].first);
            max_y=max(max_y,map[i].second);
            min_x=min(min_x,map[i].first);
            min_y=min(min_y,map[i].second);
        }
        //cout<<max_x<<" "<<max_y<<endl;
        //cout<<min_x<<" "<<min_x<<endl;
        cout<<abs(max_x)+abs(min_x)+1<<" "<<abs(max_y)+abs(min_y)+1<<endl;
    }
}


Measured memory_bytes: 3096
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll n, m;
class union_find {
public:
	vector<int>par;
	vector<int>size;

	union_find(int n) : par(n), size(n, 1) {
		for (int i = 0; i < n; i++) {
			par[i] = i;//最初の親は自分自身
		}
	}
	void init(int n) {
		par.resize(n);
		size.assign(n, 1);
		for (int i = 0; i < n; i++) {
			par[i] = i;//最初の親は自分自身
		}
	}
	//木の根を求める
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = root(par[x]);
		}
	}
	//xとyが同じ集合に属すか否か
	bool same(int x, int y) {
		return(root(x) == root(y));
	}
	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return false;//根が同じならもう併合済み
		//併合するときは"小さい方"を"大きい方"に併合させる
		if (size[x] < size[y]) {
			swap(x, y);
		}
		size[x] += size[y];
		par[y] = x;
		return true;
	}

	int getSize(int x) {
		return size[root(x)];
	}
};
int main() {
	cin >> n >> m;
	vector<P>p(m);
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		p[i] = make_pair(a, b);
	}
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		union_find tree(n);
		tree.init(n);
		for (int j = 0; j < m; j++) {
			if (i != j) {
				tree.unite(p[j].first, p[j].second);
			}
		}
		if (!tree.same(p[i].first, p[i].second)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 1LL<<60;


ll wlist[105];
ll vlist[105];
ll dp[200005];


int main(){
	int n,w;
	cin >> n >> w;
	rep1(i,n) cin >> wlist[i] >> vlist[i];

	rep1(j,n){
		repr1(i,w){
			if(i-wlist[j] < 0) break;
			dp[i] = max(dp[i-wlist[j]]+vlist[j],dp[i]);
		}
	}
	prints(dp[w]);



	return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
vector<ll> nums[200005];
ll tento(vector<ll> v){
  int kn=v.size();
  ll zcnt=0;
  ll kans=0;
  for(int i=0;i<kn;i++){
    if(v[i]==0) zcnt++;
    else kans+=zcnt;
  }
  return kans;
}
int main(){
  string s;
  cin>>s;
  int n=s.length();
  int pos=0;
  s.push_back('d');
  vector<ll> vec;
  for(int i=0;i<n;i++){
    if(s[pos]=='A'){
      vec.push_back(0);
    }
    else if(s[pos]=='B'){
      if(s[pos+1]=='C') {
        pos++;
        vec.push_back(1);
      }
      else vec.push_back(2);
    }
    else vec.push_back(2);
    pos++;
    if(pos>n) break;
  }
  int p2=0;
  for(int i=0;i<vec.size();i++){
    if(vec[i]==2) p2++;
    else nums[p2].push_back(vec[i]);
  }
  ll ans=0;
  for(int i=0;i<p2;i++){
    ans+=tento(nums[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9716
#include<iostream>
#include<algorithm>
#define INF 2147483647
using namespace std;
int data[300000],l,r,size;
int find(int s,int t,int u){
  if(s>=l&&r>=t) return data[u];
  if(r<s||l>t) return INF;
  int left=find(s,(s+t)/2,2*u+1);
  int right=find((s+t)/2+1,t,2*u+2);
  return min(left,right);
}
void update(int a,int b){
  int cur=a+size-1;
  data[cur]=b;
  while(cur!=0) {
    cur=(cur-1)/2;
    data[cur]=min(data[cur*2+1],data[cur*2+2]);
  }
}
int main(){
  int n,q,com,x,y;
  size=1;
  cin>>n>>q;
  while(size<n) size*=2;
  for(int i=0;i<size*2-1;++i) data[i]=INF;
  for(int i=1;i<=q;++i){
    cin>>com>>x>>y;
    if(com==0){
      update(x,y);
    }else{
      l=x; r=y;
      cout<<find(0,size-1,0)<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  using P = pair<Int, Int>;
  auto mul=[](P a,Int b){return P(a.first*b,a.second*b);};
  auto add=[](P a,Int b){return P(a.first,a.second+b);};
  auto sub=[](P a,Int b){return P(a.first,a.second-b);};
  P cur(1,0);
  for(Int i=0;i<n;i++){
    Int t,x;
    cin>>t>>x;
    if(t==1) cur=mul(cur,x);
    if(t==2) cur=add(cur,x);
    if(t==3) cur=sub(cur,x);
  }
  cout<<-cur.second<<" "<<cur.first<<endl;
  return 0;
}



Measured memory_bytes: 3084
N = int(input())
A = [int(x) for x in input().split()]
#A = list(map(int, input().split()))
mod = 10**9+7

partial_sum = A.copy()
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%mod)
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%mod) %mod
print(int(res))


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,i;
    cin>>n;
    string s[n];
    map<string,long long int>mt;
    for(i=0;i<n;i++){
        cin>>s[i];
        mt[s[i]]+=1;
    }
    cout<<"AC x "<<mt["AC"]<<endl;
    cout<<"WA x "<<mt["WA"]<<endl;
    cout<<"TLE x "<<mt["TLE"]<<endl;
    cout<<"RE x "<<mt["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 6792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;
	int ma=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x-1]++;
		ma=max(ma,a[x-1]);
		a[x]++;
		ma=max(ma,a[x]);
		a[x+1]++;
		ma=max(ma,a[x+1]);
	}
	cout<<ma;
}

Measured memory_bytes: 640
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!{
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    println!(
        "{}",
        if (c - a).abs() <= d || ((c - b).abs() <= d && (b - a).abs() <= d) {
            "Yes"
        } else {
            "No"
        }
    );
}


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

int main() {
    int x, y, s;
    while(cin >> x >> y >> s, x) {
        int ret = 0;
        for(int i=1; i<s; ++i) {
            for(int j=1; j<s; ++j) {
                if(i*(100+x)/100 + j*(100+x)/100 == s) {
                    ret = max(ret, i*(100+y)/100 + j*(100+y)/100);
                }
            }
        }
        cout << ret << endl;
    }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int b,long long int p)
{
	if(p==0)
	return 1;
	long long int ans=power(b,p-1);
	ans*=b;
	return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	long long int n;
	cin>>n;
	vector<long long int> a;
	a.push_back(26);
	long long int p=26,q;
	while(p<=n)
	{
		q=p*26;
		a.push_back(a[a.size()-1]+q);
		p=q;
	}
	long long int i,l;
	for(i=0;i<a.size();i++)
	if(a[i]>=n)
	break;
	l=i+1;
	if(l==1)
	p=n;
	else
	p=n-a[i-1];
//	cout<<p<<" "<<l<<endl;
	string ans="";
	while(l)
	{
	//	cout<<p<<endl;
		if(p==0)
		ans=ans+'z';
		else
		{
			long long int x=power(26,l-1),y;
			y=(p/x);
			n=p;       
			p-=x*y;
			if(n%x==0)
			y--;
			char c='a'+y;
			ans=ans+c;
		}
		l--;	
	}
	cout<<ans<<endl;
	return 0;
}



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

from functools import reduce

import math


from collections import defaultdict
from math import sqrt

def is_prime(n):
    for i in range(2, int(sqrt(n))):
        if n % i == 0:
            return False
    return True

def prime_factors(n):
    primes = defaultdict(int)
    i = 2
    mx = sqrt(n)
    while n != 1:
        if n % i == 0:
            n = n // i
            primes[i] += 1
        elif i >= mx:
            if len(primes) == 0:
                primes[i] += 1
            elif is_prime(n):
                primes[i] += 1
            break
        else:
            i += 1
    return primes

def solve_n(x):
    return (-1 + sqrt(1 + 4 * 2* x)) / 2

def solve(N: int):
    fs = prime_factors(N)
    count = 0
    for key, value in fs.items():
        val = solve_n(value)
        count += math.floor(val)

    print(count)
    return



# Generated by 1.1.7.1 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()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68276
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader bf =new BufferedReader(new InputStreamReader(System.in));
		String t;
		String[] d = new String[4];
		int[] a = new int[4],b=new int[4];
		int ht,bl;
		while((t=bf.readLine())!=null){
			ht=bl=0;
			d=t.split(" ");for(int i=0;i<4;i++)a[i]=Integer.parseInt(d[i]);
			d=bf.readLine().split(" ");for(int i=0;i<4;i++)b[i]=Integer.parseInt(d[i]);
			for(int i=0;i<4;i++)for(int j=0;j<4;j++)if(a[i]==b[j]){if(i==j){ht++;}else{bl++;}}
			System.out.println(ht+" "+bl);
		}
	}
}

Measured memory_bytes: 9244
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		char[] str = scan.nextLine().toCharArray();
		int ans = 0;
		for (char s : str) {
			if (s == '1') ans++;
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 21588
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

H,W,D=gets.chomp.split(' ').map{|n| n.to_i}
# number -> address map
# %D = r, upto
B={}
# ACC[r][q]
ACC=Array.new(H*W+1)

#Array.new(H*W+1)

0.upto(H-1){|i|
	gets.chomp.split(' ').map{|n| n.to_i}.each_with_index{|n,j|
		# puts "n,i,j:#{n},#{i},#{j}"
		B[n]=[i,j]
	}
}
# pp B

# precomputation
X=0
Y=1
1.upto(D){|i|
	prv = B[i]
	ACC[i]=0
	1.upto(H*W/D){|j|
		# puts "i,j = #{i},#{j}"
		cur = B[D*j+i]
		if(cur.nil?)
			break
		else
			diff = (prv[X]-cur[X]).abs+(prv[Y]-cur[Y]).abs
			ACC[i+D*j]=diff
			prv = cur
		end
	}
}
# accum
1.upto(D){|i|
	1.upto(H*W/D){|j|
		if(ACC[i+D*j].nil?)
			break
		else
			ACC[i+D*j]+=ACC[i+D*(j-1)]
		end
	}
}
# pp ACC


Q,d=gets.chomp.split(' ').map{|n| n.to_i}
#I=Array.new(Q)
L=0
R=1
cache = {}
0.upto(Q-1){|i|	
	sum=0
	LR = gets.chomp.split(' ').map{|n| n.to_i}
	# puts "#{LR[L]},#{LR[R]}, #{D})"
	c = cache[[LR[L],LR[R]].join("-")]
	if(!c.nil?)
		puts c
	else
		puts ACC[LR[R]]-ACC[LR[L]]
	end
}






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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> eng(N);
    for(auto& i : eng)cin >> i.first >> i.second;
    mt19937_64 mt(random_device{}());
    uniform_int_distribution<long> uid(-2000000, 2000000);
    unsigned long ans{0};
    for(unsigned long i = 0; i < 100000; ++i){
        long x{uid(mt)}, y{uid(mt)};
        long a{0}, b{0};
        for(const auto& engine : eng){
            if(x * engine.first + y * engine.second >= 0){
                a += engine.first;
                b += engine.second;
            }
        }
        if(ans < a * a + b * b)ans = a * a + b * b;
    }
    printf("%.12Lf\n", sqrt(static_cast<long double>(ans)));
    return 0;
}

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

int main()
{
  char s[200001];
  scanf("%s", s);
  int l , r;
  for (char *p = s; true; ++p)
  {
    if (*p == 'A')
    {
      l = p - s;
      break;
    }
  }
  for (char *p = s + strlen(s) - 1; true; --p)
  {
    if (*p == 'Z')
    {
      r = p - s;
      break;
    }
  }
  printf("%d\n", r - l + 1);
  return 0;
}

Measured memory_bytes: 384