akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
 
void solve(){
    int n,r;
    cin >> n >> r;
    if(n >= 10){
        cout << r;
        return ;
    }
    cout << r + 100*(10 - n);
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int_fast16_t x, a, b;
    cin >> x >> a >> b;
    cout << (abs(a - x) < abs(b - x) ? "A" : "B") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <iomanip>
#include <vector>
using namespace std;

#define C

#ifdef C
int main(void) {
	vector<double> ans;
	int n;
	cin >> n;
	while (n > 0)
	{
		vector<double> point(n);
		double ave = 0;
		for (size_t i = 0; i < n; i++)
		{
			cin>>point[i];
			ave += point[i] / n;
		}
		double sd = 0;
		for (auto a : point)
		{
			sd += pow(a - ave, 2) / n;
		}

		ans.push_back(sqrt(sd));


		cin >> n;
	}
	for (auto a : ans)
	{
		cout << fixed << setprecision(12) << a << endl;
	}

	return 0;
}
#endif // C

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  int l;
  cin >> l;

  long double v = l * l * l;
  v /= 27;
  cout << v << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int A, B;
  char op;
  
  scanf("%d %c %d", &A, &op, &B);
  
  if (op == '+')
    printf("%d", A + B);
  
  else
    printf("%d", A - B);
  
  return 0;  
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
	int b, f, r, v, n, a[4][3][10];
	cin >> n;
	for (int k = 0; k < 4; k++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 10; j++) {
				a[k][i][j] = 0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << ' '<< a[i][j][k];
				if (k == 9) {
					cout << endl;
					if (j == 2&&i!=3) {
						for (int I = 0; I < 20; I++) {
							cout << '#';
							if (I == 19) {
								cout << endl;
							}
						}
					}
				}
			}
		}
	}
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		String ans = "Odd";
		if (a*b%2==0) {
			ans = "Even";
		}
				
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 21332
#include "bits/stdc++.h"

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

int main() {
  char c;
  cin >> c;
  cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int N;

int main(int argc, char *argv[]){
    cin >> N;
    vec S(N);
    int sum = 0;
    rep(i, N){
        cin >> S[i];
        sum += S[i];
    }
    // cout << sum << endl;
    if(sum % 10 == 0 && sum > 0){
        sort(all(S));
        int flag = 0;
        rep(i, N){
            if(S[i] % 10){
                sum -= S[i];
                flag = 1;
                break;
            }
        }
        // while(sum % 10 == 0 && sum > 0){
        //     sum -= S[i++];
        // }
        if(!flag) sum = 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
  
int n, G[110][110];
int u, k, v, mincost, a, c[110], d[110], p[110];

void prim(){

  int i, j;

  for(i = 0; i < n; i++){
    c[i] = 0;
    p[i] = -1;
    d[i] = 1000000;
  }
  
  d[0]=0;
  
  while(1){
    mincost = 1000000;
    for(i = 0; i < n; i++){
      if(c[i] != 2 && d[i] < mincost){
	mincost = d[i];
	a = i;
      }
    }
    
    if(mincost == 1000000) break;
       
    c[a] = 2;
  
    for(i = 0; i < n; i++){
      if(G[a][i] != -1 && c[i] != 2 && (G[a][i] + d[a]) < d[i]){
	p[i]= a;
	d[i] = G[a][i] + d[a];
	c[i] = 1;
      }
    }
  }
  
  for(i = 0 ; i < n; i++)
    printf("%d %d\n", i, d[i]);

}

int main(){
 
  int i, j, c;
  
  for(i = 0; i < 110; i++){
    for( j = 0; j < 110; j++){
      G[i][j] = -1;
    }
  } 

  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ;j < k ;j++){
      scanf("%d%d",&v,&c);
      G[u][v] = c;
    }
  }
  
  prim();
  
  return 0;
 
}

Measured memory_bytes: 648
x, y = map(int, input().split())
def f(n):
    if n == 1:
        return 300000
    elif n == 2:
        return 200000
    elif n == 3:
        return 100000
    return 0
result = f(x) + f(y) + (400000 if x == y == 1 else 0)
print(result)

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

type result int

const (
	PairwiseCoprime result = iota
	SetwiseCoprime
	NotCoprime
)

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

	n := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	r := solve(a)
	switch r {
	case PairwiseCoprime:
		fmt.Println("pairwise coprime")
	case SetwiseCoprime:
		fmt.Println("setwise coprime")
	case NotCoprime:
		fmt.Println("not coprime")
	}
}

func gcd(a int, b int) int {
	for {
		r := a % b
		if r == 0 {
			return b
		}
		a, b = b, r
	}
}

func solve(a []int) result {
	table := make([]map[int]struct{}, 1000000+1)

	table[1] = make(map[int]struct{})

	for i := 2; i < len(table); i++ {
		if len(table[i]) > 0 {
			continue
		}

		table[i] = make(map[int]struct{})
		table[i][i] = struct{}{}

		for j := 2; i*j < len(table); j++ {
			if len(table[i*j]) == 0 {
				table[i*j] = make(map[int]struct{})
			}
			table[i*j][i] = struct{}{}
		}
	}

	g := a[0]
	k := true
	cnt := make(map[int]int)
	for i := 0; i < len(a); i++ {
		if a[i] == 1 {
			continue
		}

		for v, _ := range table[a[i]] {
			cnt[v]++
			if cnt[v] > 1 {
				k = false
			}
		}

		g = gcd(g, a[i])
	}

	if k {
		return PairwiseCoprime
	} else if g == 1 {
		return SetwiseCoprime
	} else {
		return NotCoprime
	}
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }

    int sum = 0;
    REP(i, N) {
        sum += A[i];
    }

    if (H <= sum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int W = sc.nextInt();
		
		int [] w = new int [N];
		int [] v = new int [N];
		
		int sum_v = 0;
		
		for (int i=0; i<N; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
			sum_v += v[i];
		}
		
		long [] dp = new long [sum_v+1];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		
		for (int i=0; i<N; i++) 
			for (int j=sum_v; j>=0; j--)
				if (j - v[i] >= 0 && dp[j - v[i]] != Integer.MAX_VALUE) 
					dp[j] = Math.min(dp[j], dp[j - v[i]] + w[i]);
		
		int max = 0;

		for (int i=0; i<=sum_v; i++) {
			if (dp[i] <= W && max < i)
				max = i;
		}
		
		System.out.println(max);
	}

}

Measured memory_bytes: 21844
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Maybe (fromJust)
import Debug.Trace

solve :: Integer -> Integer -> Integer
solve n m
    | n * 2 >= m = (m `div` 2)
    | otherwise = n + fromC
    where
        fromC = (m - n * 2) `div` 4

main :: IO ()
main = do
    (n:m:_) <- map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine
    print $ solve n m

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int n, a[300005];

int main(){
	scanf("%d",&n);
	for(int i=0; i<3*n; i++) scanf("%d",&a[i]);
	sort(a, a+3*n);
	reverse(a, a+3*n);
	lint ret = 0;
	for(int i=0; i<n; i++) ret += a[2*i+1];
	cout << ret << endl;
}


Measured memory_bytes: 1408
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] input = Console.ReadLine().Split();
            int[] IntInput = new int[3];

            for (int i = 0; i < 3; i++)
            {
                IntInput[i] = int.Parse(input[i]);
            }

            Array.Sort(IntInput);
            if (IntInput[0]+ IntInput[1]== IntInput[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		
		Scanner b = new Scanner(System.in);
		
		int n = b.nextInt();
		String s = b.next();
		
		if(n >= s.length()) {
			System.out.println(s);
		}
		else{
			String f = s.substring(0, n);
			System.out.println(f + "...");
		}
	}

}


Measured memory_bytes: 38452
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
 
using namespace std;
 
const int maxn = 350;
 
char a[maxn][maxn];
 
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",a[i]);
        //printf("%s\n",a[i]);
 
    }
    int sum = 0;
    for(int k=0;k<n;k++)
    {
        bool yes = true;
        for(int i=0;yes&&i<n;i++)
        {
            for(int j=0;yes&&j<n;j++)
            {
                int ii = i+k;
                int jj = j+k;
                if(i+k>=n)
                {
                    ii -= n;
                }
                if(j+k>=n)
                {
                    jj -= n;
                }
                if(a[ii][j] != a[jj][i])
                {
                    yes = false;
                }
            }
        }
        if(yes)
        {
            sum += n;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 3884
a = gets.to_i
b = gets.to_i
# s = gets.chomp
# s,t = gets.split.map(&:to_s)
# s,t = gets.split.map(&:to_s)

# s = gets.chomp.chars.uniq
# puts gets.chomp.chars.uniq.size != 1 ? "Yes" : "No"

puts a^b

Measured memory_bytes: 1916
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
constexpr llint m_pow(llint x,uint64_t n)
{
	llint res = 1;
	while(n>0){
		if(n&1){res*=x;res%=mod;}
		x*=x;x%=mod;
		n/=2;
	}
	return res;
}

int main(void){
	//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint H,W,T;cin>>H>>W>>T;
	llint gH=H/gcd(H,T),gW=W/gcd(W,T);
	llint zyo=gcd(H,T)*gcd(W,T);
	llint mto=m_pow(2,gH)+m_pow(2,gW)+m_pow(2,gcd(gH,gW))-3;
	mto%=mod;
	cout<<m_pow(mto,zyo)<<endl;
	return 0;
}


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

using namespace std;

char down_cast(char c) {
    if(isupper(c)) c=tolower(c);
    return c;
}

int main(void) {
    string s,t;
    int c[26]={};
    while(getline(cin,t)) s+=t;

    for(int i=0;i<s.size();i++) {

        if(s[i]==' ' || s[i]=='.') continue;
        c[down_cast(s[i])-'a']++;
    }

    for(int i=0;i<26;i++) {
        printf("%c : %d\n",i+'a',c[i]);
    }
    


}

Measured memory_bytes: 1200
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;

int main() {
    int n, d; cin >> n >> d;
    cout << (n + 2 * d) / (1 + 2 * d) << endl;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())

A = np.array([int(i) for i in input().split()])
A_sort = np.sort(A)

#print(A_sort)
score = 0
score += A_sort[-1]
for i in range(0, (N-2)//2):
    score += A_sort[-2-i] * 2
    
if (N-2) % 2 == 1:
    score += A_sort[-3-i]
    
print(score)


Measured memory_bytes: 50076
import numpy as np
n = int(input())

A = [int(s) for s in input().split()]
B = [int(t) for t in input().split()]
B.append(0)

A = np.array(A)
B = np.array(B)
C = B - A
dm_sum = 0

y = 0
for i in range(n+1):
    dm = C[i] + y
    if dm >= 0:
        dm_sum += A[i]
        if y >= A[i]:
            y = B[i]
        else:
            y = dm
    else:
        dm_sum += B[i] + y
        y = 0

print(dm_sum)


Measured memory_bytes: 27324
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    cost = [float('inf')] * n
    cost[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j < 0:
                break
            else:
                cost[i] = min(cost[i], cost[i - j] + abs(h[i] - h[i - j]))
    print(cost[n - 1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 54752
/*
  Code By RyeCatcher
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>
#include <utility>
#define ri register int
#define ll long long
#define ull unsigned long long
#define pb push_back
#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define SIZE 23333
using std::min;
using std::max;
using std::pair;
using std::queue;
using std::priority_queue;
using std::vector;
inline char gc(){
    static char buf[SIZE],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
template <class T>inline void read(T &x){
	x=0;int ne=0;char c;
    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;
    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;
}
const int maxn=200005;
const int inf=0x7ffffff;
int sum[maxn<<3];
int n,m,q;
inline void add(int x,int d){for(;x<=n;x+=x&(-x))sum[x]+=d;return ;}
inline int query(int x){int ans=0;for(;x;x-=x&(-x))ans+=sum[x];return ans;}
struct Pt{
	int x,y,id;
	bool operator <(const Pt &rhs)const{
		return (x==rhs.x)?(y==rhs.y?id<rhs.id:y<rhs.y):x>rhs.x;
	}
}pt[maxn<<2];
int tot=0,qry[maxn];
int main(){
	int x,y;
	read(n),read(m),read(q);
	for(ri i=1;i<=m;i++){
		read(x),read(y);
		pt[++tot]=(Pt){x,y,0};
	}
	for(ri i=1;i<=q;i++){
		read(x),read(y);
		pt[++tot]=(Pt){x,y,i};
	}
	std::sort(pt+1,pt+1+tot);
	for(ri i=1;i<=tot;i++){
		//printf("%d %d %d %d\n",i,pt[i].id,pt[i].x,pt[i].y);
		if(!pt[i].id)add(pt[i].y,1);
		else qry[pt[i].id]=query(pt[i].y);
	}
	for(ri i=1;i<=q;i++)printf("%d\n",qry[i]);
	return 0;
} 

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

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

using ll = long long;
constexpr ll INF = 10000000000;

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

using namespace std;

//fixed << setprecision(10)

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

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

	string s1 = s.substr(0, (n / 2));
	string s2 = s.substr(n / 2, n - 1);

	if (n % 2 == 1) {
		cout << "No" << endl;
	}
	else if (s1 == s2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

using namespace std;

int sq(int n){
    return n*n;
}

int main(){
    char c[10];
    while(cin>>c && c[0]!='0'){
        unsigned md=1<<30;
        int cn;
        unsigned cd=strtoul(c+1,0,16);
        rep(i,8){
            unsigned d=0;
            rep(j,3){
                static const unsigned cc[]={0x0,0xff,0xff00,0xffff,0xff0000,0xff00ff,0xffff00,0xffffff};
                d+=sq((cd>>j*8&0xFF)-(cc[i]>>j*8&0xFF));
            }
            if(d<md){
                md=d;
                cn=i;
            }
        }

        const string cstr[]= {
            "black",
            "blue",
            "lime",
            "aqua",
            "red",
            "fuchsia",
            "yellow",
            "white"
        };
        cout<<cstr[cn]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1196
class Saikoro:

    def sai(self,one,two,three,four,five,six):
        self.s1=int(one)
        self.s2=int(two)
        self.s3=int(three)
        self.s4=int(four)
        self.s5=int(five)
        self.s6=int(six)

    def turnE(self):
        e=[self.s4,self.s2,self.s1,self.s6,self.s5,self.s3]
        self.s1=e[0]
        self.s2=e[1]
        self.s3=e[2]
        self.s4=e[3]
        self.s5=e[4]
        self.s6=e[5]

    def turnN(self):
        n=[self.s2,self.s6,self.s3,self.s4,self.s1,self.s5]
        self.s1=n[0]
        self.s2=n[1]
        self.s3=n[2]
        self.s4=n[3]
        self.s5=n[4]
        self.s6=n[5]

    def turnS(self):
        s=[self.s5,self.s1,self.s3,self.s4,self.s6,self.s2]
        self.s1=s[0]
        self.s2=s[1]
        self.s3=s[2]
        self.s4=s[3]
        self.s5=s[4]
        self.s6=s[5]

    def turnW(self):
        w=[self.s3,self.s2,self.s6,self.s1,self.s5,self.s4]
        self.s1=w[0]
        self.s2=w[1]
        self.s3=w[2]
        self.s4=w[3]
        self.s5=w[4]
        self.s6=w[5]




l=input().split()
m=list(input())

sai1=Saikoro()
sai1.sai(l[0],l[1],l[2],l[3],l[4],l[5])

n=len(m)
i=0

while i<n:
    if m[i]=="E":
        sai1.turnE()
    elif m[i]=="N":
        sai1.turnN()
    elif m[i]=="S":
        sai1.turnS()
    else:
        sai1.turnW()
    i+=1
print(sai1.s1)


Measured memory_bytes: 5616
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
}

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

vector<pair< int,int> > v;
map<int,int> mp;
int N,M;
int main () {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
        if( a == N ) mp[b]++;
        if( b == N ) mp[a]++;
    }
    for(int i=0; i<M; i++) {
        int a = v[i].first;
        int b = v[i].second;
        if( a == 1 && mp[b] ) {
            cout << "POSSIBLE" << endl;
            return 0;
        } else if ( b == 1 && mp[a]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }

    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 11248
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  map<ll, ll> m;
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    m[A[i]]++;
    sum += A[i];
  }
  ll Q;
  cin >> Q;
  vector<ll> b(Q), c(Q);
  for (int i = 0; i < Q; i++) {
    cin >> b[i] >> c[i];
  }
  for (int i = 0; i < Q; i++) {
    sum -= m[b[i]] * b[i];
    sum += m[b[i]] * c[i];
    ll b_size = m[b[i]];
    m[c[i]] += b_size;
    m[b[i]] -= b_size;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 11364
#include <iostream>

using namespace std;

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << (j < a == i < b);
        }
        cout << "\n";
    }
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
#define MAX 25
#define NIL -1

struct Node {
  int parent;
  int left;
  int right;
};

Node T[MAX];
int n;

void preorder(int v) {
  if (v==NIL) {
    return;
  }
  cout << " " << v;
  preorder(T[v].left);
  preorder(T[v].right);
}

void inorder(int v) {
  if (v==NIL) {
    return;
  }
  inorder(T[v].left);
  cout << " " << v;
  inorder(T[v].right);
}

void postorder(int v) {
  if (v==NIL) {
    return;
  }
  postorder(T[v].left);
  postorder(T[v].right);
  cout << " " << v;
}

int main() {
  cin >> n;
  for (int i=0; i<n; i++) {
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  int v, l, r;
  for (int i=0; i<n; i++) {
    cin >> v >> l >> r;
    T[v].left = l;
    T[v].right = r;
    if (l!=NIL) {
      T[l].parent = v;
    }
    if (r!=NIL) {
      T[r].parent = v;
    }
  }

  int root;
  for (int i=0; i<n; i++) {
    if (T[i].parent == NIL) {
      root = i;
    }
  }

  cout << "Preorder" << endl;
  preorder(root);
  cout << endl;
  cout << "Inorder" << endl;
  inorder(root);
  cout << endl;
  cout << "Postorder" << endl;
  postorder(root);
  cout << endl;

  return 0;
}



Measured memory_bytes: 3132
N = int(input())
D,X = (int(i) for i in input().split())
A = [int(input()) for i in range(N)]

def count(a):
    tmp,cnt,i = 1,0,1
    while tmp <= D:
        cnt += 1
        tmp = a*i+1
        i+=1
    return cnt

cnt = 0
for a in A:
    cnt += count(a)
print(cnt+X)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X; cin>>X;
  cout<<(X>=30?"Yes":"No")<<endl;
}

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

using namespace std;

const int INF = 1e9 + 5;

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


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vi b(n);
    rep(i, n-1) {
        if (s.substr(i, 2) == "AC") b[i+1] = b[i] + 1;
        else b[i+1] = b[i];
    } 
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        --l; --r;
        cout << (b[r]-b[l]) << endl;
    }
    return 0;
}


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

#define max 30

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int i, a, b;
    
    scanf("%d %d", &a, &b);
    
    for (i=0; i<max; i++) {
        if (a*i-(i-1)>=b) {
            printf("%d", i);
            return 0;
        }
    }

    return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

const int MOD = 1000000007;


//a - > 1
//b ->  2

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    //方針: aもbも一律に同じリストに入れる
    //ソートして、bなら1回だけ使って次のを使うaなら、無限に使う
    ll n,h;
    cin >> n >> h;
    ll a,b;
    vector <pair<ll,int>> p;
    REP(i,n)
    {
        cin >> a >> b;
        p.push_back(pair<ll,int>{a, 1});
        p.push_back(pair<ll,int>{b, 2});
    }
    sort(p.begin(),p.end(), greater<pair<ll,int>>());

    ll res = 0;
    REP(i,n * 2)
    {
        if(p[i].second == 1)
        {
            ll tmp = (h-1)/p[i].first + 1;
            res += tmp;
            break;
        }

        ++res;
        h -= p[i].first;
        if(h <= 0)break;
    }

    cout << res << endl;

    return 0;     
}



Measured memory_bytes: 6512
from collections import deque

n, m = map(int, input().split())
P = list(map(int, input().split()))
graph = [[] for _ in range(n)]
cands = set()
for _ in range(m):
    x, y = map(int, input().split())
    graph[x - 1].append(y - 1)
    graph[y - 1].append(x - 1)
    cands.add(x - 1)

group = [-1] * n
def dfs(start, size, num):
    q = deque(maxlen=size)
    q.append(start)
    used = {start}
    group[start] = num
    while q:
        node = q.popleft()
        for to in graph[node]:
            if to in used:
                continue
            q.append(to)
            used.add(to)
            group[to] = num

count = 0
for node in cands:
    if group[node] == -1:
        dfs(node, n, count)
        count += 1

print(sum(i == P[i] - 1 or group[P[i] - 1] == group[i] != -1 for i in range(n)))


Measured memory_bytes: 37452
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    int N = SZ(s);
    REP(i, SZ(s)) {
        REP(j, SZ(s)) {
            if (i + j >= N) break;
            string t = s.substr(0, i) + s.substr(i + j, N - (i + j) + 1);
            if (t == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = A[0]
i = 2
j = 1
while(True):
    if i == N:
        break
    ans += A[j]
    i += 1
    if i == N:
        break
    ans += A[j]
    i += 1
    j += 1

print(ans)

Measured memory_bytes: 105180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

string LCS(const string& s,const string& t){
    int n = s.size(), m = t.size();

    vector<vi> dp(n+10, vi(m+10,0));
    rep(i,n){
        rep(j,m){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    /*rep(i,n+1){
        rep(j,m+1) cout << dp[i][j] << " ";
        cout << endl;
    }*/

    string ret = "";
    while(n>0 && m>0){
        if(dp[n-1][m] == dp[n][m]){
            --n;
        }else if(dp[n][m-1] == dp[n][m]){
            --m;
        }else{
            ret += s[n-1];
            --n;--m;
        }
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main(){
    string s,t;cin >> s >> t;
    cout << LCS(s,t) << endl;
}

Measured memory_bytes: 35712
X,Y,n=map(int,input().split())
x=y=0
for i in range(n):
    a,b,c=map(int,input().split())
    if c==1 and x<a:x=a
    if c==2 and X>a:X=a
    if c==3 and y<b:y=b
    if c==4 and Y>b:Y=b
print(max(X-x,0)*max(Y-y,0))


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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

bool comp(ll a, ll b) {
	return a > b;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int cont = 1;
    char l = s[0];
    for (int i = 1; i < n; i++) {
        if (s[i] == l) continue;
        l = s[i];
        cont++;
    }
    cout << cont << "\n";
	return 0;
}

Measured memory_bytes: 512
import sys
# from math import log2 // New in Python 3.3, not in PyPy3 2.4 (Python 3.2.5)

N, K = map(int, input().split())

AB = []
for _ in range(N):
    AB.append([int(s) for s in input().split()])

ans = sum([b for a, b in AB if K | a == K])
# for i in range(int(log2(K)), 0, -1):
for i in range(int.bit_length(K) - 1, 0, -1):
    if not K & (1 << i):
        continue
    km = K & ~(1 << i) | (1 << i) - 1
    anscand = sum([b for a, b in AB if km | a == km])
    ans = max(ans, anscand)
print(ans)


Measured memory_bytes: 77568
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL INF = 1e10;

int main(){
    int N;
    cin >> N;
    vector<vector<LL>> a(N, vector<LL>(N, INF)), d(N, vector<LL>(N, INF));
    bool f = false;
    for(int i = 0;i < N;i++)   for(int j = 0;j < N;j++)   cin >> a[i][j];
    for(int k = 0;k < N;k++){
        for(int i = 0;i < N;i++){
            for(int j = 0;j < N;j++){
                d[i][j] = min(a[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    LL ans = 0;
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(d[i][j] < a[i][j]){
                f = true;
            }else{
                bool ff = true;
                for(int k = 0;k < N;k++){
                    if(k == i || k == j)    continue;
                    if(d[i][k]+d[k][j] == a[i][j])  ff = false;
                }
                if(ff)  ans += a[i][j];
            }
        }
    }
    if(f)   cout << -1 << endl;
    else    cout << ans/2 << endl;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;


void merge(int *arr, int start, int split, int end) {
    int *newarr = new int[end-start];
    int l1 = split - start;
    int l2 = end - split;
    int i = 0;
    int j = 0;
    int k;
    while (true) {
        if(arr[start+i] < arr[split+j]) {
            newarr[i+j] = arr[start+i];
            i++;
        } else {
            newarr[i+j] = arr[split+j];
            j++;
        }
        if(i==l1) {
            for(k = j; k < l2; k++) {
                newarr[i+k] = arr[split+k];
            }
            break;
        }
        if(j==l2) {
            for(k = i; k < l1; k++) {
                newarr[k+j] = arr[start+k];
            }
            break;
        }
    }
    for(k = 0; k < end-start; k++) {
        arr[start+k] = newarr[k];
    }
    delete[] newarr;
}


void sort(int *arr, int start, int end) {
    if (start+1 == end) return;
    int split = (start+end)/2;
    sort(arr, start, split);
    sort(arr, split, end);
    merge(arr, start, split, end);
}


int main(void){

    long n;
    cin >> n;
    int *a = new int[n];
    int *b = new int[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a,0,n);
    sort(b,0,n);

    if(n%2==1) {
        cout<<(b[n/2]-a[n/2]+1)<<"\n";
    } else cout << (b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1) <<"\n";


    



    return 0;
}

Measured memory_bytes: 5976
#include<iostream>

using namespace std;

int main(){
  int a,b,c,k;
  cin >> a >> b >> c;
  cin >> k;
  
  for(int i = 0; i < k+1; i++){
    for(int j = 0; j < k+1; j++){
      for(int l = 0; l < k+1;l++){
        if(a << i < b << j && b << j < c << l && i + j + l <= k){
          cout << "Yes";
          return 0;
        }
      }
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
        char array[100];

        scanf("%s",array);

        if(array[0] == 'S'  && array[1] == 'U'){
                printf("7\n");
        }else if(array[0] == 'M'){
                printf("6\n");
        }else if(array[0] == 'T' && array[1] == 'U'){
                printf("5\n");
        }else if(array[0] == 'W'){
                printf("4\n");
        }else if(array[0] == 'F'){
                printf("2\n");
        }else if(array[0] == 'S'){
                printf("1\n");
        }else if(array[0] == 'T' && array[1] == 'H'){
                printf("3\n");
        }
        return 0;
}




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

int main() {
  int n, z, w;
  cin >> n >> z >> w;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << abs(a[0] - w) << endl;
  } else {
    cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x7fffffff
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int a,b,ans;
int main(){
	a=read(),b=read();
	while(a)
	{
		a/=b;
		ans++;
	}
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    STR(s);
    ll res = SZ(s) * (SZ(s) - 1) / 2;
    map<char, ll> mp;
    REP(i, SZ(s)) mp[s[i]]++;
    for(auto v: mp) res -= v.second * (v.second - 1) / 2;
    print(res + 1);
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  cin >> s1s2s3;
  int hundred, ten, one;
  hundred = s1s2s3 / 100;
  s1s2s3 = s1s2s3 % 100;
  ten = s1s2s3 / 10;
  s1s2s3 = s1s2s3 % 10;
  one = s1s2s3;
  cout << hundred + ten + one << endl;
}

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

vector<vector<int> > dp(100, vector<int>(10001, -1));
int N;
vector<int> v(100, 0), w(100, 0);

int solve(int i, int W){
  if(i == N)return 0;
  if(dp[i][W] != -1)return dp[i][W];
  if(w[i] <= W){
    return dp[i][W] = max(solve(i + 1, W - w[i]) + v[i], solve(i + 1, W));
  }else return dp[i][W] = solve(i + 1, W);
}

int main(){
  int W;
  cin >> N >> W;
  for(int i = 0; i < N; i++){
    cin >> v[i] >> w[i];
  }
  cout << solve(0, W) << endl;
}

Measured memory_bytes: 6684
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define endl '\n'

//Constants
const int N = 1e5 + 5;

//Data
int n, m;
int arr[N];

//Methods
long long lcm(long long a, long long b)
{
  return a / __gcd(a, b) * b;
}

int main()
{
  cin >> n >> m;
  for(int i = 0 ; i < n ; i++){
    cin >> arr[i];
    arr[i] >>= 1;
  }
  long long cur = arr[0];
  for(int i = 1 ; i < n ; i++){
    cur = lcm(cur, arr[i]);
    if(cur > m)
      return cout << 0 << endl, 0;
  }
  for(int i = 0 ; i < n ; i++){
    if((cur / arr[i]) % 2 == 0)
      return cout << 0 << endl, 0;
  }
  cout << (m / cur + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
double dp[301][301][301];
int main() {
    int n; cin >> n;
    int x[3]; memset(x, 0, sizeof(x));
    for (int i = 0; i < n; i++) {
        int p; cin >> p;
        x[p-1]++;
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                if (i+j+k > n || i+j+k == 0) continue;
                dp[i][j][k] = 1;
                if (i) dp[i][j][k] += dp[i-1][j+1][k] * i / n;
                if (j) dp[i][j][k] += dp[i][j-1][k+1] * j / n;
                if (k) dp[i][j][k] += dp[i][j][k-1] * k / n;
                dp[i][j][k] /= (double) (i+j+k) / n;
            }
        }
    }
    printf("%.12f\n", dp[x[2]][x[1]][x[0]]);
    return 0;
}

Measured memory_bytes: 213248
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#include<math.h>
#include<iomanip>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
typedef long double ld;
int main() {
	char c;
	cin >> c;
	c++;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
H, W, D = list(map(int, input().split()))
 
dic = {}
for i in range(H):
    for j,v in enumerate(list(map(int, input().split()))):
        dic[v] = (i,j)
 
Q = int(input())
 
Qs = []
mi = 100000
ma = 1
for i in range(Q):
    l,r = list(map(int, input().split()))
    Qs.append((l,r))
    mi = min(mi, l)
    ma = max(ma, r)
 
S = [0 for i in range(100000)]
acm = 0
pi, pj = dic[mi]
for start in range(1, D+1):
    for i in range(start, ma+1, D):
        x,y = dic[i]
        acm += abs(x-pi) + abs(y-pj)
        S[i] = acm
        pi,pj = x,y

for i in Qs:
    l,r = i
    print(S[r] - S[l])


Measured memory_bytes: 36288
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int n,m,a[200005],sum[200005],suf[200005],ans;

int main()
{
	m=read();
	n=read();
	for ( int i=1;i<=n;i++ ) 
	{
		a[i]=read();
		if(i!=1) ans+=a[i]-a[i-1];
	}
	for ( int i=2;i<=n;i++ ) sum[i]=sum[i-1]+(a[i]-a[i-1]);
	for ( int i=n-1;i>=1;i-- ) suf[i]=suf[i+1]+(a[i+1]-a[i]);
	for ( int i=2;i<n;i++ ) 
		ans=min(ans,a[1]+sum[i]+m-a[n]+suf[i+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());

		int ans;

		if (n == 1){
			ans = Math.abs(Integer.parseInt(sc.next())-x);
		}else {
			ans = gcd(Math.abs(Integer.parseInt(sc.next())-x), Math.abs(Integer.parseInt(sc.next())-x));
			for(int i=2; i<n; i++){
				int x_elem = Integer.parseInt(sc.next());
				ans = gcd(ans, Math.abs(x_elem-x));
			}
		}
		System.out.println(ans);
	}

//	public static int gcd(int a,int b) {
//		return a%b==0?b:gcd(b,a%b);
//	}

	public static int gcd(int num1, int num2) {
		int x = Math.max(num1, num2);
		int y = Math.min(num1, num2);

		while (y != 0) {
			int tmp = x;
			x = y;
			y = tmp%y;
		}
		return x;
	}
}


Measured memory_bytes: 44352
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int h, w, d; cin >> h >> w >> d;
  VVI a(h, VI(w));
  vector<P> ia(h * w);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      a[i][j]--;
      ia[a[i][j]] = P(i, j);
    }
  }

  VI t(h * w);
  for (int i = 0; i < h * w; i++) {
    if (i < d) continue;
    t[i] = t[i - d] + abs(ia[i].first - ia[i - d].first) + abs(ia[i].second - ia[i - d].second);
  }

  int q; cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r; cin >> l >> r;
    l--, r--;
    cout << t[r] - t[l] << '\n';
  }  
  return 0;
}

Measured memory_bytes: 2560