akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) {
       MyScanner sc = new MyScanner();
       int a = sc.nextInt();
       String s = sc.next();

       if (a >= 3200){
           System.out.println(s);
       }
       else{
           System.out.println("red");
       }
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b; cin >> a >> b;
    cout << a*b-a-b+1 << endl;
}

Measured memory_bytes: 256
def calc(a, b)
  x = (b + a) / 2
  return b - x
end

def main(argv)
  (n, a, b) = gets.chomp.split(' ').map(&:to_i)

  if (b - a) % 2 == 0 then
    puts calc(a, b).to_s
    return
  end

  puts [
    # 1で折り返す
    calc(1, b - a) + a,
    # nで折り返す
    calc((n - b) + a + 1, n) + (n - b) + 1
  ].min.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

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

using namespace std;

signed main()
{
    int a[3][3];
    rep(i, 3)
    {
        rep(j, 3)
        {
            cin >> a[i][j];
        }
    }
    int N;
    cin >> N;
    int b[N];
    int flag = 0;
    rep(i, N)
    {
        cin >> b[i];
    }
    rep(k, N)
    {
        rep(i, 3)
        {
            rep(j, 3)
            {
                if (a[i][j] == b[k])
                {
                    a[i][j] = -1;
                }
            }
        }
    }
    rep(i, 3)
    {
        if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1)
        {
            flag = 1;
        }
    }
    rep(j, 3)
    {
        if (a[0][j] == -1 && a[1][j] == -1 && a[2][j] == -1)
        {
            flag = 1;
        }
    }
    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1)
    {
        flag = 1;
    }
    if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1)
    {
        flag = 1;
    }
    if (flag == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

bool check(string s){//文字列の中に3,5,7が全て含まれているか？
    bool three=false,five=false,seven=false;
    for(char c : s){
        if(c == '3') three=true;
        if(c == '5') five=true;
        if(c == '7') seven=true;
    }
    return three && five && seven;//含まれて入ればtrue
}

ll dfs(string s, int n){
    if(stoll(s) > n) return 0;
  
    ll ans=0;
    if(check(s)) ans++ ;//checkでtrueが返ってくるとans = ans+1
  
  
    string ss[] = {"3","5","7"};
    for(auto c : ss){
        auto t = s+c;
        ans += dfs(t,n);
    }
  
  
    return ans;
}

int main(){
    ll n; cin >> n;
    ll ans=dfs("0",n);
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n; cin >> n;
    vector<int> p(n),sorted(n); REP(i,n) cin >> p[i];
    sorted = p;
    sort(ALL(sorted));
    ll counter = 0;
    REP(i, n) {
        if (p[i] == sorted[i]) continue;
        else counter++;
    }
    if (counter==0 or counter ==2 ) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード
ll k;
string s;




int main() {
	cin >> k >> s;
	if (s.size() <= k) cout << s << endl;
	else {
		rep(i, k) cout << s[i];
		cout << "..." << endl;
	}

	return 0;
}



Measured memory_bytes: 3632
loop do
  rps = Array.new(5)
  rps[0] = gets.to_i
  break if rps[0].zero?
  1.upto(4) do |i|
    rps[i] = gets.to_i
  end
  rpsu = rps.uniq
  if rpsu.size == 2
    x, y = rpsu.sort
    rps.each do |n|
      if (y-x) == 1
        puts n == x ? 1 : 2
      else
        puts n == x ? 2 : 1
      end
    end
  else
    5.times { puts 3 }
  end
end

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int M=4e6+5;
const int inf=INT_MAX;
int vis[N<<3],a[N<<2],lazy[N<<2];
int fa[N],id[N],son[N],top[N],size[N],deep[N];
int n,now,x[N<<3],y[N<<3],v[M],nex[M],head[N<<3];
clock_t startTime,endTime;
//{{{ read() & addedges()
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
//}}}
void dfs(int x){
	size[x]=1,deep[x]=deep[fa[x]]+1;
	for(int i=head[x];i;i=nex[i])
		if(!size[v[i]]){
			fa[v[i]]=x,dfs(v[i]);
			size[x]+=size[v[i]];
			if(size[v[i]]>size[son[x]])	son[x]=v[i];
		}
}
void dfs(int x,int t){
	top[x]=t,id[x]=++now;
	if(!son[x])	return ;
	dfs(son[x],t);
	for(int i=head[x];i;i=nex[i])
		if(!id[v[i]])	dfs(v[i],v[i]);
}
queue<int>que;
void pushdown(int x){
	a[x<<1|1]+=lazy[x],lazy[x<<1|1]+=lazy[x];
	a[x<<1]+=lazy[x],lazy[x<<1]+=lazy[x];
	lazy[x]=0;
}
int cnt[N<<2];
void check(int l,int r,int rt){
	if(a[rt]>1)	return ;
	for(int i=head[rt];i;i=nex[i])
		if(!vis[v[i]])	que.push(v[i]),vis[v[i]]=1;
	head[rt]=0;
	if(l==r){
		a[rt]=inf;
		return ;
	}
	if(lazy[rt])	pushdown(rt);
	int mid=(l+r)>>1;
	check(l,mid,rt<<1);
	check(++mid,r,rt<<1|1);
	a[rt]=min(a[rt<<1],a[rt<<1|1]);
}
void added(int l,int r,int x,int y,int z,int rt){
	if(x<=l&&y>=r){
		++a[rt],++lazy[rt];
		addedges(rt,z);
		return ;
	}
	int mid=(l+r)>>1;
	if(lazy[rt])	pushdown(rt);
	if(x<=mid)	added(l,mid,x,y,z,rt<<1);
	if(y>mid)	added(++mid,r,x,y,z,rt<<1|1);
	a[rt]=min(a[rt<<1],a[rt<<1|1]);
}
void get(int l,int r,int x,int y,int rt){
	if(x<=l&&y>=r){
		--a[rt],--lazy[rt];
		return ;
	}
	int mid=(l+r)>>1;
	if(lazy[rt])	pushdown(rt);
	if(x<=mid)	get(l,mid,x,y,rt<<1);
	if(y>mid)	get(++mid,r,x,y,rt<<1|1);
	a[rt]=min(a[rt<<1],a[rt<<1|1]);
}
void change(int x,int y){
	while(top[x]!=top[y]){
		if(deep[top[x]]<deep[top[y]])	swap(x,y);
		get(1,n,id[top[x]],id[x],1);
		x=fa[top[x]];
	}
	if(x==y)	return ;
	if(deep[x]>deep[y])	swap(x,y);
	get(1,n,id[x]+1,id[y],1);
}
void lca(int x,int y,int k){
	while(top[x]!=top[y]){
		if(deep[top[x]]<deep[top[y]])	swap(x,y);
		added(1,n,id[top[x]],id[x],k,1);
		x=fa[top[x]];
	}
	if(x==y)	return ;
	if(deep[x]>deep[y])	swap(x,y);
	added(1,n,id[x]+1,id[y],k,1);
}
void build(int l,int r,int rt){
	a[rt]=inf;
	if(l==r) return ;
	build(l,(l+r)>>1,rt<<1);
}
int main(){
	n=read();
	int res=0;
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		addedges(x,y),addedges(y,x);
	}
	dfs(1),now=0,dfs(1,1),now=0;
	memset(head,0,sizeof(head));
	build(1,n,1);
	int cnt=n<<2;
	for(int i=cnt+1;i<cnt+n;i++){
		x[i]=read(),y[i]=read();
		lca(x[i],y[i],i);
	}
	check(1,n,1);
	while(!que.empty()){
		int k=que.front();
		que.pop(),++res;
		change(x[k],y[k]);
		check(1,n,1);
	}
	if(res==n-1)	puts("YES");
	else	puts("NO");
	return 0;
}

Measured memory_bytes: 37888
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;

int main(){
  int p;
  cin >> p;
  ll a[p];
  rep(i,p)cin >> a[i];
  ll b[p]={};
  for(int i=0;i<p;i++){
    if(a[i]==0)continue;
    if(i==0){
      b[0]=1;
      b[p-1]=(p-1);
    }else{
      ll temp=1;
      ll add[p]={};
      for(int j=0;j<p-1;j++){
        add[p-1-j]=p-temp;
        b[p-1-j]+=add[p-1-j];
        b[p-1-j]%=p;
        temp*=i;
        temp%=p;
      }
    }
  }
  for(int i=0;i<p;i++)cout << b[i]%p << ' ';
  cout << endl;
return 0;}

Measured memory_bytes: 384
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var _ = Console.ReadLine().Split();
            var t = int.Parse(_[0]);
            var a = int.Parse(_[1]);

            var h = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            var minVal = int.MaxValue;
            var idx = -1;
            for(var i = 0; i < n; i++){
                var temp = (t * 1000) - (h[i] * 6);
                var d = Math.Abs(a * 1000 - temp);
                if(minVal > d){
                    minVal = d;
                    idx = i + 1;
                }
            }

            Console.WriteLine(idx);
        }
    }
}


Measured memory_bytes: 13332
#include <iostream>
#include <algorithm>
#include <cmath>
#define EPS (1.0e-12)
#define equals(a, b) (fabs((a) - (b)) < EPS)
 
using namespace std;
 
 
int S, A, C;
int M;
int N;
int R[256], I[256], O[256];
 
double m_log[300];
 
void calcR() {
  for(int i = 0; i < N; ++i) {
    if(i == 0) R[i] = (A*S+C)%M;
    else       R[i] = (A*R[i-1]+C)%M;
  }
}
 
void calcO() {
  calcR();
  for(int i = 0; i < N; ++i) {
    O[i] = (I[i]+R[i]) % M;
  }
}
 
double H() {
  double ans = 0;
  int buf[256];
  fill(buf, buf+256, 0);
 
  calcO();
 
  for(int i = 0; i < N; ++i) {
    ++buf[O[i]];
  }
 
  for(int i = 0; i < 256; ++i) {
    if(buf[i] == 0) continue;
    ans += -buf[i] * (m_log[buf[i]] - m_log[N]);
  }
  return ans;
}
 
void solve() {
  int aS, aA, aC;
  double minH = 99999999;
  for(S = 0; S <= 15; ++S) {
    for(A = 0; A <= 15; ++A) {
      for(C = 0; C <= 15; ++C) {
        double tmp = H();
        if(S == 8 || A == 7 || C == 14) {
          // for(int i = 0; i < N; ++i) cout << O[i] << " ";
          //cout << endl;
        }
        //if(tmp == 0) printf("%d %d %d %.20f\n", S, A, C, tmp);
        if(equals(tmp, minH)) {
          if(aS > S || aS == S && aA > A || aS == S && aA == A && aC > C) {
            aS = S;
            aA = A;
            aC = C;
          }
        } else if(tmp < minH) {
          minH = tmp;
          aS = S;
          aA = A;
          aC = C;
        }
      }
    }
  }
  cout << aS << " " << aA << " " << aC << endl;
}
 
int main() {
  M = 256;
  for(int i = 1; i <= 300; ++i) m_log[i] = log(i);
  while((cin >> N) && N) {
    for(int i = 0; i < N; ++i) cin >> I[i];
    solve();
  }
  return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct s{
	char s[11];
};

int compare_s(const void *a, const void *b){
	struct s *A = (struct s *)a;
	struct s *B = (struct s *)b;
	char *a_s = (char *)A->s;
	char *b_s = (char *)B->s;
	return strcmp(a_s, b_s);
}

int main(void){
	int n;
	int count = 1;
	struct s *ss;
	scanf("%d", &n);
	ss = (struct s *)malloc(sizeof(struct s) * n);
	for(int i=0; i<n; i++){
		char tmp_s[11] = { '\0' };
		scanf("%s", tmp_s);
		strcpy(ss[i].s, tmp_s);
	}
	qsort(ss, n, sizeof(struct s), compare_s);
	for(int j; j<n-1; j++){
		if(strcmp(ss[j].s, ss[j+1].s) != 0){
			count++;
		}
	}
	printf("%d\n", count);
}

Measured memory_bytes: 5740
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())
s = raw_input()
t = raw_input()

for i in xrange(len(s)):
    for j in xrange(len(t)):
        if i + j >= len(s): continue
        if t[j] != s[i + j]:
            break
    else:
        print i + j + 1
        exit()
print len(s) + len(t)



Measured memory_bytes: 4520
n = int(input())
a = list(map(int, input().split()))
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = a[i - 1] ^ sum(r[i * 2::i]) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))


Measured memory_bytes: 13112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, M, x[100000], dif[100000];
int main(int argc, char **argv) {
    cin >> N >> M;
    for(int i = 0; i < M; ++i)
        cin >> x[i];
    
    sort(x, x + M);

    for(int i = 1; i < M; ++i)
        dif[i] = x[i] - x[i - 1];
    
    sort(dif + 1, dif + M);

    int res = 0;
    for(int i = 1; i < M - (N - 1); ++i)
        res += dif[i];

    cout << res << endl;  
}

Measured memory_bytes: 1024
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function tsort(e::Array{Int,2},n,m)
	g = [Int[] for i in 1:n]
	d = zeros(Int,n)
	v = zeros(Int,n)
	for i in 1:m
		push!(g[e[1,i]],e[2,i])
		d[e[2,i]] += 1
	end
	s = Int[]
	for i in 1:n
		if d[i] == 0
			push!(s,i)
		end
	end
	l = Int[]
	while !isempty(s)
		t = pop!(s)
		push!(l,t)
		for i in 1:length(g[t])
			d[g[t][i]] -= 1
			if d[g[t][i]] == 0
				push!(s,g[t][i])
			end
		end
	end
	if length(l) == n
		l
	else
		false
	end
end

function main()
	n,m = readline() |> split |> parseMap
	e = Array{Int}(2,n-1+m)
	g = [Int[] for i in 1:n]
	for i in 1:n-1+m
		e[:,i] = readline() |> split |> parseMap
		push!(g[e[2,i]],e[1,i])
	end
	x = tsort(e,n,n-1+m)
	z = Array{Int}(n)
	for i in 1:n
		z[x[i]] = i
	end
	ans = Array{Int}(n)
	for i in 1:n
		o = 0
		oo = 0
		for j in 1:length(g[i])
			if z[g[i][j]]>oo
				oo = z[g[i][j]]
				o = g[i][j]
			end
		end
		ans[i] = o
	end
	for i in 1:n
		println(ans[i])
	end
end
main()

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

int N;
multimap<int, int> m;

int minDepth(int winner)
{
	auto count = m.count(winner);
	if (count == 0)
		return 0;

	vector<int> depths;
	depths.reserve(count);

	auto range = m.equal_range(winner);
	for (auto it = range.first; it != range.second; ++it)
	{
		depths.push_back(minDepth(it->second));
	}

	sort(depths.begin(), depths.end());
	size_t max_depth = 0;
	for (size_t i = 0; i < depths.size(); ++i)
	{
		max_depth = max(max_depth, depths[i] + depths.size() - i);
	}

	return max_depth;
}

int main()
{
	cin >> N;
	for (int i = 2; i <= N; ++i)
	{
		int a;
		cin >> a;
		m.emplace(a, i);
	}
	cout << minDepth(1) << endl;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
 
  fastio
    lli n,i,d=0,k;
    cin>>n;
    vll v(n);
    for(auto &i:v)
    	cin>>i;
    sort(v.begin(),v.end(),greater<lli>());
    d=v[0];
    k=1;
    for(i=1;i<n-1;i++)
    {
      d=d+v[k];
      if(i%2==0)
      	k++;
    }
    cout<<d<<endl;
  
	return 0;
}

Measured memory_bytes: 4772
import bisect

def prime_sieve(end):
    assert end > 1
    is_prime = [True for i in range(end)]
    is_prime[0], is_prime[1] = False, False
    primes = list()
    for i in range(2,end):
        if is_prime[i]:
            primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    return primes 

q = int(input())
lr = [list(map(int, input().split())) for i in range(q)]
a = prime_sieve(100001)
b = set(a)
c = []
for i in a:
  if (i+1) // 2 in b:
    c.append(i)
for l,r in lr:
  ans = bisect.bisect_right(c,r) - bisect.bisect_left(c,l)
  print(ans)


Measured memory_bytes: 29224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
   // freopen("input.txt", "r", stdin);
    SPEED
    ll n;
    cin >> n;
    vector<ll> h(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    vector<ll> dp(n + 1, 0);
    for (int i = 2; i <= n; ++i) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i - 2 >= 1)
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    DEBUG(dp)
    cout << dp[n];
}
/************************************** END OF PROGRAM ******************************************/


Measured memory_bytes: 2560
n = int(input())
a = list(map(int, input().split()))

if n % 3 != 0:
    if sum(a) == 0:
        print("Yes")
    else:
        print("No")
else:
    count = {}
    for i in range(n):
        count.setdefault(a[i], 0)
        count[a[i]] += 1
    num = list(count.keys())
    if len(num) > 3:
        print("No")
    elif len(num) == 3:
        if count[num[0]] == count[num[1]] and count[num[1]] == count[num[2]]:
            if num[0] ^ num[1] == num[2] and num[1] ^ num[2] == num[0] and num[2] ^ num[0] == num[1]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    elif len(num) == 2:
        if count[num[0]] == (n // 3) and count[num[1]] == (n // 3) * 2:
            if num[0] ^ num[1] == num[1] and num[1] ^ num[1] == num[0]:
                print("Yes")
            else:
                print("No")
        elif count[num[0]] == (n // 3) * 2 and count[num[1]] == (n // 3):
            if num[0] ^ num[1] == num[0] and num[0] ^ num[0] == num[1]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    elif len(num) == 1:
        if num[0] == 0:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 14212
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String s = sc.next();
		int k = sc.nextInt();
		TreeSet<String> ts = new TreeSet<>();
		for (int i = 1; i <= 5 && i <= s.length(); i++) {
			for (int j = 0; j <= s.length() - i; j++) {
				ts.add(s.substring(j, i + j));
			}
		}
		Iterator ite = ts.iterator();
		for(int i = 0; i < k - 1; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	}
}

Measured memory_bytes: 27076
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
typedef std::pair<int,int> P;

    ll N;
    ll A[52],S[52];
    P B[52];
    ll X,Y;
    ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
      cin>>A[i];
      B[i].first=A[i];
      B[i].second=i;
    }
    sort(B,B+N);
    X=B[0].first,Y=B[N-1].first;
    cout<<N*2-1<<endl;
    REP(i,N){

        if(abs(Y)-abs(X)>=0){
            cout<<B[N-1].second+1;
        }else{
            cout<<B[0].second+1;
        }
        cout<<" "<<i+1;
        cout<<endl;
    }
    if(abs(Y)-abs(X)>=0){
        REP(i,N-1)cout<<i+1<<" "<<i+2<<endl;
    }else{
        REP(i,N-1)cout<<N-i<<" "<<N-i-1<<endl;
    }

//    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(true){
            int n = scan.nextInt();
            if(n == 0)break;
            int[][] array = new int[n + 1][n + 1];
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    array[i][j] = scan.nextInt();
                }
            }
            int sum = 0;
            for(int i = 0; i < n; i++){
                int xsum = 0;
                int ysum = 0;
                for(int j = 0; j < n; j++){
                    xsum += array[j][i];
                    ysum += array[i][j];
                }
                array[n][i] = xsum;
                array[i][n] = ysum;
                sum += xsum;
            }
            array[n][n] = sum;

            for(int i = 0; i <= n; i++){
                for(int j = 0; j <= n; j++){
                    System.out.printf("%5d",array[i][j]);
                }
                System.out.println("");
            }

        }
    }
}

Measured memory_bytes: 31736
from math import sqrt
from itertools import permutations
def dist(a,b):
    return sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
n = int(input())
data = [list(map(int,input().split())) for _ in range(n)]

ans = 0
for q in permutations(data):
    for i in range(1,n):
        ans += dist(q[i-1],q[i])
for i in range(n):
    ans /= (i+1)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

#define MAX 100005

int w,h,n;

// first = yoko / second = tate
P p[100005];

int yoko[MAX];
int tate[MAX];
int max_yoko[MAX];
int max_tate[MAX];

signed main(){
  cin>>w>>h>>n;
  for(int i=0; i<n; i++){
    cin>>p[i].first>>p[i].second;
    yoko[p[i].second]=max(yoko[p[i].second],p[i].first);
    tate[p[i].first]=max(tate[p[i].first],p[i].second);
  }
  
  for(int i=h-1; i>=0; i--){
    max_yoko[i]=max(max_yoko[i+1],yoko[i]);
  }
  
  for(int i=w-1; i>=0; i--){
    max_tate[i]=max(max_tate[i+1],tate[i]);
  }
  
  int ans=INF;
  bool is0_tate=true;
  for(int i=1; i<w; i++){
    ans=min(ans,i+max_tate[i+1]);
    if(max_tate[i+1]) is0_tate=false;
  }
  
  bool is0_yoko=true;
  for(int i=1; i<h; i++){
    ans=min(ans,i+max_yoko[i+1]);
    if(max_yoko[i+1]) is0_yoko=false;
  }
  
  if(is0_yoko&&is0_tate){
    cout<<0<<en;
    RE;
  }
  cout<<ans<<en;
}





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

using namespace std;

typedef long long ll;
typedef long double ld;

const ld PIE = atan2(0, -1);
const ll MOD = 1e9 + 7;

void solve() {
	int n, q;
	cin >> n >> q;
	ll ans = 0;
	for (int k = q; k <= n + 1; ++k) {
		ll minsum = k * 1ll * (k + 1); minsum /= 2;
		ll maxsum = k * 1ll * (2 * n + 3 - k); maxsum /= 2;
		ans += maxsum - minsum + 1;
		//cout << "k: " << minsum << ' ' << maxsum << endl;
		ans %= MOD;
	}
	cout << ans << "\n";
}

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

Measured memory_bytes: 3628
import sys
input = sys.stdin.readline


def main():
    def saiki(n):
        if n == 1:
            return 1
        else:
            return 1 + 2 * saiki(n // 2)

    # n, k = map(int, input().split())
    # h = list(map(int, input().split()))
    h = int(input())

    print(saiki(h))


main()


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

int n,s;

int dfs(int i,int c,int sum){
	int res=0;
	if(n<c || c+10-i<n || s<sum)return 0;
	if(c==n&&sum==s)return 1;
	res += dfs(i+1,c,sum);
	res += dfs(i+1,c+1,sum+i);
	return res;
}
int main(){
	while(cin>>n>>s,n||s)cout<<dfs(0,0,0)<<endl;
	return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int a,b;
    string s;
    cin>>a>>b>>s;

    for(int i=0;i<s.size();i++){
        if((i<a||i>a)&&!(s[i]>='0'&&s[i]<='9')){
            cout<<"No"<<endl;
            return 0;
        }
        else if(i==a&&s[i]!='-'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}




Measured memory_bytes: 256
import java.util.*;

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

        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();

        int h = (h2 * 60  + m2) - (h1 * 60 + m1);

        System.out.println(h - k);
    }
}


Measured memory_bytes: 35816
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
ll ctoi(char c) {
    if (c == '0')return 0;
    else if (c == '1')return 1;
    else if (c == '2')return 2;
    else if (c == '3')return 3;
    else if (c == '4')return 4;
    else if (c == '5')return 5;
    else if (c == '6')return 6;
    else if (c == '7')return 7;
    else if (c == '8')return 8;
    else if (c == '9')return 9;
    else return -1;
}int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> tele(N);
    vector<ll> visit(N);
    rep(i, N)cin >> tele[i];
    ll now = 0;
    ll cnt = 0;
    ll shote = 0;
    ll start = 0;
    bool roop = false;
    while (true) {
        if (visit[now] == 1) {
            roop = true;
            start = tele[now]-1;
        }
        if (visit[now] == 2) {
            break;
        }
        if (roop)cnt++;
        else shote++;
        visit[now]++;
        now = tele[now] - 1;
    }
    shote -= cnt;
    now = 0;
    if (K < shote) {
        rep(i, K) {
            now = tele[now] - 1;
        }
        cout << now + 1 << endl;
    }
    else {
        K -= shote;
        K %= cnt;
        now = start;
 //       cout << now << " " << K << endl;
        rep(i, K) {
            now = tele[now] - 1;
        }
        cout << now + 1 << endl;
    }
}

Measured memory_bytes: 6436
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n;
long long m;
long long dp[100005];
int ans;
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=100000;i++)
		dp[i]=1e11;
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		long long w;
		int v;
		scanf("%lld%d",&w,&v);
		for(int j=100000;j>=v;j--)
		{
			dp[j]=min(dp[j],dp[j-v]+w);
			if(dp[j]<=m) ans=max(ans,j);
		}
	}
	printf("%d",ans);
	return 0;
}



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

int n , x;
int l[55],p[55];

int dfs(int lev, int d){
    if(!lev) return 1;
    if(d==1) return 0;
    if(d==l[lev]) return p[lev];
    if(d==2+l[lev-1]) return p[lev-1] + 1;
    if(d<=1+l[lev-1]) return dfs(lev-1,d-1);
    return p[lev-1] + dfs(lev-1,d-2-l[lev-1]) + 1;
}

inline void solve(){    

    cin >> n >> x;
    l[0] = p[0] = 1; //レベル0の時、層は1枚パティも1枚
    for(int i = 1; i < n; i++) {
        l[i] = 2 * l[i-1] + 3; //1つ下のレベルが2つ、その他層が3つふえる
        p[i] = 2 * p[i-1] + 1;//そのときパティは2倍かつ1層ふえる
    }
    
    cout << dfs(n,x) << endl;

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			
			int a = sc.nextInt();
			String op = sc.next();
			char o = op.charAt(0);
			int b = sc.nextInt();

		if(o == '?'){
			break;
		}
		else if(o == '-'){
			System.out.println(a - b);
		}
		else if(o == '*'){
			System.out.println(a * b);
		}
		else if(o == '/'){
			System.out.println(a / b);
		}
		else if(o == '+'){
			System.out.println(a + b);
		}
		
		}sc.close();
	}
}

Measured memory_bytes: 26340
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll d; cin >> d;
    vector<ll> c(26);
    rep(i,26) cin >> c.at(i);
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,d) rep(j,26) cin >> s.at(i).at(j);
    vector<ll> last(26,0);

    ll sat = 0;

    for(int i=1;i<=d;i++){
        ll t; cin >> t;
        t--;
        last.at(t) = i;
        sat += s.at(i-1).at(t);
        for(int j=0;j<26;j++){
            sat -= c.at(j) * (i - last.at(j));
        }
        cout << sat << endl;
    }
    return 0;
}

Measured memory_bytes: 3688
#include<iostream>
#include<map>
#include<string>
#include<vector>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define rep(i,n) FOR(i,0,n)

template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}


int main(){
	int N;
	cin >> N;
	vector<string> S = getv<string>(N);
	map<char,long long> c;
	rep(i,N) c[S[i][0]]++;
	long long sum = 0;
	sum += c['M']*c['A']*c['R'];
	sum += c['M']*c['A']*c['C'];
	sum += c['M']*c['A']*c['H'];
	sum += c['M']*c['R']*c['C'];
	sum += c['M']*c['R']*c['H'];
	sum += c['M']*c['C']*c['H'];
	sum += c['A']*c['R']*c['C'];
	sum += c['A']*c['R']*c['H'];
	sum += c['A']*c['C']*c['H'];
	sum += c['R']*c['C']*c['H'];
	cout << sum << endl;
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N1, N2, N3, N4;
    std::cin >> N1 >> N2 >> N3 >> N4;
    if (not(N1 == 1 or N2 == 1 or N3 == 1 or N4 == 1)) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    if (not(N1 == 9 or N2 == 9 or N3 == 9 or N4 == 9)) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    if (not(N1 == 7 or N2 == 7 or N3 == 7 or N4 == 7)) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    if (not(N1 == 4 or N2 == 4 or N3 == 4 or N4 == 4)) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    std::cout << "YES" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int pre[201][201];
int main() {
	IO;
	for(int i=1;i<=200;++i) {
		for(int j=1;j<=200;++j) {
			pre[i][j]=__gcd(i,j);
		}
	}
	ll n;
	cin>>n;
	ll res=0;
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=n;++j) {
			for(int k=1;k<=n;++k) {
				res+=pre[i][pre[j][k]];
			}
		}
	}
	
	cout<<res<<"\n";
	return 0;
}


Measured memory_bytes: 3808
import java.util.Scanner;

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

        if (a[2] == a[3] && a[4] == a[5]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
int main(){
      string s;
      cin>>s;
     int i,l=s.length(),c=0;
    for(i=0;i<l-1;i++){
      if(s[i]==s[i+1])
      {c=1;break;}
    }
  if(c==1) cout<<"Bad";
  else cout<<"Good";
  return 0;}

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

constexpr int N = 200, P = 998244353;

int n;
int x[N], y[N], pw[N + 1];

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cin >> n;
    for (int i = 0; i < n; ++i)
        std::cin >> x[i] >> y[i];
    
    pw[0] = 1;
    for (int i = 1; i <= n; ++i)
        pw[i] = 2 * pw[i - 1] % P;
    int ans = (pw[n] - n - 1 + P) % P;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int cnt = 0;
            for (int k = j + 1; k < n; ++k)
                if ((x[i] - x[j]) * (y[i] - y[k]) == (y[i] - y[j]) * (x[i] - x[k]))
                    ++cnt;
            ans = (ans - pw[cnt] + P) % P;
        }
    }
    
    std::cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**6)

MOD = 10**9+7


def main(input, print):
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    t = 0
    for i in reversed(range(N-1)):
        t += A[i+1]
        t %= MOD
        ans += t * A[i]
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;

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

	string a, b; cin >> a >> b;
	cout << b + a << '\n';

	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

    int N, M;
    cin >> N >> M;
    set<pii> BA;
    vector<pii> AB(N);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        BA.insert(pii(b, a));
        AB[i] = pii(a, b);
    }
    sort(all(AB));
    int pt = 0;
    int result = 0;
    multiset<int> B;
    FOR(i, 1, M + 1) {
        while (pt < N && AB[pt].first <= i) {
            B.insert(AB[pt].second);
            ++pt;
        }
        if (!B.empty()) {
            auto B_max = prev(B.end());
            result += *B_max;
            B.erase(B_max);
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 8704
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

int main()
{

    int n, k;
    cin >> n >> k;
    double sum = 0;
    rep(i, 1, n + 1)
    {
        int t = i;
        double tmp = 1.0 / n;
        while (t < k)
        {
            t *= 2;
            tmp *= 0.5;
        }
        sum += tmp;
    }
    cout << setprecision(11);
    cout << fixed << sum << endl;
}


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

int main()
{
	int a,b;
	while(cin>>a>>b)
	{
		
		for(int i=1;i<=7;i++)
			if(a+b<pow(10,i))
			{
				cout<<i<<endl;
				break;
			}
	}
	
}

Measured memory_bytes: 1204
n = int(input())
ls0 = [[int(_) for _ in input().split()] for _ in range(n)]

ls = [[0, 0, 0]]
ls.extend(ls0)

for i in range(n):
	dst = ls[i+1][0] - ls[i][0]
	dsx = abs(ls[i+1][1] - ls[i][1])
	dsy = abs(ls[i+1][2] - ls[i][2])
	if dst < dsx + dsy:
		print('No')
		break
	elif (dst - (dsx + dsy)) % 2 == 1:
		print('No')
		break
	elif i == n - 1:
		print('Yes')

Measured memory_bytes: 21876
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 1;
  FOR(i, 1, n) {
    int c = 0;
    rep(j, i) {
      if (h[i] < h[j]) break;
      c++;
    }
    if (c == i) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,i,l;
  cin>>n>>l;
  string s;
  map<string,int>m;
  for(i=0;i<n;i++){
    cin>>s;
    m[s]++;
  }
  string ans="";
  map<string,int>::iterator it;
  for(it=m.begin();it!=m.end();it++){
    while(it->second>0){
      ans+=it->first;
      it->second--;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main()
{
	dhoom;
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 0 ; i < n ; i++){
		ll x;
		cin >> x;
		ans += (x-1);
	}
	cout << ans << endl;
	return 0;
} 



Measured memory_bytes: 256
A, B = list(map(int, input().split()))

if A >= B:
    ans = A
    A -= 1
    if A >= B:
        ans += A
    else:
        ans += B
else:
    ans = B
    B -= 1
    if A >= B:
        ans += A
    else:
        ans += B

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i, n) {
		cin >> v[i];
	}
	SORT(v);
	double ans = v[0];
	rep(i, n - 1) {
		ans = (ans + v[i + 1]) / 2;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static long n = 0;





	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		if(n == 1){
			System.out.println("Hello World");
		}else{
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a+b);
		}
	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 21204