akhauriyash/Code-Regression huggingface dataset:
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();

		Arrays.fill(memo, -1);
		Main main = new Main();
		System.out.println(main.searchRucasNum(N));

	}
	static long[] memo= new long[87];
	public long searchRucasNum(int n) {
		long ans;
		if (memo[n] != -1) {
			ans = memo[n];
		}else {
			if (n == 0) {
				ans =  2;
			}else if (n == 1) {
				ans =  1;
			}else {
				ans =  searchRucasNum(n-1)+searchRucasNum(n-2);
			}
		}
		if (memo[n] == -1) {memo[n] = ans;}
		return ans;
	}

}



Measured memory_bytes: 35864
#include <stdio.h>

int main(void) {
	
	int m, f, r, goukei;
	
	while(1){
		scanf("%d %d %d",&m, &f, &r);
		
		goukei = m + f;
		
		if(m == -1 && f == -1 && r == -1){
			break;
		}
		
		if(m == -1 || f == -1){
			printf("F\n");
		}else if(goukei >= 80){
			printf("A\n");
		}else if(goukei < 80 && goukei >= 65){
			printf("B\n");
		}else if(goukei <65 && goukei >= 50){
			printf("C\n");
		}else if(goukei < 50 && goukei >= 30 && r >=50){
			printf("C\n");
		}else if( goukei >= 30 && goukei < 50){
			printf("D\n");
		}else{
			printf("F\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    int a,mi=5000,MA=0;
    int c[9]={};
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<3200)
        c[a/400]++;
        else c[8]++;
    }
    int kind=0,kindM;
    for(int i=0;i<8;i++){
        if(c[i])kind++;
    }
    if(c[8]) kindM=kind+c[8];
    else kindM=kind;
    if(kind==0) kind++;
    cout<<kind<<" "<<kindM;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	vector<int>list;
};


signed main() {
	int i, j, k;
	int n, m, cnt;
	vector<vector<vector<int>>>list(4, vector<vector<int>>(3, vector<int>(10, 0)));



	cin >> n;



	for (i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		list[b - 1][f - 1][r - 1] += v;
	}



	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < 10; k++) {
				cout << " " << list[i][j][k];
			}
			cout << endl;
		}

		if (i != 3) {
			cout << "####################" << endl;
		}
	}













	getchar();
	getchar();
	return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=3e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b;cin>>a>>b;
    if(b%a)cout<<b-a;
    else cout<<b+a;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	A := make([]int, M)
	B := make([]int, M)
	for i := 0; i < M; i++ {
		A[i] = sc.nextInt() - 1
		B[i] = sc.nextInt() - 1
	}
	un := NewUnionFind(N)
	ans := make([]int, M)
	cur := N * (N - 1) / 2
	for i := M - 1; i >= 0; i-- {
		ans[i] = cur
		a, b := A[i], B[i]
		if !un.isSame(a, b) {
			cur -= un.getSize(a) * un.getSize(b)
			un.unite(a, b)
		}
	}
	for i := 0; i < M; i++ {
		fmt.Fprintln(wtr, ans[i])
	}
}

type UnionFind struct {
	parent []int
	size   []int
}

func NewUnionFind(n int) *UnionFind {
	p := make([]int, n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = i
		s[i] = 1
	}
	return &UnionFind{p, s}
}

func (a *UnionFind) root(x int) int {
	if a.parent[x] == x {
		return x
	} else {
		a.parent[x] = a.root(a.parent[x])
		return a.parent[x]
	}
}

func (a *UnionFind) isSame(x, y int) bool {
	return a.root(x) == a.root(y)
}

func (a *UnionFind) unite(x, y int) {
	x = a.root(x)
	y = a.root(y)
	if x == y {
		return
	} else {
		a.parent[x] = y
		a.size[y] += a.size[x]
	}
}

func (a *UnionFind) getSize(x int) int {
	return a.size[a.root(x)]
}


Measured memory_bytes: 8832
#include<stdio.h>
int main(){
    int n,k;scanf("%d %d",&n,&k);
    int r,s,p;scanf("%d %d %d",&r,&s,&p);
    char t[200000];scanf("%s",t);

    int table[200000]={};
    for(int i=0;i<n;i++){
        if(t[i]=='r'){
            table[i]=p;
        }else if(t[i]=='s'){
            table[i]=r;
        }else{
            table[i]=s;
        }
    }
    //for(int i=0;i<n;i++)printf("%d ",table[i]);
    unsigned long long int ans=0;
    for(int i=0;i<k;i++)ans+=table[i];
    for(int i=k;i<n;i++){
        if(t[i]!=t[i-k])ans+=table[i];
        else t[i]='.';
    }
    printf("%llu\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)



int main(){
    int n, k;
    cin >> n >> k;
    char dat[n];
    REP(i, n) { dat[i] = 0; }
    REP(i, k){
        int d;
        cin >> d;
        int a;
        REP(j, d){
            cin >> a;
            dat[a-1] = 1;
        }
    }
    int res = 0;
    REP(i, n){
        if(dat[i] == 0) { res++; }
    }
    cout << res << endl;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

ll saiki(ll am){
  if (am==1){
    return 1;
  }
  else
  {
    return 2*saiki(am/2) + 1;
  }
  
}

int main(){
  ll h,ans;
  ans = 0;
  IN1(h);
  ans = saiki(h);
  OUT(ans);
}

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

const int MOD = 998244353;

long long ipow(long long a, long long b)
{
    if(b==0) return 1;
    long long ans = ipow(a, b/2);
    ans = ans*ans%MOD;
    if(b%2==1) ans=ans*a%MOD;
    return ans;
}
long long fact(int N)
{
    long long ret = 1;
    for(int i=1; i<=N; ++i) ret=ret*i%MOD;
    return ret;
}
int solve(int N)
{
    long long ans = ipow(3, N);

    long long nCk = fact(N)*ipow(fact(N/2), 2*(MOD-2))%MOD;;
    for(int k=N/2+1; k<=N; ++k)
    {
        nCk = nCk * ipow(k, MOD-2)%MOD*(N-k+1)%MOD;
        ans -= 2*nCk*ipow(2, N-k);
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }
    return ans;
}

int main()
{
    int N; scanf("%d", &N);
    printf("%d\n", solve(N));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
// #define mdfs
int N,M;

int main(void){
    // Your code here!
    cin >> N >> M;
    if ((N % 2 == 1) and (M % 2 == 1)) {
        cout << "Odd" << endl;
    }
    else cout << "Even" << endl;

}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())
Ak = 0

for i in range(K):
    if A >= B:
        B = B * 2
        Ak = i + 1
    else:
        break

if K - Ak > 0:
    for j in range(K - Ak):
        if B >= C:
            C = C * 2
else:
    print("No")
    exit()

if A < B and B < C:
    print("Yes")
else:
    print("No")



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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        string S = Read();
        bool[] flag = new bool[10000];
        bool[] lFlag = new bool[10];
        bool[] rFlag = new bool[10];
        bool[] cFlag = new bool[10];
        int ans = 0;

        for (int i = 0; i < N - 2; i++)
        {
            if (!lFlag[S[i] - '0'])
            {
                lFlag[S[i] - '0'] = true;
                rFlag = new bool[10];
                for (int j = N - 1; j > i + 1; j--)
                {
                    if (!rFlag[S[j] - '0'])
                    {
                        rFlag[S[j] - '0'] = true;
                        cFlag = new bool[10];
                        for (int k = i + 1; k < j; k++)
                        {
                            if (!cFlag[S[k] - '0'])
                            {
                                cFlag[S[k] - '0'] = true;
                                ans++;
                            }
                        }                        
                    }
                }
            }
        }
        return ans.ToString();
    }


    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11200
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

vector<ll> divisors(ll n){
    vector<ll> ret;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            ret.push_back(i);
            if(i * i != n)ret.push_back(n/i);
        }
    }
    sort(all(ret));
    return ret;
}

int main() {
    ll n, k, ans;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    for(auto x : divisors(accumulate(all(a), 0LL))){
        vector<ll> b(n); 
        ll ok = false, sum1 = 0, sum2 = 0;
        rep(i, n)b[i] = a[i] % x; 
        rep(i, n)sum1 += (x-b[i]) % x; sort(all(b));
        rep(i, n){
            if(max(sum1, sum2) <= k)ok = true;
            sum1 -= (x-b[i]) % x;
            sum2 += b[i];
        }
        if(ok)ans = x;
    }
    cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		try {
			while ((buffer = reader.readLine())  != null) {
				int i = Integer.valueOf(buffer);
				System.out.println(i * i * i);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 24192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using pii = pair<int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> priorities(n, vector<int>(m));
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			cin >> priorities[i][j];
			--priorities[i][j];
		}
	}
	int answer = n;
	vector<bool> alive(m, true);
	for(int iter = 0; iter < m; ++iter){
		vector<int> b(m);
		for(int i = 0; i < n; ++i){
			for(const int s : priorities[i]){
				if(alive[s]){
					++b[s];
					break;
				}
			}
		}
		const int x = max_element(b.begin(), b.end()) - b.begin();
		answer = min(answer, b[x]);
		alive[x] = false;
	}
	cout << answer << endl;
	return 0;
}



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

const int maxv = 1010;
vector<int> g[maxv];
int color[maxv];
bool dfs(int v, int c) {
    color[v] = c;
    for (int & u : g[v]) {
        if (color[u] == c) return false;
        if (color[u] == 0 and !dfs(u, -c)) return false;
    }
    return true;
}

int main() {
    int n, m;

    while (cin >> n >> m and n and m) {
        rep(i, n) g[i].clear();
        fill(color, color+n, 0);
        rep(i, m) {
            int u, v;
            cin >> u >> v;
            u--; v--;
            g[u].push_back(v);
            g[v].push_back(u);
        }
        if (!dfs(0, 1)) {
            cout << 0 << endl;
            continue;
        }
        int w=0, b=0;
        rep(i, n) {
            if (color[i] == 1) w++;
            else b++;
        }
        set<int> st;
        if (w%2 == 0) st.insert(w/2);
        if (b%2 == 0) st.insert(b/2);
        cout << st.size() << endl;
        for (int k : st) {
            cout << k << endl;
        }
    }


}



Measured memory_bytes: 3292
N, K = map(int, input().split())
MOD = 10 ** 9 + 7

R = N - K + 1
# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in range(1, 2000 + 2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD


for i in range(1, K + 1):
    if i != K:
        print(nCr(R, i) * nCr(K - 1, i - 1) % MOD)
    if i == K:
        print(nCr(R, i) % MOD)


Measured memory_bytes: 3444
#include <stdio.h>

int main(void){

        int a, b;
        int area, len;
        scanf("%d %d", &a, &b);

        if (1 <= a  && a <= 100 && 1 <= b && b <= 100){
                area = a * b;
                len = a*2 + b*2;
        }

        printf ("%d %d\n", area, len);

        return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  ll n;
  cin >> n;
  string s;
  while(n){
    char c = 'a' + (n+25) % 26;
    s =  c + s;
    n = (n - (n + 25) % 26) / 26;
  }
  cout << s <<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    ll N;
    set<string> T;
    cin >> N;
    string s;
    for(int i = 0; i < N; i++){
        cin >> s;
        T.insert(s);
    }
    /*for(set<string>::iterator it = T.begin(); it != T.end(); it++){
        cout << *it << endl;
    }*/
    cout << T.size() << endl;
    return 0;
}

Measured memory_bytes: 19252
n,m=map(int,input().split())
sa=set()
sb=set()
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        sb.add(b)
    if b==n:
        sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")

Measured memory_bytes: 19024
#include <stdio.h>
#include <math.h>

#define PI 3.14159265358979323846264338327950L

 int main(void) {
 int a, b, h, m;
scanf("%d%d%d%d", &a, &b, &h, &m);

 long double rad = PI * 2 * (
 (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long
double)m / 60.0);

 long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
b) * cosl(rad);

 printf("%20.20Lf\n", sqrtl(rsq));


 return 0;
 }


Measured memory_bytes: 2580
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

char s[6001];
int a[6000];
int b[6000];
int h[6001];
int m[6001];
int z[6001];

string solvea(int l, int r) {
    int i;
    string ans = "";
    
    for (i = l; i < r; i++) {
        if (s[i] == 'a') {
            ans += "ab";
            i = b[a[i]];
        }
    }
    
    return ans;
}

string solveb(int l, int r) {
    int i, j;
    string ans = "";
    
    for (i = 0; i < (r - l) / 2; i++) {
        int c[2] = {};
        string tmp = "";
        
        for (j = l; j < r; j++) {
            if (c[s[j] - 'a']++ >= i) tmp += s[j];
        }
        
        if (tmp > ans) ans = tmp;
    }
    
    return ans;
}

int main() {
    int n, ca = 0, cb = 0, i;
    vector <string> v;
    string ans = "";
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < n * 2; i++) {
        if (s[i] == 'a') {
            a[i] = ca++;
            h[i + 1] = h[i] - 1;
        } else {
            b[cb++] = i;
            h[i + 1] = h[i] + 1;
        }
    }
    
    m[n * 2] = z[n * 2] = n * 2;
    
    for (i = n * 2 - 1; i >= 0; i--) {
        m[i] = m[i + 1];
        z[i] = z[i + 1];
        if (h[i] >= h[m[i]]) m[i] = i;
        if (h[i] == 0) z[i] = i;
    }
    
    for (i = 0; i < n * 2; ) {
        if (s[i] == 'a') {
            v.push_back(solvea(i, z[i + 1]));
        } else {
            v.push_back(solveb(i, z[i + 1]));
        }
        
        i = z[i + 1];
    }
    
    for (i = v.size() - 1; i >= 0; i--) {
        if (v[i] + ans > ans) ans = v[i] + ans;
    }
    
    printf("%s\n", ans.c_str());
    
    return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline

n = int(input())

from collections import defaultdict

d = defaultdict(int) # d[(a, b)] : 先頭a, 末尾b

for i in range(1, n + 1):
    i_str = str(i)
    d[(i_str[0], i_str[-1])] += 1

ans = 0

for i in range(1, 10):
    for j in range(10):
        ans += d[(str(i), str(j))] * d[(str(j), str(i))]

print(ans)

Measured memory_bytes: 68292
n,m,*t=`dd`.split.map &:to_i
edges=t.each_slice(2).map{|a,b|[a-1, b-1]}

g=[[]]
visited=[]
dfs=->v do
    return if visited[v]
    visited[v]=true
    g[v].each{|u|dfs[u]}
end

p (0...m).count{|i|
    g=(0...n).map{[]}
    edges.each_with_index{|e,j| a,b=e; (g[a] << b; g[b] << a) if i!=j}
    visited=[false]*n
    dfs[0]
    visited.any?{|e|!e}
}

Measured memory_bytes: 4096
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  LL a, b, c, d; cin >> a >> b >> c >> d;
  LL i = max(a*c, a*d);
  LL j = max(b*c, b*d);
  cout << max(i, j) << endl;
}


Measured memory_bytes: 3648
from itertools import permutations
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

a = [i+1 for i in range(n)]
for i,per in enumerate(list(permutations(a))):
    if per == p:
        x = i
    if per == q:
        y = i
print(abs(x-y))


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

int main() {
  int h = 0, m = 0, s = 0;
  cin >> s;
  h = s/3600;
  m = (s - (h*3600))/60;
  s = (s - (h*3600))-(m*60);
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

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

int main() {
    int N, A, B, C, X;
    while (cin >> N >> A >> B >> C >> X, N) {
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int Y;
            cin >> Y;

            if (i != 0) {
                X = (A * X + B) % C;
                ans++;
            }
            while (true) {
                if (X == Y)
                    break;

                X = (A * X + B) % C;
                ans++;
                if (ans > 10000)
                    break;
            }
        }
        if (ans > 10000)
            cout << -1 << endl;
        else
            cout << ans << endl;
    }
}

Measured memory_bytes: 3072
#include<cstdio>
long long n,m;
bool f(int x)
{
	return (x%3==0);
}
int main()
{
	scanf("%lld%lld",&n,&m);
	if(f(n)||f(m)||f(n+m)) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1LL<<31;

int main(){
    ll q;
    cin >> q;
    rep(i,q){
        ll a,b;
        cin >> a >> b;
        if(a==b){
            cout << 2*a-2 << endl;
            continue;
        }
        else{
            ll le=0,ri=INF;
            while(ri-le>1){
                ll mid=(ri+le)/2;
                if(((mid+1)/2)*(mid+1-(mid+1)/2)>a*b-1){
                    ri=mid;
                }
                else{
                    le=mid;
                }
            }
            cout << le-1 << endl;
        }
    }
} 

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll n;
  cin >> n;
  auto countodd = mvec<ll>(100001);
  auto counteven = mvec<ll>(100001);
  rep(i, 0, n){
    ll v;
    cin >> v;
    if(i%2==0) countodd[v]++;
    else counteven[v]++;
  }
  ll maxodd1{}, maxodd2{}, maxeven1{}, maxeven2{}, v1{}, v2{};
  rep(i, 0, 100001){
    if(maxodd1 <= countodd[i]){
      maxodd2 = maxodd1;
      v2 = v1;
      maxodd1 = countodd[i];
      v1 = i;
    }
    else if(maxodd2 <= countodd[i]){
      maxodd2 = countodd[i];
      v2 = i;
    }
  }
  rep(i, 0, 100001){
    if(v1 != i){
      maxeven1 = max(maxeven1, counteven[i]);
    }
    if(v2 != i){
      maxeven2 = max(maxeven2, counteven[i]);
    }
  }
  ll ans = n - max(maxodd1 + maxeven1, maxodd2 + maxeven2);
  cout << ans << rt;
}

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

//方針
//sから３つ数字を取る素直な全探索では制限時間をオーバーする
//そこで, 暗証番号の総数が小さいことに着目する
//暗証番号の総数を全探索する
//問題のテーマ：計算量を落とす工夫が求められる全探索問題である

int main(void){
    int n;
    cin >> n;
    
    string s;
    cin >> s;
    
    
    int numberOfPIN = 0;
    
    //000~999
    for (int i = 0; i < 1000; i++){
        int position_of_PIN = 0;
        
        vector<int> each_keta_number = {i/100, (i/10)%10, (i)%10};
        
        for (int i = 0; i < n; i++){
            if (s[i] == each_keta_number[position_of_PIN] + '0') position_of_PIN++;
            
            if (position_of_PIN == 3) break; //PINを一つ発見した
        }
        
        if (position_of_PIN == 3) numberOfPIN++;
    }
    cout << numberOfPIN << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	string a, b;
	cin >> a >> b;
	int c = atoi((a + b).c_str());
	int d = sqrt(c);
	if(d * d == c) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

const int MAX_N = 100005;
int n, primes[101];

void input() {
    RI(n);
}

void div(int a) {
	int m=a;
	for(int i=2; i<=m; i++) {
		while(a>0 && a%i==0) {
			a/=i;
			primes[i]++;
		}
	}
}

void solve() {
	if(n < 10) {
		printf("0\n");
		return;
	}
	for (int i = 2; i <= n; ++i)
	{
		div(i);
	}
	int a=0, b=0, c=0, d=0, e=0;
	for(int i = 2; i <= n; i++) {
		// printf("%d %d\n", i, primes[i]);
		if(primes[i]>=74) e++;
		if(primes[i]>=24) a++;
		if(primes[i]>=14) b++;
		if(primes[i]>=4) c++;
		if(primes[i]>=2) d++;
	}
	// cout << a << ' ' << b << ' ' << c << ' ' << d << endl;
	int ans = e;
	// 24 2
	ans += a*(d-1);
	// 14 4
	ans += b*(c-1);
	// 4 4 2
	ans += (c-1)*c/2 * (d-2);
	cout << ans << endl;
}

int main( int argc, char *argv[] ) {
	input();
	solve();
   return 0;
}

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

using namespace std;

using P = pair<long, int>;

#define mining(a, b) a = min(a, b)

int main() {
    int n;
    long x;
    cin >> n >> x;
    long a[n], mins[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
        mins[i] = 1000000000000000;
    }
    long ans = 1000000000000000;
    for (int k=0; k<n; k++) {
        long sum = x * k;
        for (int i=k; i<n+k; i++) {
            mining(mins[i%n], a[i-k]);
            sum += mins[i%n];
        }
        mining(ans, sum);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <numeric>
#include <unordered_map>

using namespace std;
using ll = long long;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (A <= C && C <= B) {
        cout << "Yes" << endl;
    } else if(B <= C && C <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

x = iinp()

if x == 0:
    print(1)
else:
    print(0)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 123;
#define int long long 
int n, m;
pair <int, int> a[maxn];
string s[60], t[60];
int dp[2][5005];
main () { 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;

    for(int i = 0; i <= 1; i++)
    for(int j = 0; j < 5000; j++)
    	dp[i][j] = 1e9;
    dp[0][0] = 0;
    for(int i = 1; i <= m; i++) {
    	int cost, b;
    	int msk = 0;
    	cin >> cost >> b;
    	for(int j=  0; j < b; j++) {
    		int x;
    		cin >> x;
    		x--;
    		msk |= 1 << x;
    	}
    	int cur = i % 2;
    	int prev = cur ^ 1;

    	for(int j = 0; j < (1 << n); j++) {
    		dp[cur][j] = min(dp[cur][j], dp[prev][j]);
    		dp[cur][j | msk] = min(dp[cur][j | msk], dp[prev][j] + cost);
    	}
    	for(int j = 0; j < (1 << n) ; j++)
    		dp[prev][j] = 1e9;
    }
    if(dp[m % 2][(1 << n) - 1] >= 1e9) cout << -1;
    else cout << dp[m % 2][(1 << n) - 1];
}




Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

int in[1000101];
char inc[1000010];

int x2[1000100];

int main() {

    memset(x2, 0 , sizeof(x2));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n >> inc;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 0) {
            x2[i] = x2[i>>1] + 1;
        }
    }
    n--;
    for (int i = 0; i < n; i++) {
        in[i] = abs(inc[i] - inc[i + 1]);
    }
    int x2only = 1;
    for (int i = 0; i < n; i++) {
        if (in[i] == 1) {
            x2only = 0;
        }
    }
    if (x2only) {
        for (int i = 0 ; i < n ;i ++) {
            in[i] /= 2;
        }
    }
    ll xx2(0);
    ll ans(0);
    for (int i = 0; i < n; i++) {
        if (xx2 == 0) {
            ans += in[i];
        }
        ans %= 2;
        xx2 = xx2 + x2[n - i - 1] - x2[i + 1];
    }
    if (x2only) {
        cout << ans * 2 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a, b, c; cin >> a >> b >> c;
	cout << max({a,b,c}) - min({a,b,c}) << endl;
}


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

struct NODE{
	int to,cost,ticket;
	NODE(int to,int cost,int ticket) : to(to) , cost(cost) , ticket(ticket) {}
	NODE(){}
};


bool operator < (const NODE &a,const NODE &b){
	return a.cost > b.cost;
}

int main(){
	int c,n,m,s,d;
	while(cin >> c >> n >> m >> s >> d && n){
		s--,d--;
		vector<NODE> e[100];
		for(int i = 0 ; i < m ; i++){
			int a,b,f;
			cin >> a >> b >> f;
			a--,b--;
			e[a].push_back(NODE(b,f,-1));
			e[b].push_back(NODE(a,f,-1));
		}
		int done[110][15] = {};
		priority_queue<NODE> Q;
		Q.push(NODE(s,0,c));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if( done[q.to][q.ticket]++ ) continue;
			else done[q.to][q.ticket] = true;
			if( q.to == d){
				cout << q.cost << endl;
				break;
			}
			for(int i = 0 ; i < e[q.to].size() ; i++){
				Q.push(NODE(e[q.to][i].to,q.cost+e[q.to][i].cost,q.ticket));
				if( q.ticket ) Q.push(NODE(e[q.to][i].to,q.cost+e[q.to][i].cost/2,q.ticket-1));
			}
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ld> vld;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<double> vd;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 27;
const lli INF = 1e18;
const lli MOD = 13;
const double EPS=1e-6;

bool mm[N];
vi primes(1,2);
void sieve(){
	for(int i = 4; i<N; i+=2)mm[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!mm[i])for(int j = i*i; j<N; j+=i)mm[j]=1;
	for(int i = 3; i<N; i+=2)if(!mm[i])primes.pb(i);
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


lli solve(){
	int n; cin>>n;
	lli a,b,c=0LL; cin>>a>>b;
	fore(i,0,n-2){lli x; cin>>x; c^=x;}
	lli d= (a+b-c);
	if(d<0)return -1;
	if(d&1)return -1;
	d/=2LL;
	if(d>a)return -1;
	for(int i = 60;i>=0;i--)if((d &(1LL<<i)) and (c &(1LL<<i)))return -1;
	lli res = 0;
	for(int i = 60;i>=0;i--){
		if(c & (1LL<<i)){
			lli aux = res|(1LL<<i);
			if((aux^d)<=a and ((aux^d)^c)>=b)res=aux;
		}
	}
	res^=d;
	lli bb = b+(a-res);
	if(bb^res==c and res>0)return a-res;
	return -1;
}
int main(){ _
	cout<<solve()<<ENDL;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(snip_i, n) cin >> h.at(snip_i);
  rrep(i, n){
    // cerr << h.at(i) << " ";
    if(i == 0) break;
    // cerr << h.at(i-1) << endl;
    if(h.at(i-1) > h.at(i)){
      if(h.at(i-1)-1 > h.at(i)){
        cout << "No" << endl;
        return 0;
      }else{
        h.at(i-1)--;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 n;
    cin >> n;

    s64 ans = 0;
    for (s64 r = 1; r * r <= n; ++r)
    {
        if (n % r == 0 && n / r - 1 > r)
        {
            ans += n / r - 1;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main() {
  ll i, j, k;
  
  
  ll N, M;
  cin >> N >> M;
  ll s=0;
  ll a[111];
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    s+=a[i];
  }
  
  ll cnt=0;
  for(i=0; i<N; i++) {
    if(4*M*a[i]>=s) cnt++;
  }
  
  if(cnt>=M) pt("Yes");
  else pt("No");
  
  
}




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

const int nm = 200010;

int n, a[nm];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 2; i <= n; ++i) {
        int p;
        scanf("%d", &p);
        a[p]++;
    }
    for (int i = 1; i <= n; ++i) {
        printf("%d\n", a[i]);
    }
}


Measured memory_bytes: 4596
import java.util.Scanner;
class Main{
 public static void main(String args[]){
  int m,f,r,g;
  Scanner sc = new Scanner(System.in);
  while(true){
   m=sc.nextInt();
   f=sc.nextInt();
   r=sc.nextInt();
   g=m+f;
   if(m==-1 && f==-1 && r==-1)
    break;
   if(m==-1 || f==-1 || g<30)
    System.out.println("F");
   else if(g>=80)
    System.out.println("A");
   else if(g>=65)
    System.out.println("B");
   else if(g>=50)
    System.out.println("C");
   else if(g>=30)
    if(r>=50)
     System.out.println("C");
    else
     System.out.println("D");
   }
 }
}


Measured memory_bytes: 26268
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        d: usize,
    }
    print!("Christmas");
    for _ in 0..25 - d {
        print!(" Eve");
    }
    println!("");
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a))
	cout << "Yes\n";
	else cout << "No\n";
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> A;

vector<pair<int,int>> hoge(vector<int> A) {
	if(A.size()==4) {
		return {{0,0},{1,0},{1,1},{0,1}};
	}
	int i,N=A.size(),j;
	
	FOR(i,N) {
		if(A[i]==1 && A[(i+1)%N]==0) break;
	}
	vector<int> B;
	B.push_back(A[(i+N-1)%N]);
	FOR(j,N-3) B.push_back(A[(i+2+j)%N]);
	vector<pair<int,int>> P=hoge(B),R;
	while(P[0].first>=P[1].first) {
		FORR(p,P) {
			swap(p.first,p.second);
			p.first=-p.first;
		}
	}
	
	FORR(p,P) p.first*=2,p.second*=2;
	P.insert(P.begin()+1,{P[0].first+1,P[0].second});
	P.insert(P.begin()+2,{P[0].first+1,P[0].second+1});
	P[3].second++;
	vector<int> Xs,Ys;
	FORR(p,P) {
		Xs.push_back(p.first);
		Ys.push_back(p.second);
	}
	sort(ALL(Xs));
	sort(ALL(Ys));
	Xs.erase(unique(ALL(Xs)),Xs.end());
	Ys.erase(unique(ALL(Ys)),Ys.end());
	
	
	FOR(j,N) {
		int x=lower_bound(ALL(Xs),P[(j-(i-1)+N)%N].first)-Xs.begin();
		int y=lower_bound(ALL(Ys),P[(j-(i-1)+N)%N].second)-Ys.begin();
		R.push_back({x,y});
	}
	
	return R;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int rot=0;
	FOR(i,N) {
		cin>>x;
		A.push_back(x==90);
		if(A[i]==1) rot++;
		else rot--;
	}
	if(rot!=4) return _P("-1\n");
	
	auto ret=hoge(A);
	FORR(r,ret) cout<<r.first<<" "<<r.second<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    vi a(n);
    rep(i,n) a[i] = s[i]-'1';
    bool flg=false;
    rep(i,n)if(a[i]==1) flg=true;
    if (!flg)rep(i,n) a[i]/=2;
    rep(i,n) a[i]%=2;
    auto f=[](int n){
        int ret=0;
        while(n/=2) ret+=n;
        return ret;
    };
    int ans=0;
    rep(i,n){
        if (a[i]==0) continue;
        int x = f(n-1)-f(n-i-1)-f(i);
        ans = (x==0)? (ans+1)%2 : ans;
    }

    if (!flg) ans*=2;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 5276