akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	x := sint64()
	printf("%d\n", sol(x))
}

func sol(x int64) int64 {
	for k := int64(1); k <= int64(360); k++ {
		if (k*x)%360 == 0 {
			return k
		}
	}
	return -1
}


Measured memory_bytes: 1844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
const ll INF = 10e9;
const ll mod = 10e9+7;

int main(){
  string s,t; cin>>s>>t;
  rep(i, s.size()){
    if (s == t){
      cout << "Yes" << endl;
      return 0;
    }
    s = s.back() + s.substr(0, s.size()-1);
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
	int x=0;
	char ch=' ';
	bool flag=false;
	while(!isdigit(ch))
	{
		if(ch=='-')flag=true;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return flag?-x:x;
}
const int MAX_N=2005;
int n;
int A[MAX_N];
bool vis[MAX_N];
vec g[MAX_N];
vec g2[MAX_N];
int in[MAX_N];
void dfs(int v)
{
	if(vis[v])return;
	vis[v]=true;
	rep(i,0,g[v].size())
	{
		int to=g[v][i];
		if(!vis[to])
		{
			g2[v].pb(to);
			dfs(to);
		}
	}
}
void topo()
{
	set <int> s;
	rep(i,0,n)if(!vis[i])
	{
		dfs(i);
		s.insert(-i);
	}
	while(!s.empty())
	{
		int t=-*s.begin();
		s.erase(s.begin());
		rep(i,0,g2[t].size())
		{
			int to=g2[t][i];
			s.insert(-to);
		}
		cout<<A[t]<<" ";
	}
}
int main()
{
	cin>>n;
	rep(i,0,n)cin>>A[i];
	sort(A,A+n);
	rep(i,0,n)rep(j,0,n)if(__gcd(A[i],A[j])>1)
	{
		g[i].pb(j);
	}
	topo();
	return 0;
}



Measured memory_bytes: 16000
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		long ans = 0;
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			ans += map.getOrDefault(i - A[i], 0);
			int c = A[i] + i;
			map.put(c, map.getOrDefault(c, 0) + 1);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 70932
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    ll s;cin >> s;
    ll x1,y1,x2,y2,x3,y3;
    x1 = 0;y1 = 0;
    if(s <= 1e9){
        x2 = 0;y2 = 1;
        x3 = s;y3 = 0;
    }
    else if(s == (ll)1e18){
        x2 = (ll)1e9;y2 = 0;
        x3 = 0;y3 = (ll)1e9;
    }
    else{
        x2 = 1e9;y2 = 1;
        x3 = (ll)1e9 - s%(ll)(1e9);y3 = s/1e9+1;
    }
    cout << x1 <<" " <<  y1 <<" "<< x2 <<" "<< y2 <<" "<< x3 <<" " << y3 << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = x + y/2;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i + 1 == p[i] and i != n - 1:
        p[i],p[i + 1] = p[i + 1],p[i]
        ans += 1
    elif i + 1 == p[i]:
        ans += 1 
print(ans)

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

int c1, c5, c10, c50, c100, c500;
int main() {
  cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
  int x = c1 + 5*c5 + 10*c10 + 50*c50 + 100*c100 + 500*c500;
  cout << (x >= 1000 ? 1 : 0) << "\n";
  return 0;
}

Measured memory_bytes: 3028
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL n;
    cin >> n;
    cout << n * ( n - 1 ) / 2 << endl;

    return 0;
}



Measured memory_bytes: 256
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
const LL MAXN = 100000 + 5;
LL n, m, f[MAXN], sz[MAXN], gg[MAXN];
struct edge {
	LL a, b;
} ed[MAXN];
LL find(LL x) {return x == f[x] ? x : f[x] = find(f[x]);}
int main() {
	cin >> n >> m;
	for (LL i = 1; i <= m; ++i) {
		scanf("%lld%lld", &ed[i].a, &ed[i].b);
	}
	for (LL i = 1; i <= n; ++i) sz[i] = 1, f[i] = i;
	LL ans = (n - 1) * n / 2;
	for (LL i = m; i >= 1; --i) {
		gg[i] = ans;
		LL x = find(ed[i].a), y = find(ed[i].b);
		if (x != y) {
			ans -= sz[x] * sz[y];
			f[x] = y;
			sz[y] += sz[x];
		}
	}
	for (LL i = 1; i <= m; ++i) printf("%lld\n", gg[i]);
	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    vector<int> p(3);
    p.at(0)=a+b;
    p.at(1)=a-b;
    p.at(2)=a*b;

    cout << *max_element(p.begin(), p.end());
}

Measured memory_bytes: 256
n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  # x番目がほしいときにchars[x-1]としたくないので、chars[0]は使わないことにします

n_rem = n  # 入力を直接操作すると、もし後々必要になったときに面倒なので
res = ""

while True:
    x = n_rem % 26
    # 余りが0、つまりzの場合は、26にします
    if x == 0:
        x = 26
    res += chars[x]

    # xを引いて、26で割ります
    n_rem -= x

    # 0なら終了します
    if n_rem == 0:
        break

    n_rem //= 26

# 0桁目が先頭で、最後の桁が末尾になっているので、反転させます
print(res[::-1])


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

int main()
{
	int a,b;
	cin >> a>>b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}
	else if(a>b) {
		cout << "a > b" << endl;
	}
	
    return 0;
}

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

public class Main
{
  int h, w, max = 0;
  int[][] x;
  char[][] g;
  
  Main(Scanner in, PrintWriter out)
  {
    g = new char[h = in.nextInt()][w = in.nextInt()];
    for (int i = 0; i < h; i++)
      g[i] = in.next().toCharArray();
    
    x = new int[h][w];
    for (int i = 0; i < h; i++)
    {
      int at = 0, st = 0;
      while (at < w)
      {
        int cnt = 0;
        st = at;
        while (at < w && g[i][at] != '#')
        {
          cnt++;
          at++;
        }
        for (int j = st; j < at; j++)
          x[i][j] += cnt;
        at++;
      }
    }
    
    for (int i = 0; i < w; i++)
    {
      int at = 0, st = 0;
      while (at < h)
      {
        int cnt = 0;
        st = at;
        while (at < h && g[at][i] != '#')
        {
          cnt++;
          at++;
        }
        for (int j = st; j < at; j++)
          x[j][i] += cnt;
        at++;
      }
    }
    
    for (int[] y : x)
      for (int z : y)
        max = Math.max(max, z-1);
    out.println(max);
  }

  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new	Main(in, out);
    out.close();
  } 
}


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

int main() {
  int n, d, a;
  cin >> n >> d >> a;
  pair<int, int> pairs[n];
  for (int i = 0; cin >> pairs[i].first >> pairs[i].second; ++i) {}
  sort(pairs, pairs + n);
  int64_t diff[n];
  diff[0] = pairs[0].second;
  for (int i = 1; i < n; ++i) {
    diff[i] = pairs[i].second - pairs[i - 1].second;
  }
  int64_t sum = 0, result = 0;
  for (int i = 0, j = 0; i < n; ++i) {
    sum += diff[i];
    if (sum > 0) {
      auto current = (sum - 1) / a + 1;
      result += current;
      sum -= current * a;
      while (j < n && pairs[j].first - d <= pairs[i].first + d) {
        ++j;
      }
      if (j < n) {
        diff[j] += current * a;
      }
    }
  }
  cout << result;
  return 0;
}


Measured memory_bytes: 6244
#include <stdio.h>
 
#define N 100
 
int queue[N] = {};
int b = 0, e = 0;
int step[N] = {};

void ENQ(int);
int DEQ();
int isemp();
void clear();
void BFS(int[], int s, int n);

int main(int argc,char *argv)
{
    int n, i, j, u, k, v;
    int cnt = 0;
    int table[N*N] = {};
    scanf( "%d", &n );
 
    clear();
 
    for( i=0; i<n; ++i ) {
        scanf( "%d %d", &u, &k );
        for( j=0; j<k; ++j ) {
            scanf("%d", &v);
            table[((u-1)*N)+(v-1)] = 1;
        }
    }
 
    BFS( table, 1, n );
 
    for( i=0; i<n; ++i )
        printf("%d %d\n", i+1, step[i]);
 
    return 0;
}
void ENQ( int v ) {
    queue[b++] = v;
}
int DEQ() {
    return queue[e++];
}
int isemp() {
    return b == e;
}
 
void clear()
{
    int i;
    for( i=0; i<N; ++i ) {
        queue[i] = 0;
        step[i] = -1;
    }
    b = 0;
    e = 0;
}
 
void BFS( int table[], int s, int n )
{
    int u, v;
 
    ENQ( s - 1 );
    while( !isemp() ) {
        u = DEQ();
        if ( step[u] == -1 )
            step[u] = 0;
                     
        for( v=0; v<n; ++v ) {
            if ( table[u*N+v] == 1 && step[v] == -1 ) {
                step[v] = step[u] + 1;
                ENQ( v );
            }
        }
    }
}


Measured memory_bytes: 2024
#include <iostream>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;
using ll = long long;

const int NMAX = 100;
int F[NMAX][10];
int P[NMAX][11];

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

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> F[i][j];
		}
	}


	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> P[i][j];
		}
	}

	int ans = -(1 << 31);

	for (int i = 1; i < 1024; i++) {
		int sumP = 0;
		for (int j = 0; j < N; j++) {
			int sumi = 0;
			for (int k = 0; k < 10; k++) {
				if ((i >> k) & 1 && F[j][k]) {
					sumi++;
				}
			}
			sumP += P[j][sumi];
		}
		ans = max(ans,sumP);
	}

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


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        ArrayList<Integer> a = new ArrayList<Integer>();
        for(int i=0; i<N; i++){
            a.add(Integer.parseInt(sc.next()));
        }
        
        Collections.sort(a, Comparator.reverseOrder());
        
        int Alice_score = 0;
        int Bob_score = 0;
        int i=0;
        while(a.size() != 0){
            if(i % 2 == 0){
                Alice_score += a.get(0);
            }else{
                Bob_score += a.get(0);
            }
            i++;
            a.remove(0);
        }
        System.out.println(Alice_score - Bob_score);
    }
}

Measured memory_bytes: 21844
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                cnt += 1

print(cnt)

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

bitset <1000001> primeArr;
void sieve()
{
	int num_sqrt = sqrt(1000000);
	primeArr[1] = 1;
	for (int i = 4; i <= 1000000; i += 2)
		primeArr[i] = 1;

	for (int i = 3; i <= num_sqrt; i += 2) {
		for (int j = 2; i*j <= 1000000; j++)
			primeArr[i*j] = 1;
	}
}

int primeFactor(int n, vector<int> &arr){
    int c = 0;
    while(n%2 == 0){
        arr[c++] = 2;
        n = n/2;
    }
    for(int i=3;i<=sqrt(n);i+=2){
        while(n%i == 0){
            arr[c++] = i;
            n = n/i;
        }
    }
    if(n >2)
        arr[c++] = n;
    return c;
}


int main()
{
    int x, y;
    cin >> x >> y;
    cout << x + (y/2) << endl;
	return 0;
}


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

int main() {
    int m,f,r,sum;
    
    while(true){
        cin >> m >> f >> r;
        sum = m+f;
        
        if(m == -1 && f == -1 && r == -1) {
            break;
        }
        
        if(m == -1 || f == -1) {
            cout << "F" << endl;
            continue;
        }
        
        if(sum >= 80) {
            cout << "A" << endl;
            continue;
        }
        
        if(sum >= 65 && sum < 80) {
            cout << "B" << endl;
            continue;
        }
        
        if(sum >= 50 && sum < 65) {
            cout << "C" << endl;
            continue;
        }
        
        if(sum >= 30 && sum <  50) {
            if(r >= 50){
                cout << "C" << endl;
            }else{
                cout << "D" << endl;
            }
            continue;
        }
        
        if(sum < 30) {
            cout << "F" << endl;
            continue;
        }
    }
}


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

double arr[3000];
double memo[3000][3000];

double combinations(int start,int n, int h){
	if(start == n){
		if(h > n - h){
			return 1;
		}
		else return 0;
	}

	if(memo[start][h] != -1) return memo[start][h];

	return memo[start][h] =  arr[start] * combinations(start+1,n,h+1) +  
		((1 - arr[start])  *	combinations(start+1,n,h));
}

int main(){
	int N;
	cin>>N;
	
	for(int i = 0; i < N; ++i){
		cin>>arr[i];
	}
	
	for(int i = 0; i < 3000; ++i){
		for(int j = 0; j < 3000; ++j){
			memo[i][j] = -1;
		}
	}
	cout<<fixed<<setprecision(20);
	cout<<combinations(0, N,0)<<endl;
}



Measured memory_bytes: 74352
def counting_sort(A, k):
    C = [0] * (k + 1)
    for a in A:
        C[a] += 1
    j = 0
    for i, c in enumerate(C):
        for k in range(c):
            A[j + k] = i
        j += c


K = 10_000
N = int(input())
A = list(map(int, input().split()))
counting_sort(A, K)
print(*A)



Measured memory_bytes: 224504
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
ll exgcd(ll a, ll b, ll & x, ll & y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;   
    }
    ll d = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
ll inv(ll a, ll MOD) {
    ll x, y;
    exgcd(a, MOD, x, y);
    x = (x % MOD + MOD) % MOD;
    return x;
}
ll fac[200010];
void init(int p) {
    fac[0] = 1;
    for (int i = 1; i <= p; i++) fac[i] = fac[i - 1] * i % mod;
}
ll lucas2(ll n, ll m) {
    ll ret = 1, a, b;
    while (n && m) {
        a = n % mod, b = m % mod;
        if (a < b) return 0;
        ret = ret * fac[a] % mod * inv(fac[b] * fac[a - b] % mod, mod) % mod;
        n /= mod, m /= mod;
    }
    return ret;
}
int main()
{
    ll x, y, n, m;

    scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
    ll ans = 0;
    init(200005);
    ll z = y, p = n + m - 2;
    for (ll i = 0; i <= n - x - 1; i++) {
        ans = ans + lucas2(z + i - 1, i) * lucas2(p - z - i, n - 1 - i) % mod;
        ans %= mod;
        //printf("1  %lld  %lld\n", i, ans);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
int N,H,A[100000],all=0;
scanf("%d %d",&H,&N);
  for(int i=0;i<N;i++){
  scanf("%d",&A[i]);
    all+=A[i];
  }
  if(all>=H){
  printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N;
    char t[27];
    fgets(t, 27, stdin);
    N = atoi(t);

    char S[10001];
    fgets(S, 10001, stdin);

    int i=0;
    while(S[i] != '\0'){
        if(S[i] != '\n') printf("%c", 'A'+(S[i]-'A'+N)%26);
        i++;
    }
    
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string h; cin >> h;
  if(h == s) a--;
  else b--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 3596
//created by pyoxiao on 2020/04/19
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
const int N = 2e5 + 7;
int n, SZ[N], deg[N];
vector<int> ver[N];
void dfs(int x, int fa) {
    SZ[x] = 1;
    for(auto to : ver[x]) {
        if(to == fa) continue;
        dfs(to, x); 
        SZ[x] += SZ[to];
    }
}
void solve() {
    scanf("%d", &n);
    for(int i = 2; i <= n; i ++) {
        int x;
        scanf("%d", &x);
        deg[x] ++;
    }
    //dfs(1, 0);
    for(int i = 1; i <= n; i ++) {
        printf("%d\n", deg[i]);
    }
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 9284
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // 2個
		int dimension = scan.nextInt(); // 3次元

		int[][] index = new int[n][dimension];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < dimension; j++) {
				index[i][j] = scan.nextInt();
			}
		}

		
		int count = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				
				int sum = 0;
				
				for (int k = 0; k < dimension; k++) {
					sum += Math.pow(index[i][k] - index[j][k], 2);
				}
				int root = (int) Math.sqrt(sum);
				if (root * root == sum) {
					count++;
				}
			}

		}

		System.out.println(count);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;

int n, m, x, ans = INF;
vector<int> c(12);
vector<vector<int>> a(12, vector<int>(12));

int main() {
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }

  for (int s = 0; s < (1 << n); s++) {
    int cost = 0;
    vector<int> d(m);
    for (int i = 0; i < n; i++) {
      if (s & 1 << i) {
        cost += c[i];
        for (int j = 0; j < m; j++) d[j] += a[i][j];
      }
    }
    bool ok = true;
    for (int j = 0; j < m; j++)
      if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }

  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl "\n"

using namespace std;

int n, d;

int main(){
    vector<int> v;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> d;
        v.push_back(d);
    }

    sort(v.begin(), v.end());

    cout << v[n/2] - v[(n/2)-1];






}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 892
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

l,r = readInts()

ans = float("inf")
for i in range(l,min(r+1,l+2020)):
  for j in range(i+1, min(r+1,l+2020)):
    ans = min(ans,(i*j)%2019)

print(ans)

Measured memory_bytes: 9452
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int gcd(int a, int b){
  if(a%b==0) return b;
  else return gcd(b, a%b);
}

int main(){
  ll N, ans=0;
  cin>>N;
  rep1(i, N){
    rep1(j, N){
      rep1(l, N) {
        int tmp=gcd(i, j);
        ans += gcd(tmp, l);
      }
    }
  }
  out(ans);
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>

struct Point{double x,y;};

void koch(int n, struct Point a, struct Point b){
  if(n == 0) return;
  struct Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y -s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n - 1, t, b);
}

int main(){
  struct Point a, b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}


Measured memory_bytes: 2036
N = int(input())
H = list(map(int, input().split()))
diff = [0] * N
ret = "Yes"
for i in range(1,N):
    if H[i] - H[i-1] > 0:
        H[i] -= 1
    elif H[i] - H[i-1] < 0:
        ret = "No"
print(ret)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int R,G,B,n;
  cin>>R>>G>>B>>n;
  int r,g,b;
  r = n/R;
  g = n/G;
  b = n/B;
  long long ans=0;
  int rest;
  REP(i,r+1){
    REP(j,g+1){
      rest = n-R*i-G*j;
      if(rest%B==0 && 0<=rest/B && rest/B<=b){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
    
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
     
label = list(map(int,input().split()))
d0 = dice(label)
d1 = list(map(int,input().split()))
for op in 'EEENEEENEEESEEESEEENEEEN':
    if d0.get_label() == d1:
        print('Yes')
        break
    d0.roll(op)
else:
    print('No')


Measured memory_bytes: 5608
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

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

	if (H % A == 0) {
		cout << H / A << endl;
	}
	else {
		cout << H / A + 1 << endl;
	}
	return 0;
} 

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

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

struct UF{
	int par[1002],r[1002],cnt[1002];
	void init(){
		rep(i,1002){
			par[i] = i;
			r[i] = 0;
			cnt[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			par[x] = y;
			cnt[y] += cnt[x];
		}
		else {
			par[y] = x;
			cnt[x] += cnt[y];
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
}uf;

int main(){
	static int v;
	static char a[1002][1002];
	scanf("%d",&v);
	rep(i,v){
		scanf("\n");
		rep(j,v){
			scanf("%c",&a[i][j]);
		}
	}
	
	static int dp[1002][1002][2];
	rep(x,2004)rep(j,1002)rep(k,2){
		int i = x-j;
		if(i >= 1002 || i < 0)continue;
		if(i+j <= 1){
			dp[i][j][k] = 0;
			continue;
		}
		dp[i][j][k] = 0;
		if(k == 1)dp[i][j][k] += dp[i][j][k-1];
		if(i >= 1)dp[i][j][k] += dp[i-1][j][k^1];
		if(j >= 2)dp[i][j][k] += dp[i+1][j-2][k];
		if(dp[i][j][k] == 0)dp[i][j][k] = 1;
		else dp[i][j][k] = 0;
	}
	
	uf.init();
	int cnt = 0;
	rep(i,v)rep(j,v){
		if(a[i][j] == 'Y'){
			cnt ++;
			uf.unit(i,j);
		}
	}
	cnt /= 2;
	
	int b = 0 , c = 0 , d = 0;
	rep(i,v){
		if(uf.find(i) == i){
			if(uf.cnt[i]%2 == 0)b ++;
			else c ++;
			d += uf.cnt[i]*(uf.cnt[i]-1)/2;
		}
	}
	if(dp[b][c][(d-cnt)%2] == 0)puts("Taro");
	else puts("Hanako");
}

Measured memory_bytes: 11964
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

bool is_prime(int n) {
    for (ll i = 2; i*i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

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

    int n;
    cin >> n;
    int cnt = 0;
    while (n--) {
        int x;
        cin >> x;
        cnt += is_prime(x);
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3164
#include<iostream>
#include<tuple>
#include<algorithm>

using std::begin;
using std::end;

std::tuple<int, int, int> sort(int a, int b, int c) {
  int xs[] = {a, b, c};
  std::sort(begin(xs), end(xs));
  return std::make_tuple(xs[0], xs[1], xs[2]);
}

int main(int, char**) {
  int a, b, c;
  int cnt{0}, ei{0}, cho{0}, don{0};

  while(std::cin >> a >> b >> c) {
    auto t = sort(a, b, c);
    {
      int a, b, c;
      std::tie(a, b, c) = t;
      if(a + b <= c) break;
      ++cnt;
      int m2 = a * a + b * b;
      if(m2 == c * c) ++cho;
      else if(m2 > c * c) ++ei;
      else ++don;
    }
  }

  std::cout << cnt << ' ' << cho << ' ' << ei << ' ' << don << std::endl;
}



Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>

  int main (void){
   int A,B;
   
   scanf("%d %d",&A,&B);
   
   if(1>A,B || A,B>9){
   exit(0);
   }
   
   if(A+B>=10){
   printf("error");
   return 0;
   }else{
   printf("%d",A+B);
   return 0;
   }
  }

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

using namespace std;

int main() {
  int N, M, H;
  cin >> N;
  bool cond{true};
  while (cond && cin >> H) {
    M = max(M, H);
    cond &= (M - H <= 1);
  }
  cout << (cond ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// dislike list
vector<int> D;

// n is one digit
bool dislike(int n){
    for(int d : D){
        if(n == d){
            return true;
        }
    }
    return false;
}

// n is some digit
bool like(int n){
    while(n!=0){
        int digit_one = n % 10;
        if(dislike(digit_one)){
            return false;
        }
        n /= 10;
    }
    return true;
}

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N, K;
    cin >> N >> K;

    FOR(i, 0, K){
        int d;
        cin >> d;
        D.push_back(d);
    }

    while(true){
        if(like(N)){
            p(N);
            return 0;
        }
        else{
            N++;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

long long int lng(long long int a,long long int b){
    long long int t;
    t = a%b;
    a = b;
    b = t;
    if(t == 0){
        return a;
    }else{
        return lng(a,b);
    }
}

int main(){
    long long int ansi;
    long long int A,B,C,D;
    cin >> A >> B >>C >> D;
    long long int lmg =C / lng(C,D) * D;
    ansi = B - B/C - B/D + B/lmg -(A-1 - (A-1)/C - (A-1)/D + (A-1)/lmg);
    cout << ansi << endl;
}

Measured memory_bytes: 888
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // int a = sc.nextInt();
        // int b = sc.nextInt();
        // int c = sc.nextInt();
        int count = 0;
        int[] color = new int [3];
        for(int i = 0;i < 3;i++){
            color[i] = sc.nextInt();
        }
        for(int i = 0;i < 3;i++){
            for(int j = i+1; j < 3;j++){
                if(color[i] == color[j]){
                    count++;
                }
            }
        }
        if(count >=2){
            System.out.println(1);
        }
        else if(count == 1){
            System.out.println(2);
        }
        else{
            System.out.println(3);
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

const int MAX_DIGIT = 50;

int main(void)
{
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<ll> dn(MAX_DIGIT+1, 0);
    REP(i, N){
        REP(j, MAX_DIGIT){
            if(A[i]&(1LL<<j)) dn[j]++;
        }
    }

    ll ans = 0;
    for (int d = MAX_DIGIT; d >= -1; d--) {
        if(d!=-1 && !(K&(1LL<<d))) continue;
        ll tmp = 0;
        for (int e = MAX_DIGIT; e >= 0; e--) {
            ll mask = 1LL<<e;
            if(d<e){
                if(K&mask) tmp += (N-dn[e])*mask;
                else tmp += dn[e]*mask; 
            }else if(e == d){
                tmp += mask * dn[e];
            }else{
                tmp += mask * max(dn[e], N - dn[e]);
            }
        }
        ans = max(ans, tmp);
    }
    pr(ans);
}

Measured memory_bytes: 1024
package main

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

type TupleInt struct {
	A int
	B int
}

func main() {
	sc := NewScanner()
	H, N := sc.NextInt(), sc.NextInt()
	t := make([]TupleInt, N)
	for i := 0; i < N; i++ {
		t[i] = TupleInt{sc.NextInt(), sc.NextInt()}
	}
	dp := make([]int, H+1)
	fillInt(dp, t[0].B*H)
	dp[0] = 0
	for j := 0; j < H; j++ {
		for i := 0; i < N; i++ {
			p := j + t[i].A
			if p > H {
				p = H
			}
			dp[p] = min(dp[p], dp[j]+t[i].B)
			//fmt.Println(p, i, dp[p])
		}
	}
	fmt.Println(dp[H])
}
func fillInt(arr []int, v int) {
	for i := 0; i < len(arr); i++ {
		arr[i] = v
	}
}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 768
import math
while True:
    x = []
    n = int(input())
    if n == 0:
        break
    x = input().split( )
    suu = [float(s) for s in x]
#    print(x)
    kota = float(0)
    for a in suu:
        kota += ((a-sum(suu)/n)**2)/n
    print(math.sqrt(kota))


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

int main(){
  int a,b;
  cin >> a;
  b = a/15;
  cout << 800*a-200*b << endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int h,w;
	while(scanf("%d%d", &h,&w)){
		if(h == 0 && w == 0)
			break;
		int i,c;
		for(i =0; h > i; i++){
			for(c = 0; w > c; c++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
 
typedef pair<int,int> pr;
typedef pair<int,pr > ppr;
const int INF=2<<20;

int main() {
	// your code goes here
	int n;
	while(cin >> n && n){
		bool ans=true;
		int bill[101][2]={};
		for(int j=0;j<2;j++)
			for(int i=0;i<n;i++)
				cin >> bill[i][j];
		for(int i=1;i<n;i++)
			if(bill[i][0]==2 && bill[i][1]==2 && bill[i-1][0]==2 && bill[i-1][1]==2 )
			ans=false;
		if(bill[n-1][0]==2 && bill[n-1][1]==2 && bill[n-1][0]==2 && bill[n-1][1]==2 )
			ans=false;
		if(!ans)
		cout <<"NA" << endl;
		else{
			int minim=2<<20;
			for(int i=0;i<2;i++){
			int now=0,bills=i,jump=0;
			while(bill[now][bills]==1 && bill[now+1][bills]==1) now++;
			while(now<n-1 || bill[now][bills]==2){
				while(bill[now][bills]==1&&bill[now+1][bills]==1) now++;//&& 
				while(bill[now][bills]==2) now--;
				if(now==n-1)
				break;
				jump++;
				bills=(bills+1)%2;
				now=min(n-1,now+2);
			}
			minim=min(minim,jump);
			}
			cout << minim << endl;
		}
		
	}
	return 0;
}

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

typedef long long ll;

int main(){
  int N;
  string S;
  cin>>N>>S;
  
  ll r=0,g=0,b=0;
  for(auto c:S){
    if(c=='R')++r;
    else if(c=='G')++g;
    else ++b;
  }
  
  ll ans=r*g*b;
  for(int i=0;i<N-1;++i){
    for(int j=i+1;j<N;++j){
      if(S[i]==S[j])continue;
      int k=j*2-i;
      if(k>=N||S[k]==S[i]||S[k]==S[j])continue;
      --ans;
    }
  }
  
  cout<<ans<<endl;
}

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

int main()
{
    int n, m;
    int ans[50] = {};
    cin >> n >> m;

    int x, y;
    for (int i = 0; i < m; ++i)
    {
        cin >> x >> y;
        ++ans[x - 1];
        ++ans[y - 1];
    }
    for (int i = 0; i < n; ++i)
        cout << ans[i] << endl;
}

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

int main(){

    int x[5],i;
    int ans = 0;
    rep(i,5){
        cin >> x[i];
    }

    rep(i,5){
        if(x[i] == 0){
            ans = i + 1;
            cout << ans << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	int k;
	int a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; ++i) {
		if(i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    for(int i = 1; i < 10; i++) {
      for(int j = 1; j < 10; j++) {
        if((i * j) == n) ans = "Yes";
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  double n,m,d;
  cin >> n >> m >> d;
  cout << fixed << setprecision(10) << endl;
  if(d == 0){
    cout << (n) * (m - 1) / n / n << endl; 
  }
  else{
    cout << 2 * (n - d) * (m - 1) / n / n << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

template<typename type> vector<type> divisor(type n)
{
    vector<type> res;
    for(type i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            res.push_back(i);
            if(i * i != n) res.push_back(n / i);
        }
    }
    return res;
}
map<Int, Int> prime_factor(Int N, const vector<Int> &is_prime)
{
    map<Int, Int> result;
    while(N > 1)
    {
        result[is_prime[N]]++;
        N = N / is_prime[N];
    }
    return result;
}

vector<Int> eratosthenes(const Int &N)
{
    vector<Int> is_prime(N + 1);
    for(int i = 0; i < is_prime.size(); i++) is_prime[i] = i;
    is_prime[1] = 0;

    for(Int i = 2; i * i <= N; i++)
    {
        if(is_prime[i] != i) continue;
        for(Int j = 2 * i; j <= N; j += i)
        {
            is_prime[j] = min(is_prime[j], i);
        }
    }
    return is_prime;
}

void solve()
{
    Int n; cin >> n;
    vector<Int> is_prime = eratosthenes(n);
    Int ans = 0;
    for(Int c = 1; c <= n; c++)
    {
        map<Int, Int> mp = prime_factor(n - c, is_prime);
        Int cnt = 1;
        for(const auto &x : mp)
        {
            cnt *= (x.second + 1);
        }
        ans += cnt;
    }
    cout << ans - 1 << "\n";

}

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


Measured memory_bytes: 11108