akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
} 
  
// Driver program to test above function 
int main() 
{ 
    // generate prime factors of number 
    // upto 10^6 
    generatePrimeFactors(); 
  	ll n;
    cin>>n;
    // int a[n+1];
    // for(int i=0;i<=n;i++)
    // {
    // 	a[i] = i;
    // }
  
    // int q = sizeof(a) / sizeof(a[0]); 
  	ll sum = 0;
    for (int i = 1; i < n; i++) 
    {
    	int b = calculateNoOFactors(n-i);
    	sum += b;
    } 
  	cout<<sum<<endl;
    return 0; 
} 

Measured memory_bytes: 7532
program main
    implicit none
    integer(8) n,k
    integer(8) i,d,min
    read(*,*) n,k

    d = mod(n,k)
    min = d
    
    do i = 1,100000
        if(min == 0) exit
        d = abs(d-k)
        if(d < min) then
            min = d
        end if
    end do
    write(*,*) min

end program

Measured memory_bytes: 640
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()

ans=0
for k in range(105,n+1,2):
    c=0
    for i in range(1,int(k**0.5)+1):
        if k%i==0:
            c+=2
    if i**2==k:
        c-=1
    if c==8:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

ll n,m;
ll ans = 0;
vl num(100005,1);

struct UnionFind{
    vl p;
    vl rank;

    UnionFind(ll n){
        rank.resize(n,0);
        p.resize(n,0);
        rep(i,n){
            p[i] = i;
            rank[i] = 0;
        }
    }

    ll find(ll x){
        if(x != p[x]) p[x] = find(p[x]);
        return p[x];
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        ans += num[x] * num[y];
        if(rank[x] > rank[y]){
            p[y] = x;
            num[x] += num[y];
        }else{
            p[x] = y;
            num[y] += num[x];
            if(rank[x] == rank[y]) rank[y]++;
        }
    }
};

int main() {
    cin >> n >> m;
    vpl edges(m);
    vl a;
    rep(i,m){
        cin >> edges[i].first >> edges[i].second;
        edges[i].first--; edges[i].second--;
    }
    UnionFind uf(n);
    for(ll i=m-1; i>0; i--){
        uf.unite(edges[i].first, edges[i].second);
        a.push_back(n*(n-1)/2-ans);
    }
    while(!a.empty()){
        cout << a.back() << endl;
        a.pop_back();
    }
    cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 6132
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static class Player implements Comparable<Player> {
		int number;
		int score;

		public int compareTo(Player o) {
			if (this.score == o.score) {
				return this.number - o.number;
			} else {
				return o.score - this.score;
			}
		}
	}

	public static void main(String srgs[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		Player player[];

		while (true) {
			n = sc.nextInt();
			sc.nextLine();
			if (n == 0) {
				break;
			}
			player = new Player[n];
			for (int i = 0; i < n; i++) {
				String s[] = sc.nextLine().split(" ");
				player[i] = new Player();
				player[i].number = Integer.valueOf(s[0]);
				int index = 1;
				for (int j = 1; j <= 10; j++) {
					if (j != 10) {
						if (Integer.valueOf(s[index]) == 10) {
							player[i].score += Integer.valueOf(s[index]) + Integer.valueOf(s[index + 1]) + Integer.valueOf(s[index + 2]);
							index += 1;
						} else if (Integer.valueOf(s[index]) + Integer.valueOf(s[index + 1]) == 10) {
							player[i].score += Integer.valueOf(s[index]) + Integer.valueOf(s[index + 1]) + Integer.valueOf(s[index + 2]);
							index += 2;
						} else {
							player[i].score += Integer.valueOf(s[index]) + Integer.valueOf(s[index + 1]);
							index += 2;
						}
					} else {
						player[i].score += Integer.valueOf(s[index]) + Integer.valueOf(s[index + 1]);
						if (index + 2 < s.length) {
							player[i].score += Integer.valueOf(s[index + 2]);
						}
					}
				}
			}
			Arrays.sort(player);
			for (int i = 0; i < n; i++) {
				System.out.println(player[i].number + " " + player[i].score);
			}
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        cin>>n>>x>>y;
        if(n*x<=y)
            cout<<n*x<<endl;
        else
            cout<<y<<endl;

    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3648
using System;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 10000; i++)
            {
                var input = int.Parse(Console.ReadLine());
                if (input == 0) return;
                Console.WriteLine($"Case {i}: {input}");
            }
        }

    }
}



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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int gcd(int a,int b){
    int r;
    if(a<b) swap(a,b);
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int atcoder(){
    ll a,b,k;
    cin>>a>>b>>k>>k;
    if(k%2==1) cout<<b-a<<ENT;
    else cout<<a-b<<ENT;
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
// +build ignore
package main

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

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

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

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

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

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

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

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

func gcd(x, y int) int {
	if x%y != 0 {
		return gcd(y, x%y)
	}
	return y
}

func pow(n int) int {
	return n * n * n * n * n
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	X := sc.nextInt()

	for i := -119; true; i++ {
		for j := -119; pow(j) < X-pow(i); j++ {
			if pow(i)-pow(j) == X {
				fmt.Println(i, j)
				return 0
			}
		}
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 1756
#include <iostream>
using namespace std;
int main(){
    int a,b;
    

    cin >> a >> b;
   

    if(a > b) {
        for (int i = 0; i < a; i++) {
            cout << b;
        }
      
    }
    else {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  for(ll p = 2; p*p <= n; p++){
    if(n%p != 0) continue;
    int num = 0;
    while(n%p == 0){
      num++;
      n /= p;
    }
    res.push_back(make_pair(p,num));
  }
  if(n != 1) res.push_back(make_pair(n,1));
  return res;
}

int main(){
  ll a,b;
  cin >>a>>b;
  ll g;
  g = gcd(a,b);
  auto pf = prime_factorize(g);
  cout << pf.size() + 1 << endl;
}

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

int main()
{
  int n = 0, m = 0;
  std::cin >> n >> m;
  std::vector<std::pair<bool, int>> b;
  b.push_back(std::make_pair(true, 1));
  for(int i = 1; i < n; ++i)
  {
    b.push_back(std::make_pair(false, 1));
  }
  
  for(int i = 0; i < m; ++i)
  {
    int x, y;
    std::cin >> x >> y;
    --x; --y;
    if(b[x].second > 0)
    {
      --(b[x].second);
      ++(b[y].second);
      b[y].first = b[x].first || b[y].first;
      if(b[x].second == 0)
      {
        b[x].first = false;
      }
    }
  }
  
  int suspect = 0;
  for(auto &item : b)
  {
    if(item.first)
    {
      ++suspect;
    }
  }
  
  std::cout << suspect;
      
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int A, B; cin >> A >>B;
    int res = 0;
    while(B > 1) {
        B -= A - 1;
        res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int r, c;
int g[105][105];
int n;
int l[10005];

pii order[10005];

int main() {
  scanf("%d%d", &r, &c);
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  int orderSize = 0;
  for(int i = 0; i < r; i++) {
    if(i%2==0) {
      for(int j = 0; j < c; j++) {
        order[orderSize++] = pii(i, j);
      }
    }
    else {
      for(int j = c-1; j >= 0; j--) {
        order[orderSize++] = pii(i, j);
      }
    }
  }
  int nextOrder = 0;
  for(int i = 0; i < n; i++) {
    while(l[i]--) {
      g[order[nextOrder].first][order[nextOrder].second] = i+1;
      nextOrder++;
    }
  }
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      printf("%d", g[i][j]);
      if(j == c-1) printf("\n");
      else printf(" ");
    }
  }
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    map<string,ll> S;
    REP(i,0,N) {
        string s;
        cin >> s;
        ++S[s];
    }
    ll M;
    cin >> M;
    map<string,ll> T;
    REP(i,0,M) {
        string t;
        cin >> t;
        ++T[t];
    }

    ll sum = 0;
    FORR(s,S) sum = MAX(sum,s.second-T[s.first]);
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))
R = []

tmp = 0
pm = -1
for i in range(N):
    pm *= -1
    tmp += A[i] * pm
R.append(tmp)

for i in range(1, N):
    tmp = 2 * A[i-1] - R[i-1]
    R.append(tmp)

print(*R)

Measured memory_bytes: 95720
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  int a[n];
  int xy[n][14][2];				//n人目 a[n]個の証言　[0]=x(誰が) [1]=y(正か偽か)
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    for(int j=0;j<a[i];j++){
      scanf("%d%d",&xy[i][j][0],&xy[i][j][1]);
    }
  }
  int pa[n],c=0,max=0,flag=0,skip=0;			//そのパターンにおける正直者を格納する
  int i,j,k,l,m;
  for(i=0;i<(1<<n);i++){//22
    c=0;skip=0;
    for(int s=0;s<n;s++){
      pa[s]=0;
    }
   for(j=0;j<n;j++){//33					0(1人目),j(j+1人目)
     if(i&(1<<j)){			
  		     pa[c]=j+1;
       c++;
     }
   }//33
    for(k=0;k<c;k++){//44				//候補者を一人一人見ていく
      if(skip)break;
      for(l=0;l<a[pa[k]-1];l++){//55			//その人の証言数はa[pa[k]-1]　これを精査する
        if(skip)break;
       for(m=0;m<c;m++){//66
         flag=0;
         if(skip)break;
         if(xy[pa[k]-1][l][0]==pa[m])			//被証言者が正直者か否か
         {flag=1;
         break;}
       }//66
      if(flag){//正直者への証言の場合
        if(xy[pa[k]-1][l][1]==0){
          skip=1;
          break;
        }
      }
       else{//嘘つきへの証言の場合
         if(xy[pa[k]-1][l][1]==1){
           skip=1;
           break;
         }
       }
         
       
    }//55
  }//44
    if(!skip){
	if(c>max)max=c;
    }
  
}//22
printf("%d",max);
return 0;
}

    
    
    


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

ll solve() {
    ll N;
    cin >> N;
    vector<vector<ll>> c(10, vector<ll>(10));
    for ( int i = 1; i <= N; i++ ) {
        int k = i;
        while ( k >= 10 ) k/=10;
        c[k][i%10]++;
    }
    ll ans = 0;
    for ( int i = 1; i <= N; i++ ) {
        int k = i;
        while ( k >= 10 ) k/=10;
        ans += c[i%10][k];
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  IN(N,K);
  vll tmp(N,0);
  REP(i,K){
    ll d;
    IN(d);
    REP(j,d){
      ll A;
      IN(A);
      A--;
      tmp[A]++;
    }
  }

  ll ans = 0;
  REP(i,N){
    if(tmp[i]==0) ans++;
  }

  OUT(ans);


  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    V<double> v(N);
    PQR<double> pq;
    for(int i = 0; i < N; ++i) {
        double v; cin >> v;
        pq.push(v);
    }
    while(pq.size()>1){
        double a = pq.top();
        pq.pop();
        double b = pq.top();
        pq.pop();
        a = (a+b)/2.;
        pq.push(a);
    }
    printf("%.10f",pq.top());
  
    return 0;
}


Measured memory_bytes: 256
while True:
    a = list(map(lambda x : int(x), input().split(" ")))
    if a[0] == 0 and a[1] == 0:
        break

    for i,i_ in enumerate(range(a[0])):
        for j,j_ in enumerate(range(a[1])):
            if i == 0 or i == a[0] - 1 or j == 0 or j == a[1] - 1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()

Measured memory_bytes: 6808
import java.lang.Math;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);
        double a = sc.nextDouble();

        System.out.printf("%f %f",(a*a*Math.PI),((a+a)*Math.PI));
        sc.close();
    }
}



Measured memory_bytes: 28104
#include <iostream>

using namespace std;

int main(){
  int m,f,b;cin>>m>>f>>b;
  int total=m+f;
  if(total-b>=0){
    if(m-b>=0){
      cout<<0<<endl;
    }else{
      cout<<b-m<<endl;
    }
  }else{
    cout<<"NA"<<endl;
  }
}


Measured memory_bytes: 3100
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
a = LIST()
 
anss = [False]*8
cnt = 0
 
for i in range(N):
	if a[i] >= 3200:
		cnt += 1
	else:
		anss[a[i]//400] = True
 
MIN = max(sum(anss), 1)
MAX = sum(anss)+cnt
print(MIN, MAX)

Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int a,p; cin >> a >> p;
  cout << (3*a + p) / 2 << "\n";
  return 0;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a!=c)cout<<"Yes"<<endl;//cかわいそう
  else if(b==c&&a!=b)cout<<"Yes"<<endl;//aかわいそう
  else if(c==a&&b!=c)cout<<"Yes"<<endl;//bかわいそう
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3596
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort(key=lambda x:x[1])

#経過時間
cnt_times = 0
for i in range(N):
    if cnt_times + AB[i][0] <= AB[i][1]:
        cnt_times += AB[i][0]
    else:
        print("No")
        exit()
        
print("Yes")

Measured memory_bytes: 53728
class FenwickTree:
    def __init__(self, size):
        self.size = size
        self.array = [0]*size
 
    def add(self, index, value):
        while index < self.size:
            self.array[index] += value
            index += index&(-index)
 
    def sum(self, index):
        answer = 0
        while index > 0:
            answer += self.array[index]
            index -= index&(-index)
        return answer
 
    def rangesum(self, start, end):
        return self.sum(end)-self.sum(start-1)


def solve():
    N, Q = map(int, input().split())
    *c, = map(int, input().split())
    tree2 = FenwickTree(N+1)
    m = [list(map(int, input().split())) for _ in range(Q)]
    idxs = sorted(list(range(Q)), key=lambda i: m[i][1])

    right = 0
    pos = [-1] * (N+1)
    ans = [-1] * (Q)

    for idx in idxs:
        l, r = m[idx]
        for i in range(right, r):
            x = pos[c[i]]
            if x != -1:
                tree2.add(x, -1)
            pos[c[i]] = i+1
            tree2.add(i+1, 1)
        ans[idx] = tree2.rangesum(l, r)
        right = r
    print(*ans, sep="\n")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 239936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int a,b,c,d;
    char ca,cb,cc,cd;
    cin>>ca;
    cin>>cb;
    cin>>cc;
    cin>>cd;
    a=ca-'0';
    b=cb-'0';
    c=cc-'0';
    d=cd-'0';
    if(a+b+c+d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<"=7";
    }else if(a+b+c-d==7){
        cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<"=7";
    }else if(a+b-c-d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<"=7";
    }else if(a+b-c+d==7){
        cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<"=7";
    }else if(a-b+c+d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<"=7";
    }else if(a-b+c-d==7){
        cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<"=7";
    }else if(a-b-c-d==7){
        cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<"=7";
    }else if(a-b-c+d==7){
        cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<"=7";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define TRUE 1
#define FALSE 0

typedef struct {
	char val[100];
	int length;
}string;

int get_length(const char *str){
	int length = 0;
	while (*str++){
		length++;
	}
	return length;
}

string get_s(){
	string input;
	scanf("%s", &input.val);
	input.length = get_length(input.val);

	return input;
}
int solve(string s, string p){
	int i, j;

	for (i = 0; i < s.length + p.length; i++){
		for (j = 0; j < p.length; j++){
			if (s.val[(i + j)%s.length] != p.val[j]){
				break;
			}
			if (j == p.length - 1){
				return TRUE;
			}
		}
	}
	return FALSE;
}

int main(){
	string s, p;

	s = get_s();
	p = get_s();

	(solve(s, p) == 1) ? puts("Yes") : puts("No");
}


Measured memory_bytes: 2140
#include <iostream>

using namespace std;
int main(){
	int n,m,sum,count;
	for(int i=1;cin.eof()==false;i++){
		n = -1;
		cin >> n >> m;
		if (n == -1) break;
		sum = n + m;
		//cout << sum << endl;
		count = 0;
		while(sum!=0){
			sum /= 10;
			count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n,count=0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n-1; i++) {
		if ((a[i - 1] < a[i] && a[i] < a[i + 1])||(a[i - 1] > a[i] && a[i] > a[i + 1])) { count++; }
	}
	cout << count;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication26
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string order = Console.ReadLine();
            int b = 0;
            int a0 = int.Parse(input[0]);
            int a1 = int.Parse(input[1]);
            int a2 = int.Parse(input[2]);
            int a3 = int.Parse(input[3]);
            int a4 = int.Parse(input[4]);
            int a5 = int.Parse(input[5]);
            //int[] saikoro = { a0, a1, a2, a3, a4, a5 };
            for (int i =  0; i < order.Length; i++ )
            {
                string ord = order[i].ToString();
                if (ord == "N")
                {
                    b = a0;
                    a0 = a1;
                    a1 = a5;
                    a5 = a4;
                    a4 = b;
                }
                else if (ord == "S")
                {
                    b = a0;
                    a0 = a4;
                    a4 = a5;
                    a5 = a1;
                    a1 = b;
                }
                else if (ord == "W")
                {
                    b = a0;
                    a0 = a2;
                    a2 = a5;
                    a5 = a3;
                    a3 = b;
                }
                else if (ord == "E")
                {
                    b = a0;
                    a0 = a3;
                    a3 = a5;
                    a5 = a2;
                    a2 = b;
                }
            }
            Console.WriteLine(a0);
        }
    }
}

Measured memory_bytes: 9216
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]

from operator import itemgetter
ab.sort(key=itemgetter(1))

cnt = 0
flag = True
for i in range(N):
    cnt += ab[i][0]
    if cnt > ab[i][1]:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 53728
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;
    
    namespace ConsoleApp2
    {
    class Program
    {
        static string S;
        static long ans = 0;
        static long N;
        static long M;
        static Node[] Nodes;
        static void Main(string[] args)
        {

            var map = new int[3][];
            for (int i = 0; i < 3; i++)
            {
                map[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            }

            var a1 = 0;
            var b1 = map[0][0] - a1;
            var b2 = map[0][1] - a1;
            var b3 = map[0][2] - a1;
            var a2 = map[1][0] - b1;
            var a3 = map[2][0] - b1;

            if(a2+b2 == map[1][1] && a2 + b3 == map[1][2] && a3+ b2 == map[2][1] && a3 + b3 == map[2][2])
            {
                Console.WriteLine("Yes");   
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }


    }

    class Node
    {
        long num = -1;
        public List<long> adj;
        public Node(long inp)
        {
            this.num = inp;
            adj = new List<long>();
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)

int main(){
  int a,b,d=INT_MAX;cin>>a>>b;
  b--;
  vector<int>c(a);
  rep(i,a)cin>>c[i];
  sort(c.begin(),c.end());
  rep(i,a-b){
    d=min(c[i+b]-c[i],d);
  }
  cout<<d;
  }

Measured memory_bytes: 640
//2019.8.22 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
const int N=1e4+10;
namespace MAIN{
    int n,k;
    char str[N];
    char mn='z',mx='a',ans[N],tmp[N];
    inline void solve(RG char *s,res k){
        res now=n,len=0;
        while(now&&s[now]==mn)now--,len++;
        while(k&&len<n)len<<=1,--k;
        if(len>=n){
            for(res i=1;i<=n;i++)ans[i]=mn;
            printf("%s\n",ans+1);exit(0);
        }
        for(res i=1;i<=len;i++)tmp[i]=mn;
        for(res i=len+1;i<=n;i++)tmp[i]=s[now--];
        for(res i=1;i<=n;i++){
            if(ans[i]!=tmp[i]){
                if(ans[i]>tmp[i]){
                    for(res j=1;j<=n;j++)ans[j]=tmp[j];
                }
                break;
            }
        }
    }
    inline void MAIN(){
        n=read(),k=read(),scanf("%s",str+1);
        for(res i=1;i<=n;i++)mn=min(mn,str[i]),mx=max(mx,str[i]),ans[i]='z',str[(n<<1)-i+1]=str[i];
        if(mn==mx){printf("%s\n",str+1);return;}
        if(str[n]==mn)solve(str,k);
        for(res i=n;i<=n<<1;i++)if(str[i]==mn)solve(str+i-n,k-1);
        printf("%s\n",ans+1);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}


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

int main(){
	int x, y, x_list[3000], y_list[3000], small, big;

	for (int i = 0; i < 3000; i++){
		cin >> x >> y;
		if (x ==0 && y == 0){
			break;
		}
		x_list[i] = x;
		y_list[i] = y;
	}

	for (int i = 0; i < 3000; i++){
		if (x_list[i] == 0 && y_list[i] == 0){
			break;
		}
		small = min(x_list[i], y_list[i]);
		big = max(x_list[i], y_list[i]);
		cout << small << " " << big << endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll solve(ll n,ll x,ll y,ll m) {
  ll ans=1;
  ans-=m*x;
  ans+=m*y;
  n-=m*2;
  if(x-1<=n) return ans+n;
  return 0;
}

void Main() {
  ll n,x,y;
  cin >> n >> x >> y;
  ll l=0,r=n+1;
  rep(t,500) {
    ll m1=(l*2+r)/3,m2=(l+r*2)/3;
    ll d1=solve(n,x,y,m1),d2=solve(n,x,y,m2);
    if(d1<d2) l=m1;
    else r=m2;
  }
  ll ans=1+n;
  REP(i,-5,5) {
    ll m=l+i;
    if(m<0) continue;
    ans=max(ans,solve(n,x,y,m));
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	string s, t, u;
	cin >> s >> t >> u;
	cout << char(s[0] - 'a' + 'A') << char(t[0] - 'a' + 'A') << char(u[0] - 'a' + 'A') << endl;
	return 0;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}
function mput(n){return (n%mod+mod)%mod;}

var n,g,cp,pp,ans;

//var myOut = main();
//if(myOut !== undefined)console.log(myOut);

function main(){
  n = next();
  g = xArray("[]",n);
  cp = Array(n);
  pp = Array(n);
  ans = Array(n);
  fset(2*n);
  for(var i = 1; i < n; i++){
    var a = next()-1, b = next()-1;
    g[a].push(b);
    g[b].push(a);
  }
  dfs(0,-1);
  dfsr(0,-1);
  return ans.join("\n");
}

function dfs(v,p){
  var cnow = [0,1];
  for(var i = 0; i < g[v].length; i++){
    if(g[v][i] === p)continue;
    var t = dfs(g[v][i],v);
    cnow[1] = mul(cnow[1],t[1],ncr(cnow[0]+t[0],t[0]));
    cnow[0] += t[0];
  }
  cnow[0]++;
  return cp[v] = cnow;
}
function dfsr(v,p){
  if(p === -1){
    ans[v] = cp[v][1];
    for(var i = 0; i < g[v].length; i++){
      if(g[v][i] === p)continue;
      dfsr(g[v][i],v);
    }
    return;
  }
  var t = ans[p];
  t = mul(t,inv(mul(cp[v][1],ncr(n-1,cp[v][0]))));
  t = mul(t,cp[v][1],ncr(n-1,cp[v][0]-1));
  ans[v] = t;
  for(var i = 0; i < g[v].length; i++){
    if(g[v][i] === p)continue;
    dfsr(g[v][i],v);
  }
}

if (process.argv.length <= 2) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=240000"] });
else {
  var myOut = main();
  if(myOut !== undefined)console.log(myOut);
}

Measured memory_bytes: 209932
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

long long int dp[2][110][4];
//0->未確定,1->確定
int main()
{
	string N;
	int K;
	cin >> N;
	cin >> K;
	
	int D = N.size();
	dp[0][0][0] = 1;
	for (int i = 1; i <= D; i++) {
		int d = N[i-1] - '0';
		if (d != 0) {
			dp[0][i][1] = dp[0][i - 1][0];
			dp[0][i][2] = dp[0][i - 1][1];
			dp[0][i][3] = dp[0][i - 1][2];
			dp[1][i][0] = dp[1][i - 1][0] + dp[0][i - 1][0];
			dp[1][i][1] = 9 * dp[1][i - 1][0] + (d - 1) * dp[0][i - 1][0] + dp[1][i - 1][1] + dp[0][i - 1][1];
			dp[1][i][2] = 9 * dp[1][i - 1][1] + (d - 1) * dp[0][i - 1][1] + dp[1][i - 1][2] + dp[0][i - 1][2];
			dp[1][i][3] = 9 * dp[1][i - 1][2] + (d - 1) * dp[0][i - 1][2] + dp[1][i - 1][3] + dp[0][i - 1][3];
		}
		else {
			dp[0][i][0] = dp[0][i - 1][0];
			dp[0][i][1] = dp[0][i - 1][1];
			dp[0][i][2] = dp[0][i - 1][2];
			dp[0][i][3] = dp[0][i - 1][3];
			dp[1][i][0] = dp[1][i - 1][0];
			dp[1][i][1] = 9 * dp[1][i - 1][0] + dp[1][i - 1][1];
			dp[1][i][2] = 9 * dp[1][i - 1][1] + dp[1][i - 1][2];
			dp[1][i][3] = 9 * dp[1][i - 1][2] + dp[1][i - 1][3];
		}
	}
	cout << dp[0][D][K] + dp[1][D][K] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//a???????????????
		int a = sc.nextInt();
		//b???????????????
		int b = sc.nextInt();
		//a??b d(??´??°)
		int d = a / b;
		//a??b?????????r(??´??°)
		int r = a % b;
		//a??b f (???????°???°?????°)
		double f = (double) a / (double) b;
		//f??????????????´
		String ff = String.format("%.5f",f);
		//??¨???
		System.out.println(d + " " + r + " " + ff);
	}
}

Measured memory_bytes: 26320
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    string s, t;
    scan(s);
    scan(t);

    int n = s.length.to!int, m = t.length.to!int;

    auto dp = new int[][](n + 1, m + 1);
    foreach (i ; 1 .. n + 1) {
        dp[i][0] = i;
    }
    foreach (j ; 1 .. m + 1) {
        dp[0][j] = j;
    }

    foreach (i ; 1 .. n + 1) {
        foreach (j ; 1 .. m + 1) {
            dp[i][j] = min(dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + (s[i-1] != t[j-1]));
        }
    }

    writeln(dp[n][m]);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 6332
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int N,M,X,cnt=0,cnt2=0;
    cin >>N>>M>>X;
    vi A(M+1);
    FOR(i,1,M) {
        cin >>A[i];
        if(A[i]<X) cnt++;
        if(A[i]>X) cnt2++;
    }
    cout <<min(cnt,cnt2);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  string s, t;
  cin >> s >> t;
  ll ima = 0;
  ll tugi = 0;
  ll sl = s.length();
  ll tl = t.length();
  ll a[26]={};
  vector<ll> al[26];
  
  rep(i,sl){
    a[s[i]-'a'] = 1;
    al[s[i]-'a'].push_back(i+1);
  }
  rep(i,sl){
    a[s[i]-'a'] = 1;
    al[s[i]-'a'].push_back(i+sl+1);
  }
  
  rep(i,tl){
    if(a[t[i]-'a']==0){
      cout << -1 << endl;
      return 0;
    }
  }
  
  rep(i,tl){
    auto Iter1 = upper_bound(al[t[i]-'a'].begin(), al[t[i]-'a'].end(), ima);
    
    if(*Iter1>sl){
      ima=*Iter1-sl;
      tugi++;
    }else{
      ima=*Iter1;
    }
    //cout << ima << endl;
  }
    
  cout << tugi*sl+ima << endl;
}

Measured memory_bytes: 2800