akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
  int N;
  cin >> N;
  const char* result = "No";
  for (div_t d = div(N, 10); (0 < d.quot) || (0 < d.rem); d = div(d.quot, 10)) {
    if (d.rem == 7) {
      result = "Yes";
      break;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc=new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int num = 7;
        int res = 1;
        if(k % 2 == 0 || k % 5 == 0){
            System.out.println("-1");
        }else if(k == 1 || k == 7){
            System.out.println("1");
        }else{
            while(num != 0){
                num = (num * 10 + 7) % k;
                res++;
            }
            System.out.println(res);
        }
    }
}


Measured memory_bytes: 35644
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[100][100];
int  s1[100][100];
int main()
{
    int h,w;
    cin>>h>>w;
    memset(s1,0,sizeof(s1));
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>s[i][j];
        }
    }
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
    {
        if(s[i][j]=='.')
        {
            if(s[i-1][j]=='#')
            s1[i][j]++;
            if(s[i+1][j]=='#')
            s1[i][j]++;
            if(s[i-1][j+1]=='#')
            s1[i][j]++;
            if(s[i-1][j-1]=='#')
            s1[i][j]++;
            if(s[i+1][j+1]=='#')
            s1[i][j]++;
            if(s[i+1][j-1]=='#')
            s1[i][j]++;
             if(s[i][j+1]=='#')
            s1[i][j]++;
             if(s[i][j-1]=='#')
            s1[i][j]++;
        }
    }
    for(int i=1;i<=h;i++)
      {
          for(int j=1;j<=w;j++)
            {

                if(s[i][j]=='#')
                    cout<<"#";
                else
                cout<<s1[i][j];
            }
            cout<<endl;
      }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint A, B, m;
    cin >> A >> B >> m;
    vector<lint> a(A);
    lint amin = inf;
    for (int i = 0; i < A; ++i) {
        cin >> a[i];
        chmin(amin, a[i]);
    }
    vector<lint> b(B);
    lint bmin = inf;
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
        chmin(bmin, b[i]);
    }
    lint ret = amin + bmin;
    for (int i = 0; i < m; ++i) {
        lint x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        chmin(ret, a[x] + b[y] - c);
    }
    cout << ret << "\n";
    return 0;
}

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

long long N, X;
long long x[int(1e5)];
long long D;

unsigned long long gcd(unsigned long long a, unsigned long long b){
    if(a < b)
        gcd(b, a);
    else if(a % b)
        gcd(b, a % b);
    else
        return b;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> X;
    for(int n=0; n<N; n++)cin >> x[n];
    D = abs(x[0] - X);
    long long dis;
    for(int n=1; n<N; n++){
        dis = abs(x[n] - X);
        if(dis % D){
            D = gcd(dis, D);
        }
    }
    cout << D << "\n";
    return 0;
}

Measured memory_bytes: 1024
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]
 
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
mod=10**9+7
x,y=map(int,input().split())
if (x+y)%3==0 and y>=0.5*x and y<=2*x:
    k=(x+y)//3
    h=y-k
    ans=1
    for i in range(k-h+1,k+1):
        ans*=i
        ans%=mod
    for i in range(1,h+1):
        ans*=mod_inv(i,mod)
        ans%=mod
    print(ans)
else:
    print(0)

Measured memory_bytes: 41964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  if(N <= 1000){  
  cout << 1000-N << endl;
}
  else if(N<= 2000){
    cout << 2000-N << endl;
  }
 else if(N<= 3000){
    cout << 3000-N << endl;
  }
   else if(N<= 4000 ){
  cout << 4000-N << endl;
  }
   else if(N<= 5000){
    cout << 5000-N << endl;
  }
   else if(N<= 6000){
    cout << 6000-N << endl;
  }
   else if(N<= 7000){
    cout << 7000-N << endl;
  }
   else if(N<= 8000){
    cout << 8000-N << endl;
  }
   else if(N<= 9000){
    cout << 9000-N << endl;
  }
   else if(N<= 10000){
    cout << 10000-N << endl;
  }
}

Measured memory_bytes: 3616
use std::io::{BufRead, Write};
use std::io;
use std::collections::HashMap;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let _n: usize = buf.trim_right().parse().unwrap();
    buf.clear();
    input.read_line(&mut buf).unwrap();
    let a: Vec<usize> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut cnt: HashMap<usize, usize> = HashMap::new();
    for x in a {
        *cnt.entry(x).or_insert(0) += 1;
    }
    let result: usize = cnt.into_iter().map(|(idx, cnt)| if cnt < idx { cnt } else { cnt - idx }).sum();
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "4
3 3 3 3
",
            "1\n",
        );
    }

    #[test]
    fn case2() {
        test(
            "5
2 4 1 4 2
",
            "2\n",
        );
    }

    #[test]
    fn case3() {
        test(
            "6
1 2 2 3 3 3
",
            "0\n",
        );
    }

    #[test]
    fn case4() {
        test(
            "1
1000000000
",
            "1\n",
        );
    }

    #[test]
    fn case5() {
        test(
            "8
2 7 1 8 2 8 1 8
",
            "5\n",
        );
    }
}

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

using namespace std;

using ll = long long;
using dd = double;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<dd>;
using vb = vector<bool>;

template <class T, class V>
istream& operator>>(istream& in, pair<T, V>& pair) {
    return in >> pair.first >> pair.second;
}

template <class T>
istream& operator>>(istream& in, vector<T>& elements) {
    for (size_t i = 0; i < elements.size(); ++i) {
        in >> elements[i];
    }
    return in;
}

template <class Container, class Element>
bool Contains(const Container& container, const Element& element) {
    return container.find(element) != container.end();
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& elements) {
    for (const T& element : elements) {
        out << element << ' ';
    }
    return out;
}

template <class T, class V>
ostream& operator<<(ostream& out, const pair<T, V>& pair) {
    out << pair.first << ' ' << pair.second;
}

#define FOR(i,n) for(size_t i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(c) sort((c).begin(), (c).end())

int main() {
    ios_base::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    unordered_map<char, int> m;
    FOR(i, s.size()) {
        ++m[s[i]];
    }
    if (m.size() == 2 && m.begin()->second == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
import math
def permutations_count(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

n=int(input())
a=list(map(int,input().split()))

s=[0]*(n+1)
for i in range(1,n+1):
    s[i]=s[i-1]+a[i-1]
#print(s)
ans=0
for k,v in Counter(s).items():
    if k==0:
        ans+=v-1+permutations_count(v-1,2) if v>=3 else v-1
    elif v>=2:
        ans+=permutations_count(v,2)

print(ans)

Measured memory_bytes: 41748
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll A, B, N;
ll Solve(ll X){
  return (A * X) / B - A * (X / B);
}

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

  if (N >= B){
    cout << Solve(B - 1) << endl;
  }else{
    cout << Solve(N) << endl;
  }

  return 0;
}


Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

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

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	defer out.Flush()

	a := next()
	for i := 0; i < len(a); i++ {
		if a[i] >= 65 && a[i] <= 90 {
			fmt.Fprintf(out, "%s", strings.ToLower(string(a[i])))
		} else if a[i] >= 97 && a[i] <= 122 {
			fmt.Fprintf(out, "%s", strings.ToUpper(string(a[i])))
		} else {
			fmt.Fprintf(out, "%s", string(a[i]))
		}
	}

	fmt.Fprintf(out, "\n")
}

func next() string {
	sc.Scan()
	return sc.Text()
}



Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, y;
    cin >> n >> y;
    rep(i, n+1) {
        for(int j = 0; j <= n-i; j++) {
            int k = n - i - j;
            if(j * 10000 + i * 5000 + k * 1000 == y) {
                cout << j << ' ' << i << ' ' << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 1005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,x[MAX],y[MAX];
int bin[35];
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		x[i]=read(),y[i]=read();
	int type=(abs(x[1]+y[1])&1);
	for(int i=2;i<=n;i++)
		if((abs(x[i]+y[i])&1)!=type)
			return puts("-1"),0;
	bin[0]=1;
	for(int i=1;i<=30;i++)
		bin[i]=bin[i-1]<<1;
	if(!type)
		puts("32"),printf("1 ");
	else
		puts("31");
	for(int i=30;i>=0;i--)
		printf("%d ",bin[i]);
	putchar('\n');
	for(int i=1;i<=n;i++)
	{
		long long nx=0,ny=0;
		if(!type) nx++,putchar('R');
		for(int j=30;j>=0;j--)
		{
			long long tx=x[i]-nx,ty=y[i]-ny;
			if(abs(tx)>abs(ty))
			{
				if(tx>0) nx+=bin[j],putchar('R');
				else nx-=bin[j],putchar('L');
			}
			else
			{
				if(ty>0) ny+=bin[j],putchar('U');
				else ny-=bin[j],putchar('D');
			}
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a[5][2],s,d,f,g,h,i,j;
	for(i=0;i<4;i++){
		for(j=0;j<2;j++)
			scanf("%d",&a[i][j]);
	}
	for(i=0;i<4;i++){
		if(a[i][0]==1) printf("%d\n",a[i][1]*6000);
		else if(a[i][0]==2) printf("%d\n",a[i][1]*4000);
		else if(a[i][0]==3) printf("%d\n",a[i][1]*3000);
		else if(a[i][0]==4) printf("%d\n",a[i][1]*2000);
	}
	return 0;
}

Measured memory_bytes: 2696
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    candidates=[]
    n,a,b = map(int,input().split())
    [candidates.append(s) for s in input().rstrip()]
    limit=a+b
    b_counter=1

    for idx in range(1,len(candidates)+1):
        if 'a' in candidates[idx-1] and limit > 0:
            limit-=1
            print("Yes")
        elif 'b' in candidates[idx-1] and limit > 0 and b_counter <= b:
            b_counter+=1
            limit-=1
            print("Yes")
        else:
            print("No")
    
if __name__=="__main__":
    main()

Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];

	bool flag = 1;
	int fin = 0;
	int count = 0;

	do {
		int min = INF;
		int index;
		FOR(i, fin, n){
			if (min > a[i]){
				min = a[i];
				index = i;
			}
		}
		int tmp;
		if (min < a[fin]){
			tmp = a[fin];
			a[fin] = min;
			a[index] = tmp;
			count++;
		}

		fin++;

		if (fin == n) flag = 0;

	} while (flag);

	REP(i, n){
		if (i < n-1) cout << a[i] << " ";
		else cout << a[i] << endl;
	}

	cout << count << endl;


}


Measured memory_bytes: 3096
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

I,O,T,J,L,S,Z = inpl()
ans1 = ans2 = O
if I > 0 and J > 0 and L > 0:
	ans1 += 3 + (I-1)//2*2 + (J-1)//2*2 + (L-1)//2*2
ans2 += I//2*2 + J//2*2 + L//2*2
print(max(ans1,ans2))


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

class Pg
{
    static void Main() => Operate.Read().ToList().ForEach(v => Console.WriteLine(Operate.Calq(v).Min()));
}
class Operate
{
    internal static IEnumerable<int> Calq(int e)
    {
        for (int z = 0; Math.Pow(z, 3) <= e; ++z)
        {
            var ZxZxZ = Math.Pow(z,3);
            var y = (int)Math.Sqrt(e - ZxZxZ);
            var x = e - (ZxZxZ + Math.Pow(y,2));
            yield return (int)x + y + z;
        }
    }
    internal static IEnumerable<int> Read()
    {
        int n;
        while ((n = int.Parse(Console.ReadLine())) != 0)
            yield return n;
    }
}


Measured memory_bytes: 16364
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

A, B = MAP()
print(A*B)

Measured memory_bytes: 10044
a = gets.chomp.to_i
cnt = 10**5

for i in 1..10**5
  if a % i == 0
  t = (a / i).to_s
  #p t
  u = i.to_s
  #p u
  if t.length <= u.length 
  s = u.length
  else
    s = t.length
  end
  if cnt >= s
    cnt = s
  end
  #puts s
  end
end
puts cnt
  

Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/


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

    ll n, a ,b;
    cin>>n>>a>>b;
    vector<ll> x(n);
    for (int i = 0; i<n; i++) cin>>x[i];
    ll res = 0;
    for (int i = 0; i<n-1; i++) res+=min(b, a*(x[i+1]-x[i]));
    cout<<res;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int> A(N); rep(i,N) std::cin >> A[i];

  for(int i=0; i<K; i++) {

    std::vector<int> S(N+1);
    for(int j=0; j<N; j++) {
      S[ std::max(0, j-A[j])   ] += 1;
      S[ std::min(N, j+A[j]+1) ] -= 1;
    }
    for(int j=1; j<=N; j++) S[j] += S[j-1];

    A = S;
    
    bool flag = true;
    for(int j=0; j<N; j++) if ( A[j] != N ) flag = false;
    if ( flag ) break;
  }

  rep(j,N) std::cout << A[j] << " ";
  std::cout << std::endl;

  return 0;
}



Measured memory_bytes: 5560
import numpy as np

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
array = np.array([a, b, c, d, e])
rlist = [a % 10, b % 10, c % 10, d % 10, e % 10]
value = 0
for i in range(0, 4):
    tmpr = rlist[i] % 10
    if tmpr != 0 and 10 - tmpr > value:
        value = 10 - tmpr
tenList = [int(a / 10) * 10 + 10, int(b / 10) * 10 + 10, int(c / 10) * 10 + 10, int(d / 10) * 10 + 10, int(e / 10) * 10 + 10]
for i in range(0, 5):
    tmp = tenList[i]
    if rlist[i]  == 0:
        tenList[i] = tmp - 10
sumv = sum(tenList)
print(int(sumv - value))

Measured memory_bytes: 12468
<?php
list($n) = ints();
$a = ints();
for ($i = $n - 1; $i >= 0; --$i) {
    $t = 0;
    for ($j = $i + $i + 1; $j < $n; $j += $i + 1) $t += $b[$j];
    $b[$i] = ($t + $a[$i]) % 2;
}
for ($i = 0; $i < $n; ++$i) if ($b[$i] === 1) $ans[] = $i + 1;
echo count($ans) . PHP_EOL;
echo implode(' ', $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> G(n, vector<int>(0));
  for(int i=0;i<m;i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<int> p(n-1);
  int ans = 0;
  iota(p.begin(), p.end(), 1);
  sort(p.begin(), p.end());
  do {
    int start = 0;
    bool ok = true;
    for(int i=0;i<n-1;i++) {
      if(find(G[start].begin(), G[start].end(), p[i]) == G[start].end()) {
        ok = false;
        break;
      } else {
        start = p[i];
      }
    }
    if(ok) ans++;
  } while (next_permutation(p.begin(), p.end()));

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
} 
void solve()
{
    int a, b;
    cin >> a >> b;
    int f = a;
    a *= 2;
    b -= a;
    if(b%2==0&&b/2<=f&&b/2>=0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int N = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.nextLine());
        long ans = 0L;
        int rem = 0;
        for (int i = 0; i < N; i++) {
            int n = Integer.parseInt(scanner.nextLine());
            if (n > 0 && rem == 1) {
                ans++;
                n--;
            }
            ans += n / 2;
            rem = n % 2;
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 91868
import sys

stdin = sys.stdin
ni = lambda: int(stdin.readline())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

t = na()
if t[0]+t[1] >= 24:
    print(t[0]+t[1]-24)
else:
    print(t[0]+t[1])


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{
  private static int in_N;
  private static int in_Y;



  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;


    int   in_N;
    int[] in_A1;
    int[] in_A2;

    int cnt;
    int cnt_sum;
    int tmp_sum;
    int ans;

    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));

      in_str = new String(in_stream.readLine());
      in_N   = Integer.parseInt(in_str);

      in_A1 = new int[in_N];
      in_A2 = new int[in_N];

      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      for(cnt=0; cnt<in_N; cnt++)
      {

        in_A1[cnt] = Integer.parseInt(in_str_split[cnt]);
      }

      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      for(cnt=0; cnt<in_N; cnt++)
      {

        in_A2[cnt] = Integer.parseInt(in_str_split[cnt]);
      }


      ans = 0;
      for(cnt=0; cnt<in_N; cnt++)
      {
        tmp_sum = 0;
        for(cnt_sum=0; cnt_sum<=cnt; cnt_sum++)
        {
          tmp_sum += in_A1[cnt_sum];
        }
        for(cnt_sum=cnt; cnt_sum<in_N; cnt_sum++)
        {
          tmp_sum += in_A2[cnt_sum];
        }

        if(ans < tmp_sum)
        {
          ans = tmp_sum;
        }
      }

      UtilLog.ans_ln("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }



}



class Data
{
  public int     m_now_N_1k;
  public int     m_now_N_5k;
  public int     m_now_N_10k;
  public int     m_now_Y;
  public boolean m_result;


  public Data()
  {
    m_now_N_1k  = 0;
    m_now_N_5k  = 0;
    m_now_N_10k = 0;
    m_now_Y     = 0;
    m_result    = false;
  }

  public Data
  (
    Data i_ref
  )
  {
    this.m_now_N_1k  = i_ref.m_now_N_1k;
    this.m_now_N_5k  = i_ref.m_now_N_5k;
    this.m_now_N_10k = i_ref.m_now_N_10k;
    this.m_now_Y     = i_ref.m_now_Y;
    this.m_result    = i_ref.m_result;
  }



  public int getN()
  {
    return m_now_N_1k + m_now_N_5k + m_now_N_10k;
  }
}



class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


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

int main()
{
	//レシート

	int N;
	int ans[5];
	int a;
	int i = 0;
	while (true)
	{
		cin >> N;
		if (N == 0) break;
		for (int j = 0; j < 9; j++) {
			cin >> a;
			N -= a;
		}
		ans[i] = N;
		i++;
	}
	for (int k = 0; k < 5; k++)
		cout << ans[k] << endl;

	//コンテスト	
	/*
	int W[10], K[10];
	for (int i = 0; i < 10; i++) {
		cin >> W[i];
	}
	for (int i = 0; i < 10; i++) {
		cin >> K[i];
	}
	sort(W, W + 10);
	reverse(W, W + 10);
	sort(K, K + 10);
	reverse(K, K + 10);
	cout << W[0] + W[1] + W[2] << " " << K[0] + K[1] + K[2] << endl;
	*/
	//ポイントカード
	/*
	int N, M;
	cin >> N >> M;
	int a;
	int A[5000];
	int b = 0;
	int x = 0;
	for (int i = 0; i <  M; i++) {
		cin >> a;
		if (a < N) {
			A[x]=a;
			x++;
		}
		else
		{
			b++;
		} 
		cin >> a;
	}
	int sum = 0;
	if (b < M - 1) {
		sort(A, A+x);
		reverse(A, A+x);
		for (int i = 0; i < M - 1 - b; i++) {
			sum += N - A[i];
		}
	}
	cout << sum << endl;
	*/

	//合計時間
	/*
	int sum=0, n;
	for (int i = 0; i < 4; i++) {
	cin >> n;
	sum += n;
	}
	cout << sum / 60 << endl;
	cout << sum % 60 << endl;
	//平均点
	/*
	int P[5];
	int sum=0;
	for (int i = 0; i < 5; i++) {
	cin >> P[i];
	if (P[i] < 40) P[i] = 40;
	sum += P[i];
	}
	cout << sum / 5 << endl;
	*/
	//投票
	/*
	int N, M;
	cin >> N >> M;
	int A[1000], vote[1000];
	for (int i = 0; i < N; i++) {
	cin >> A[i];
	vote[i] = 0;
	}
	int b;
	for (int i = 0; i < M; i++) {
	cin >> b;
	for (int j = 0; j < N; j++) {
	if (A[j] <= b) {
	vote[j]++;
	break;
	}
	}
	}
	int temps = 0, ans;
	for (int i = 0; i < N; i++) {
	if (vote[i] > temps) {
	temps = vote[i];
	ans = i;
	}
	}
	cout << ans + 1 << endl;
	*/

	//2.すごろく	
	/*
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int A_count[100];
	A_count[0] = 1;
	for (int i = 0; i < n; i++)
	{
	cin >> A;
	if (A == 1)
	{
	if (A == _A)
	{
	A_count[k]++;
	}
	else
	{
	k++;
	A_count[k] = 2;
	}
	}
	_A = A;
	}
	sort(A_count, A_count + k + 1);
	cout << A_count[k] << endl;
	*/

	//タイムカード
	/*
	int t[2][3];
	int x[3][3];
	for (int n=0; n < 3; n++)
	{
	for (int i=0; i < 2; i++)
	for (int k=0; k < 3; k++)
	cin >> t[i][k];

	for (int m = 2; m >= 0; m--)
	{
	x[n][m] = t[1][m] - t[0][m];
	if (t[0][m] > t[1][m])
	{
	x[n][m] += 60;
	t[1][m - 1]--;
	}
	}
	}
	for (int n= 0; n < 3; n++)
	{
	cout << x[n][0] << ' ' << x[n][1] <<' '<< x[n][2] << endl;
	}
	*/



	return 0;
}


Measured memory_bytes: 3004
g=[[0]*5 for _ in[0]*5]
for i in range(9):
 e=input()
 for j in range(4+i%2):
  if int(e[j]):
   if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1
   else:r=g[i//2];r[j]+=2;r[j+1]+=8
y,x,k=0,1,1
a='1'
while 1:
 k=k%4+2
 for _ in[0]*4:
  k+=1
  if g[y][x]&int(2**(k%4)):a+=str(k%4);break
 if k%2:x+=[1,-1][(k%4)>1]
 else:y+=[-1,1][(k%4)>0]
 if x+y==0:break
print(''.join('URDL'[int(c)]for c in a))


Measured memory_bytes: 5604
import collections

N = int(input())
a = list(map(int, input().split()))
C = collections.Counter(a)
L = len(C)
e = list(C.keys())
if (L == 1) and (C[0] > 0):
    print("Yes")
elif (L == 2) and (C[e[0]] * 2 == C[e[1]]):
    print(((e[0] ^ e[0] == e[1]) or (e[1] ^ e[1] == e[0])) and "Yes" or "No")
elif (L == 3) and (C[e[0]] == C[e[1]]) and (C[e[1]] == C[e[2]]):
    print(((e[0] ^ e[1]) == e[2]) and "Yes" or "No")
else:
    print("No")


Measured memory_bytes: 14468
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	digits, loop := nextInt(), nextInt()
	var num = make(map[int]string)

	if loop == 0 {
		if digits == 1 {
			fmt.Println(0)
			return
		} else if digits == 2 {
			fmt.Println(10)
			return
		} else if digits == 3 {
			fmt.Println(100)
			return
		}
	}

	for i := 0; i < loop; i++ {
		s, c := nextInt(), nextInt()
		if 1 < digits && s == 1 && c == 0 {
			fmt.Println(-1)
			return
		}
		if digits < s {
			fmt.Println(-1)
			return
		}
		str := strconv.Itoa(c)
		if num[s] == "" || num[s] == str {
			num[s] = str
		} else {
			fmt.Println(-1)
			return
		}
	}
	var ans int
	for i := 0; i < digits; i++ {
		digit := digits - i
		if num[i+1] != "" {
			val, _ := strconv.Atoi(num[i+1])
			ans += int(math.Pow(float64(10), float64(digit-1))) * val
		} else if num[i+1] == "" && i == 0 {
			ans += int(math.Pow(float64(10), float64(digit-1)))
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

const D: usize = 10;

fn main() {
  input! {
    h: usize,
    w: usize,
    cost: [[i64; 10]; 10],
    fld: [[i32; w]; h],
  }
  let mut cost = cost;
  for k in 0 .. D {
    for i in 0 .. D {
      for j in 0 .. D {
        cost[i][j] = cmp::min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  let mut ans = 0;
  for v in &fld {
    for &a in v {
      if a >= 0 {
        let a = a as usize;
        ans += cost[a][1];
      }
    }
  }

  println!("{}", ans);
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] + [float('inf')]*(n)
for i in range(m):
    for j in range(a[i],n+1):
        dp[j] = min(dp[j],dp[j-a[i]]+1)
        
print(dp[-1])


Measured memory_bytes: 7524
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long

const int MOD=1e9+7;

string s;
int k;
string ans[10];

bool smaller(string a,string b)
{
	if(b=="") return true;
	return a<=b;
}

int main()
{
	cin>>s;
	scanf("%d",&k);
	for(int i=0;i<s.size();i++)
		for(int j=1;j<=k;j++)
		{
			if(i+j>s.size()) continue;
			string tmp=s.substr(i,j);
			int id=k;
//			cout<<tmp<<endl;
			while(id!=0&&smaller(tmp,ans[id-1])) 
				id--; 
//			cout<<id<<" "<<ans[id]<<endl;
			if(ans[id]==tmp) continue;
			for(int l=k-1;l>id;l--) ans[l]=ans[l-1];
			ans[id]=tmp;
		}
//	for(int i=0;i<k;i++) cout<<ans[i]<<endl;
	cout<<ans[k-1];
	return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    const int mod = 1000000007;

    int h, w; cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; ++i) cin >> a[i];

    vector<vector<int>> dp(h, vector<int>(w, 0));
    dp[0][0] = 1;

    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(i == 0 && j == 0) continue;
            if(a[i][j] == '.') {
                int num = 0;
                if(i > 0) num += dp[i-1][j];
                if(j > 0) num += dp[i][j-1];
                dp[i][j] = num%mod;
            }
        }
    }

    cout << dp[h-1][w-1] << endl;

    return 0;
}


Measured memory_bytes: 9216
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=110;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
string a,b;
signed main()
{
    cin>>a>>b;
    int n=a.length(), m=b.length();
    if(n>m) puts("GREATER");
    else if(n<m) puts("LESS");
    else
    {
        for(ri int i=0;i<n;i++)
        {
            if(a[i]<b[i]) { puts("LESS"); return 0; }
            if(a[i]>b[i]) { puts("GREATER"); return 0; }
        }
        puts("EQUAL");
    }
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    char a; cin >> a;
    if (islower(a)) cout << "a" << endl;
    else cout << "A" << endl;

    return 0;
}

Measured memory_bytes: 3644
from sys import stdin

readline = stdin.readline
def main():
    # _, *keys = map(lambda s: ''.join(sorted(s.rstrip())), open(0))
    _, *keys = map(lambda s: tuple(sorted(s)), open(0))
    primes = {}
    res = 0
    for key in keys:
        if key in primes:
            res += primes[key]
            primes[key] += 1
        else:
            primes[key] = 1
    print(res)


if __name__ == "__main__":
    main()


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

from itertools import accumulate

for _ in range(k):
    imos=[0]*(n+1)
    for i in range(n):
        l=max(0,i-a[i])
        r=min(n,i+a[i]+1)
        imos[l]+=1
        imos[r]-=1
    a=list(accumulate(imos[:n]))
    if a.count(n)==n:
        break
print(*a)


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

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] face = input.split(" ");
        int num  = Integer.parseInt(br.readLine());
        
        Dice dice = new Dice();
        dice.setFace(face);
        for (int i = 0; i < num; i++) {
        	String question = br.readLine();
        	String[] q = question.split(" ");
        	String top = q[0];
        	String front = q[1];
        	
        	for (int j = 0; j < 3; j++) {
        		if (dice.getTop().equals(top)) { 
        			break;
        		}
        		dice.roll("S");
        	}
        	
        	for (int k = 0; k < 3; k++) {
        		if (dice.getTop().equals(top)) {
        			break;
        		}
        		dice.roll("W");
        	}
        	
        	for (int l = 0; l < 3; l++) {
        		if (dice.getFront().equals(front)) {
        			break;
        		}
        		dice.roll("WSE");
        	}
        	System.out.println(dice.getRight());
        }
        
    }
}

class Dice {
    private String top;
    private String front;
    private String right;
    private String left;
    private String back;
    private String bottom;

    private char direction[];

    public void setFace(String[] face) {
        this.top = face[0];
        this.front = face[1];
        this.right = face[2];
        this.left = face[3];
        this.back = face[4];
        this.bottom = face[5];
    }

    public void roll(String directions) {
        this.direction = directions.toCharArray();

        String temp;
        for (int i = 0; i < direction.length; i++) {
            switch(direction[i]) {
                case 'N':
                    temp = this.top;
                    this.top = this.front;
                    this.front = this.bottom;
                    this.bottom = this.back;
                    this.back = temp;
                    break;
                case 'W':
                    temp = this.top;
                    this.top = this.right;
                    this.right = this.bottom;
                    this.bottom = this.left;
                    this.left = temp;
                    break;
                case 'E':
                    temp = this.top;
                    this.top = this.left;
                    this.left = this.bottom;
                    this.bottom = this.right;
                    this.right = temp;
                break;
                case 'S':
                    temp = this.top;
                    this.top = this.back;
                    this.back = this.bottom;
                    this.bottom = this.front;
                    this.front = temp;
                    break;
            }

        }

    }

    public String getTop() {
        return this.top;
    }
    
    public String getFront() {
    	return this.front;
    }
    
    public String getRight() {
    	return this.right;
    }

}



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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

bool isKaibun(int num) {
  int temp = num;
  int reverse = 0;
  int remain;
  while(temp!=0) {
    remain = temp % 10;
    reverse = reverse * 10 + remain;
    temp /= 10;
  }
  return num == reverse;
}

int main() {
  int A,B; cin >> A >> B;
  int cnt;
  for (int i=A; i<=B;i++) {
    if (isKaibun(i)) cnt++;
  }
  dump(cnt);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    A = [int(input()) for _ in range(5)]
    k = int(input())

    for i in range(5):
        for j in range(i+1, 5):
            if A[j] - A[i] > k:
                print(":(")
                return

    print("Yay!")

main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
 if(n%1000==0)
   cout<<0<<endl;
  else{
  while(n%1000>1000){
    n=n%1000;
  }cout<<1000-(n%1000)<<endl;
  } return 0;
}

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

const int INF=1001001001;

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    --x; --y;
    vector<int>ans(n);
    rep(sv,n){
        vector<int>dist(n,INF);
        queue<int>q;
        auto push=[&](int v, int d){
            if(dist[v]!=INF)return;
            dist[v]=d;
            q.push(v);
        };
        push(sv,0);
        while(!q.empty()){
            int v=q.front(); q.pop();
            int d=dist[v];
            if(v-1>=0)push(v-1,d+1);
            if(v+1<n)push(v+1,d+1);
            if(v==x)push(y,d+1);
            if(v==y)push(x,d+1);
        }
        rep(i,n)ans[dist[i]]++;
    }
    rep(i,n)ans[i]/=2;
    for(int i=1;i<=n-1;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // 入力をpush_back(d)やarray[d]に使う時に無駄な変数を使わない

// ------------------- include, typedef, define END. -------------------

void solve(string ans, string kore_de_douda){
	int hit = 0, blow = 0;
	FOR(i, 0, 4){
		if (ans[i] == kore_de_douda[i])
			hit++;
		else{
			if (kore_de_douda.find(ans[i])!=string::npos)
				blow++;
		}
	}
	cout << hit << " " << blow << endl;
}

int main(){
	fastIO;
	string ans, kore_de_douda;
	while (cin >> ans >> kore_de_douda, ans!="0"||kore_de_douda!="0"){
		solve(ans, kore_de_douda);
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i,Asum=0,Bsum=0;
  cin >>N;
  vector<int> vec(N);
  for(i=0;i<N;i++) cin >>vec.at(i); 
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
//  for(i=0;i<N;i++) cout <<vec.at(i)<<endl;
  
  if(N%2==0){
    for(i=0;i<N/2;i++){
      Asum=Asum+vec.at(2*i);
      Bsum=Bsum+vec.at(2*i+1);
    }
  }
  else {
    for(i=0;i<(N-1)/2;i++){
      Asum=Asum+vec.at(2*i);
      Bsum=Bsum+vec.at(2*i+1);
    }
    Asum=Asum+vec.at(N-1);
  }
//  cout <<"Asum="<<Asum<<endl;
//  cout <<"Bsum="<<Bsum<<endl;    
  cout <<Asum-Bsum<<endl;
}

Measured memory_bytes: 256
while True:
    result = []
    try:
        sentence = raw_input()
        s_i = None
        for i, c in enumerate(sentence):
            if s_i == None:
                s_i = i
            if c == ' ' or c == ',' or c == '.':
                if 3 <= len(sentence[s_i:i]) <= 6:
                    result.append(sentence[s_i:i])
                s_i = None
        else:
            print ' '.join(result)
    except EOFError:
        break

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

vector<int> sieve(int n) {
	vector<int> res;
	vector<bool> is_prime(n + 1, true);
	
	is_prime[0] = is_prime[1] = false;
	
	for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
		res.push_back(i);
		is_prime[i] = false;
		for (int j = 2; i * j <= n; j++) if (is_prime[i * j]) {
			is_prime[i * j] = false;
		}
	}
	
	REP(i, n + 1) if (is_prime[i]) res.push_back(i);
	sort(res.begin(), res.end());
	return res;
}

int main() {
	vector<int> prime = sieve(1000000);
	set<int> ss;
	REP(i, prime.size()) ss.insert(prime[i]);
	
	int n;
	while (cin >> n, n) {
		int ans = 0;
		REP(i, prime.size()) {
			if (prime[i] * 2 > n) break;
			if (ss.find(n - prime[i]) != ss.end()) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6684