akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();

		int A = sc.nextInt();

		int B = sc.nextInt();

		int C = sc.nextInt();

		int D = sc.nextInt();

		int a, b, e, ans;

		if(A%C==0) a = A/C;

		else a = A/C + 1;

		if(B%D==0) b = B/D;

		else b = B/D + 1;

		e = Math.max(a,b);

		ans = L - e;

		System.out.println(ans);
	}

}



Measured memory_bytes: 26328
n, Y = map(int, input().split())
Y = Y // 1000
x, y, z = -1, -1, -1
for i in range(n + 1):
  d = Y - 10 * i
  r = n - i
  if d < 0:
    break
  if (5 * r - d) % 4 == 0:
    a = (5 * r - d) // 4
    b = r - a
    if a >= 0 and b >= 0:
      x, y, z = i, b, a
      break
print(x, y, z)
     

Measured memory_bytes: 3064
N = int(input())
S = input()
m = 10 ** 6
tot1 = 0
cnt1 = 0
cnt0 = 0
for s in S:
    if(s == '#'):
        cnt0 += 1
    else:
        cnt1 += 1
        tot1 += 1
    m = min(m,cnt0-cnt1)
m += tot1
m = min(m,tot1)
print(m)

Measured memory_bytes: 9484
def is_prime(x):
    if x == 2:
        return True
    if (x < 2) or (x%2 == 0):
        return False
    return all(x%i for i in xrange(3, int(x**(0.5) + 1), 2))

N = input()
print sum(is_prime(input()) for i in range(N))

Measured memory_bytes: 6756
#include <stdio.h>
#include <string.h>
#include <ctype.h>

static long long calc(char *str);

int main(int argc, char *argv[])
{
	char S[16];
	int i, j, v, n;
	long long total = 0LL;
	fgets(S, sizeof(S), stdin);
	n = strlen(S) - 1;
	if ( n == 1 ){
		printf("%d\n", S[0] - '0');
		return 0;
	}
	for ( i = 0; i < 2<<(n-2); i++ ){
		int k = 0;
		char tmp[32] = {0};
		tmp[k++] = S[0];
		for ( j = 1, v = 1; j < n; j++, v <<= 1){
			if ( i&v ){
				tmp[k++] = '+';
			}
			tmp[k++] = S[j];
		}
		fprintf(stderr, "%s:%lld\n", tmp, calc(tmp));
		total += calc(tmp);
	}
	printf("%lld\n", total);
	return 0;
}

static long long calc(char *str)
{
	int i;
	long long t = 0, n = 0;
	for ( i = 0; i < strlen(str); i++ ){
		if ( isdigit(str[i]) ){
			n = n * 10 + str[i] - '0';
		} else {
			t += n;
			n = 0;
		}
	}
	return t + n;
}


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

using namespace std;

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

	int x,n;
	cin>>x>>n;
	vector<bool>chk(n+5);
	int num;
	int mx=0,mn=200;
	for(int i=0;i<n;++i)
	{
		cin>>num;
		chk[num]=true;
		mx=max(mx,num);
		mn=min(mn,num);
	}
	int dif=200,ans=0;

	for(int i=0;i<=110;++i)
	{
		if(!chk[i] && abs(x-i)<dif)
		{
			dif=abs(x-i);
			ans=i;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3628
N = int(input())
A = list(map(int,input().split()))
B = "APPROVED"

for i in range(N):
  if A[i] % 2 == 0:
    if (A[i] % 3 != 0) and (A[i] % 5 != 0):
      B = "DENIED"
print(B)
         

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> A(n), dp(n, INT_MAX); dp[0] = 0;
    for(int i = 0; i < n; i++)
        cin >> A[i];
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= k && j <= i; j++){
                dp[i] = min(dp[i], (dp[i-j] + abs(A[i] - A[i-j])));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4044
n,m = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(m)]
a ,b= [],[]
for i in x:
	if i[0]==1:
		a.append(i[1])
	if i[1]==n:
		b.append(i[0])
if len(a)+len(b) == len(set(a+b)): print("IMPOSSIBLE")
else: print("POSSIBLE")

Measured memory_bytes: 51656
import java.util.*;
class Main {
	public static void main (String[] args) {
		int[] hills = new int[3];
		hills[0] = 0;
		hills[1] = 0;
		hills[2] = 0;
		Scanner scan = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			int hill = scan.nextInt();
			if (hills[2] < hill) {
				if (hills[1] < hill) {
					if (hills[0] < hill) {
						hills[2] = hills[1];
						hills[1] = hills[0];
						hills[0] = hill;
					} else {
						hills[2] = hills[1];
						hills[1] = hill;
					}
				} else {
					hills[2] = hill;
				}
			}
		}
		for (int topThree : hills) {
			System.out.println(topThree);
		}
	}
}

Measured memory_bytes: 17356
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

ans = 0
cnt = 1
# 最大値は一回だけ
ans += A[0]

# N-2個は、2,2,3,3,..i,i,...のように取る
flag = False
for i in range(1, len(A)-1):
    ans += A[cnt]
    if flag == False:
        flag = True
    else:
        flag = False
        cnt += 1
print(ans)

Measured memory_bytes: 31592
/*
"اله السماء يعطينا النجاح ونحن عبيده نقوم ونبني" 
"تكفيك نعمتي لان قوتي في الضعف تكمل"
created by shady rafet 
my face book : https://www.facebook.com/profile.php?id=100019579575853
never give up
one day i will do it ':(

*/
#include <bits/stdc++.h>
using namespace std;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ul;
const ll oo = 1e18;
const ll N = 1e6;
const ll mod = 1e9 + 7;
#define point complex<double>
const double pi = acos(-1);
double dot(point a, point b)
{
    return (conj(a) * b).real();
}
double cross(point a, point b)
{
    return (conj(a) * b).imag();
}
ll inv[N],fact[N];
ll fb(ll x, ll y)
{
    if(y == 0)
    return 1;
   ll ans = fb(x,y/2);
   ans = (ans * ans)%mod;
   if(y % 2 !=0)
   {
       ans = (ans*(x%mod))%mod;
   }
   return ans ;
}
void pre(ll n)
{
    fact[0] = 1;
    inv[0] = 1;
    for ( int i = 1;i<=n;i++)
    {
        fact[i] = (i * fact[i-1])% mod;
        inv[i] = fb(fact[i], mod-2);
    }
}
ll ncr (ll n , ll r)
{
      return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}
ll npr (ll n,ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}
vector<int> adj[N];
bool visted[N];
int main()
{
   int n;
   cin>>n;
  int sum = 0;
  for(int i = 1;i<=n;i++)
  {
      int x;
      cin>>x;
      if(i%2&&x%2)
      sum++;
  }
  cout<<sum;
    return 0;
}

Measured memory_bytes: 27044
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
    int len = vp.size(); s << "\n";
    for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size(); s << "\n";
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    s << "\n"; return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
    int len = v.size(); s << "\n";
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) { s << vv[i]; }
    return s;
}

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) { s << vv[i]; }
    return s;
}

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int len = s.length();
    vi a(len);
    rep (i, len) {
        a[i] = (s[i] - 'a');
    }
    rep (i, len) {
        if (a[i] == 0) {
            continue;
        }
        int cost = 26 - a[i];
        if (k >= cost) {
            a[i] = 0;
            k -= cost;
        }
    }
    a[len-1] += k;
    a[len-1] %= 26;
    rep (i, len) {
        printf("%c", ('a' + a[i]));
    }
    printf("\n");

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m,x;

int main(){
    cin >> n >> m >> x;
    vector<ll> a(m);
    rep(i,m)cin >> a[i];
    sort(ALL(a));
    ll num = lower_bound(ALL(a),x) - a.begin();
    cout << min(num,m-num) << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
   int A, B;
   std::cin >> A >> B;

   int count = 0;
   for(int i=A; i<=B; ++i){
      bool flag = true;
      if(i/10000!=i%10) flag = false;
      if((i/1000)%10!=(i/10)%10) flag = false;
      if(flag) ++count;
   }
   std::cout << count << std::endl;
   return 0;
}


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

using namespace std;

int main() {
	int n,r;
	string a,b,c;
	cin >> n;
	cin >> a >> b >> c;
	r=0;
	for(int i=0;i<n;i++){
		if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
			r += 2;
		}else if(a[i] == b[i] && b[i] == c[i]) {
			r += 0;
		}else {
			r += 1;
		}
	}
	cout << r << endl;
	return 0;
}

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


def main():
    dict = {'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}
    x, y = input().split()
    if dict[x] > dict[y]:
        print('>')
    elif dict[x] < dict[y]:
        print('<')
    else:
        print('=')


if __name__ == '__main__':
    main()

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

using namespace std;

int v[200000];
vector <vector <int> > e;

void DFS(int x, int d)
{
	v[x] = 1;

	if (d == 2)
		return;
	
	for (int i = 0; i < e[x].size(); i++)
		if (!v[e[x][i]])
			DFS(e[x][i], d+1);
}

int main()
{
	int n, m, a, b;
	cin >> n >> m;
	e.resize(n);
	
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		e[a-1].push_back(b-1);
		e[b-1].push_back(a-1);
	}
	
	DFS(0, 0);
	cout << (v[n-1] ? "POSSIBLE" : "IMPOSSIBLE");
}

Measured memory_bytes: 12784
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");

        int n = Integer.valueOf(arr01[0]);
        int mysum = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                //                System.out.println(arr02[i] + " " + arr02[j]);
                mysum += Integer.valueOf(arr02[i]) * Integer.valueOf(arr02[j]);
            }

        }

        System.out.println(mysum);
    }

}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main (void){
    int a,b;
    cin >> a >> b;
    if (a>b)
    {
        cout<< "a > b"<<endl;
        return 0;
    }
    if (a==b)
    {
        cout<< "a == b"<<endl;
        return 0;
    }
    if (a<b)
    {
        cout<< "a < b"<<endl;
        return 0;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  for(int i=0; i<a; i++) {
    if(!('0' <= s.at(i) && s.at(i) <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }
  if(s.at(a) != '-') {
    cout << "No" << endl;
    return 0;
  }
  for(int i=a+1; i<s.size(); i++) {
    if(!('0' <= s.at(i) && s.at(i) <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int tele[100001],dis[100001];
int *child_list[100001],child_num[100001];

struct dat{
  int dist,num;
};

int calc(int n);
int comp(const void *p1,const void *p2);
void recalc(int n,int dist);

int main(void){
  int N,K,i,j,m=0;
  struct dat data[100001];
  int write=0;
  
  scanf("%d%d",&N,&K);
  
  for(i=1;i<=N;i++){
    scanf("%d",&tele[i]);
    if(child_num[tele[i]]==0){
      child_list[tele[i]]=(int *)calloc(1,sizeof(int));
    }else{
      child_list[tele[i]]=(int *)realloc(child_list[tele[i]],sizeof(int)*(child_num[tele[i]]+1));
    }
    child_list[tele[i]][child_num[tele[i]]]=i;
    child_num[tele[i]]++;
  }
  
  if(tele[1]!=1) m++;

  data[1]=(struct dat){0,1};
  for(i=2;i<=N;i++){
    calc(i);
    data[i]=(struct dat){dis[i],i};
  }

  qsort(data+1,N,sizeof(data[1]),comp);

  for(i=1;i<=N;i++){
    if(data[i].dist!=dis[data[i].num]) data[i].dist=dis[data[i].num];
    if(data[i].dist<=K) continue;
    
    write=data[i].num;
    for(j=1;j<K;j++){
      write=tele[write];
    }
    //printf("write=%d\n",write);
    tele[write]=1;
    m++;
    recalc(write,1);
    /*printf("dist=");
    for(j=1;j<=N;j++) printf("%d%c",dis[j],j==N?'\n':' ');
    printf("parent=");
    for(j=1;j<=N;j++) printf("%d%c",tele[j],j==N?'\n':' ');*/
  }

  printf("%d\n",m);

  return 0;
}

int calc(int n){
  if(n!=1 && dis[n]==0) dis[n]=calc(tele[n])+1;
  return dis[n];
}

void recalc(int n,int dist){
  int i;
  if(dis[n]<dist) return;
  dis[n]=dist;
  for(i=0;i<child_num[n];i++) recalc(child_list[n][i],dist+1);
}

int comp(const void *p1,const void *p2){
  struct dat n1,n2;
  n1=*(struct dat *)p1;
  n2=*(struct dat *)p2;
  return n2.dist-n1.dist;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;
	cin >> s;

	int ans = 0;
	bool check = true;
	int b = 0, f = (int)s.size()-1;
	while(b <= f){
		if(s[b] == s[f]){
			b++, f--;
			continue;
		}else if(s[b] == 'x'){
			b++, ans++;
			continue;
		}else if(s[f] == 'x'){
			f--, ans++;
			continue;
		}else{
			check = false;
			break;
		}
	}

	if(check)
		cout << ans << endl;
	else
		cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k,ct=0;
    cin>>a>>b>>c>>k;
    while(k>0)
    {
        if(k>=a)
        {
            ct=a;
            k=k-a;
        }
        else
        {
            ct=k;
            k=0;
        }
        if(k>=b)
            k=k-b;
        else
            k=0;
        if(k>=c)
        {
            ct=ct-c;
            k=k-c;
        }
        else
        {
            ct=ct-k;
            k=0;
        }

    }

    cout<<ct;
    return 0;

}

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

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < M; i++) cin >> B[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	int sum = 0,ans=0;
	for (int i = 0; i < N; i++,sum=0) {
		for (int j = 0; j < M; j++) {
			sum += A[i][j] * B[j];
		}
		if (sum + C > 0) ans++;
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <unistd.h>

using namespace std;

typedef pair<int,int> ii;

const int MAXN = 10004;

int n,k;
int p[MAXN*2];
stack<int> s;
set<ii> nodes;
bool visited[MAXN*2];
int scc[MAXN*2];

int other(int a){
    if(a>=MAXN) return a-MAXN;
    return a+MAXN;
}

void dfs1(int node){
    if(visited[node]) return;
    visited[node]=true;
    auto it=nodes.upper_bound(ii(p[node]-k, 2*MAXN));
    for(;it!=nodes.end() && it->first<p[node]+k;){
        if(it->second==node){
            it++;
        }else{
            int nxt=it->second;
            nodes.erase(it);
            dfs1(other(nxt));
            it=nodes.upper_bound(ii(p[node]-k, 2*MAXN));
        }
    }
    s.push(node);
}

void dfs2(int node, int start){
    if(scc[node]!=-1) return;
    scc[node]=start;
    auto it=nodes.upper_bound(ii(p[other(node)]-k, 2*MAXN));
    for(;it!=nodes.end() && it->first<p[other(node)]+k;){
        if(it->second==other(node)){
            it++;
        }else{
            int nxt=it->second;
            nodes.erase(it);
            dfs2(nxt, start);
            it=nodes.upper_bound(ii(p[other(node)]-k, 2*MAXN));
        }
    }
}


bool ok(int g){
    k=g;
    nodes.clear();
    for(int i=0;i<n;++i){
        nodes.emplace(p[i], i);
        nodes.emplace(p[MAXN+i], MAXN+i);
    }
    fill(visited, visited+MAXN*2, false);
    fill(scc, scc+MAXN*2, -1);
    for(int i=0;i<n;++i){
        if(!visited[i]){
            dfs1(i);
        }
        if(!visited[i+MAXN]){
            dfs1(i+MAXN);
        }
    }
    nodes.clear();
    for(int i=0;i<n;++i){
        nodes.emplace(p[i], i);
        nodes.emplace(p[MAXN+i], MAXN+i);
    }
    while(!s.empty()){
        int i=s.top();
        s.pop();
        if(scc[i]==-1) dfs2(i, i);
    }
    for(int i=0;i<n;++i){
        if(scc[i]==scc[MAXN+i]){
            return false;
        }
    }
    return true;
}


int main(){
    scanf("%d", &n);
    for(int i=0;i<n;++i){
        scanf("%d%d", &p[i], &p[i+MAXN]);
    }
    int lo=0,hi=1000000009;
    while(lo<hi){
        int mid=lo+(hi-lo+1)/2;
        if(ok(mid)){
            lo=mid;
        }else{
            hi=mid-1;
        }
    }
    printf("%d", lo);
}


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

#define N 100010
int n;
struct Graph {
	struct node {
		int to, nx, w;
		node () {}
		node (int to, int nx, int w) : to(to), nx(nx), w(w) {}
	}a[N << 1];
	int head[N], pos;
	void init() {
		memset(head, 0, sizeof head);
		pos = 0;
	}
	void add(int u, int v, int w) {
		w &= 1;
		a[++pos] = node(v, head[u], w); head[u] = pos;
		a[++pos] = node(u, head[v], w); head[v] = pos;
	}
}G;
#define erp(u) for (int it = G.head[u], v = G.a[it].to, w = G.a[it].w; it; it = G.a[it].nx, v = G.a[it].to, w = G.a[it].w)

int res[N];
void DFS(int u, int fa) {
	erp(u) if (v != fa) {
		if (w & 1) {
			res[v] = res[u] ^ 1;
		} else {
			res[v] = res[u];
		}
		DFS(v, u);
	}
}

int main() {
	while (scanf("%d", &n) != EOF) {
		G.init();
		for (int i = 1, u, v, w; i < n; ++i) {
			scanf("%d%d%d", &u, &v, &w);
			G.add(u, v, w);
		}
		res[1] = 0;
		DFS(1, 1);
		for (int i = 1; i <= n; ++i) {
			printf("%d\n", res[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#define ll long long
#define IOS std::ios::sync_with_stdio(false);

using namespace std;
const int inf = 0x3f3f3f3f;
const ll mod =  1e9 + 7;

int main()
{
    IOS
    string a,b;
	cin>>a>>b;
	a = a + a;
	for(int i=0,j=0;i<a.size();i++)
	{
		if(a[i] == b[j])
		{
			j++;
		}
		else
		{
			j = 0;
		}
		if(j == b.size())
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;

    return 0;
}


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

int main(){
  string s;
  int tot = 700;
  
  cin >> s;
   if (s[0] == 'o'){
    tot += 100;
  }
  if (s[1] == 'o'){
    tot += 100;
  }
  if (s[2] == 'o'){
    tot += 100;
  }
  cout << tot << endl;
}

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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 1e5 + 5, inf = 2e9;
const ll mod = 1e9 + 7;

vector<pair<int, ll>> v[3];

int main()
{
    VIC
    int n;
    cin >> n;
    for (auto &i : v)
    {
        for (int j = 0; j < n; j++)
        {
            int x;
            cin >> x;
            i.emplace_back(x, 0);
        }
        sort(i.begin(), i.end());
    }
    for (int i = 0; i < n; i++)
    {
        int low = 0, high = n - 1, mid, ans = n;
        while (high >= low)
        {
            mid = (high + low) / 2;
            if (v[2][mid].first > v[1][i].first)
                ans = mid,
                high = mid - 1;
            else
                low = mid + 1;
        }
        v[1][i].second = n - ans;
    }
    ll tot = 0;
    for (int i = 1; i < n; i++)
        v[1][i].second += v[1][i - 1].second;
    for (int i = 0; i < n; i++)
    {
        int low = 0, mid, high = n - 1, ans = n;
        while (high >= low)
        {
            mid = (high + low) / 2;
            if (v[1][mid].first > v[0][i].first)
                high = mid - 1,
                ans = mid;
            else
                low = mid + 1;
        }
        if (ans == 0)
            tot += v[1][n - 1].second;
        else
            tot += v[1][n - 1].second - v[1][ans - 1].second;
    }
    cout << tot;
    return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define nl "\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define trav(x) for(auto& i: x)

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

	int a, b;
	cin >> a >> b;
	if(a > 9 || b > 9) {
		cout << -1 << nl;
	} else {
		cout << a * b << nl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

double EPS = 0.000001;

using namespace std;

bool ok[16130];

int main()
{
  REP(i, 127)
    ok[i*i] = true;

  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N);
  REP(i,N) REP(j, D)
  {
    int x;
    cin >> x;
    X[i].push_back(x);
  }
  int ans = 0;
  REP(i,N-1)
    for (int j=i+1;j<N;j++)
    {
      int d = 0;
      REP(k,D)
      {
        d += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      if (ok[d]) ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n ,ans = 0;
	cin>>n;
	n*=2;
	int a[n];
	for(int i =0 ; i < n ;i ++)
	{
		cin>>a[i];
	}
	sort(a,a + n);
	for(int i = 0 ; i < n;i +=2)
	{
		ans+=min(a[i],a[i + 1]);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){

  string S;
  cin>>S;
  int count=0;
  int ans=0;
  for(int i=0;i<=(int)S.length()-1;i++){
  
    if(S[i]=='A'||S[i]=='T'||S[i]=='C'||S[i]=='G'){
    
      count++;
    }
    else{
    
      if(count>ans)ans=count;
      count=0;
    }
  }
  if(ans<count)ans=count;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        String a = sc.next();
        char c[] = a.toCharArray();
        int len = c.length;

        long cnt[] = new long[26];
        for (int i = 0; i < len; i++) {
            for (int j = 'a'; j <= 'z'; j++) {
                if (c[i] == j) {
                    cnt[j - 'a']++;
                }
            }
        }

        long max = len * (len - 1L) / 2;
        for (int i = 0; i < 26; i++) {
            max -= (cnt[i] * (cnt[i] - 1) / 2);
        }
        System.out.println(max + 1);
    }

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


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

#define  loop(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  loopeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         1000000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)
#define TEST_CASE(t)      for(ll int z=1;z<=t;z++)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9
#define  inf                     0x7fffffff

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define    lfl                        long double
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
#define  ret                     return

///*/////////////////// /// *
/*//    author-joydip007x  ///  *

///     Date<^>XX/08/2018    *///

ll n,k;
char p[sz] , q[sz] ; string s;
bool zere=false;
int main()
{


    cin>>n>>k>>s;
    ll L=0, R=n;
    for(int i=1 ; i<=k ; i++)
    {
        cin>>p[i]>>q[i];
    }
    for(int i=k ; i ; i--){

        if(  q[i]=='L')
        {
            if( L<n  and s[L]==p[i]  ) ++L;
            if( R<n and  s[R]==p[i]  ) ++R;
         }
        else{
            if( L>0 and s[L-1]==p[i] ) --L;
            if(R>0 and  s[R-1]==p[i]  ) --R;
        }
    }
    ///cout<<L<<" : "<<R<<endl;
    cout<<R-L;

}


Measured memory_bytes: 1028
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  ll n;
  cin >>n;
  cout <<fixed<<setprecision(3)<<n*2*3.14159<<endl;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

void solve(){
    int a[5];
    for(int i = 0 ; i < 5; i++) cin >> a[i];
    for(int i = 0; i < 5; i++){
        if(!a[i]){
            cout << i+1 << '\n';
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3604
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#define pb push_back
using namespace std;

namespace Header_Template {
  typedef long long li;
  template<class T>inline void read(T &x) {
    x = 0;
    T tmp = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-') c = getchar();
    if (c == '-') tmp = -1, c = getchar();
    while (c >= '0' && c <= '9')
      x = (x << 1) + (x << 3) + c - '0', c = getchar();
    x *= tmp;
  }
  template<class T>inline void Max(T &x, T y) {
    if (y > x) x = y;
  }
  template<class T>inline void Min(T &x, T y) {
    if (y < x) x = y;
  }
}
using namespace Header_Template;

const int N = 2e5 + 10;
int n, a[N];

int main(void) {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  sort(a + 1, a + 1 + n);
  int ansx = a[n], ansy;
  double tmp = 1.0 * ansx / 2.0, d = 1e16;
  for (int i = 1; i < n; ++i)
    if (fabs(tmp - a[i]) < d) {
      d = fabs(tmp - a[i]);
      ansy = a[i];
    }
  printf("%d %d\n", ansx, ansy);
  
  return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ll sum = 0 ;
    string s ;
    cin >> s ;

    for (int i = 0; i < s.size(); i++) {
        sum += (s[i] - '0') ;
    }
    if (sum % 9 == 0)   cout << "Yes\n" ;
    else    cout << "No\n" ;

    return 0 ;
}


Measured memory_bytes: 3680
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

const int DI[4] = {1, 0, -1, 0};
const int DJ[4] = {0, 1, 0, -1};

char buf[100][100];
int dist[100][100];
const int INF = 10000000;

int main(void) {
  int nRow, nCol;
  scanf("%d%d", &nRow, &nCol);
  REP(i, nRow) {
    scanf("%s", buf[i]);
  }
  REP(i, nRow) REP(j, nCol) {
    dist[i][j] = INF;
  }
  queue<pair<int,int> > q;
  q.push(make_pair(0, 0));
  dist[0][0] = 0;
  while(!q.empty()) {
    pair<int,int> cur = q.front(); q.pop();
    int ci = cur.first;
    int cj = cur.second;
    REP(d, 4) {
      int ni = ci + DI[d];
      int nj = cj + DJ[d];
      if(ni >= 0 && ni < nRow && nj >= 0 && nj < nCol && dist[ni][nj] == INF && buf[ni][nj] == '.') {
        q.push(make_pair(ni, nj));
        dist[ni][nj] = dist[ci][cj] + 1;
      }
    }
  }
  int res = 0;
  REP(i, nRow) REP(j, nCol) {
    if(buf[i][j] == '.') {
      ++res;
    }
  }
  // cerr << dist[nRow-1][nCol-1] << endl;
  res -= dist[nRow-1][nCol-1]+1;
  printf("%d\n" , dist[nRow-1][nCol-1] == INF ? -1 : res);
  
  return 0;
}


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

int main(){
    string s ;
    cin >> s ;
    int n = s.size() ;
    vector<int> ans(n,0) ;
    int count = 1 ;
    for (size_t i = 0; i < n - 1; i++)
    {
        if (s.at(i) == s.at(i+1))
        {
            /* code */
            count ++ ;
        }
        else
        {
            if (s.at(i) == 'R')
            {
                ans.at(i) += count / 2 + count % 2 ;
                ans.at(i+1) += count / 2 ;
            }else
            {
                ans.at(i - count) += count / 2 ;
                ans.at(i - count + 1) += count / 2 + count % 2 ;
            }
            count = 1 ;

            
        }
        
    }
    ans.at(n-1 - count) += count / 2 ;
    ans.at(n-1 - count + 1) += count / 2 + count % 2 ;
    for (size_t i = 0; i < n-1; i++)
        {
            /* code */
            cout << ans.at(i) << " " ;
        }
        cout << ans.at(n-1) << endl ;
        
}

Measured memory_bytes: 1024
#include <iostream> 
#include <numeric> 
#include <cstdlib> 
#include <climits> 
#include <cmath> 
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <memory> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <string> 
#include <vector> 
using namespace std; 

#define rep(i, n) for(int i = 0; i < n; i++) 
#define rep2(i, m, n) for(int i = m; i < n; i++) 
const double EPS = 1E-9; 
typedef long long ll; 
typedef pair<int, int> P; 
typedef pair<int, P> PP; 
typedef complex<double> xy_t; 
const int INF = 1 << 30; 

int n;
string a[20];
string b[20];
map<string, int> memo;

string convert(const string& s, int id){
  string res;
  int asz = a[id].size();
  int ssz = s.size();
  rep(i, ssz){
    if(i > ssz - asz){
      res += s[i];
    }else{
      bool ok = true;
      rep(j, asz){
	if(s[i+j] != a[id][j]) ok = false;
      }
      if(ok){
	res += b[id];
	i += asz - 1;
      }else{
	res += s[i];
      }
    }
  }
  //cout << s << " *** " << res << endl;
  return res;
}

int bfs(const string &s, const string &t){
  memo.clear();
  memo[s] = 1;
  string a, b;
  queue<string> que;
  que.push(s);

  while(!que.empty()){
    a = que.front();
    que.pop();
    if(a == t) return memo[a] - 1;
    rep(i, n){
      b = convert(a, i);
      if(b.size() <= t.size() && memo[b] == 0){
	memo[b] = memo[a] + 1;
	que.push(b);
      }
    }
  }
  return -1;
}

int main(){
  string c, d;
  while(cin >> n && n){
    rep(i, n){
      cin >> a[i] >> b[i];
    }
    cin >> c >> d;
    cout << bfs(c, d) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
    char a,b,c,d;
    scanf("%c%c%c%c",&a,&b,&c,&d);
    if(a==b && b==c && c==d && a==d)
        printf("No\n");
    else if(a==c && b==d)
        printf("Yes\n");
    else if(a==d && b==c)
        printf("Yes\n");
    else if(a==b && c==d)
    printf("Yes\n");
     else
        printf("No\n");
}


Measured memory_bytes: 128
#include<stdio.h>

int A[1000000], n;
int binarySearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while(left < right) {
		mid = (left+ right) / 2;
		if(key == A[mid]) return 1;
		if(key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

int main() {
	int i, q, k, sum = 0;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	
	scanf("%d", &q);
	for(i = 0; i < q; i++) {
		scanf("%d", &k);
		if(binarySearch(k)) sum++;
	}
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,rem;cin>>n;n--;
  string ans;
  while(n>-1) {
    rem=n%26,n/=26;
    ans+='a'+rem;
    n--;
  }
  reverse(ALL(ans));print(ans);
  return 0;
}

Measured memory_bytes: 3656
S = input()
Q = int(input())
is_norm = True  # Sが元の順番かどうか
s_head = ""     # 元のSに対して先頭側につく文字列
s_tail = ""     # 元のSに対して末尾側につく文字列

for i in range(0, Q):
    query = input().split()
    if int(query[0]) == 1:
        is_norm = not is_norm
    else:
        if is_norm:
            if int(query[1]) == 1:
                s_head = query[2] + s_head
            else:
                s_tail = s_tail + query[2]
        else:
            if int(query[1]) == 1:
                s_tail = s_tail + query[2]
            else:
                s_head = query[2] + s_head

if is_norm:
    print(s_head + S + s_tail)
else:
    print(s_tail[::-1] + S[::-1] + s_head[::-1])

Measured memory_bytes: 4440
open System

let [|N;Y|] = stdin.ReadLine().Split(' ') |> Array.map int


let printS (a,b,c) = printfn "%d %d %d" a b c

seq { for i in 0..N do
        for j in 0..(N-i)
            -> (i,j,N-i-j)}
|> Seq.tryFind (fun (a,b,c) -> a * 10000 + b * 5000 + c * 1000 = Y)
|> (fun opt -> if Option.isSome opt then Option.get opt else (-1,-1,-1))
|> printS

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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;

int N, A[MAX];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    multiset<int> s;
    for(int i=0;i<N;i++){
        auto itr = s.lower_bound(A[i]);
        if(itr == s.begin()){
            s.insert(A[i]);
        } else {
            s.erase(--itr);
            s.insert(A[i]);
        }
    }

    cout << s.size() << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max<R>(x, 0.0));}

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

// Problem Specific Parameter:
template <int depth>  struct Segment_tree {
	const static int h = depth;
	const static int n = 1 << h;

	using T = long long;
	T data[2 * n];
	const T out = 0LL;

	inline T vmerge(T l, T r) {return l + r;}

	void init() {
		fill_n(data, 2 * n, out);
	}

	void update(int p, T x) { // set value at position p
		data[p += n] += x;
		for (; p > 1; p >>= 1) {
			data[p >> 1] = vmerge(data[p], data[p ^ 1]);
		}
	}

	T query(int l, int r) {  // sum on interval [l, r)
		T resl = out, resr = out;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) resl = vmerge(data[l++], resl);
			if (r & 1) resr = vmerge(resr, data[--r]);
		}
		return vmerge(resl, resr);
	}
};

Segment_tree<17> rsq;

int main(void) {
	int n, q;
	cin >> n >> q;

	rsq.init();

	rep(loop, q) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com)
			cout << rsq.query(x, y + 1) << endl;
		else
			rsq.update(x, y);
	}
	return 0;
}

Measured memory_bytes: 5152
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanString()
	ans := 0
	for i := 0; i < len(n); i++ {
		a, _ := strconv.Atoi(string(n[i]))
		ans += a
	}
	
	if ans%9 == 0 {
		fmt.Fprintln(wr, "Yes")
	} else {
		fmt.Fprintln(wr, "No")
	}
}


Measured memory_bytes: 2520
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a!=b&&b==c)
  cout << a <<endl;
    else if(b!=a&&a==c)
  cout << b <<endl;
    else if(c!=b&&b==a)
  cout << c <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>

using namespace std;
using ll = long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;







int main(){
    string s;
    getline(cin, s); 
    int n = s.size();
    
    int f = s[0] - '0';
    
    vector<int> prev(2019,0);
    vector<int> next(2019,0);
    
    prev[f] = 1;
    
    int sum = 0;
    for(int i = 1; i < n;i++){
        int c = s[i] - '0';
        next = vector<int> (2019,0);
        next[c] = 1;
        for(int j = 0; j< 2019; j++){
            int count = prev[j];
            if (j==0){
                sum += count;
            }
            int nt = (10*j+c)%2019;
            next[nt] += count;
        }
        prev.swap(next);
    }

    sum += prev[0];
    cout << sum;

}









Measured memory_bytes: 3728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

int main(){
    int n;
    cin >> n;
    int c = 0;
    rep(i,n){
        if((i+1)%2==1){
            c++;
        }
    }
    cout.precision(10);
    cout << (double)(c)/(double)(n) << endl;
    return 0;
}

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

int main() {
    int N, T, S;
    cin >> N >> T >> S;
    int answer = 0;
    vector<int> dp(T + 1, 0);
    for(int i = 1; i <= N; ++i) {
        int A, B;
        cin >> A >> B;
        for(int t = T; t >= B; --t) {
            if(t - B < S && S < t) continue;
            dp[t] = max(dp[t], dp[t - B] + A);
            answer = max(answer, dp[t]);
        }
//         for(auto d:dp)cout<<" "<<d;cout<<endl;
    }
    cout << answer << endl;
}

Measured memory_bytes: 1204
package main

import (
	"fmt"
	"math"
)

/**
isprime(x)
  if x == 2
    return true

  if x < 2 または x が偶数
    return false

  i = 3
  while i <= x の平方根
    if x が i で割り切れる
      return false
    i = i + 2

 return true
 */

func isPrime(x int) bool {
	if x == 2 {
		return true
	} else if x < 2 || x % 2 == 0 {
		return false
	}
	sqrt := int(math.Floor(math.Sqrt(float64(x))))
	for j := 3; j <= sqrt; j = j + 2 {
		if x % j == 0 {
			return false
		}
	}
	return true
}




func main (){
	var n int
	cnt := 0
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		if isPrime(x) {
			cnt ++
		}
	}
	fmt.Println(cnt)
}



Measured memory_bytes: 1772
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

string s;
ll k;

void init()
{
}

void solve()
{
    if(k == 1) cout << s[0] << endl;
    else{
        bool allone = true;
        REP(i, k){
            if(s[i] != '1'){
                cout << s[i] << endl;
                return;
            }
        }
        cout << '1' << endl;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s >> k;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, k;
	cin >> n >> k;
	
	vector<ll> v(n + 1);
	vector<double> dp(n + 1);
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	
	for(int i = 1; i <= n; i++){
		dp[i] = 1.0 * v[i] * (v[i] + 1) / 2.0;
		dp[i] = 1.0 * dp[i] / v[i];
		dp[i] += dp[i - 1];
	}
	
	double ans = 0.0;
	
	for(int i = 1; i + k - 1 <= n; i++){
		int lo = i, hi = i + k - 1;
		double sum = dp[hi] - dp[lo - 1];
		ans = max(ans, sum);
	}
	
	cout << setprecision(10) << fixed;
	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

const string YES = "Good", NO = "Bad";

int main() {
    string S;
    cin >> S;
    char temp = S[0];
    REP(i, 1, 4) {
        if (temp == S[i]) {
            cout << NO << endl;
            return 0;
        }
        temp = S[i];
    }
    cout << YES << endl;

    return 0;
}

Measured memory_bytes: 256