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



public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int a[] = new int[n+1];
    for(int i =1; i<n+1; i++){
      a[i] = scanner.nextInt();
    }

    int ans  =0;
    for(int i = 1; i < n+1; i+= 2){
      if( a[i] % 2 == 1){
        ans++;
      }
    }
    


    System.out.println(ans);
    
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 35952
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int n;
	cin >> n;
	cout << (n + 1) / 2;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>

#include<thread>

using namespace std;

using ll = long long;



int main()
{
	int A, B, C, X, Y;

	cin >> A >> B >> C >> X >> Y;


	if (X > Y)
	{
		swap(X, Y);
		swap(A, B);
	}

	int ans = 0;

	if (A + B < 2*C)
	{
		ans += (A + B)*X;
	}
	else
	{
		ans += 2 * C*X;
	}

	if (B < 2 * C)
	{
		ans += B*(Y - X);
	}
	else
	{
		ans += 2 * C*(Y - X);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define vii vector<pair<int,int> >
#define vi vector<ll>
#define ll long long
#define rep(i,a,b) for(i=a;i<=b;i++)
#define inf 100000000000000000
 
using namespace std;
 
long double dp[3000][3000];
long double p[3000]; 
 
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0) 
            {
                dp[i][j]=dp[i-1][j]*(1-p[i]);
            }
            else{
                dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
            }
        }
    }
    long double ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i>n-i)
        {
            ans+=dp[n][i];
        }
    }
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 139136
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable._
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}

object Main {
  def solve(sc: => Scanner): Unit = {
    val N, M = sc.nextInt
    val A = Array.fill(sc.nextInt)(sc.nextInt)
    val B = Array.fill(N)((sc.nextInt - 1, sc.nextInt)).sortWith((x, y) => x._2 > y._2)
    var score = 0
    var count = M
    for (a <- B) {
      val use = math.min(math.min(A(a._1), count), 1)
      score += use * a._2
      count -= use
      A(a._1) -= use
    }
    println(score)
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 252116
l = map(int, raw_input().split())
n = l[0]
m = l[1]
mod = 1000000000 + 7

'''
def mod_pow(x,n,mod): 
    ll ret = 1;
    while n > 0:
        if n & 1 :
            (ret *= x) %= mod
        (x *= x) %= mod
        n /= 2
    return ret

def combo(n,k,mod):
    if n / 2 < k:
        k = n - k
    bunshi = 1
    for i in range(n - k + 1,n + 1):
        bunshi *= i;
        bunshi %= mod;
    bunbo = 1
    for i in range(1,k + 1):
        bunbo *= i;
        bunbo *= mod;

    (bunshi *= mod_pow(bunbo(bunshi,mod - 2,mod)) %= mod)
'''

def f(n):
    ret = 1
    for i in  range(1,n + 1) :
        ret *= i
        ret %= mod
    return ret

if m < n :
    l = n
    n = m
    m = l

if n == m :
    print (2 * f(n) * f(n) % mod)
elif m - n < 2 :
    print (f(n) * f(m) % mod)
else:
    print (0)


Measured memory_bytes: 5764
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int N = 1e4;
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}



int32_t main(){
   
   speed_cubing 
   
   int x;
   cin>>x;

   int sum = 100;

   for(int i=1;;i++){
      sum+=sum/100;
      if(sum>=x){
         cout<<i;
         return 0;
      }
   }
    
   return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<vector<pair<int,int>>> data(N);
  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    data[i].resize(tmp);
    for(int j=0;j<tmp;j++){
      cin>>data[i][j].first>>data[i][j].second;
      data[i][j].first--;
    
    }
  }
  int ans=0;
  for(int bit=0;bit<(1<<N);bit++){//bitで1立っている人が正直者だと決め打ち
    
    int flag=1;
    for(int i=0;i<N;i++){//以下、確かめる
      if(!(bit&(1<<i)))continue;
      for(auto xy:data[i]){//i人目の証言から確認
        int x=xy.first;
        int y=xy.second;
        if(y==1&&!(bit&(1<<x)))flag=0;
        if(y==0&&(bit&(1<<x)))flag=0;
      }
    }
    // cout<<"flag"<<flag<<endl;
    int cnt=0;
    if(flag==1){
      for(int p=0;p<N;p++){
        if(bit&(1<<p))cnt++;
      }
    }
  ans=max(cnt,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
def dfs(v):
    global gone
    stack = [v]
    gone[v] = True
    while stack:
        v = stack.pop()
        for w in graph[v]:
            if gone[w] == False:
                stack.append(w)
            gone[w] = True

n,m = map(int,input().split())
exist = [False for i in range(n+1)]
gone = [False for i in range(n+1)]
graph = [[] for _ in range(n+1)]
for i in range(m):
    x,y,z = map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)
    exist[x] = True
    exist[y] = True
ans = 0

for i in range(1,n+1):
    if exist[i] == True:
        if gone[i] == False:
            dfs(i)
            ans += 1
    else:
        ans += 1

print(ans)

Measured memory_bytes: 24388
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll N,A,B;
    cin >> N >> A >> B;
    if((A-B)%2 == 0){
        cout <<abs(A-B)/2<< "\n";
    }else{
        if(A>B){
            swap(A,B);
        }
        if(A-1>N-B){
            ll Ar = A + N - B + 1;
            ll Br = N;
            cout <<N-B+1+abs(Ar-Br)/2<< "\n";
        }else{
            ll At = 1;
            ll Bt = B - A;
            cout <<A + abs(At-Bt)/2<< "\n";
        }
    }
}

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

using namespace std;

int main() {
	int m,n;
	cin >> n >> m;
	vector<int>a(n);
	int cnt=0;
	int sum=0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];

	}

	for (int i=0;i<n;i++){
		if (a[i]*4*m>=sum){
			cnt++;
		}
	}
	if (cnt >=m){
		cout << "Yes"<<endl;
	}
	else{
		cout << "No" <<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && x + r <= W) 
	{
		if (y - r >= 0 && y + r <= H) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else 
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3088
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] t = new int[N];
		int T = 0;
		for (int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
			T += t[i];
		}
		long[] v = new long[N];
		for (int i = 0; i < N; i++) {
			v[i] = sc.nextLong();
		}

		double[] maxA = new double[T * 2 + 1];
		double[] maxB = new double[T * 2 + 1];

		int passed = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <= t[i]; j++) {
				int time = passed + j;
				maxA[time * 2] = Math.min(v[i],
						(time == 0) ? 0 : maxA[time * 2 - 1] + 0.5);
				if (j == 0 && i > 0) maxA[time * 2] = Math.min(maxA[time * 2], v[i - 1]);
				if (j == t[i]) continue;
				maxA[time * 2 + 1] = Math.min(v[i], maxA[time * 2] + 0.5);
			}
			passed += t[i];
		}

		passed = 0;
		for (int i = N - 1; i >= 0; i--) {
			for (int j = 0; j <= t[i]; j++) {
				int time = T - (passed + j);
				maxB[time * 2] = Math.min(v[i], (time == T) ? 0 : maxB[time * 2 + 1] + 0.5);
				if (j == 0 && i < N - 1) {
					maxB[time * 2] = Math.min(maxB[time * 2], v[i + 1]);
				}
				if (j == t[i]) continue;
				maxB[time * 2 - 1] = Math.min(v[i], maxB[time * 2] + 0.5);
			}
			passed += t[i];
		}

		double answer = 0;
		for (int i = 0; i < T * 2 + 1; i++) {
			answer += Math.min(maxA[i], maxB[i]) * 0.5;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23252
p = list(map(int, input().split()))
n = int(input())

l = [min(p[0] * 4, p[1] * 2, p[0] * 2 + p[1], p[2]), p[3]]
ppl = [l[0], l[1] / 2]

if (ppl[0] <= ppl[1]):
    print(n * l[0])
else:
    print((n//2)*l[1] + (n % 2) * l[0])


Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	sc.Scan()
	s := sc.Text()
	return strconv.Atoi(s)
}

func main() {
	sc.Split(bufio.ScanWords)

	w, _ := nextInt()
	h, _ := nextInt()
	x, _ := nextInt()
	y, _ := nextInt()
	r, _ := nextInt()

	result := "No"
	if (0+r) <= x && x <= (w-r) && (0+r) <= y && y <= (h-r) {
		result = "Yes"
	}

	fmt.Printf("%s\n", result)
}



Measured memory_bytes: 1092
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          int[] n = ReadLine().Split(' ').Select(int.Parse).ToArray();
          string a = "", b = "";
          for(int i = 0;i < n[1]; i++){
              a += n[0];
          }
          for(int i = 0;i < n[0]; i++){
              b += n[1];
          }
          int ans = a.CompareTo(b);
          if(ans == 0) WriteLine(a);
          else if(ans < 0) WriteLine(a);
          else if(ans > 0) WriteLine(b);
      }
   }
}

Measured memory_bytes: 11488
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  vector<ll> vl;
  vl.push_back(a * c);
  vl.push_back(a * d);
  vl.push_back(b * c);
  vl.push_back(b * d);

  ll big = *max_element(vl.begin(), vl.end());
  if (big < 0) {
    if (a <= 0 && b >= 0 || c <= 0 && d >= 0) big = 0;
  }

  cout << big << endl;
    
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}	
}


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

typedef long long ll;

int main() {
    int N, M, A, B, start, goal;
    cin >> N >> M;
    vector<vector<int>> edge(N, vector<int>(0));
    vector<int> X(0), Y(0);
    vector<bool> done(N, false);
    rep(i, M) {
        cin >> A >> B;
        A--;
        B--;
        edge[A].push_back(B);
        edge[B].push_back(A);
        if (i == 0) {
            X.push_back(A);
            done[A] = true;
            start = A;
            Y.push_back(B);
            done[B] = true;
            goal = B;
        }
    }
    bool f = true;
    while (f) {
        f = false;
        rep(i, edge[start].size()) {
            int j = edge[start][i];
            if (done[j]) continue;
            start = j;
            done[j] = true;
            X.push_back(j);
            f = true;
            break;
        }
    }
    f = true;
    while (f) {
        f = false;
        rep(i, edge[goal].size()) {
            //cout << "i=" << i << " ";
            int j = edge[goal][i];
            if (done[j]) continue;
            goal = j;
            done[j] = true;
            Y.push_back(j);
            f = true;
            //cout << j << endl;
            break;
        }
    }
    cout << X.size() + Y.size() << endl;
    rep(i, X.size()) {
        cout << X[X.size() - 1 - i]  + 1 << " ";
    }
    rep(i, Y.size()) {
        cout << Y[i] + 1;
        if (i == Y.size() - 1) cout << endl;
        else cout << " ";
    }
    /*
    rep(i, N) {
        cout << i << " ";
        rep(j, edge[i].size()) {
            cout << edge[i][j] << " ";
        }
        cout << endl;
    }
    */
}

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

# In[4]:


import collections


# In[2]:


N = int(input())
D = list(map(int, input().split()))


# In[7]:


mod = 998244353
if D[0] == 0:
    ans = 1
    tmp = 1
    cnt = 0
    for i,x in sorted(collections.Counter(D[1:]).items(), key=lambda x:x[0]):
        if i == cnt+1:
            ans *= (tmp**x)%mod
            tmp = x
            cnt += 1
        else:
            ans = 0
            break
    print(ans%mod)
else:
    print(0)


# In[ ]:






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

using namespace std;
typedef long long ll;

const int N=1e6+10;
const int mod=998244353;
ll n;
ll k,m,x;
ll a[N];
int b[N];
int ans[N];
string s;
int vis[N];
map<ll,int> mp;
int used[25];
int cmp(int a, int b){
    return a>b;
}
ll dp[N];
ll pre[N];


int main()
{
    cin>>n>>x>>m;
    a[1]=x;
    mp[x]=1;
    ll xunhuan=0;
    ll sum=x;
    for(int i=2;i<=n;i++){
        a[i]=(a[i-1]*a[i-1])%m;
        if(mp[a[i]]){
            xunhuan=i;
            break;
        }
        mp[a[i]]=i;
        sum+=a[i];
    }
    //int ans=0;
    if(xunhuan==0){
        cout<<sum<<endl;
    }
    else{
        //cout<<xunhuan<<endl;
        ll start=mp[a[xunhuan]];
        ll endd=xunhuan-1;
        ll xsum=0;
        ll jie=endd-start+1;
        //cout<<a[789]<<endl;
        for(ll i=start;i<=endd;i++){
            xsum+=a[i];
        }
        ll le=n-endd;
        ll num=le/jie;
        ll shengyu=le%jie;
        sum=sum+num*xsum;
        for(ll i=start;i<=endd;i++){
            if(shengyu==0) break;
            sum+=a[i];
            shengyu--;
            if(shengyu==0) break;
        }
        cout<<sum<<endl;


    }


}



Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


signed main(){
  int N, A, B, ans = 1, f = 0;
  scanf("%lld%lld%lld", &N, &A, &B);
  if(A+1 < B){
    if(ans < A)ans += min(A-1, N);
    N -= min(A-1, N);
    ans += (N/2)*(B-A);
    if(N%2)ans++;
  }else{
    ans += N;
  }
  printf("%lld\n", ans);
  return 0;
}






Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long


class AAddSubMul {
public:
    void solve(std::istream &in, std::ostream &out) {
      int a, b;
      in >> a >> b;
      int t = max(a + b, a - b);
      t = max(t, a * b);
      out << t << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AAddSubMul solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

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

#define MOD 10e9+7

using namespace std;

int main(){
int X,A;
cin >> X >> A;
cout << (X<A?0:10)<< endl;
return 0;
}


Measured memory_bytes: 3592
import sys

n = int(input())
w_list = [input() for _ in range(n)]
for i in range(1, len(w_list)):
    if w_list[i - 1][-1] == w_list[i][0]:
        if not w_list[i] in w_list[0:i]:
            pass
        else:
            print("No")
            sys.exit(0)
    else:
        print("No")
        sys.exit(0)

print("Yes")

Measured memory_bytes: 3060
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val lengths =
    List.fill(N)(sc.nextInt() -> sc.nextInt).combinations(2).map {
      case Seq((x1, y1), (x2, y2)) =>
        math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))
    }
  println(lengths.sum * 2 / N)
}


Measured memory_bytes: 55720
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println(a < b ? "a < b" : a > b ? "a > b" : "a == b");
	}
}

Measured memory_bytes: 26244
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1
a.sort()
if n % 2:
    b = a[n//2]
    ans = 0
    for i in range(n):
        ans += abs(a[i] - b)
    print(ans)
else:
    b1 = (a[n//2-1] + a[n//2] + 1) // 2
    b2 = (a[n//2-1] + a[n//2]) // 2
    ans1, ans2 = 0, 0
    for i in range(n):
        ans1 += abs(a[i] - b1)
        ans2 += abs(a[i] - b2)
    print(min(ans1, ans2))


Measured memory_bytes: 25708
#include<stdio.h>

int main(void)
  {
  int N, i;
  long s;
  
  scanf("%d",&N);
  s=0;
  for(i=1; i<=N; i++){
    if      (i%3==0);
    else if (i%5==0);
  	else s=s+i;
  }
  printf("%ld\n",s);
  
  return 0;
}

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

int main() {
  long N, i, countm = 0, ans = 0;
  cin >> N;
  
  vector<long> a(N);
  for(i = 0; i < N; i++){
    cin >> a.at(i);
  }
  
  for(i = 0; i < N; i++){
    if(a.at(i) < 0){
      countm++;
      a.at(i) = -a.at(i);
    }
  }
  
  if(countm % 2 == 0){
    for(i = 0; i < N; i++){
      ans += a.at(i);
    }
  }
  else{
    sort(a.begin(), a.end());
    ans = -a.at(0);
    for(i = 1; i < N; i++){
      ans += a.at(i);
    }
  }
  
  cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 1e5+10;

int N, H[MAX];

int solve() {
    int ans = 0;
    int count = 0;
    REP (i, N-1) {
        if (H[i] >= H[i+1]) {
            count++;
            ans = max(ans, count);
        } else {
            count = 0;
        }
    }
    return ans;
}

int main() {
    cin >> N;
    REP (i, N) cin >> H[i];
    cout << solve() << endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = [list(map(int, input().split())) for i in range(q)]

ans = sum(a)
from collections import Counter
cnt = Counter(a)

for i, j in s:
    #ans = ans - i * cnt[i] + j * cnt[j]
    if j in cnt:
        cnt[j] += cnt[i]
    else:
        cnt[j] = cnt[i]
        
    ans = ans - i * cnt[i] + cnt[i] * j
    if i in cnt:
        cnt.pop(i)
    #ans = ans + j * cnt[j]
    #print(ans, cnt)
    print(ans)

Measured memory_bytes: 40324
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  int a[n];
  long long y=0,z=0;
  long mod=1000000007;
  for(int i=0;i<n;i++){
	scanf("%d",&a[i]);
  }
  long long b=0,sum=0;
  for(int i=1;i<n;i++){
	b=(b+a[i-1])%mod;
    sum=(sum+a[i]*b)%mod;
  }
  printf("%lld",sum);
  
  return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n), b(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (Int i = 0; i < n; i++) {
        cin >> b[i];
    }
    sort(all(a));
    sort(all(b), greater<Int>());
    Int sum = 0;
    for (Int i = 0; i < n; i++) {
        sum += a[i];
    }
    if (sum <= k) {
        dump(0);
        return 0;
    }
    Int ok = 1e18;
    Int ng = 0;
    while (abs(ok - ng) > 1) {
        Int mid = (ok + ng) / 2;
        Int cnt = 0;
        for (Int i = 0; i < n; i++) {
            cnt += max((Int)0, a[i] - mid / b[i]);
        }
        if (cnt <= k) {
            ok = mid;
        }
        else {
            ng = mid;
        }
    }
    dump(ok);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<vector<P>> T(n+1);
    for(int i = 0; i < n-1; i++){
        int a, b, w;
        cin >> a >> b >> w;
        T[a].push_back(make_pair(b, w));
        T[b].push_back(make_pair(a, w));
    }

    vector<int> color(n+1);
    vector<bool> isvisit(n+1, false);
    queue<int> Q;
    Q.push(1);
    isvisit[1] = true;
    color[1] = 0;
    while(!Q.empty()){
        int cur = Q.front();
        Q.pop();
        for(int i = 0; i < T[cur].size(); i++){
            if(!isvisit[T[cur][i].first]){
                isvisit[T[cur][i].first] = true;
                if(T[cur][i].second % 2 == 0){
                    color[T[cur][i].first] = color[cur];
                }else{
                    color[T[cur][i].first] = (color[cur]+1)%2;
                }
                Q.push(T[cur][i].first);
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << color[i] << endl;
    }
    return 0;
}

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

int main()
{
    ll N;
    cin >> N;
    vector<string> S(N);
    ll Mcount = 0;
    ll Acount = 0;
    ll Rcount = 0;
    ll Ccount = 0;
    ll Hcount = 0;
    for(ll i = 0; i < N; i++)
    {
        string tmp;
        cin >> tmp;
        S[i] = tmp;
        if(tmp[0] == 'M')Mcount++;
        if(tmp[0] == 'A')Acount++;
        if(tmp[0] == 'R')Rcount++;
        if(tmp[0] == 'C')Ccount++;
        if(tmp[0] == 'H')Hcount++;
    }

    ll count = 0;
    //ll B[] = {0,1,2,3,4};
    ll C[] = {Mcount,Acount,Rcount,Ccount,Hcount};

    for(ll i = 0; i < 5; i++)
    {
        for(ll j = i+1; j < 5; j++)
        {
            for(ll k = j+1; k < 5; k++)
            {
                count += C[i] * C[j] * C[k];
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 6144
#include "bits/stdc++.h"
#include <set>

using namespace std;
#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int c[3][3];
	int sum = 0;
	rep(i, 3) {
		rep(j, 3) {
			int tmp;
			cin >> tmp;
			c[i][j] = tmp;
			sum += tmp;
		}
	}
	if (sum % 3 != 0) {
		print("No");
		return 0;
	}
	sum /= 3;
	if (((c[0][0] + c[1][1] + c[2][2]) != sum )||( (c[0][1]+c[1][2]+c[2][0])!=sum)|| ((c[0][2] + c[1][0] + c[2][1]) != sum)) {
		print("No");
		return 0;
	}
	print("Yes");
}

Measured memory_bytes: 3604
N, D = map(int, input().split())
XX = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i1, zahyo_1 in enumerate(XX):
    for i2, zahyo_2 in enumerate(XX):
        if i1 == i2:
            continue
        total = 0
        for index in range(D):
            total += (zahyo_1[index] - zahyo_2[index])**2
        val = total ** (1/2)
        if isinstance(val, complex):
            val = val.real
        if val.is_integer():
            ans += 1

print(ans//2)


Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K;

  std::cin >> N >> K;

  std::cout << (K * 2 - 1 <= N ? "YES" : "NO") << std::endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-


def countingSort(lst, n):
    cnt_lst = [0] * (max(lst)+1)

    for i in range(0, n):
        cnt_lst[lst[i]] += 1

    i = 0
    result = []
    for j, cnt in enumerate(cnt_lst):
        for _ in range(0, cnt):
            result.append(j)
    return result


if __name__ == "__main__":
    n = int(input())
    lst = [int(val) for val in input().split()]
    result = countingSort(lst, n)
    print(" ".join([str(val) for val in result]))

Measured memory_bytes: 242152
#include<iostream>
#include<cstdio>
#define max(a,b) (a>b?a:b)
#define lowbit(a) (a&-a)
using namespace std;
int n,num[1005];

//main
long long anss[2];
int ans[1005],tail[2],last[1005];
int cnt=0;
int maxs=-0x3f3f3f3f,maxi;
bool flag=false;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&num[i]);
    for(int i=1;i<=n;i++){
        if(num[i]>0) {
            anss[i&1]+=num[i];
            flag=true;
            last[i]=tail[i&1];
            tail[i&1]=i;
        }
        maxi=(maxs>num[i]?maxi:i),maxs=max(maxs,num[i]);  
    }
    if(!flag){
        printf("%d\n",maxs);
        for(int i=n;i>=maxi+1;i--)
            ans[++cnt]=i;
		for(int i=1;i<maxi;i++)
            ans[++cnt]=1;
        printf("%d\n",cnt);
        for(int i=1;i<=cnt;i++)
            printf("%d\n",ans[i]); 
        return 0;
    }
    int t=anss[1]>anss[0];
    printf("%lld\n",anss[t]);
    int now=tail[t],mid;
    for(int i=n;i>tail[t];i--)
        ans[++cnt]=i;
    while(last[now]!=0){
        //printf("\t%d\n",last[now]);
        mid=(now+last[now]>>1);
        for(int i=mid;i>last[now];i--){
            ans[++cnt]=i;
        }
        now=last[now];
    }
    for(int i=1;i<now;i++)
		ans[++cnt]=1;
    printf("%d\n",cnt);
    for(int i=1;i<=cnt;i++)
        printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define endl '\n'
#define lli long long int
#define rep(i, s, e) for (int i = s; i < e; i++)

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> R, G, B;
    rep(i, 0, N)
    {
        switch (S[i])
        {
        case 'R':
            R.push_back(i);
            break;
        case 'G':
            G.push_back(i);
            break;
        case 'B':
            B.push_back(i);
            break;
        default:
            break;
        }
    }
    const int res = R.size() * G.size() * B.size();
    unsigned int even = 0;
    for (int r : R)
    {
        const int rr = 2 * r;
        for (int g : G)
        {
            const int gg = 2 * g;
            int rg = r + g;
            for (int b : B)
            {
                const int bb = 2 * b;
                const int br = b + r;
                const int bg = b + g;
                // r<g<b
                if (gg == br || bb == rg || rr == bg)
                    even++;
            }
        }
    }
    cout << res - even << endl;
}

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

int main(){
    int N;
    cin >> N;
    long long A[N], B[N];
    vector<pair<long long, long long> > a;

    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
        a.push_back(make_pair(B[i],A[i]));
    }
    sort(a.begin(), a.end());

    long long count = 0;
    bool res = true;

    for(int i = 0; i < N; i++){
        count += a[i].second; 
        if(count > a[i].first){
            res = false;
        }
    }

    if(res){
        cout << "Yes" << endl;
    }

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

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    loop(i,0,n)cin>>a[i];
    ll ans = 0;
    loop(i,0,n){
        if(i%2 == 0 && a[i]%2 == 1){
            ans++;
        }
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    #ifndef ONLINE_JUDGE
        end_routine();
    #endif
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[110];
int B[110];
int C[110];
int D[110];
int n,m,q;

int solve(int a,ll x)
{
    if(a>n){

        vector<int> dd;

        for(int i=0;i<a;i++){
            dd.push_back(x%10);
            x/=10;
        }

        reverse(dd.begin(),dd.end());


        int x,y,z;
        int res = 0;

        for(int i=0;i<q;i++){
            x = A[i];
            y = B[i];
            z = C[i];

            if((dd[y]-dd[x])==z){
                res+=D[i];
            }
        }

        return res;
    }

    ll cur = x%10;

    int res = 0;

    for(int i=cur;i<m;i++){
        res = max(res,solve(a+1,x*10+i));
    }

    return res;
}


int main()
{
    int k,a,b,x,y;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>m>>q;

    for(int i=0;i<q;i++){
        cin>>A[i]>>B[i]>>C[i]>>D[i];
        A[i]--; B[i]--;
    }

    int res = solve(1,0);

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

int a[2][100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int t;
		scanf("%d",&t);
		a[i%2][t]++;
	}
	int M[2][2]={},c[2][2];
	for(int i=1;i<=100000;i++){
		for(int j=0;j<2;j++){
			if(M[j][0]<=a[j][i]){
				M[j][1]=M[j][0];
				c[j][1]=c[j][0];
				M[j][0]=a[j][i];
				c[j][0]=i;
			}else if(M[j][1]<=a[j][i]){
				M[j][1]=a[j][i];
				c[j][1]=i;
			}
		}
	}
	int ans;
	if(c[0][0]==c[1][0])ans=M[0][0]+max(M[0][1],M[1][1]);
	else ans=M[0][0]+M[1][0];
	printf("%d",n-ans);
}

Measured memory_bytes: 896
# -*- coding: utf-8 -*-
"""
Created on Fri Jul  6 22:20:31 2018
ABC097A
@author: maezawa
"""

s = input()
k = int(input())

perm = []

n = len(s)
for i in range(1, 6):
    for j in range(n-i+1):
        perm.append(s[j:j+i])
    
ans_array = sorted(set(perm))
#print(ans_array)
print(ans_array[k-1])
    

Measured memory_bytes: 5068
let z()=List.map int_of_string(Str.split(Str.regexp_string" ")(read_line()))open Array;;match z()with|[r;c]->(let a=make_matrix(r+1)(c+1)0in for i=0to r-1do let x=of_list(z())in for j=0to c-1do a.(i).(j)<-x.(j);a.(i).(c)<-a.(i).(c)+x.(j)done done;for i=0to c-1do for j=0to r-1do a.(r).(i)<-a.(r).(i)+a.(j).(i)done;a.(r).(c)<-a.(r).(c)+a.(r).(i)done;for i=0to r do for j=0to c do Printf.printf(if j=0then"%d"else" %d")a.(i).(j)done;print_newline()done)|_->()

Measured memory_bytes: 4444
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using std::min;
using std::max;
using std::swap;
using std::vector;
typedef double db;
typedef long long ll;
#define pb(A) push_back(A)
#define pii std::pair<int,int>
#define all(A) A.begin(),A.end()
#define mp(A,B) std::make_pair(A,B)
const int N=8e5+5;
const int mod=924844033;

int fac[N],ifac[N];
int n,m,cnt,head[N],buc[N];
int a[N],b[N],sze[N],lim,rev[N];

struct Edge{
    int to,nxt;
}edge[N<<1];

void add(int x,int y){
    edge[++cnt].to=y;
    edge[cnt].nxt=head[x];
    head[x]=cnt;
}

int ksm(int a,int b=mod-2,int ans=1){
    while(b){
        if(b&1) ans=1ll*ans*a%mod;
        a=1ll*a*a%mod;b>>=1;
    } return ans;
}

void ntt(int *f,int opt){
    for(int i=1;i<lim;i++) if(i<rev[i]) swap(f[i],f[rev[i]]);
    for(int mid=1;mid<lim;mid<<=1){
        int tmp=ksm(5,(mod-1)/(mid<<1));
        if(opt<0) tmp=ksm(tmp);
        for(int R=mid<<1,j=0;j<lim;j+=R){
            for(int w=1,k=0;k<mid;k++,w=1ll*w*tmp%mod){
                int x=f[j+k],y=1ll*f[j+k+mid]*w%mod;
                f[j+k]=(x+y)%mod;f[j+k+mid]=(mod+x-y)%mod;
            }
        }
    } if(opt<0) 
        for(int in=ksm(lim),i=0;i<lim;i++) f[i]=1ll*f[i]*in%mod;
}

void dfs(int now){
    sze[now]=1; buc[n]++;
    for(int i=head[now];i;i=edge[i].nxt){
        int to=edge[i].to;
        if(sze[to]) continue;
        dfs(to); sze[now]+=sze[to]; buc[sze[to]]--;
    } buc[n-sze[now]]--;
}

int getint(){
    int X=0,w=0;char ch=getchar();
    while(!isdigit(ch))w|=ch=='-',ch=getchar();
    while( isdigit(ch))X=X*10+ch-48,ch=getchar();
    if(w) return -X;return X;
}

void init(int n){
    fac[0]=ifac[0]=1;
    for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
    ifac[n]=ksm(fac[n]);
    for(int i=n-1;i;i--) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}

signed main(){
    n=getint();init(N-5);
    for(int i=1;i<n;i++){
        int x=getint(),y=getint();
        add(x,y),add(y,x);
    } dfs(1);
    lim=1;while(lim<=n+n) lim<<=1;
    for(int i=1;i<lim;i++) rev[i]=(rev[i>>1]>>1)|(i&1?lim>>1:0);
    for(int i=0;i<=n;i++)
        a[n-i]=1ll*(buc[i]+mod)*fac[i]%mod,
        b[i]=ifac[i];
    ntt(a,1),ntt(b,1);
    for(int i=0;i<lim;i++) a[i]=1ll*a[i]*b[i]%mod;
    ntt(a,-1);
    for(int i=1;i<=n;i++) printf("%lld\n",1ll*a[n-i]%mod*ifac[i]%mod);
    return 0;
}


Measured memory_bytes: 36736
a = input()
l = len(a)
blk = a
i = 0
rem = 0
num0 = 0
num1 = 0
while i < l:
    if blk[i] == "0":
        num0 += 1
    else:
        num1 += 1
    i += 1
rem = min(num0, num1)
print(rem * 2)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

string dp[100][100];
string m[100];

string mymax(string a,string b){
	if(a.size()>b.size())return a;
	if(a.size()<b.size())return b;
	int i;
	for(i=0;i<a.size();i++){
		if(a[i]>b[i])return a;
		if(a[i]<b[i])return b;
	}
	return a;
}

int main() {
	int w,h;
	while(cin>>w>>h,w){
		int i,j;
		string res="0";
		for(i=0;i<h;i++){
			cin>>m[i];
			for(j=0;j<w;j++){
				if('A'<=m[i][j]&&m[i][j]<='Z')dp[i][j]="";
				else if(i==0&&j==0)dp[i][j]=m[i][j];
				else if(i==0)dp[i][j]=dp[i][j-1]+m[i][j];
				else if(j==0)dp[i][j]=dp[i-1][j]+m[i][j];
				else dp[i][j]=mymax(dp[i-1][j],dp[i][j-1])+m[i][j];
				res=mymax(res,dp[i][j]);
				if(dp[i][j]=="0")dp[i][j]="";
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

ld f(ld a, ld b, ld theta) {
    ld temp;
    if(numeric_limits<ld>::epsilon() + theta > M_PI_2) return 0.0L;
    temp = b * tan(M_PI_2 - theta);
    if(temp <= a) return a * temp * b / 2.0L;
    else return a * a * b - a * a * tan(theta) * a / 2.0L;
}

int main(void) {
    ll a, b, x;
    ld ok = M_PI_2;
    ld ng = 0.0L;
    cin >> a >> b >> x;
    rep(_, 1e6) {
        ld mid = (ok + ng) / 2.0L;
        if(f(a, b, mid) < x) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(6) << 180 * ok / M_PI << endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int i,s,k,max,kai;
	while(0==0)
	{
		scanf("%d",&k);
		if(k==0)break;
		kai=k;
		scanf("%d",&s);
		max=s;
		if(s==0) kai--;
		for(i=1;i<k;i++){
			scanf(" %d",&s);
			if(max<s) max=s;
			if(s==0) kai--;
		}
		if(max<2) printf("NA\n");
		else printf("%d\n",kai+1);
	}
	return 0;
}

Measured memory_bytes: 1040
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;

struct Node{
	int key;
	Node *right,*left,*parent;
};

Node *root,*NIL;

Node * treeMinimun(Node *x){
	while(x->left != NIL) x=x->left;
	return x;
} 

Node * treeSuccessor(Node *x){
	if(x->right != NIL) return treeMinimun(x->right);
	Node *y = x->parent;
	while(y!=NIL && x == y->right){
		x=y;
		y=y->parent;
	} 
	return y;
} 

void treeDelete(Node *z){
	Node *y;
	Node *x;
	
	if(z->left == NIL || z->right==NIL) y=z;
	else y=treeSuccessor(z);
	
	if(y->left!=NIL){
		x=y->left;
	}else{
		x=y->right;
	}
	
	if(x!=NIL){
		x->parent = y->parent;
	}
	
	if(y->parent==NIL){
		root=x;
	}else{
		if(y==y->parent->left){
			y->parent->left=x;
		}else{
			y->parent->right=x;
		}
	}
	
	if(y!=z){
		z->key=y->key;
	} 
	free(y);
}

void insert(int k){
	Node *y=NIL;
	Node *x=root;
	Node *z;
	
	z=(Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while(x != NIL){
		y=x;
		if(z->key < x->key){
			x=x->left;
		} else {
			x=x->right;
		}
	}
	
	z->parent = y;
	if(y==NIL){
		root = z;
	}  else {
		if(z->key<y->key){
			y->left=z;
		} else{
			y->right=z;
		}
	}
}

Node * find(Node *u,int k){
	while(u!=NIL && k!= u->key){
		if(k<u->key) u=u->left;
		else u=u->right;
	}
	return u;
} 

void inorder(Node *u){
	if(u==NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(Node *u){
	if(u==NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}



int main() {
	
	int n,i,x;
	string com;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		cin>>com;
		if(com[0]=='f'){
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t!=NIL) printf("yes\n");
			else printf("no\n");
		}else if(com=="insert"){
			scanf("%d",&x);
			insert(x);
		}else if(com=="print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}else if(com=="delete"){
			scanf("%d",&x);
			treeDelete(find(root,x));
		}
	}
	
	return 0;
}

Measured memory_bytes: 21972