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

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[][] array = new int[n][m];
        int[] cost = new int[n];
        int[] sum = new int[m];

        for (int i = 0; i < n; i++) {
            cost[i] = sc.nextInt();
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
                sum[j] += array[i][j];
            }
        }
        for (int i = 0; i < m; i++) {
            if (sum[i] < x) {
                System.out.println(- 1);
                return;
            }
        }
        long ans = Long.MAX_VALUE;
        int limit = (int) Math.pow(2, n);
        parent : for (int i = 1; i < limit; i++) {
            int v = i;
            int[] target = new int[m];
            int index;
            long costSum = 0;
            while ((index = Integer.lowestOneBit(v)) > 0) {
                int t = (int)(Math.log(index) / Math.log(2));
                costSum += cost[t];
                for (int j = 0; j < m; j++) {
                    target[j] += array[t][j];
                }
                v -= index;
            }
            for (int j = 0; j < m; j++) {
                if (target[j] < x) {
                    continue parent;
                }
            }
            ans = Math.min(costSum, ans);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37680
#define ll long long
#define ffor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  vector<int> a(250001);
  deque<int> deq;
  rep(i, n) scanf("%d", &a[i]);

  rep(i, n) {
    if (i % 2 == (n - 1) % 2)
      deq.push_front(a[i]);
    else
      deq.push_back(a[i]);
  }

  for (auto x : deq) printf("%d ", x);
  printf("\n");
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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;}

char a;

signed main(){
    cin>>a;
    if(a<97)cout<<"A"<<endl;
    else cout<<"a"<<endl;
}

Measured memory_bytes: 3632
A, B, C, D, E = [int(input()) for _ in range(5)]

menu = [A, B, C, D, E]

time_dig = [-(-food // 10) for food in menu]
time_mod_10 = [_ % 10 for _ in menu if _ % 10 != 0]
time_mod_10.append(10)

print((sum(time_dig) - 1) * 10 + min(time_mod_10))

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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    UnionFind tree(n);
    for(ll i=0;i<m;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        tree.merge(a,b);
    }
    int res=0;
    for(ll i=0;i<n;i++){
        res=max(res,tree.size(i));
    }
    cout << res << endl;
    return 0;
}  


Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  string A, B;
  cin >> A >> B;
  if( A.size() > B.size() ){
    cout << "GREATER" << endl;
    return 0;
  }else if( A.size() < B.size() ){
    cout << "LESS" << endl;
    return 0;
  }else if( A.size() == B.size() ){
    for( int i = 0; i < A.size(); i++ ){
      if( A.at(i) > B.at(i) ){
        cout << "GREATER" << endl;
        return 0;
      }else if( A.at(i) < B.at(i) ){
        cout << "LESS" << endl;
        return 0;
      }
    }
  }
  cout << "EQUAL" << endl;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    int i;
    for(i=0;i<n;i++)
        cin >> h[i];
    int dp[n];
    dp[0] = 0;
    for(i=1;i<n;i++)
    {
        int j;
        dp[i] = 1e9;
        for(j=1;j<=k;j++)
        {
            if(i-j >= 0)
                dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[n-1];
}

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

int main()
{
    char s[4][4];int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
            cin>>s[i][j];
    }cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

vector<int> G[MAX];

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

    vector<int> H(N);
    for (auto &i : H) cin >> i;

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    auto f = [&](int i) {
        bool res = 1;
        for (auto &u : G[i]) {
            res &= H[i] > H[u];
        }
        return res;
    };

    int ans = 0;
    rep(i, N) {
        if (f(i)) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 11180
# coding: utf-8
# Your code here!

import sys

n = int(input())

if n % 2 == 1:
    print(0)
    sys.exit()
    
if n < 2:
    print(0)
    sys.exit()
    
l = list()
# 2 * 5
l.append(10)
# 2 * 5 * 5
l.append(50 )
# 2 * 5 * 5 * 5
l.append(250 )
# 2 * 5 * 5 * 5 * 5
l.append(1250 )
# 2 * 5 * 5 * 5 * 5 * 5
l.append(6250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5
l.append(31250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(156250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(781250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(3906250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(19531250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(97656250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(488281250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(2441406250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(12207031250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(61035156250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(305175781250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(1525878906250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(7629394531250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(38146972656250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(190734863281250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(953674316406250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(4768371582031250 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(23841857910156200 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(119209289550781000 )
# 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5
l.append(596046447753906000 )

result = 0
for a in l:
    result += n // a
    
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
    int n;cin>>n;
    map<int,int> M;
    vector<int> pre(n+1);
    vector<int> cnt(maxn);
    int GCD=0;
    for(int i=1;i<=n;i++) {
    	cin>>pre[i];cnt[pre[i]]++;
    	GCD=__gcd(GCD,pre[i]);
    }
    if(GCD!=1) {cout<<"not coprime\n";return 0;}
	bool ok=1;
	for(int i=2;i<maxn;i++) {
		int tot=0;
		for(int j=i;j<maxn;j+=i) {
			tot+=cnt[j];
		}
		if(tot>1) {ok=0;break;}
	}   
	if(!ok) cout<<"setwise coprime\n";
    else cout<<"pairwise coprime\n";
    return 0;
}

Measured memory_bytes: 11160
//b.c B-Ringo's Favorite Numbers

#include<stdio.h>

int main(void){
    int d,n;
    scanf("%d %d",&d,&n);
    if(d==0){
        if(n==100){
            n*=1;
            n+=1;
        }else{
            n*=1;
        }
    }else if(d==1){
        if(n==100){
            n*=100;
            n+=100;
        }else{
            n*=100;
        }
    }else{
        if(n==100){
            n*=10000;
            n+=10000;
        }else{
            n*=10000;
        }
    }
    printf("%d\n",n);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int X = Integer.parseInt(scan.next());
        scan.close();
        
        int happy = 0;

        int a = X/500;
        int b = (X%500)/5;

        happy += 1000*a + 5*b;
        
        System.out.println(happy);
        // System.out.println(a);
        // System.out.println(b);
    }
}

Measured memory_bytes: 23252
from collections import deque

n,m=map(int,input().split())
graph=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

ans=[-1 for _ in range(n)]
ch=[False for _ in range(n)]

def bfs(graph):
    ch[0]=True
    Q=deque()
    Q.append([graph[0],0])

    while len(Q)>0:
        v,y=Q.popleft()

        for e in v:
            if ch[e]==False:
                ch[e]=True
                ans[e]=y
                Q.append([graph[e],e])



bfs(graph)

for i in range(1,len(ans)):
    if ans[i]==-1:
        print("No")
        exit()
    ans[i]+=1

print("Yes")
for i in range(1,len(ans)):
    print(ans[i])


Measured memory_bytes: 40648
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
 
ll solve(ll N){
    ll ans = 0;
    return ans;
}
 
int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(a+b+c >= 22) print("bust");
    else print("win");
}

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

using namespace std;

typedef long long LL;

#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
LL f(LL a,LL b){
    return (a/b)*b;
}
int main(){
    LL I,O,T,J,L,S,Z;
    cin>>I>>O>>T>>J>>L>>S>>Z;
    LL res=0;
    res=max(res,O+f(J,2)+f(L,2)+f(I,2));
    if(J>0&&L>0&&I>0)
        res=max(res,O+f(J-1,2)+f(L-1,2)+f(I-1,2)+3);
    cout<<res<<endl;

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\n'
int main()
{
    int N;
    cin >> N;
    vector<lli> A(N + 10);
    rep(i, 0, N)
    {
        cin >> A[i];
        if (A[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    lli res = 1;
    const lli limit = 1000000000000000000;
    rep(i, 0, N)
    {
        if (A[i] > limit / res)
        {
            res = -1;
            break;
        }
        res *= A[i];
    }
    cout << res << endl;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;


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



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    ll N, P;
    cin >> N >> P;
    auto ps = prime_factorize(P);
    ll ans = 1;
    for(auto pb: ps){
        ans *= pow(pb.first, pb.second/N);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::io::Write;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut cnt = vec![0u64; n + 1];
    let a: Vec<usize> = it.map(|s| s.parse().unwrap()).collect();
    for a in a.iter() {
        cnt[*a] += 1;
    }
    let mut sum = 0;
    for c in cnt.iter() {
        sum += *c * (*c - 1) / 2;
    }
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    for &a in a.iter() {
        let c = cnt[a];
        let ans = sum - c * (c - 1) / 2 + (c - 1) * (c - 2) / 2;
        writeln!(out, "{}", ans).ok();
    }
}

fn main() {
    run();
}

Measured memory_bytes: 12540
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int length=s.length();
	for(int i=0;i<length;i++){
		if(s[i]==','){
			cout<<' ';
		}else{
			cout<<s[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    bool used[30]={0};
    for(int i=0;i<28;i++){
        int a;
        cin>>a;
        used[--a]=true;
    }
    for(int i=0;i<30;i++){
        if(used[i])continue;
        cout<<i+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
using System;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] hwk = new int[2];
            int count = 0;
            hwk = Array.ConvertAll(System.Console.ReadLine().Split(' '), int.Parse);
            int[,] c = new int[hwk[0], hwk[1]];
            int[,] d = new int[hwk[0], hwk[1]];
            for (int i=0;i<hwk[0];i++)
            {
                string a = System.Console.ReadLine();
                for(int j=0;j<hwk[1];j++)
                {
                   if( a.Substring(j, 1) == "."){
                        c[i, j] = 0;
                    }
                    else
                    {
                        c[i, j] = 1;
                    }
                }
            }

            for(int x=0; x< Math.Pow(2,hwk[0]);x++)
            {


                for (int y = 0; y < Math.Pow(2, hwk[1]); y++)
                {
                    Array.Copy(c, d, c.Length);
                    for (int k = 0; k < hwk[0]; k++)
                    {
                        var k2 = (x >> k) & 1;
                        if (k2 == 1)
                        {
                            for (int i = 0; i < hwk[1]; i++)
                            {
                                d[k, i] = 0;
                            }
                        }
                    }
                    for (int k = 0; k < hwk[1]; k++)
                    {
                        var k2 = (y >> k) & 1;
                        if (k2 == 1)
                        {
                            for (int i = 0; i < hwk[0]; i++)
                            {
                                d[i, k] = 0;
                            }
                        }
                    }
                    int sum = 0;
                    for (int i = 0; i < hwk[0]; i++)
                    {
                        for (int j = 0; j < hwk[1]; j++)
                        {
                            sum += d[i, j];
                        }
                    }
                    if (sum == hwk[2])
                    {
                        count += 1;
                    }
                }
       
            }
            System.Console.WriteLine(count);


        }
    }
}

Measured memory_bytes: 27884
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    _    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

#define Task ""
#define F first
#define S second
#define push_back pb
#define bit(x, i) (x >> i) & 1
#define inf 1e9 + 7
#define INF 1e18 + 7

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int maxn = 1e5 + 5;

string s, t;

void Solve()
{
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    s = " " + s;
    t = " " + t;
    int res = inf;
    for (int i = 1; i <= n - m + 1; i ++)
    {
        int cnt = 0;
        for (int j = 0; j < m; j ++)
            if (s[i+j] != t[j+1]) cnt ++;
        res = min(res, cnt);
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    if(fopen(Task".inp", "r"))
    {
        freopen(Task".inp","r",stdin);
        freopen(Task".out","w",stdout);
    }
    int test_case = 1;
//    cin >> test_case;
    while (test_case --)
        Solve();
    return 0;
}


Measured memory_bytes: 3616
n = gets.chomp.to_i
k = gets.chomp.to_i
x = gets.chomp.split.map{|num|num.to_i}

sum = 0
(0...n).each do |i|
    sum += (x[i]-0).abs > (x[i]-k).abs ? (x[i]-k).abs*2 : (x[i]-0).abs*2
end
puts sum

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

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

    if (max < sum - max) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,C=map(int,input().split())
    x,v=[0]*N,[0]*N
    for i in range(N):
        x[i],v[i]=map(int,input().split())
    ans=0
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=S[i]+v[i]
    x2=[C-x[N-1-i] for i in range(N)]
    v2=list(reversed(v))
    S2=[0]*(N+1)
    for i in range(N):
        S2[i+1]=S2[i]+v2[i]
    
    MAX=[0]*(N+1)
    for i in range(N):
        MAX[i+1]=max(MAX[i],S[i+1]-x[i])
    MAX2=[0]*(N+1)
    for i in range(N):
        MAX2[i+1]=max(MAX2[i],S2[i+1]-x2[i])
    
    x.append(0)
    x2.append(0)
    for i in range(-1,N):
        ans=max(ans,S2[i+1]-x2[i]*2+MAX[-(i+2)],S[i+1]-x[i]*2+MAX2[-(i+2)])
    print(ans)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 50652
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	ll a, b, c;
	cin >> a >> b >> c;
	ll l = 4 * a * b;
	ll r = c - a - b;
	if (r < 0) {
		put("No");
		return 0;
	}
	r = r * r;
	if (l < r) {
		put("Yes");
	} else {
		put("No");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        double sum = 0;
        int n;
        double s = 0;
        double sum1 = 0;
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                n = sc.nextInt();
                if (n == 0) {
                    break;
                }
                int[] scores = new int[n];
                for (int i = 0; i < scores.length; i++) {
                    scores[i] = sc.nextInt();
                    sum = sum + (double)scores[i];
                }

                double average = 0, variance = 0;
                average = sum / (double)n;

                for (int j = 0; j < scores.length; j++) {
                    sum1 = ((double)scores[j] - average) * ((double)scores[j] - average);
                    s = s + sum1;
                    variance = s / n;
                }

                System.out.println(Math.sqrt(variance));
                sum=0;
                s=0;
            }
        }
    }
}



Measured memory_bytes: 31068
#include<stdio.h>

#define MAX 1000000000

int gcd(int x,int y){

  int r;
  int temp;

  if(x < y){
    temp = x;
    x = y;
    y = temp;
  }

  while(y > 0){
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

int main(){

  int x;
  int y;

  scanf("%d",&x);
  scanf("%d",&y);

  if(x < 1 || x > MAX || y < 1 || y > MAX){
    return -1;
  }

  printf("%d\n",gcd(x,y));

  return 0;
}

Measured memory_bytes: 592
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a,b,k,c=0;
    while(cin>>a>>b>>k)
    {
        c=0;
        int i;
        for(i=min(a,b);i>=1;i--)
        {
            if(a%i==0&&b%i==0)
            {
                c++;
                if(c==k)
                {
                    cout<<i<<endl;
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const ll mod = 998244353;
ll n,curr;
ll a[200009];
ll mp[200009];
bool done[200009];
int main(){
    fast,cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(int i=0;i<n;i++){
        if(done[a[i]]) continue;
        done[a[i]] = 1;
        ll x = mp[a[i]];
        curr += (x*(x-1))/2;
    }
    for(int i=0;i<n;i++){
        cout<<curr-mp[a[i]]+1<<endl;
    }
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    LL ans=1000;
    for ( int i=0; i<n; ) {
        int j=i;
        while ( j<n&&a[j]==a[i] ) j++;
        if ( j<n&&a[i]<a[j] ) {
            ans=ans%a[i]+ans/a[i]*a[j];
        }
        i=j;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i, n){
        cin >> a.at(i);
    }
    int touch = 0;
    int idx = 1;
    while (touch < 100000){
        idx = a.at(idx);
        touch ++;
        if (idx == 2) break;
    }
    if (idx == 2) cout << touch << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
using namespace std;

#define mod 300002
#define ll  long long
#define endl "\n"

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int x;
	cin >> x;
	double sum = 0, y;
	for (int i = 0; i < x; i++) {
		cin >> y;
		sum += (1 / y);
	}
	printf("%.7lf\n", 1 / sum);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll n, k;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  if(k==0){
    cout << n * n << endl;
    return 0;
  }
  ll ans = 0;
  FOR(b, k+1, n+1){
    ll f = n / b * (b - k);
    if(n%b) f += max(0ll, n % b - k + 1);
    ans += f;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	int o = 1;
	while(o < n) o <<= 1;
	auto dp = vector<int>(n + 1);
	for(auto i = 2; i <= n; ++i){
		if(s[i - 2] == 'A' && s[i - 1] == 'C') dp[i] = 1;
		dp[i] += dp[i - 1];
	}
	for(auto i = 0; i < q; ++i){
		int l, r;
		cin >> l >> r;
		cout << dp[r] - dp[l] << endl;
	}
	
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll K;
string S;

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

  cin>>S>>K;
  ll N=S.size();
  bool same=true;
  rep(i,N-1){
    if(S[i]!=S[i+1])same=false;
  }
  if(same){
    ll L=N*K;
    cout<<L/2<<endl;
    return 0;
  }
  vector<ll> ls;
  for(ll i=0;i<N;){
    ll j=i;
    while(j<N&&S[i]==S[j])j++;
    ls.push_back(j-i);
    i=j;
  }

  if(S[N-1]==S[0]){
    ll p=0,s=N-1,plen=0,slen=0;
    while(S[0]==S[p])p++,plen++;
    while(S[N-1]==S[s])s--,slen++;
    ll sum=0;
    rep(i,ls.size())sum+=ls[i]/2;
    cout<<(sum-(plen/2)-(slen/2))*K+((plen+slen)/2)*(K-1)+(plen/2)+(slen/2)<<endl;
  }else{
    ll sum=0;
    rep(i,ls.size())sum+=ls[i]/2;
    cout<<sum*K<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int m[3] = {},x;
int mm[3] = {500,100,50};
int dfs(int z, int n){
    if(n > 2){
        if(z == 0)ret 1;
        else ret 0;
    }

    int ans = 0;
    rep(i,0,m[n]+1){
        ans += dfs(z-mm[n] * i , n+1);
    }
    ret ans;
}
int main(){
    
    rep(i,0,3)cin >> m[i];
    cin >> x;

    P(dfs(x,0));

	
	return  0;
}

Measured memory_bytes: 256
n=int(input())
number=[int(i) for i in input().split()]

for i in range(n):
  if number[i]%2==1 or number[i]%3==0 or number[i]%5==0:
    number[i]=0
    
if all(number[i]==0 for i in range(n)):
  print("APPROVED")
else:
  print("DENIED")

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w,n;
    cin>>h>>w>>n;
    cout<<min((n+h-1)/h,(n+w-1)/w);
    return 0;
}


Measured memory_bytes: 256
/*  ex4_2
    L40S38  */
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
 int main(void){
     int hour_length,minute_length,hour,minute;
     scanf("%d %d %d %d",&hour_length,&minute_length,&hour,&minute);
     //hour_length:時針の長さ[cm]
     //minute_length:分針の長さ[cm]
     //hour,minute:hour時minute分
     double dif=(2*M_PI)/(12*60)*(hour*60+minute)-(2*M_PI)/60*minute;
     //dif:時針と分針のなす角[rad]
     //余弦定理を用いてans_2(求める距離の2乗)を求める
     double ans_2=pow(hour_length,2)+pow(minute_length,2)-2*hour_length*minute_length*cos(dif);
     printf("%.9f\n",sqrt(ans_2));
     return 0;
}

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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int x, a, b, n;
    cin >> x >> a >> b >> n;
    vector<string> t{"nobiro", "tidime", "karero"};
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        int idx = distance(t.begin(), find(t.begin(), t.end(), s));
        if(idx == 0)
            x += a;
        if(idx == 1)
            x += b;
        if(idx == 2)
            x = 0;
        x = max(x, 0);
    }
    cout << x << endl;
}



Measured memory_bytes: 3208
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 305;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int n, d;
	cin >> n >> d;
	int cnt = 0;
	d *= d;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (x*x + y*y <= d) cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3652
n=int(input())
d=dict()
for i in input():
    if i in d:
        d[i]+=1
    else:
        d[i]=1
#print(d)
for i in range(1,n):
    d1=dict()
    for j in input():
        if j in d1:
            d1[j]+=1
        else:
            d1[j]=1
    d2=dict()
    for k,j in d.items():
        if k in d1:
            d2[k]=min(j,d1[k])
    #print(d1,d2)
    d=d2
#print(d)
s=''
for i,j in sorted(d.items(),key=lambda x:x[0]):
    s+=i*j
print(s)

Measured memory_bytes: 9204
import java.util.*;

public class Main {
	
	private int[] fib = new int [45];
	
	Main() {
		for(int i=0;i<45;i++) {
			if(i<=1)fib[i]=1;
			else fib[i]=fib[i-1]+fib[i-2];
		}
	}
	
	int get(int n) {
		return fib[n];
	}
	
	public static void main(String[] args) {
		System.out.println(new Main().get(new Scanner(System.in).nextInt()));
	}
}


Measured memory_bytes: 26188
#include<stdio.h>
#include <string.h>

int main()
{
  char S[100001],temp;
    scanf("%s",&S);
  char T[4][8]={"maerd","remaerd","esare","resare"};
  
  int s,i,j,a,k;
  
  
  s=strlen(S);
  
  for(i=0;i<s/2;i++)
  {
    temp=S[i];
    S[i]=S[s-i-1];
    S[s-i-1]=temp;
  }

  
  for(i=0;i<4 && strlen(S)>1;i++)
  {
    k=strlen(T[i]);
    s=strlen(S);

    a=strncmp(S,T[i],k);
    if(a==0)
    {
      for(j=0;j<s;j++)
      {
        S[j]=S[j+k];
      }
      i=-1;
    }
  }

  a=strlen(S);
  if(a==0)
  {
      printf("YES");
  }
  else
  {
      printf("NO");
  }


  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


bool is_prime[30001];
vector<int> PRIME;

int main(){

	for(int i = 0; i <= 30000; i++){
		is_prime[i] = true;
	}

	for(int i = 2; i <= sqrt(30000); i++){
		if(is_prime[i]){
			for(int k = 2*i; k <= 30000; k += i){
				is_prime[k] = false;
			}
		}
	}

	for(int i = 2; i <= 30000; i++){
		if(is_prime[i]){
			PRIME.push_back(i);
		}
	}

	int T;
	while(true){
		scanf("%d",&T);
		if(T == 0)break;

		int ans = 0;

		for(int a = 0; a < PRIME.size(); a++){
			if(PRIME[a] > T)break;
			for(int b = a; b < PRIME.size(); b++){
				if(PRIME[a]+PRIME[b] > T)break;
				int c = T -(PRIME[a]+PRIME[b]);

				if(!is_prime[c])continue;

				if(PRIME[b] <= c && (PRIME[a]+PRIME[b]) > c && (PRIME[b]+c) > PRIME[a] && (c+PRIME[a]) > PRIME[b])ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3324
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] p = new int[N];
		for(int i=0; i<N; i++)
			p[i] = sc.nextInt();
		
		double max = 0;
		double sum = 0;
		for(int i=0; i<N; i++) {
			sum += (1.0 + p[i])/2;
			if(i>=K)
				sum -= (1.0 + p[i-K])/2;
			max = Math.max(max, sum);
		}
		
		System.out.println(max);
		sc.close();
	}
}


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

int main(){

  string S;
  bool tar=false;
  getline(cin, S);

  for(int i=1; i<S.size(); i++){
    if((S.size()-i)%2) continue;
    for(int j=0; j<(S.size()-i)/2; j++){
      if(S[j]!=S[(S.size()-i)/2+j]){
        tar = false;
        break;
      }
      tar = true;
    }
    if(tar){
      cout << S.size() - i << endl;
      return 0;
    }
  }

  return 0;
}


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

int N,M,K;
int main(){
  cin >> N >> M >> K;
  if(K==0 || K==N*M){
    cout << "Yes" << endl;
    return 0;
  }
  for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
      if(i*j+(N-i)*(M-j)==K){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    /*int a,rem,j=0;
    int bn[100000];
    cin>>a;
    while(a!=0){
         rem=a%2;
    bn[j++]=rem;
    a/=2;
    }


    for(int i=j;i>=0;i--)
        printf("%d",bn[i]); */

        int a,b,c;
        cin>>a>>b;
        if(a==b)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};
use std::convert::TryInto;

#[fastout]
fn main() {
    input! {
        n: usize,
        xy: [(isize, isize); n]
    }
    let route_count = factorial(n);
    let duplicate_count = route_count * (n - 1) / combination(n, 2);
    let mut ans: f64 = 0.0;
    for i in 0..(n-1) {
        for j in (i + 1)..n {
            let x_diff = xy[i].0 - xy[j].0;
            let y_diff = xy[i].1 - xy[j].1;
            let distance: usize = (x_diff * x_diff + y_diff * y_diff).try_into().unwrap();
            ans += (distance as f64).sqrt() * duplicate_count as f64;
        }
    }
    println!("{}", ans / route_count as f64);
}

fn factorial(n: usize) -> usize {
    if n == 0 {
        return 1;
    }
    return (1..=n).product();
}

fn combination(n: usize, m: usize) -> usize {
    let numerator: usize = (1..=m).product();
    let denominator: usize = ((n - m + 1)..=n).product();
    return denominator / numerator;
}

Measured memory_bytes: 2216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		str=str.toUpperCase();
		System.out.println(str);
	}
}

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

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r){
  if(l>=r)return;
  int root=pre[pos++];
  int m=distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

void solve(){
  pos=0;
  rec(0,pre.size());
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<post[i];
  }
  cout<<endl;
}

int main(){
  int k;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k;
    pre.push_back(k);
  }
  for(int i=0;i<n;i++){
    cin>>k;
    in.push_back(k);
  }
  solve();
  return 0;
}



Measured memory_bytes: 3164
n=int(input())
t=dict()
tramp=[[True]*13 for i in range(4)]
pic={"S":0,"H":1,"C":2,"D":3}
pic2={j:i for i,j in pic.items()}
for i in range(n):
    a,b=input().split()
    tramp[pic[a]][int(b)-1]=False
for i in range(4):
    for j in range(13):
        if tramp[i][j]:
            print(pic2[i],j+1)

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

const int N_MAX = 300010;

vector<int> primes;
void sieve(){
    vector<bool> is_prime(N_MAX, true);
    
    int cnt = 1;
    while(true){
        for(int i=-1; i<=2; i+=2){
            int x = cnt*7 + i;
            if(is_prime[x]){
                for(int j=2*x; j<N_MAX; j+=x)
                    is_prime[j] = false;
                primes.push_back(x);
            }
        }
        if(cnt*7 > N_MAX)
            break;
        cnt++;
    }
}

int N;

void solve(){
    cout << N << ":";
    
    for(auto v: primes) if(N%v == 0)
        cout << " " << v;
    
    cout << endl;
}

int main(){
    sieve();
    while(cin >> N, N != 1)
        solve();
    
    return 0;
}

Measured memory_bytes: 3272
package main

import (
    "fmt"
)

func main() {
    var (
        n int
        list []int
    )
    fmt.Scan(&n)
    list = make([]int, n)
    for i:=0; i < n; i++ {
        fmt.Scan(&list[i])
    }
    list_print(list)
    insertion_sort(list, n)

}

func insertion_sort(a []int, n int ){
    var v, i, j int
    for i = 1 ; i < n ; i++ {
        v = a[i]
        for j = i-1; j >= 0 && a[j] > v; j-- {
            a[j+1] = a[j]
        }
        a[j+1] = v
        list_print(a)
    }
}

func list_print(list []int) {
    var i int
    for i=0; i<len(list); i++ {
        if i == 0 {
            fmt.Print(list[i])
        } else {
            fmt.Print(" ", list[i])
        }
    }
    fmt.Print("\n")
}



Measured memory_bytes: 1220
# coding: utf-8
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

def match(x, y):
    return all(a[x:x+M]==b for a,b in zip(A[y:], B))

print(any(match(x, y) for y in range(N-M+1) for x in range(N-M+1)) and "Yes" or "No")

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

//1つ目の要素の最大値に応じて調整
const ll MX = 100000;

struct UnionFind{
    vector<ll> par;
    vector<ll> sz;
    //type1, type2の数
    vector<ll> tp[2];

    UnionFind(ll n){
        par.resize(n);
        sz.resize(n);
        tp[0].resize(n);
        tp[1].resize(n);
        for (ll i = 0; i < n; i++){
            par[i] = i;
            sz[i] = 1;
            tp[i >= MX][i]++;
        }
    }

    ll find(ll x){
        if (par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sz[x] > sz[y])
            swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        tp[0][y] += tp[0][x];
        tp[1][y] += tp[1][x];
    }

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

    ll size(ll x){
        return sz[find(x)];
    }
};


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

    ll n;
    cin>>n;
    UnionFind uni(300100);

    for (ll i = 0; i < n;i++){
        ll x, y;
        cin >> x >> y;
        x--, y--;
        uni.unite(x, MX + y);
    }
    ll ans = 0;
    for (int i = 0; i < 200000;i++){
        if(uni.find(i)==i){
            ans += uni.tp[0][i] * uni.tp[1][i];
        }
    }
    ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include<stdio.h>
int main(){
  long long int a,b,k;
  scanf("%lld %lld %lld\n",&a,&b,&k);
  if(a<=k){
    b=b-(k-a);
    if(b<0){
      b=0;
    }
    a=0;
  }
  else{
    a=a-k;
  }
  printf("%lld %lld\n",a,b);
  return 0;
}

Measured memory_bytes: 128