akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define ll long long
#define M 1000000007
#define mod 998244353
#define fs first
#define sc second

int main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int n,i,j,k,a;
  double s=0;
  cin>>n;
  for(i=1;i<=n;i++)
  {
    if(i%2==1)
      s++;
  }
  cout<<fixed<<setprecision(13)<<s/n*1.0;
  return 0;
}

Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Chars, Bytes};

#[allow(dead_code)]
type Pi = (i32, i32);
#[allow(dead_code)]
fn pri<T: std::fmt::Display>(x: T) {
    println!("{}", x);
}

#[fastout]
fn main() {
    input!{
        n: i64,
    }
    let mut ans = 0;
    for i in 1..n+1 {
        if i % 3 != 0 && i % 5 != 0 {ans += i;}
    }
    pri(ans);
}

Measured memory_bytes: 2200
loop do
	h, w = gets.split.map{ |s| s.to_i }
	break if h == 0 && w == 0
	h.times do |y|
		w.times do |x|
			if (x + y) % 2 == 0
				print "#"
			else
				print "."
			end
		end
		puts
	end
	puts
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

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

    int k;
    cin >> k;
    ll sum = 0;
    FOR (a, 1, k + 1)
        FOR (b, 1, k + 1)
            FOR (c, 1, k + 1)
                sum += gcd(gcd(a, b), c);
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		String s = String.valueOf(n);
		long a = Integer.parseInt(s.charAt(0)+"");
		long l = s.length();
		boolean all = true;
		for(char c : s.toCharArray()) {
			if(c != '9') {
				all = false;
			}
		}
		int wa = 0;
		for(char c : s.toCharArray()) {
			wa += (c - '0');
		}
		if(l == 1) {
			System.out.println(s);
			return;
		}
		System.out.println(all ? Math.max(wa, 9L*l) : Math.max(9*(l-1)+a-1, wa));
	}
}


Measured memory_bytes: 22612
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;

#define INF 1e9

int main(){
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  long long score;
  long long a[x];
  long long b[y];
  long long c[z];
  for(int i=0;i<x;i++){
    cin >> a[i];
    a[i] = -1*a[i];
  }
  for(int i=0;i<y;i++){
    cin >> b[i];
    b[i] = -1*b[i];
  }
  for(int i=0;i<z;i++){
    cin >> c[i];
    c[i] = -1*c[i];
  }

  sort(a,a+x);
  sort(b,b+y);
  sort(c,c+z);

  priority_queue<long long> q;

  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      for(int l=0;l<z;l++){
        q.push(-1*(a[i]+b[j]+c[l]));
        if((i+1)*(j+1)*(l+1)>k){
          break;
        }
      }
    }
  }


  for(int i=0;i<k;i++){
    score = q.top();
    q.pop();
    cout << score << endl;
  }


  return 0;
}


Measured memory_bytes: 18792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

h, w = LI()
if w == 1 or h == 1:
    print(1)
else:
    print((h * w + 1) // 2)


Measured memory_bytes: 39664
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int r,c,k;
ll v[3000][3000];
ll dp[3][3000][3000];
ll mx[3][3000][3000];
int main(){
	ios::sync_with_stdio(0);
	memset(v,0,sizeof(v));
	cin>>r>>c>>k;
	rep(i,k){
		int x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		v[x][y]=z;
	}
	rep(i,r)
	rep(j,c){
		dp[0][i][j]=v[i][j];
		if(i)
		dp[0][i][j]+=max(dp[0][i-1][j],max(dp[1][i-1][j],dp[2][i-1][j]));
		if(j){
			dp[0][i][j]=max(dp[0][i][j],dp[0][i][j-1]);
		}
		if(j)
		dp[1][i][j]=max(dp[1][i][j-1],dp[0][i][j-1]+v[i][j]);
		if(j)
		dp[2][i][j]=max(dp[2][i][j-1],dp[1][i][j-1]+v[i][j]);
	}
	cout<<max(dp[2][r-1][c-1],max(dp[1][r-1][c-1],dp[0][r-1][c-1]));
	re 0;
}

Measured memory_bytes: 284864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using V = vector<int>;
using VV = vector<V>;
using P = pair<int, int>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;


template<typename T>
struct RMQ {
  vector<T> v;
  VV st; // sparse table
  int op(int a, int b) { return v[a]==v[b] ? min(a, b) : (v[a]<v[b] ? a : b); } 
  void init(const vector<T> &_v) {
    v = _v;
    int n = v.size();
    st = {V(n)}; iota(all(st[0]), 0);
    for (int j=1; 1<<j <= n; ++j) {
      int m = n-(1<<j)+1;
      st.push_back(V(m));
      rep(i, m) st[j][i] = op(st[j-1][i], st[j-1][i+(1<<(j-1))]);
    }
  }
  int index(int l, int r) { int d = 31-__builtin_clz(r-l); return op(st[d][l], st[d][r-(1<<d)]); }
  T query(int l, int r) { return v[index(l, r)]; }
};


V dall(1);
V tl, tour, dep;
vector<vector<tuple<int, int, int>>> G;
RMQ<int> R;
int tt = 0;

VV cd, ct;

void dfs(int &t, int u, int p=-1, int depth=0) {
  tour[t] = u;
  dep[t] = depth;
  tl[u] = t++;
  for (auto &[v, c, d] : G[u]) if (v != p) {
    cd[c].push_back(d);
    dall.push_back(d);
    ct[c].push_back(tt++);
    dfs(t, v, u, depth+1);
    cd[c].push_back(-d);
    dall.push_back(-d);
    ct[c].push_back(tt++);
  }
  tour[t] = p;
  dep[t] = depth-1;
  ++t;
}

int lca(int u, int v) {
  return tour[R.index(min(tl[u], tl[v]), max(tl[u], tl[v]))];
}


int main() {
  int n, q; cin >> n >> q;
  tl.assign(n, 0);
  tour.assign(2*n, 0);
  dep.assign(2*n, 0);
  G.assign(n, vector<tuple<int, int, int>>());
  cd.assign(n, V(1));
  ct.assign(n, V());

  rep(i, n-1) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --b;
    G[a].emplace_back(b, c, d);
    G[b].emplace_back(a, c, d);
  }

  int t = 0;
  dfs(t, 0);
  R.init(dep);

  auto cE = cd;
  for (auto &v : cE) for (auto &e : v) e = clamp(e, -1, 1);
  for (auto &v : cd) rep(i, v.size()-1) v[i+1] += v[i];
  for (auto &v : cE) rep(i, v.size()-1) v[i+1] += v[i];
  rep(i, dall.size()-1) dall[i+1] += dall[i];

  auto f = [&] (int x, int y, int u, int v) {
    int &i = tl[u];
    int &j = tl[v];
    int ix = lower_bound(all(ct[x]), i) - ct[x].begin();
    int jx = lower_bound(all(ct[x]), j) - ct[x].begin();

    int res = dall[j] - dall[i];
    res -= cd[x][jx] - cd[x][ix];
    res += (cE[x][jx] - cE[x][ix]) * y;
    return res;
  };

  rep(_, q) {
    int x, y, u, v; cin >> x >> y >> u >> v;
    --u, --v;
    int w = lca(u, v);
    int ans = f(x, y, w, u) + f(x, y, w, v);
    cout << ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 47524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  
  map<ll, ll> m;
  ll pro = 0;
  rep(i, 0, n) {
    ll a;
    cin >> a;
    if(a < 3200) m[a/400]++;
    else pro++;
  }
  
  ll siz = m.size();
  ll mini= 1;
  if(siz != 0) mini = siz;
  ll maxi = siz+pro;
  
  cout << mini << " " << maxi << "\n";

}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC125
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int T = int.Parse(s[2]);
            Console.WriteLine((T / A) * B);
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(){
	int t;
	while(~scanf("%d", &t)){
		if(t==1){
			printf("Hello World\n");
		}
		else if(t==2){
			int a, b;
			scanf("%d%d", &a, &b);
			printf("%d\n", a+b);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    long long m; cin >> m;
    vector<string> t(m);
    for (int i = 0; i < m; i++)
    {
        cin >> t[i];
    }
    //準備終わり
    vector <long long> ans(n);   
    string now;
    for (int i = 0; i < n; i++)
    {
        now = s[i];
        for (int j = 0; j < n; j++)
        {
            if (s[j] == now)
            {
                ans[i] = ans[i] + 1;
            }
            
        }
        for (int j = 0; j < m; j++)
        {
            if (t[j] == now)
            {
                ans[i] = ans[i] - 1;
            }
            
        }
    }
    long long final = 0; 
    for (int i = 0; i < n; i++)
    {
        final = max(final,ans[i]);
    }
    cout << final << endl;
}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))

na = {}
for i in a:
    x = i - 1
    y = i
    z = i + 1
    na.setdefault(x, 0)
    na.setdefault(y, 0)
    na.setdefault(z, 0)
    na[x] += 1
    na[y] += 1
    na[z] += 1

print(max(na.values()))


Measured memory_bytes: 18796
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  for (int i=0; i<N; i++) cin >> S[i];
  vector<int> next(4,0);
  
  for (int i=0; i<N; i++) {
    if (S[i] == 'P') next[0]++;
    else if (S[i] == 'W') next[1]++;
    else if (S[i] == 'G') next[2]++;
    else if (S[i] == 'Y') next[3]++;
  }
  int cnt = 0;
  for (int i=0; i<4; i++) {
    if (next[i]) cnt++;
  }
  if (cnt == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
}

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

string s;

int main(void){
  cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i == j){
	continue;
      }
      else{
	if(s[i] == s[j]){
	  cout << "no" << endl;
	  return 0;
	}
      }
    }
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    int a = 0;
    int b = 0;
    for (int i = 0;i < n;i++){
        int k;
        scanf("%d",&k);
        if (k%4==0){
            a++;
        }
        else if (k%2 == 0){
            b++;
        }
    }
    if (n > 1+a*2+b){
        printf("No\n");
    }
    else if (n == 1+a*2+b&&b!=0){
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define ll long long

ll min(ll a,ll b){
  if(a>b){
    return b;}
  else{
    return a;}
}

int cmpfunc(const void *a,const void *b){
  ll ans= (*(ll*)a-*(ll*)b);
  if(ans<0) return -1;
  if(ans==0) return 0;
  else return 1;
}

int main(){
  ll n;
  ll k;
  scanf("%lld%lld",&n,&k);
  ll a[200100];
  for(ll i=0;i<n;i++){
    scanf("%lld",&a[i]);}

  qsort(a,n,sizeof(ll),cmpfunc);
  
  ll left0 = 0;
  while(left0<n && a[left0]<0){
    left0++;}
  ll left1 = left0;
  //printf("%d\n",left0);
  while(left1 < n && a[left1]==0){
    left1++;}
  ll fu,zero,sei;
  fu = left0*(n-left1);
  zero = (left1-left0)*(left0+n-left1)+(left1-left0)*(left1-left0-1)/2;
  sei = (n-left1)*(n-left1-1)/2 + left0*(left0-1)/2;
  //printf("%d\n",fu+zero);

  ll ans;

  if(k <= fu){
    ll left = -1000000000000000001;//always false
    ll right = 0;//always true
    /*
    if(k==1){
      ans = a[0]*a[n-1];
      printf("%lld\n",ans);
      return 0;}
    */
    while(left+1 !=right){
      ll count = 0;
      ll mid = (left+right)/2;
      //mid 以下の個数
      ll indfu=0;
      for(ll i=left1;i<n;i++){
	while(a[i]*a[indfu]<=mid){
	  indfu++;}
	count += indfu;}
      if(count>=k){
	right = mid;}
      else{
	left = mid;}
    }
    ans = right;}

  else if(k <= fu+zero){
    ans = 0;}

  else{
    ll left = 0;//always false
    ll right = 1000000000000000000;//always true
    /*
    if(k==fu+zero+1){
      if(left0>=2){
	ans = min(a[left1]*a[left1+1],a[left0-1]*a[left0-2]);}
      else{
	ans = a[left1]*a[left1+1];}
      printf("%lld\n",ans);
      return 0;}
    */
    while(left+1 !=right){
      ll count = 0;
      ll mid = (left+right)/2;
      //mid 以下の個数
      ll indsei=left1;
      for(ll i=n-1;i>=left1;i--){
	while(indsei<n && a[i]*a[indsei]<=mid){
	  indsei++;}
	if(indsei>i){
	  count += indsei-left1-1;}
	else{
	  count += indsei-left1;}
      }
      //printf("%lld %lld ",mid,count);
      ll indfu = left0-1;
      for(ll i=0;i<left0;i++){
	while(indfu >= 0 && a[i]*a[indfu]<=mid){
	  indfu--;}
	if(indfu<i){
	  count += left0-indfu-2;}
	else{
	  count += left0-indfu-1;}
      }
      if(count/2+fu+zero >= k){
	right = mid;}
      else{
	left = mid;}
      //printf("%lld\n",count);
    }
    ans=right;}

  //print
  printf("%lld\n",ans);
  //printf("%lld\n",fu+zero);

  return 0;
}


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

void Main() {
    // input
    int a;
    cin >> a;

    // translate
    int ans = a + a * a + a * a * a;


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<char,int> m;
	while(n--){
		string str;
		cin>>str;
		if(str[0]=='A'){
			m['A']++;
		}else if(str[0]=='T'){
			m['T']++;
		}else if(str[0]=='R'){
			m['R']++;
		}else{
			m['W']++;
		}
	}
	cout<<"AC x "<<m['A']<<"\n";
	cout<<"WA x "<<m['W']<<"\n";
	cout<<"TLE x "<<m['T']<<"\n";
	cout<<"RE x "<<m['R']<<"\n";
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int mod = 2019;

int main() {
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  int amari[220000];
  int ans = 0;
  map<int,int> mp;
  mp[0]++;
  int ten = 1;
  rep(i,s.size()) {
    if(i==0) {
      string t = "";
      t += s[i];
      int m = stoi(t);
      mp[m]++;
      amari[i] = m;
      continue;
    }
    string t = "";
    t += s[i];
    int m = stoi(t);
    ten *= 10;
    ten %= mod;
    int ten2 = ten;
    ten2 *= m;
    ten2 %= mod;
    ten2 += amari[i-1];
    ten2 %= mod;
    amari[i] = ten2;
    mp[amari[i]]++;
  }
  for(auto p : mp) {
    int m = p.second;
    ans += m*(m-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a;
  int count=0;
  int countt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==0){
      countt++;
      if(a%3==0){
        count++;
      }
      else if(a%5==0){
        count++;
        
      }
      else{
        cout<<"DENIED"<<endl;
        return 0;
      }
    }
    
  }
 
  cout<<"APPROVED"<<endl;


  
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long gcd(long long a,long long b)
{
	if(a == 0)
	{
		return b;
	}
	while(b != 0)
	{
		if(a > b) a = a - b;
		else b = b - a;
	}
	return a;
}

int main()
{
	long long a,b;
	while(cin>>a>>b)
	{

		cout<<gcd(a,b)<<endl;
		
		
		//cout<<a + b<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
def solve():
    s = [int(x) for x in input()]
    n = len(s)
    m = int(input())
    dp = [[[0] * 5 for _ in range(2)] for _ in range(n + 1)]
    dp[0][0][0] = 1

    for i in range(n):
        for k in range(m + 1):
            dp[i + 1][1][k + 1] += dp[i][1][k] * 9  # add 1-9
            dp[i + 1][1][k] += dp[i][1][k]  # add 0
            if s[i] > 0:
                dp[i + 1][1][k + 1] += dp[i][0][k] * (s[i] - 1)  # add lower s[i]
                dp[i + 1][1][k] += dp[i][0][k]  # add 0
                dp[i + 1][0][k + 1] += dp[i][0][k]  # add s[i]
            else:
                dp[i + 1][0][k] += dp[i][0][k]  # add s[i] = 0
    print(dp[n][0][m] + dp[n][1][m])


solve()


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

int main(){
    int N,T,A;
    cin>>N>>T>>A;
    vector<int> H(N);
    for(int i=0;i<N;i++){
        int x; cin>>x;
        H[i]=abs(T*1000-x*6-A*1000);
    }

    int a=100000000;
    for(int i=0;i<N;i++){
        a=min(a,H[i]);
    }
    for(int i=0;i<N;i++){
        if(a==H[i]){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
<?php
  while (true) {
    $str = trim(fgets(STDIN));
    if ($str == 0) {
      return;
    }
    $sum = 0;
    for($i = 0; $i < strlen($str); $i++) {
      $sum += $str[$i];
    }
    print ($sum . "\n");
  }
?>

Measured memory_bytes: 6564
/*
 Author: nilesh8757
 */
#include<bits/stdc++.h>
 using namespace std;

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;


clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const int N=505;
bool vis[N][N];
int a[N][N];
int h,w;

int32_t main()
{
  FIO

  cin>>h>>w;
  rep(i,1,h)
  {
  	rep(j,1,w)
  	 {
  	 	cin>>a[i][j];
  	 }
  }
  vii from,to;
  rep(i,1,h)
  {
  	rep(j,1,w)
  	{
       if(a[i][j]&1)
       {
       	  if(i+1<=h and a[i+1][j]&1)
       	  {
       	  	a[i][j]--; a[i+1][j]++;
       	  	from.pb({i,j}); to.pb({i+1,j});
       	  }
       	  else if(j+1<=w and a[i][j+1]&1)
       	  {
       	  	a[i][j]--; a[i][j+1]++;
       	  	from.pb({i,j}); to.pb({i,j+1});
       	  }
       	  else if(i+1<=h)
       	  {
       	  	a[i][j]--; a[i+1][j]++;
       	  	from.pb({i,j}); to.pb({i+1,j});
       	  }
       	  else if(j+1<=w)
       	  {
       	  	a[i][j]--; a[i][j+1]++;
       	  	from.pb({i,j}); to.pb({i,j+1});
       	  }
       }
  	}
  }
  
  cout<<from.size()<<endl;
  forn(i,from.size())
  {
  	cout<<from[i].ff<<" "<<from[i].ss<<" "<<to[i].ff<<" "<<to[i].ss<<endl;
  }
  timer();
  return 0;
}  

Measured memory_bytes: 8164
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  vll A(N);
  repeat(i,N){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  ll ans = 0;
  repeat(i,N/2){
    ans += 2*(A[(N+1)/2+i]-A[i]);
  }
  if(!(N&1)){
    ans += A[N/2-1]-A[N/2];
  }else{
    ans += max(A[N/2]-A[N/2+1],A[N/2-1]-A[N/2]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>

int main()
{
  long long n, m;
  scanf("%lld %lld", &n, &m);
  if (n >= m)
  {
    puts("0");
    return 0;
  }
  
  long long x[100000];
  long long l[100000];
  for (int i = 0; i < m; ++i)
  {
    scanf("%lld", x + i);
  }
  std::sort(x, x + m);
  for (int i = 0; i < m - 1; ++i)
  {
    l[i] = x[i + 1] - x[i];
  }
  std::sort(l, l + m - 1, std::greater<int>());
  printf("%lld\n", x[m - 1] - x[0] - std::accumulate(l, l + n - 1, 0));
  return 0;
}

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

#define PI 3.141592653589793238462643383279
typedef long long ll;
const long double EPS = 1e-9;
const ll MOD = 1e9+7;
#define N 111
int l[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(20);
    #ifdef LOCAL_TEST
    freopen("input.txt","r",stdin);
    #endif
    int n; cin >> n;
    int s = 0;
    for(int i=0;i<n;i++) cin >> l[i], s += l[i];
    sort(l, l + n);
    cout << ((2 * l[n - 1] < s) ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W, K;
char S[20][2000] = {};

int main() {
    cin >> H >> W >> K;
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) cin >> S[i][j];
    }

    int res = 1001001001;
    for(int k=0; k<(1 << (H - 1)); ++k) {
        int cnt = __builtin_popcount(k);
        //cout << k << '\n';
        vector<pair<int, int>> interval;
        for(int i=0; i<H; ++i) {
            int s = i;
            while(((k >> i) & 1) == 0 && i < H - 1) ++i;
            int t = i;
            interval.emplace_back(s, t);
        }

        vector<int> white(interval.size(), 0), white2(interval.size(), 0);
        for(int j=0; j<W; ++j) {
            for(int l=0; l<interval.size(); ++l) {
                int tmp = 0;
                for(int h=interval[l].first; h<=interval[l].second; ++h) tmp += S[h][j] - '0';
                if(tmp > K) {
                    cnt = 1001001001;
                } else {
                    white2[l] = tmp;
                }
            }

            bool ok = true;
            for(int l=0; l<interval.size(); ++l) {
                if(white[l] + white2[l] > K) {
                    ok = false;
                    ++cnt;
                    white = white2;
                    break;
                }
            }
            if(ok) {
                for(int l=0; l<interval.size(); ++l) {
                    white[l] += white2[l];
                }
            }
        }  
        res = min(res, cnt);
    }
    cout << res << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#define SENTINEL 2e9
using namespace std;
 
long long  cnt;
void Merge(int* A, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int *L,*R;
  L = new int[n1+1]; R=new int[n2+1];
  for(int i=0;i<n1;i++){
      L[i] = A[left + i];
  }
  for(int i = 0; i< n2;i++){
      R[i] = A[mid + i];
  }
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  int i = 0;
  int j = 0;
  for(int k = left; k < right; k++){
    if(L[i] <= R[j]){
        A[k] = L[i];
        i = i + 1;
    } else {
		cnt += n1-i;
        A[k] = R[j];
        j = j + 1;
    }
  }
}
 
void Merge_Sort(int* A, int left, int right){
  if(left+1 < right){
    int mid = (left + right)/2;
    Merge_Sort(A, left, mid);
    Merge_Sort(A, mid, right);
    Merge(A, left, mid, right);
  }
}
          
int main(){
    int *a;
    int n;
    cnt = 0;
    scanf("%d",&n);
    a = new int[n];
    for(int i=0;i<n;i++){
        scanf(" %d",&a[i]);
    }
    Merge_Sort(a, 0, n);
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 25412
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] p = new int[N];
		int range = rui(N) / N;
		int pposi = 0;
		List<Integer> zumip = new ArrayList<Integer>();
		
		for(int i = 0; i < N-1; i++) {
		    p[i] = sc.nextInt();
		    int pcount = 0;
		    for(int j = 1; j <= N; j++) {
		        if(zumip.contains(j)) {
		            continue;
		        }else if(j == p[i]) {
		            pposi += pcount * range + 1;
		            zumip.add(j);
		        }
		        pcount++;
		    }
		    range = range / (N-i-1);
		}
		p[N-1] = sc.nextInt();
		
		int[] q = new int[N];
		range = rui(N) / N;
		int qposi = 0;
		List<Integer> zumiq = new ArrayList<Integer>();

		for(int i = 0; i < N-1; i++) {
		    q[i] = sc.nextInt();
		    int qcount = 0;
		    for(int j = 1; j <= N; j++) {
		        if(zumiq.contains(j)) {
		            continue;
		        }else if(j == q[i]) {
		            qposi += qcount * range + 1;
		            zumiq.add(j);
		        }
		        qcount++;
		    }
		    range = range / (N-i-1);
		}
		
		if(pposi > qposi) {
		    System.out.println(pposi - qposi);
		}else {
		    System.out.println(qposi - pposi);
		}
	}
	
	static int rui(int a) {
	    if(a == 1) {
	        return 1;
	    }else {
	        return a * rui(a-1);
	    }
	}
}


Measured memory_bytes: 21844
#include<stdio.h>

int IsPrime(int);

int main(void){
  int data,n,i,j,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data);
    if(IsPrime(data)==1) count++;
    //printf("data=%d count=%d\n",data,count);
  }

  printf("%d\n",count);
  return 0;
}

int IsPrime(int x){
  int i;

  if(x==2) return 1;
  if(x<2||x%2==0) return 0;

  for(i=3;i<=x/i;i+=2)
    if(x%i==0) return 0;

  return 1;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> ans(n);
  rep(i,n) ans[a[i] - 1] = i + 1; 
  rep(i,n) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 1664
from itertools import accumulate
from bisect import bisect_left,bisect_right

def main():
    n,m,k=map(int,input().split())
    a=[0]+list(accumulate(map(int,input().split())))
    b=[0]+list(accumulate(map(int,input().split())))

    result = 0
    for i in range(n+1):
        tmp = k - a[i]
        if tmp < 0:
            continue
        tmpNum = i + bisect_right(b, tmp) - 1
        if tmpNum > result:
            result = tmpNum

    print(result)       


if __name__ == "__main__":
    main()

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
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; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

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

	vector<int> v(26);
	rep(i, s.length()){
		if (v[s[i]-97] != 0){
			cout << "no" << endl;
			return 0;
		}
		v[s[i]-97] = 1;
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 3628
void main() {
	auto N = ri;
	auto A = readAs!(int[]);
	if(A.sort().uniq.array.length == N) writeln("YES");
	else writeln("NO");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 10360
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#define inf 10000000001LL
#define MAX 100001
using namespace std;

//ifstream in("input.txt");
//ofstream out("output.txt");

int T;
int N, M, W;
string s;


int main() {
	int k = 1;
	cin >> N;
	while (k * 2 <= N) k *= 2;
	cout << k;
}

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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;



int main() {
const ll INF = 1001001001;
const ld PI = 3.14159265358979323846;
int N,count=0;
cin>>N;
if(N==100000){
count=90909;
}
else if(N>=10000){
    count=N-9090;
}
else if(N>=1000){
    count =909;
}
else if(N>=100){
    count=N-90;
}
else if(N>=10){
    count=9;
}
else{
    count=N;
}

cout<<count<<endl;
return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";

const int INF = 1001001001;

using namespace std;


int main() {

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

    vector<vector<int>> mm(n, vector<int>(m + 1));
    rep(i, n) {
        rep(j, m + 1) {
            cin >> mm[i][j];
        }
    }
    
    int minN = INF;
    rep(i, 1 << n) {

        vector<int> sk(m, 0);
        int pri = 0;

        rep(j, n) {
            if (i & (1 << j)) {
                rep(k, m) {
                    sk[k] += mm[j][k + 1];
                }
                pri +=  mm[j][0];
            }
        }
        bool is = true;
        
        rep(j, m) {
            //AS(sk[j]);
            
            if (sk[j] < x)
                is = false;
        }
        //cout<<endl; 
        //AA(pri);
        //AA(is);
        if(is) minN = min(minN, pri); 
    }

    if (minN == INF) minN = -1;
    
    AA(minN);
}

Measured memory_bytes: 3632
import math

short,long,hour,min=map(int,input().split())
hour = 360 / 12 * hour + 360/12/60*min
min = 360 / 60 * min

rasian = abs(hour - min)

length = math.sqrt(short*short + long*long - 2*short*long*math.cos(math.radians(rasian)))

print(length)

Measured memory_bytes: 9424
import sys
c = [list(map(int, input().split())) for _ in range(3)]

ans = 'Yes'
for i in range(c[0][0] + 1):
    b = [c[0][0] - i, c[0][1] - i, c[0][2] - i]
    a = [i, abs(b[0] - c[1][0]), abs(b[0] - c[2][0])]
    for j in range(1, 3):
        for k in range(3):
            if c[j][k] != a[j] + b[k]:
                ans = 'No'
                break
        if ans != 'Yes':
            break
    if ans == 'Yes':
        break
    if i != c[0][0]:
        ans = 'Yes'

print(ans)

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int m;
string s;

int main()
{
  cin >> m;
  while(m--){
    cin >> s;
    set<string> st;
    rep(i, s.size()-1){
      string l, rl = s.substr(0, i+1);
      string r, rr = s.substr(i+1, s.size()-i-1);
      l = rl;
      r = rr;
      reverse(ALL(rl));
      reverse(ALL(rr));
      st.insert(l + r);
      st.insert(r + l);
      st.insert(l + rr);
      st.insert(rr + l);
      st.insert(rl + r);
      st.insert(r + rl);
      st.insert(rl + rr);
      st.insert(rr + rl);
    }
    cout << st.size() << endl;
  }

  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>


int main(void) {
	int year, month, day;

	scanf("%d/%d/%d", &year, &month, &day);

	if (month <= 4) {
		std::cout << "Heisei" << std::endl;
	}
	else {
		std::cout << "TBD" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int N,K;
    cin >> N >> K;
    vector<int> kazu(N);
    for(int i=0; i<K; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int c;
            cin >> c;
            kazu.at(c-1)++;
        }
    }
    int count=0;
    for(int i=0; i<N; i++){
        if(kazu.at(i) ==0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var nt = Reads();
            var N = nt[0];
            var T = nt[1];
            var t = Reads();
            long ans = 0;
            for (int i = 0; i <N-1; i++)
            {
                ans += Math.Min(T, t[i + 1] - t[i]);
            }
            ans += T;
            Console.WriteLine(ans);

            
           
         
            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 28704
#include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;
    using vll = vector<ll>;
    using vvll = vector<vll>;
    using vvvll = vector<vvll>;
    using vs = vector<string>;
    #define rep(i, n) for (int i = 0; i < (n); i++)
    #define repb(i, a, b) for (int i = (a); i < (b); i++)
    #define ALL(a) (a).begin(),(a).end()
    #define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
    inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
    const ll MOD = 1000000007;
     
    int main()
    {
        int N;
        cin >> N;
        vll A(N);
        rep(i, N)
        {
            cin >> A[i];
        }
        vll gl(N);
        vll gr(N);
        gl[0] = A[0];
        gl[1] = GCD(A[0], A[1]);
        gr[N - 2] = GCD(A[N - 1], A[N - 2]);
        gr[N - 1] = A[N - 1];
        repb(i, 1, N-1)
        {
            gl[i + 1] = GCD(gl[i], A[i + 1]);
            gr[N - i - 2] = GCD(A[N - i - 2], gr[N - i - 1]);
        }
        ll ans = 1;
        rep(i, N)
        {
            if(i == 0)
            {
                ans = max(ans, gr[i + 1]);
            }
            else if(i == N-1)
            {
                ans = max(ans, gl[i - 1]);
            }
            else
            {
                ans = max(ans, GCD(gr[i + 1], gl[i - 1]));
            }
        }
        cout << ans << endl;
    }

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

int main() {

    int n,l;
    cin >> n >> l;
    vector<string> moji(n);

    for(int i = 0; i < n; i++){
          cin >> moji.at(i);
    }

    sort(moji.begin(), moji.end());
    
    for(int i = 0; i < n; i++){
        cout << moji.at(i);
    }

    cout << endl;


}



Measured memory_bytes: 256
n=int(input())
ans=[0 for i in range(n)]
for x in range(1,100):
  for y in range(1,x+1):
    for z in range(1,y+1):
      i=x**2+y**2+z**2+x*y+y*z+z*x
      if i<=n:
        if x==y and y==z:
          ans[i-1]+=1
        elif x==y or y==z:
          ans[i-1]+=3
        else:
          ans[i-1]+=6
for i in ans:
  print(i)

Measured memory_bytes: 9364
n = int(input())
k = int((n*2)**.5) + 1

if (k - 1) * k / 2 == n:
  print('Yes')
  print(k)
else:
  print('No')
  exit()

t = [1] * (k - 1)

for i in range(1, k - 1):
  t[i] = t[i-1] + i

for i in range(k-1):
  s = (t[max(i, j)] + min(i, j) for j in range(k-1))
  print(k-1, *s)
print(k - 1, *(t[j] + j for j in range(k-1)))

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

int main() {
  ll n;
  cin>>n;
  ll sum=0;
  for(ll i=0;i<n+1;i++){
if(i%3!=0&&i%5!=0) sum+=i;
  }
  cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define pi 31415926
#define maxn 100000007
#define minn -100000007
using namespace std;
signed main() {
	int n,m, k, x, t, maxx=0;
	cin >> n >> m >> k;
	int a[n+1], b[m+1];
	a[0]=0, b[0]=0;
	for (int i=1; i<=n; i++) {
		cin >> x;
		a[i]=a[i-1]+x;
	}
	for (int i=1; i<=m; i++) {
		cin >> x;
		b[i]=b[i-1]+x;
	}
	int L=0, R=n+m, lastf, lastr;
	while (L<=R) {
		lastf=L, lastr=R;
		bool f=false;
		int Mid=(L+R)/2;
		for (int i=0; i<=min(n, Mid); i++)
			if (Mid-i<=m) {
				t=a[i]+b[Mid-i];
				if (t<=k) {
					maxx=max(maxx, Mid);
					f=true;
					break;
				}
			}
		if (f) L=Mid;
		else R=Mid;
		if (lastf==L&&lastr==R) {
			f=false;
			for (int i=0;i<=min(n, R); i++)
				if (R-i<=m) {
					t=a[i]+b[R-i];
					if (t<=k) {
						cout << max(maxx,R) << endl;
						return 0;
					}
				}
			L=R+1;
		}
	}
	cout<<maxx<<endl;
	return 0;
}

Measured memory_bytes: 6736
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;


int main(){
    int A,B,C;
    cin >> A >> B >>C;
    
    cout<< max(10*A+B+C, max(A+C+10*B, A+B+10*C)) <<endl;
    
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, w);
    
    //vi dp(101000, INF);
    vector<int> dp(101000, INF);
    dp[0] = 0;

    rep(i, n) {
        int2(yui, kyoko); // weight value
        for (int j = dp.size()-1; j > 0; j--) {
            if (dp[j] != INF) {
                dp[j + kyoko] = min(dp[j + kyoko], 
                        dp[j] + yui);
            }
        }
        dp[kyoko] = min(dp[kyoko], yui);
        /*
        rep(i, 11) std::cout << dp[i] << " ";
        cout << endl;
        */      
    }

    for (int i = dp.size()-1; i >= 0; i--) {
        if (dp[i] <= w) {
            std::cout << i << std::endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

main(){
    long long k;
    char c[101];
    scanf("%s",c);
    scanf("%lld",&k);

    int i=0;
    int l=0;
    while(1){
        if(c[i]!='1')
            break;
        l+=1;
        if(l==k)
            break;
        i++;
    }
    printf("%c\n",c[i]);
    return 0;
}

Measured memory_bytes: 128
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	// buf := make([]byte, 10000)
	// scanner.Buffer(buf, 1000000)
	return scanner
}

func scanInt(s *bufio.Scanner) int {
	if s.Scan() {
		t := s.Text()
		if v, err := strconv.Atoi(t); err == nil {
			return v
		}
		panic(fmt.Sprintln("Could't scan int from input", t))
	}
	panic(s.Err())
}

func genPrimes(n int) []int {
	p := make([]int, n)
	for i := 2; i < n; i++ {
		if p[i] == 0 {
			p[i] = i
		}
		for j := i * i; j < n; j += i {
			if p[j] == 0 {
				p[j] = i
			}
		}
	}
	return p
}

func pow(p, n, m int) int {
	if n == 0 {
		return 1
	}

	r := pow(p, n/2, m) % m
	r *= r
	r %= m
	if n&1 == 1 {
		r *= p
		r %= m
	}
	return r
}

func main() {
	const m int = 1000000007
	sc := newScanner()
	n := scanInt(sc)
	a := make([]int, n)
	maxA := 0
	for i := 0; i < n; i++ {
		a[i] = scanInt(sc)
		if a[i] > maxA {
			maxA = a[i]
		}
	}

	p := genPrimes(maxA + 1)
	f := make(map[int]int)
	for i := 0; i < n; i++ {
		fa := make(map[int]int)
		x := a[i]
		for x > 1 && p[x] > 0 {
			fa[p[x]]++
			x /= p[x]
		}
		for k, v := range fa {
			if f[k] < v {
				f[k] = v
			}
		}
	}

	lcm := 1
	for k, v := range f {
		lcm *= pow(k, v, m)
		lcm %= m
	}

	res := 0
	for i := 0; i < n; i++ {
		res += lcm * pow(a[i], m-2, m) % m
		res %= m
	}

	fmt.Println(res)
}


Measured memory_bytes: 9984
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int number = r * 100 + g * 10 + b;
    if (number % 4 == 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 35488
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		int t = Integer.parseInt(tmpArray[2]);
		
		
		String delivery = br.readLine();
		
		System.out.println(solve(delivery, n, m, t));
		
	}
	
	static int solve(String delivery, int n, int m, int t){
		String[] tmpArray = delivery.split(" ");
		
		int delTime[] = new int[n];
		int outsideTime = 0;
		for(int i = 0; i < n; i++){
			delTime[i] = Integer.parseInt(tmpArray[i]);
		}
		
		for(int i = 0; i < n; i++){
			if(i == 0){
				outsideTime += m;
			}
			else if(delTime[i] - delTime[i - 1] > m*2){
				outsideTime += m*2;
			}
			else {
				outsideTime += delTime[i] - delTime[i - 1];
			}
//			System.out.println("i = "+i+" outsideTime = "+outsideTime);
		}
		outsideTime += Math.min(m, t-delTime[n - 1]);
		
		return t - outsideTime;
	}

}

Measured memory_bytes: 24388