akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (h, n) = readLine()!!.split(" ").map { it.toInt() }
    val list = readLine()!!.split(" ").map { it.toInt() }
    val desc = list.sortedDescending()

    var sum = 0
    for (atack in desc) {
        sum += atack
        if (sum >= h) {
            println("Yes")
            return
        }
    }
    println("No")
}

Measured memory_bytes: 47776
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}

const int mod = 1e9+7;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
char s[257];
char revc(char c)
{
	if (c>='a'&&c<='z') return 'A'+c-'a';
	else return 'a'+c-'A';
}
string getf(int msk)
{
	string ret;
	if (__builtin_popcount(msk)==1)
	{
		ret.PB(__builtin_ctz(msk)+'a');
		return ret;
	}
	else
	{
		int x = __builtin_ctz(msk&(-msk));
		int nmsk = msk-(1<<x);
		string t = getf(nmsk);
		ret += t;
		ret.PB('a'+x);
		reverse(t.begin(), t.end());
		for (int i=0; i<t.size(); i++) t[i] = revc(t[i]);
		ret += t;
		ret.PB('A'+x);
		return ret;
	}
}
vector<pair<int,int> > rt;
int curx, cury;
void go(int x, int y)
{
	while (curx<x) curx++, rt.PB(MP(curx, cury));
	while (curx>x) curx--, rt.PB(MP(curx, cury));
	while (cury<y) cury++, rt.PB(MP(curx, cury));
	while (cury>y) cury--, rt.PB(MP(curx, cury));
}
void out(string s)
{
	assert(s.size()<250000);
	curx = cury = 0;
	rt.PB(MP(0, 0));

	for (int i=0; i<s.size(); i++)
	{
		bool f;
		int x;
		if (s[i]>='a'&&s[i]<='z')
		{
			f = true;
			x = s[i]-'a';
		}
		else
		{
			f = false;
			x = s[i]-'A';
		}
		if (f)
		{
			go(x, 0);
			go(x, 1);
			go(x+1, 1);
			go(x+1, 0);
		}
		else
		{
			go(x+1, 0);
			go(x+1, 1);
			go(x, 1);
			go(x, 0);
		}
	}
	go(0, 0);
}
int main()
{
	cin>>n;
	cin>>s;
	for (int i=0; i<(1<<n); i++)
	{
		if (s[i]=='1')
		{
			for (int j=0; j<(1<<n); j++)
			{
				if ((i&j)==j&&s[j]=='0')
				{
					puts("Impossible");
					return 0;
				}
			}
		}
	}
	puts("Possible");
	string ans;
	for (int i=0; i<(1<<n); i++)
	{
		if (s[i]=='0')
		{
			ans += getf(i);
		}
	}
	out(ans);
	putsi(rt.size()-1);
	for (int i=0; i<rt.size(); i++) putsii(rt[i].FF, rt[i].SS);
	return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, m;
  cin >> n >> m;
  vector <string> in(n);
  vi row(n, 1), col(m, 1);
  for(int i = 0; i < n; i++){
    cin >> in[i];
    if(in[i] == string(m, '.')){
      row[i] = 0;
    }
  }
  for(int j = 0; j < m; j++){
    string x = "";
    for(int i = 0; i < n; i++){
      x += in[i][j];
    }
    if(x == string(n, '.')){
      col[j] = 0;
    }
  }
  for(int i = 0; i < n; i++){
    if(!row[i]) continue;
    for(int j = 0; j < m; j++){
      if(!col[j]) continue;
      cout << in[i][j];
    }
    cout << "\n";
  }

}

Measured memory_bytes: 256
import sys
from collections import Counter

# sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    a = read_int_list()
    a.sort()
    c = Counter(a)
    l = set()
    for i in a:
        if c[i] >= 2:
            l.add(i)
    l = list(l)
    l.sort()

    res = 0
    if len(l) >= 1:
        m = l[-1]
        if c[m] >= 4:
            res = m * m
        else:
            if len(l) >= 2:
                p = l[-2]
                res = m * p
    print(res)


main()


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

using namespace std;

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

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

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

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


signed main(void) {
	string s;
  cin >> s;
  if(s.size()==3)reverse(all(s));
  cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        int min = Math.min(a,b);
        for (int i = 1; i<=min;i++) {
            if (a % i == 0 && b % i == 0) list.add(i);
        }
        list.sort(Collections.reverseOrder());
        System.out.println(list.get(k - 1));
    }
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)

#include <string>
int main(){
	int ans=0;
	string str;
	cin >> str;
	for(int i=2;i<str.length();i+=2){
		string s1,s2;
		FOR(j,0,i/2) s1 += str[j];
		FOR(j,i/2,i) s2 += str[j];
		if(s1 ==s2) ans = i;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,A[50];
int sol(int i, int m){
  if(m==0) return 1;
  if(i>=n) return 0;
  int res=sol(i+1,m)||sol(i+1,m-A[i]);
  return res;
}
int main()
{
  int q,M,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(sol(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 580
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,z,cnt;double tmp;
void solve(){
	cin>>n;map<pii,int>m;
	rep(i,1,n){
		cin>>tmp;int c1=0,c2=0;
		z=llround(tmp*1e9);
		while((z%2)==0)z/=2,c1++;
		while((z%5)==0)z/=5,c2++;
		m[mp(c1,c2)]++;
	}
	for(auto i:m)
		for(auto j:m){
			if(i<j){
				if(i.F.F+j.F.F>=18 and i.F.S+j.F.S>=18)cnt+=i.S*j.S;
			}
			if(i==j){
				if(i.F.F+j.F.F>=18 and i.F.S+j.F.S>=18)cnt+=i.S*(j.S-1)/2;
			}
		}
	cout<<cnt;
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  double a, b, x;
  double pi = acos(-1);
  cin >> a >> b >> x;
  double ans = 0;
  if(x >= a*a*b/2){
    x = a*a*b - x;
    ans = atan(2.0*x/(a*a*a));
    ans = 180*ans/pi;
  }else{
    ans = atan(2.0*x/(b*a*b));
    ans = 180*ans/pi;
    ans = 90 - ans;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 4012
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x[][] = new int[n][d];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < d; j++){
				x[i][j] = sc.nextInt();
			}
		}
		
		int count = 0;
		for(int i = 0; i < n-1; i++){
			for(int j = i+1; j < n; j++){
				double a = 0;
				for(int k = 0; k < d; k++){
					a += Math.pow((double)(x[i][k] - x[j][k]),2);
				}
				for(int k = 0; k <= (int)a; k++){
					if(Math.pow((double)k,2.0) == a){
						count += 1;
					}
				}
			}
		}
		
		System.out.println(count);
	}
}

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

void Main()
{
  const ll WARU = 1000000000 + 7;
  ll N,K;
  cin >> N >> K;
  ll cnt = 0; 
  for (ll i = K; i <= N+1; i++) {
    cnt += i*N - (i*(i-1)/2) - (i*(i-1)/2 - 1);
    cnt %= WARU;
  }
  cout << cnt << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1e9
#define MAX_N 810
typedef vector<int> Vec;
typedef pair<int,int> pii;
 
struct Edge{
    int to,cost;
    Edge(int to,int cost) :
	to(to),cost(cost) {}
};
 
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
int N;
Graph G;
bool leaf[MAX_N];
 
Vec dijkstra(int s){
    Vec dist(N,INF);
    dist[s] = 0;
    priority_queue<pii,vector<pii>,greater<pii> > Q;
    Q.push(pii(0,s));
    while(!Q.empty()){
	pii p = Q.top(); Q.pop();
	int v = p.second;
	if(dist[v] < p.first){
	    continue;
	}
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    Edge &e = G[v][i];
	    if(dist[v] + e.cost < dist[e.to]){
		dist[e.to] = dist[v] + e.cost;
		Q.push(pii(dist[e.to],e.to));
	    }
	}
    }
    return dist;
}
 
int getFarthestPoint(int v){
    Vec vec = dijkstra(v);
    int resv = -1, max = -1;
    for(int i = 0 ; i < N ; i++){
	if(max < vec[i] && vec[i] != INF){
	    max = vec[i];
	    resv = i;
	}
    }
    return resv;
}
 
int getTreeDiameter(){
    int v = -1;
    for(int i = 0 ; i < N ; i++){
	if(!leaf[i]){
	    v = i;
	    break;
	}
    }
    int v1 = getFarthestPoint(v);
    int v2 = getFarthestPoint(v1);
    Vec d = dijkstra(v2);
    int res = 0;
    for(int i = 0 ; i < (int)d.size() ; i++){
	if(d[i] != INF){
	    res = max(res,d[i]);
	}
    }
    return res;
}
 
void init(){
    for(int i = 0 ; i < (int)G.size() ; i++){
	G[i].clear();
    }
    G.clear();
    G.resize(N);
}
 
int main(){
    while(cin >> N, N){
	init();
	int sum = 0;
	Vec p(N-1);
	for(int i = 0 ; i < N-1 ; i++){
	    cin >> p[i]; p[i]--;
	}
	Graph G2(N);
	for(int i = 0 ; i < N-1 ; i++){
	    int d; cin >> d; sum += d;
	    G2[p[i]].push_back(Edge(i+1,d));
	    G2[i+1].push_back(Edge(p[i],d));
	}
	memset(leaf,false,sizeof(leaf));
	for(int i = 0 ; i < (int)G2.size() ; i++){
	    if(G2[i].size() == 1){
		leaf[i] = true;
	    }
	}
	for(int i = 0 ; i < (int)G2.size() ; i++){
	    if(!leaf[i]){
		for(int j = 0 ; j < (int)G2[i].size() ; j++){
		    if(!leaf[G2[i][j].to]){
			G[i].push_back(G2[i][j]);
			sum += G2[i][j].cost;
		    }
		}
	    }
	}
	cout << sum-getTreeDiameter() << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
//Name : Rupa Dey
  //Date : 27 august 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gap " ";
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b,time,print=0;
    cin>>a>>b>>time;
    if(a<=b) cout<<time<<endl;
    else if(2*b>a) cout<<2*time<<endl;
    else
    {
        print = ((a+b-1)/b)*time;
      cout<<print<<endl;

    }



}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


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

namespace CPLib
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = s[0];
            int m = s[1];
            if (n == m)
            {
                WriteLine("Yes");
            }
            else WriteLine("No");
        }
    }
}


Measured memory_bytes: 13268
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar[4] = {{0,1},{0,-1},{1,0},{-1,0}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n,k;cin>>n>>k;
  int ans = 0;
  while(n){
    n/=k;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    if (n < 1200) cout << "ABC" << endl;
    else if (n < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class292
    {
        static int N;
        static void Main()
        {
            N = int.Parse(Console.ReadLine());
            var P = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var Q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(Math.Abs(Order(P)-Order(Q)));
        }

        static int Order(int[] A)
        {
            var e = Enumerable.Range(1, N).ToList();
            int sum = 0;
            for(int i = 1; i <= N; i++)
            {
                int count = 0;
                foreach(int j in e)
                {
                    if (A[i-1] == j)
                    {
                        sum +=count*Bikkuri(N-i);
                        break;
                    }
                    count++;
                }
                e.Remove(A[i-1]);
            }
            return sum;
        }
        static int Bikkuri(int n)
        {
            int ans = 1;
            for (int i = 1; i <= n; i++)
                ans *= i;
            return ans;
        }
    }
}


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

int main(){
    while(true){
        int n, m;
        int d, p;
        multiset<pair<int, int> , greater<pair<int, int> > > s;
        multiset<pair<int, int> , greater<pair<int, int> > >::iterator it;
        int e=0;
        cin >> n >> m;
        if(!(n||m)) break;
        for(int i=0;i<n;++i){
            cin >> d >> p;
            s.insert(make_pair(p, d));
        }
        it = s.begin();
        while(it != s.end() && m > 0){
            m -= (*it).second;
            ++it;
        }
        if(m < 0){
            --it;
            e += (*it).first * (-m);
            ++it;
        }
        while(it != s.end()){
            e += (*it).second * (*it).first;
            ++it;
        }
        cout << e << endl;
    }
}

Measured memory_bytes: 1660
N = int(input())
#w_list = map(int,input().split())
w_list = list(map(int,input().split()))
w_sum = sum(w_list)
left = 0
right = 0
dif_list = []
for i in range(N):
    right = w_sum - left
    dif_list.append(abs(right-left))
    left += w_list[i]
dif_list.append(abs(right-left))

print(min(dif_list))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

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

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    vector<int> friends[501];
    int m;
    cin>>m;
    REP(i,m){
      int a,b;
      cin>>a>>b;
      friends[a].push_back(b);
      friends[b].push_back(a);
    }
    set<int> ans;
    REP(i,friends[1].size()){
      int s = friends[1][i];
      ans.insert(s);
      REP(i,friends[s].size()){
        ans.insert(friends[s][i]);
      }
    }

    if(ans.size()!=0)cout<<ans.size()-1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include<iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include<queue>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include <map>
#include<string.h>
#include<sstream>
#include<stack>
#include<unordered_map>
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <cstdio>
#include <cstdlib>
#define ll long long
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define arr2dof vector  vector<vector<int>>dp(N,vector<int>(2, inf));
using namespace std;
const int N = 2e5 + 5, inf = 1e9+7 ;
const double ep = 0.0000000001;
const double pi = 3.14159265359;
const long long inff= 1e18;
	
int dp[3005][3005];

int main()
{
	string s, t,tmp;
	cin >> s >> t;
	tmp = min(s, t);
	t = max(s, t);
	s = tmp;
	     for (int i = 1; i <= s.length(); ++i)
		for (int l = 1; l <= t.length(); ++l) {
	          {
			if (s[i - 1] == t[l - 1]) {
				dp[i][l] = 1 + dp[i - 1][l - 1];
			}
			else {
				dp[i][l] = max(dp[i - 1][l], dp[i][l - 1]);
			}
		}
	}
	int a = t.length(), b = s.length();
	string ans = "";
	while (true) {
		if (dp[b][a -1] == dp[b-1][a] && dp[b][a - 1] == dp[b - 1][a - 1] && dp[b][a - 1] == 0) {
			if (t[a - 1] == s[b - 1])
			ans += t[a - 1];
			break;
		}
		if (dp[b][a - 1] == dp[b - 1][a]&&t[a-1]==s[b-1]) {
			ans += t[a - 1];
			a--;
			b--;
		}
		else if (dp[b][a - 1] > dp[b - 1][a]) {
			a--;
		}
		else {
			b--;
		}
}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 35456
#include<stdio.h>
int main(void)
{
	int a, b, c, d=0, i;
	scanf("%d %d %d", &a, &b, &c);
	for (i=a;i <= b; ++i) {
		if (c%i==0) {
			d=d+1;
		}
	}
	printf("%d\n", d);
	return 0;
}
			


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int a,b,k;
    cin >> a >> b >> k;

    for(int i = min(a,b);i >= 1; --i){
        if(a % i == 0 && b % i == 0){
            k--;
        }
        if(k <= 0){
            cout << i << endl;
            break;
        }
    }
   return 0;
}


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

const int maxn = 1e6;
int a[maxn + 10], f[maxn + 10];
int n, ans;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    cin >> n;
    f[0] = 0;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        f[i] = max(f[i - 1], a[i]);
    }
    ans = 0;
    for (int i = n; i > 1; --i)
        if (f[i - 1] > a[i]) ans += f[i - 1] - a[i];
    cout << ans;
}


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

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

  int n;cin>>n;
  if(n==1){
    cout<<"Hello World"<<endl;
  }
  else {
    int a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }

  return 0;
}


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

int main() {
    vector<int> vec(3);
    for (int i = 0; i < 3; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    if (vec[0] == vec[1] && vec[0] == 5 && vec[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>
#include <assert.h>

using namespace std;

#define endl '\n'

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

    int n, m;
    cin >> n >> m;

    vector<int> cost(1 << n, 1000000000);
    cost[0] = 0;

    for (int i = 0; i < m; ++i) {
        int mask = 0;

        int a, b; cin >> a >> b;

        for (int j = 0; j < b; ++j) {
            int u; cin >> u; u--;
            mask |= 1 << u;
        }

        for (int ms = (1 << n) - 1; ms >= 0; --ms)
            cost[ms | mask] = min(cost[ms | mask], cost[ms] + a);
    }

    if (cost.back() == 1000000000)
        cost.back() = -1;

    cout << cost.back() << endl;

    return 0;
}

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

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

int main(){
    string S;
    cin >> S;
    int ans = 0;
    int N = (int)S.size();
    rep(i, N){
        int cnt = 0;
        if(S[i] == S[i+1] && S[i] == 'R'){
            cnt++;
            while(S[i] == S[i+1] && S[i] == 'R' && i < N){
                i++;
                cnt++;
            }
        }else if(S[i] == 'R'){
            cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, K;
    cin >> A >> B >> K;

    vector<int> vec;
    int N;
    N = max(A, B);
    for(int i=1;i<=N;i++){
        if(A%i == 0 && B%i == 0)
            vec.push_back(i);
    }
    // 降順ソート
    sort(vec.begin(), vec.end(), greater<int>());

    cout << vec[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long calc(int p, string s) {
    if (p == 2 || p == 5) {
        long ans = 0;
        for (int i = cast(int)s.length-1; i >= 0; i--) {
            if ((s[i] - '0') % p == 0) {
                // 下一桁が p で割り切れるので、区間 [0, i] は全て p で割り切れる
                ans += i + 1;
            }
        }
        return ans;
    }

    long[int] d = [0: 1];
    int x = 0;
    int t = 1;
    foreach_reverse (c; s) {
        x = (x + (c - '0') * t) % p;
        t = 10 * t % p;
        d[x]++;
    }
    return d.values.map!(e => e * (e - 1) / 2).sum;
}

void main() {
    int n, p; scan(n, p);
    string s = read!string;
    writeln(calc(p, s));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    string s;
    ll k;
    cin >> s >> k;

    rep(i, s.size()){
        int num = s[i] - '0';
        if(num == 1 && i + 1 < k){
            continue;
        }else{
            cout << num << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)
max = 0
count = 0
(n-1).times do |i|
    if h[i] >= h[i+1]
        count+=1
    else
        if max < count
            max = count
        end
        count = 0
    end
end
if max < count
    max = count 
end
puts max

Measured memory_bytes: 9732
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define rep1(i,n) for(int i=1;i<=((int)(n));i++)
#define repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=1010;

int n,m,ans;
string s,t;

int main()
{
	cin>>s>>t;
	n=SZ(s);m=SZ(t);

	ans=INF;
	for(int i=0;i<n-m+1;i++)
	{
		int cnt=0;
		for(int j=i;j<i+m;j++) if(s[j]!=t[j-i]) cnt++;
		ans=min(ans,cnt);
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main(){
    ll x;
    cin>>x;
    ll th=x/500,a=0;
    a+=(1000*th);
    x-=(th*500);
    a+=(x-x%5);
    cout<<a<<endl;
    return 0;
}

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

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

  int t;
  t = N % 500;

  if (t <= A) {
    cout << "Yes" << endl;

  }

  else {
    cout << "No" << endl;

  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> adj[100];
int dist[100];
int maxdeg[100];

int dfs1(int v, int p) {
    int ans = 0;
    for (int c : adj[v])
        if (c != p)
            ans = max(ans, dfs1(c, v) + 1);
    return ans;
}
void dfs2(int v, int p, int d) {
    maxdeg[d] = max(maxdeg[d], (int) adj[v].size());
    for (int c : adj[v])
        if (c != p)
            dfs2(c, v, d + 1);
}

pair<int, long> solve(int n) {
    if (n == 2)
        return make_pair(1, 2L);

    for (int i = 0; i < n; i++)
        dist[i] = dfs1(i, -1);

    int *c1 = min_element(dist, dist + n);
    int *c2 = find(c1 + 1, dist + n, *c1);

    fill_n(maxdeg, n, 0);

    if (c2 == dist + n) {
        dfs2(c1 - dist, -1, 0);
        long ans = maxdeg[0];
        for (int i = 1; i < *c1; i++)
            ans *= maxdeg[i] - 1;

        for (int v : adj[c1 - dist]) {
            fill_n(maxdeg, n, 0);
            dfs2(c1 - dist, v, 0);
            dfs2(v, c1 - dist, 0);
            long ans2 = 2 * (maxdeg[0] - 1);
            for (int i = 1; i < *c1; i++)
                ans2 *= maxdeg[i] - 1;
            ans = min(ans, ans2);
        }

        return make_pair(*c1 + 1, ans);
    } else {
        dfs2(c1 - dist, c2 - dist, 0);
        dfs2(c2 - dist, c1 - dist, 0);

        long ans = 2 * (maxdeg[0] - 1);
        for (int i = 1; i < *c1 - 1; i++)
            ans *= maxdeg[i] - 1;
        return make_pair(*c1, ans);
    }
}

int main() {
    int n;
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n; i++)
            adj[i].clear();
        for (int i = 0; i < n - 1; i++) {
            int u, v;
            scanf("%d %d", &u, &v);
            u--, v--;
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        pair<int, long> p = solve(n);
        printf("%d %ld\n", p.first, p.second);
    }
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	if(x >= 'a') cout << 'a';
	else cout << 'A';
	
	return 0;
}


Measured memory_bytes: 3632
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())))
counts = []
now = l[0]
count = 1
for i in range(1, n):
  if l[i] == now:
    count += 1
  else:
    counts.append(count)
    now = l[i]
    count = 1
  
  if i == n-1:
    counts.append(count)

if len(counts) <= k:
  print(0)
else:
  counts = sorted(counts)
  print(sum(counts[:-k]))

Measured memory_bytes: 25644
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int n;
	string s;
	int k;
	cin >> n >> s >> k;
	char c = s[k - 1];
	rep(i, s.size()) {
		if (s[i] != c) {
			s[i] = '*';
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 256
import bisect;n,k=map(int,input().split());s=input();f=[0]*n;f[0]=1-int(s[0])
for i in range(1,n):f[i]=(1-int(s[i]))*int(s[i-1])
for i in range(n-1):f[i+1]+=f[i]
a=0
for l in range(n):r=bisect.bisect_right(f,k+f[l]*int(s[l]));a=max(a,r-l)
print(a)

Measured memory_bytes: 44124
import sys

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    vw = [None] * N
    for i in range(N):
        vw[i] = tuple(map(int, input().split()))

    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i, (v, w) in enumerate(vw):
        for j in range(W + 1):
            if j - w < 0:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w] + v)

    ans = max(dp[-1])
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 25516
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();  	
}

const int MAXN = 2e5 + 10, INF = 1e18, MOD = 1e9 + 7;
int n, k;
int a[MAXN];

struct node {
  	int Max, Min;
} t[4 * MAXN];

void build(int v, int tl, int tr) {
 	if (tl == tr) {
 	    t[v].Min = a[tl];
 	    t[v].Max = a[tl];
 	}
 	else {
 	 	int tm = (tl + tr) / 2;
 	 	build(v * 2, tl, tm);
 	 	build(v * 2 + 1, tm + 1, tr);
 	 	t[v].Min = min(t[v * 2].Min, t[v * 2 + 1].Min);
 	 	t[v].Max = max(t[v * 2].Max, t[v * 2 + 1].Max);
 	}
}    	

int queryMin(int v, int tl, int tr, int l, int r) {
 	if (l > tr || r < tl) {
 	 	return INF;
 	}

 	if (l <= tl && tr <= r) {
 	 	return t[v].Min;
 	}

 	int tm = (tl + tr) / 2;
 	int ans1 = queryMin(v * 2, tl, tm, l, r);
 	int ans2 = queryMin(v * 2 + 1, tm + 1, tr, l, r);
 	return min(ans1, ans2);
}

int queryMax(int v, int tl, int tr, int l, int r) {
	if (l > tr || r < tl) {
	 	return -INF;
	}

	if (l <= tl && tr <= r) {
	 	return t[v].Max;
	}

	int tm = (tl + tr) / 2;
	int ans1 = queryMax(v * 2, tl, tm, l, r);
	int ans2 = queryMax(v * 2 + 1, tm + 1, tr, l, r);
	return max(ans1, ans2);
}

void solve() {                     
	cin >> n >> k;	
	for (int i = 0; i < n; ++i) {
	    cin >> a[i];
	}

	build(1, 0, n - 1);

	vector<int> ps(n);
	ps[0] = 1;
	for (int i = 1; i < n; ++i) {
	    if (a[i] > a[i - 1]) {
	     	ps[i] = ps[i - 1] + 1;
	    }
	    else {
	        ps[i] = 1;
	    }
	}

	dbg(queryMax(1, 0, n - 1, 6, 9));

	int cnt = 0, ok = 0;
	for (int i = 0; i < n - k + 1; ++i) {
	 	int l = INF, r = -INF;
	 	if (i > 0) l = a[i - 1];
	 	r = a[i + k - 1];
	 	int _min = INF, _max = -INF;
	 	/*for (int j = max(0ll, i - 1); j < i + k; ++j) {
	 	 	_min = min(a[j], _min);
	 	 	_max = max(a[j], _max);
	 	} */

	 	_min = queryMin(1, 0, n - 1, max(0ll, i - 1), i + k - 1);
	 	_max = queryMax(1, 0, n - 1, max(0ll, i - 1), i + k - 1);

	 	dbg(_min << " " << _max);
	 	int cur = ps[i + k - 1];

	 	if (cur >= k) {
	 	 	ok = 1;
	 	}
	 	
	 	if (l == _min && r == _max || (cur >= k)) {
	 	 	continue;
	 	}

        cnt++;	
	}

	cout << cnt + ok << endl;
}    	



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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vll zero(60), one(60);
  for(int i=0;i<n;++i) {
    ll a; cin >> a;
    int now = 0;
    for(int i=0;i<60;++i) {
      if(a % 2) {
        one[now]++;
      } else {
        zero[now]++;
      }
      a /= 2;
      now++;
    }
  }

  ll now = 1;
  ll ans = 0;
  for(int i=0;i<60;++i) {
    ans += now * zero[i] % MOD * one[i] % MOD;
    ans %= MOD;
    now *= 2;
    now %= MOD;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
/*--------------------------------
  Author: The Ace Bee
  Blog: www.cnblogs.com/zsbzsb
  This code is made by The Ace Bee
--------------------------------*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#define rg register
using namespace std;
template < typename T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while (!isdigit(c)) f |= (c == '-'), c = getchar();
	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
	s = f ? -s : s;
}
typedef long long LL;
int n; char S[30];
inline LL calc(int s) {
	s |= 1 << (n - 1);
	LL res = 0, fi = 0;
	for (rg int i = 1; i <= n; ++i) {
		fi = 1ll * fi * 10ll + (LL) (S[i] - 48);
		if (s >> (i - 1) & 1) res += fi, fi = 0ll;
	}
	return res;
}
int main() {
	scanf("%s", S + 1), n = strlen(S + 1);
	LL res = 0;
	for (rg int s = 0; s < 1 << (n - 1); ++s) res += calc(s);
	printf("%lld", res);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://abc059.contest.atcoder.jp/tasks/abc059_b
 */
public class Main {
	 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
	
		String ans=null;
		if(a.equals(b)){
			ans = "EQUAL";
		}else if(a.length() > b.length() ){
			ans = "GREATER";
		}else if( a.length() < b.length() ){				
			ans = "LESS";
		}else {
			ans = a.compareTo(b)>0 ? "GREATER" : "LESS";
		}
		
		System.out.println(ans);
 
	}
 
}

Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF
#define mp
#define pb

#define fi
#define se

#define each

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int main(){
	while(1){
		int N;
		int xy[440][440];
		rep(y,440){
			rep(x,440){
				xy[y][x]=-1;
			}
		}
		cin >> N;
		if(N==0) break;
		xy[200][200]=0;
		rep(i,N-1){
			int t,d;
			cin >> t >> d;
			rep(x,440){
				rep(y,440){
					if(xy[y][x] == t){
						xy[dy[d]+y][dx[d]+x] = i+1;
					}
				}
			}
		}
		// for (int y = 190; y < 210; ++y)
		// {
		// 	for (int x = 10; x < 210; ++x)
		// 	{
		// 		printf("%2d ",xy[y][x]);
		// 	}
		// 	cout <<endl;
		// }
		// cout << endl;

		int r=0,l=440,u=440,b=0;
		rep(y,440){
			rep(x,440){
				if(xy[y][x]!=-1){
					r = max(r,x);
				}
			}
		}
		rep(y,440){
			rep(x,440){
				if(xy[y][x]!=-1)
				{
					l = min(l,x);
				}
			}
		}
		rep(y,440){
			rep(x,440){
				if(xy[y][x]!=-1){
					b = max(b,y);
				}
				
			}
		}
		rep(y,440){
			rep(x,440){
				if(xy[y][x]!=-1){
					u = min(u,y);
				}		
			}
		}
		// cout << r<<" " << l << " " << u << " " << b<<endl;
		cout << r-l+1 << " " << b-u+1 <<endl;
	}
	return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int n;cin>>n;int a[n];
    rep(i,n) cin>>a[i];
    int ans=0;
    rep(i,n){
        if(i%2==0 and a[i]%2) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 300000000000001
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef vector<pair<ll,ll> > vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll N = 200001;
const ll M = log2(N);

struct point {
    ll x, y, i;
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    if(n & 1) return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll ans = fast_exp(x, n / 2);
        return ans * ans % mod;
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m, x, y, ans = 0, s, l;
        cin >> n;
        for(int i = 1; i <= n; i++)
        {
            cin >> x;
            if(x % 2 == i % 2 && i % 2 == 1) ans++;
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3616