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

public class Main {
	public static void main(String[] args) {
	int C = 0;
	Scanner in = new Scanner(System.in);
	int n = in.nextInt();
	int[] S = new int[n];
	
	for(int i = 0;i<n;i++){
		S[i] = in.nextInt();
	}
	int q = in.nextInt();
	int[] T = new int[q];
	for(int i = 0;i<q;i++){
		T[i] = in.nextInt();
	}
	
	for(int i = 0;i<q;i++){
		int temp = T[i];
		for(int j = 0;j<n;j++){
			if(S[j] == temp){
				C++;
				break;
			}
		}
	}
	System.out.println(C);
	}
}

Measured memory_bytes: 39252
#include <bits/stdc++.h> 
using namespace std ;
signed main(){
  string s,t ;
  cin >> s >> t ;
  int n = s.size(),m=t.size() ;
  vector<vector<int>>dp(n+1,vector<int>(m+1)) ;
    
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
      if(s[i-1]==t[j-1])
        dp[i][j]=1+dp[i-1][j-1] ;
      else 
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]) ;
    }
  string ans ;
  int i=n,j=m ;
  while(i>0||j>0){
    if(i>0&&dp[i-1][j]==dp[i][j])
      --i ;
    else if(j>0&&dp[i][j-1]==dp[i][j])
      --j ;
    else
      ans+=s[i-1],--i,--j ;
  }
  reverse(ans.begin(),ans.end()) ;
  cout << ans << endl ;
}

Measured memory_bytes: 38584
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)

	fmt.Println(strings.ToUpper(string(s1[0]) + string(s2[0]) + string(s3[0])))
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  int a,b,c;
  cin>>a>>b;
  cout<<a*b/2<<endl;
}

Measured memory_bytes: 256
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
num = [[0, 0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            num[i][1] += 1
        if (i < j) and (a[i] > a[j]):
            num[i][0] += 1
num_np = np.array(num)
ks = k * (k - 1) // 2 % 1000000007
sum_left = sum(num_np[:,0])
sum_right = sum(num_np[:,1])
output = (sum_left * k) % 1000000007 + (sum_right * ks) % 1000000007
print(output % 1000000007)

Measured memory_bytes: 14464
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <tuple>
#include <unordered_set>

using namespace std;
int main() {
    int h,w;
    cin >> h >> w;
    unordered_set<int> bl;
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            char inp;
            cin >> inp;
            if(inp=='#'){
                bl.insert(1000*i+j);
            }
        }
    }
    auto bl1 = bl;
    vector<int> fl;
    for(auto blc : bl){
        fl.push_back(blc);
    }
    int ctr = 0;
    while(ctr < h*w){
        if(bl.size()>=h*w) break;
        vector<int> newfl;
        for(auto it = fl.begin(); it != fl.end(); ++it){
            int i,j;
            i = (*it)/1000;
            j = (*it)%1000;
            int np;
            if(i>0){
                np = *it - 1000;
                if(bl.count(np)==0){
                    newfl.push_back(np);
                    bl.insert(np);
                }
            }
            if(i < h -1){
                np = *it + 1000;
                if(bl.count(np)==0){
                    newfl.push_back(np);
                    bl.insert(np);
                }
            }
            if(j>0){
                np = *it - 1;
                if(bl.count(np)==0){
                    newfl.push_back(np);
                    bl.insert(np);
                }
            }
            if(j < w-1){
                np = *it +1;
                if(bl.count(np)==0){
                    newfl.push_back(np);
                    bl.insert(np);
                }
            }
        }
        ctr++;
        fl = newfl;
    }
    cout << ctr << endl;
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int K, N;
    cin >> K >> N;
    vector<int> arr(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    vector<int> subarr;
    for (int j = 0; j < N; j++) {
        if (j == 0) continue;
        subarr.push_back(arr[j] - arr[j - 1]);
    }
    subarr.push_back(K - arr[N - 1] + arr[0]);

    sort(subarr.begin(), subarr.end(), greater<int>());
    cout << K - subarr[0] << endl;
    return 0;
}


Measured memory_bytes: 2168
/* lcm.cpp
    gcdを利用して最小公倍数を求めるアルゴリズム
*/

#include <bits/stdc++.h>
using namespace std;

long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

/*  lcm (a, b) : 2整数版
    入力：整数 a, b
    出力：aとbの最小公倍数
*/
long long lcm(long long a, long long b) {
    long long d = gcd(a, b);
    return a / d * b;
}

/* lcm (vec) : ベクトルでの多整数版
    入力：整数のベクトル vec
    出力：すべての要素の最小公倍数
    注意：最小公倍数がオーバーフローする時は素因数分解を使う
*/
long long lcm(const vector<long long> &vec) {
    long long l = vec[0];
    for (int i = 0; i < (int)vec.size() - 1; i++) {
        l = lcm(l, vec[i + 1]);
    }
    return l;
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    cout << lcm(A) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    restaurant = [[S[i], P[i], i] for i in range(N)]
    restaurant.sort(key=lambda x: (x[0], 100 - x[1]))
    print('\n'.join([str(r[2]+1) for r in restaurant]))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]"
    P = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()


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

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(abs(b-a) <= d && abs(c-b) <= d || abs(c-a) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int I=in.nextInt();
		while(I-->0)
		{
			int cnt=0;
			int X=in.nextInt(),Y=in.nextInt(),W=in.nextInt(),H=in.nextInt();
			int N=in.nextInt();
			for(int j=0;j<N;j++)
			{
				int x=in.nextInt(),y=in.nextInt();
				if(X<=x&&x<=X+W&&Y<=y&&y<=Y+H)
					cnt++;
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int sum = 0;
    sum += h[0];
    rep3(i, 1, n) sum += max(0, h[i] - h[i - 1]);
    cout << sum << endl;
}



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

int main()
{
    int k, x;
    cin >> k >> x;

    for (auto i = k-1; i >=  1; i--)
    {
        cout << x - i << " ";
    }
    cout << x << " ";
    for (auto i = 1; i <= k - 1; i++)
    {
        cout << x + i << " ";
    }
    cout << endl;
}

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


int main(){
	int n;
	cin >> n;
	
	priority_queue<int> que;
	rep(i,n){
		int l;
		cin >> l;
		que.push(l);
	};
	
	int maxi = que.top();
	que.pop();
	
	int sum = 0;
	while(!que.empty()){
		sum += que.top();
		que.pop();
	}
	
	if(maxi < sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

template<class T>
T min(T a, T b) {
    return (a < b) ? a : b;
}

template<class T>
T max(T a, T b) {
    return (a > b) ? a : b;
}

struct st {
    int num, order;
};

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

    st A[(int)1e5];
    for (int i = 0; i < N; i++) {
        int in;
        cin >> in;
        A[i] = { i + 1, in };
    }

    std::sort(A, A+N, [](st a, st b) { return a.order < b.order;} );

    for (int i = 0; i < N; i++) {
        cout << A[i].num << ' ';
    }

    return 0;
}



Measured memory_bytes: 1536
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=0;
    cin>>n;
    map<string, ll> mp;
    rep(i,n){
        string s;
        cin>>s;
        sort(ALL(s));
        mp[s]++;
    }
    for(auto p :mp) sum+=p.second*(p.second-1)/2;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[100];
    cin>>a;
    int s=0,maxx=0;
    int len=strlen(a);
    for(int i=0; i<len; i++)
    {
        if(a[i]=='A'||a[i]=='T'||a[i]=='G'||a[i]=='C')
            s++;
        else
        {
            if(maxx<s)maxx=s;
            s=0;
        }
    }
    if(maxx<s)maxx=s;
    cout<<maxx<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	int max_g = 1;
	for (int i = 1; i * i <= m; ++i) {
		if (m % i == 0) {
			int j = m / i;
			if ((long long) i * n <= m) {
				max_g = max(max_g, i);
			}
			if ((long long) j * n <= m) {
				max_g = max(max_g, j);
			}
		}
	}

	cout << max_g << "\n";

	return 0;

}

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

int main()
{
  while(true){
    int n;
    cin >> n;

    if(n==0)
      break;

    int a[1000];
    for(int i=0; i<n; i++){
      cin >> a[i];
    }

    int dif = 1000001;

    for(int i=0; i<n-1; i++){
      for(int j=i+1; j<n; j++){
	int d = abs(a[i]-a[j]);

	if(d<dif){
	  dif = d;
	}
      }
    }

    cout << dif << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    static Scanner sc = new Scanner();

    internal static void Main(string[] args) {
        var N = sc.nextInt();
        var dic = new Dictionary<char, int>();
        for (char c = 'a'; c <= 'z'; c++) {
            dic.Add(c, int.MaxValue);
        }

        for (int i = 0; i < N; i++) {
            var S = ReadLine();
            var tmp = new Dictionary<char, int>();
            for (char c = 'a'; c <= 'z'; c++) {
                tmp.Add(c, 0);
            }
            foreach (char c in S) {
                tmp[c]++;
            }

            foreach (var kvp in tmp) {
                dic[kvp.Key] = Math.Min(dic[kvp.Key], kvp.Value);
            }
        }
        dic.OrderBy(kvp => kvp.Key);
        foreach (var kvp in dic) {
            if (kvp.Value == int.MaxValue) { continue; }
            Write(new string(kvp.Key, kvp.Value));
        }
        WriteLine();
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {

        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		System.out.println(
				A.substring(0,1) + 
				B.substring(0,1) + 
				C.substring(0,1)  
				);
	}
}


Measured memory_bytes: 23892
#include<stdio.h>
int main(){
  int a, b, c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==7){
    if(b==5&&c==5){printf("YES\n");}else{printf("NO\n");}
  }else if(b==7){
    if(a==5&&c==5){printf("YES\n");}else{printf("NO\n");}
  }else if(c==7){
    if(b==5&&a==5){printf("YES\n");}else{printf("NO\n");}
  }else{
    printf("NO\n");
  }
  return 0;  
}



Measured memory_bytes: 128
import java.io.*;
import java.util.*;
 
public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;
 
  private static PrintWriter _err = new PrintWriter(System.err);
 
  private void solve(Scanner sc, PrintWriter out) {
    Set<Integer> set = new HashSet<>();
    while (sc.hasNextInt()) {
      set.add(sc.nextInt());
    }
    out.println(set.size());
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();
 
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();
 
    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
n = int(input())
s = ""
if n == 0:
    print(0)
    exit()
    
while True:
    si = n % 2
    if si == -1:
        si = 1
    s += str(si)
    n = (n-si)//(-2)
    if n == 0:
        break
print(s[::-1])

Measured memory_bytes: 61832
N, D = gets.chomp.split.map(&:to_i)

dots = []
N.times { dots << gets.chomp.split.map(&:to_i) }

ans = 0
N.times do |i|
  (i + 1).upto(N - 1) do |j|
    next if i == j
    square_diff_sum = dots[i].zip(dots[j]).map { |d1, d2| (d1 - d2)**2 }.inject(0, &:+)
    ans += 1 if square_diff_sum**0.5 == (square_diff_sum**0.5).to_i
  end
end

puts ans

Measured memory_bytes: 1916
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int nex[400001];
int to[400001];
int val[400001];
int head[200001];
int f[200001];
int idx,x,y,z;
int inf=2147483647;
bool vis[200001];
struct Point
{
    int number,dis;
    inline bool operator < (const Point &a) const
    {
        return dis>a.dis;
    }
};
void addedge(int a,int b,int c)
{
    nex[++idx]=head[a];
    head[a]=idx;
    to[idx]=b;
    val[idx]=c;
}
int n;int answer[100050];
int main()
{
    int n,x,y;scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<n;i++)
    {
        addedge(i,i+1,1);addedge(i+1,i,1);
    }addedge(x,y,1);addedge(y,x,1);//cout<<"ddjxd";
	for(int s=1;s<n;++s){
    memset(vis,0,sizeof(vis));
priority_queue <Point> q;
    for(int i=1;i<=n;i++)
        f[i]=inf;Point tmp;
    tmp.number=s,tmp.dis=0;
    f[tmp.number]=0;  
    q.push(tmp);
    while(!q.empty())
    {
        int here=q.top().number;
        q.pop();
        if(vis[here])
            continue;
        vis[here]=1;
        for(int j=head[here];j;j=nex[j])
            if(f[to[j]]>val[j]+f[here]&&(!vis[to[j]]))
            {
                f[to[j]]=f[here]+val[j];
                tmp.number=to[j];
                tmp.dis=f[to[j]];
                q.push(tmp);
            }
    }
    for(int i=s+1;i<=n;++i)answer[f[i]]++;
    //for(int i=1;i<=n;i++)printf("%d ",f[i]);
	}for(int i=1;i<n;++i)cout<<answer[i]<<endl;
}

Measured memory_bytes: 4608
#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<bitset>
#include<stack>
#include<memory>
#include<math.h>

using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef pair < int, int> P;
/****Union-Ford-Tree***/
int par[int(0x7ffffff)];//Parent
int Rank[int(0x7ffffff)];//Deep_of_the_Tree

//int a[100] = { 4,2,3,1,5 }, m[100] ={3,2,2};
//int n = 0;
//const ll mod = 1000000007;


//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		Rank[i] = 0;
	}
}
//木の根探し
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (Rank[x] < Rank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

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

int main()
{
	ll n;
	cin >> n;
	ll a[10000];
	double averange = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		averange += a[i];
	}
	double res = INF;
	ll ans = 0;
	
	averange = averange / n;
	//cout << averange << endl;
	for (int i = n - 1; i >= 0; i--) {
		if (res >= abs(averange - a[i])){
		res = abs(averange - a[i]);
		ans = i;
	}

}
	cout << ans << endl;
}

Measured memory_bytes: 256
/*  ex9_2
    Rikuta  */
#include <stdio.h>
#include <stdlib.h>
// リストのノード（スタック内の各データ）の定義
typedef struct node
{
    char elem;
    struct node *next;
} node;

//プロトタイプ宣言
void push(node **cube, char elem);
void pop(node **cube);
char last(node **cube);

int main(void)
{   
    //最初のノードがさす先．
    node *cube = NULL;
    //countの初期化
    int count = 0;
    while (1)
    {   
        //一時的な文字の宣言
        char temp_char;
        //入力
        scanf("%c", &temp_char);
        //改行で終了
        if (temp_char=='\n')
        {
            break;
        }
        if (temp_char=='0')
        {   
            if (last(&cube)=='1')
            {
                //0が入力され，cubeの最後の文字が1なら，cubeをpopして，カウントを+2
                pop(&cube);
                count+=2;
            }
            else
            {   
                //0が入力され，cubeの最後の文字が0なら，0をpush
                push(&cube, temp_char);
            }
            
            
        }
        if (temp_char=='1')
        {
            if (last(&cube) == '0')
            {
                //1が入力され，cubeの最後の文字が0なら，cubeをpopして，カウントを+2
                pop(&cube);
                count+=2;
            }
            else
            {
                //1が入力され，cubeの最後の文字が1なら，1をpush
                push(&cube, temp_char);
            }
        }
    }
    //countを出力
    printf("%d\n", count);
    return 0;
}

//スタックにデータを追加
void push(node **cube, char elem)
{
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    //確保できないならエラー
    if (new == NULL)
        exit(1);
    //新しいデータの要素はelemでそれに続くものはcubeとなる
    new->elem = elem;
    new->next = *cube;
    //新しいノードが1番目に更新される．
    *cube = new;
}

//スタックからデータを取り出す
void pop(node **cube)
{
    node *tmp = *cube;
    //データがなければエラー
    if (tmp == NULL)
        exit(1);
    //cubeを次のノードに移行させる
    *cube = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
}

//スタックの最初を参照する．
char last(node **cube)
{
    //最初の文字が入る変数の宣言
    char elem;
    node *tmp = *cube;
    //データがなければ'-'を返す．
    if (tmp == NULL)
        return '-';
    //データの最初をelemとして返す
    elem = tmp->elem;
    return elem;
}


Measured memory_bytes: 4716
#include<stdio.h>
#define MAX 50

int n, r;
int D[MAX+1], tmp[MAX+1];

void cut( int p, int c ){
    int i;
    for ( i = p; i < p + c; i++ ) tmp[i-p+1] = D[i];
    for ( i = 1; i < p; i++ ) tmp[i+c] = D[i];
    for ( i = 1; i < p + c; i++ ) D[i] = tmp[i];
}

void simulate(){
    int p, c, i, rest;
    
    for ( i = 1; i <= n; i++ ) { D[i] = n-i+1; }
    for ( i = 0; i < r; i++ ){
        scanf("%d %d", &p, &c);
        cut( p, c );
    }
    
    printf("%d\n", D[1]);
}

int input(){
    scanf("%d %d", &n, &r);
    if ( n == 0 && r == 0 ) return 0;
    return 1;
}

int main(){
    while ( input() ) simulate();
    return 0;
}
 

Measured memory_bytes: 0
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

import functools
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N,X = map(int, sys.stdin.readline().split())
    x = list(map(int, sys.stdin.readline().split()))
    l=[]
    for i in range(N):
        l.append(abs(X-x[i]))
    ans = reduce(gcd,l)
    print(ans)

Measured memory_bytes: 16288
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int P[][] = new int[10][10];
        for (int i = 1; i <= N; i++) {
            int fd = i;
            while ((fd = fd / 10 > 0 ? fd / 10 : fd) >= 10);
            int ld = i % 10;
            P[fd][ld]++;
        }

        int ans = 0;
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                ans += P[i][j] * P[j][i];
            }
        }
        System.out.println(ans);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }

    public static double nextDouble() throws Exception {
        return Double.parseDouble(nextString());
    }
}

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

#include <algorithm>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N + 1);
    vector<ll> B(M + 1);

    rep(i, N) {
        ll c;
        cin >> c;
        A[i + 1] = A[i] + c;
    }

    rep(i, M) {
        ll c;
        cin >> c;
        B[i + 1] = B[i] + c;
    }

    ll ans = 0;
    rep(i, N + 1) {
        ll tot = A[i];
        ll diff = K - tot;
        if (diff < 0) {
            continue;
        }
        ll cnt = upper_bound(B.begin(), B.end(), diff) - B.begin() - 1;
        // cout << "i" << i << "cnt" << cnt << endl;
        ans = max(ans, i + cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6396
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main = do
  getLine
  ns <- getIntList
  let n = sum . map ((1%).fromIntegral) $ ns
  print . fromRational $ (1/n)
  

-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 636
n, a, b = list(map(int, input().split()))
mod = 10**9 + 7

def choose(n, a):
    x = 1
    y = 1
    for i in range(1, a + 1):
        x = (x * (n - i + 1)) % mod
        y = (y * i) % mod
    return (x * pow(y, mod - 2, mod)) % mod

print((pow(2, n, mod) - 1 - choose(n, a) - choose(n, b)) % mod )


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define ALL(x) begin(x),end(x)
#define ll long long
#define ld long double

int main(){
  string n;
  cin >> n;
  int ans = 0;
  rep(i,n.size()) ans += (int)n[i]-48;
  if(ans%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

typedef long long int lli;

int main() {
    vector< vector<int> > vec(100001, vector<int>());
    vector<bool> ans(100001, true), used(100001, false);
    int n, u, v, w;
 
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> u >> v >> w;
        vec[u].push_back(v);
        vec[u].push_back(w);
        vec[v].push_back(u);
        vec[v].push_back(w);
    }

    queue<int> qu;
    qu.push(1);
    while(!qu.empty()) {
        // cout << qu.top() << endl;
        int crnt = qu.front();
        for (int i = 0; i < vec[crnt].size(); i+=2) {
            int next = vec[crnt][i], _w = vec[crnt][i+1];
            
            if (used[next]) continue;
            
            if (_w%2)   ans[next] = !ans[crnt];
            else        ans[next] = ans[crnt];
            
            qu.push(vec[crnt][i]);
        }
        used[crnt] = true;
        qu.pop();
    }

    for (int i=1; i<=n; i++) {
        cout << (ans[i] ? 1 : 0) << endl;
    }


    return 0;
}


Measured memory_bytes: 6400
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  s = input()
  print(s[0] + str(len(s)-2) + s[len(s)-1])
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
#2問目
MAX = 10 ** 18
N = int(input())
A = list(map(int, input().split()))
result = 1

if 0 in A:
    result = 0
else:
    for i in range(N):
        result *= A[i]
        if result > MAX:
            result = -1
            break
print(result)

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

using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int p1 = n * a;
    int p2 = b;
    int ans = p1;
    if (p1 > p2) {
        ans = p2;
    }
    cout << ans << endl;
}

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

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector <int> ans(n+1, 0);
    for(int i = 1; i <= n; i++) {
        for(int j = i+1; j <= n; j++) {
            int dist = min(min(j - i, abs(j-y) + abs(i-x) + 1), abs(j-x) + abs(i-y) + 1);
            ans[dist]++;
        }
    }

    for(int i = 1; i < n; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  string S;
  cin >> N >> S;
  
  vector<long long> c(26,1);
  long long k;
  for (long long i=0;i<N;i++) {
    k=S.at(i)-'a';
    c.at(k)++;
  }
  
  long long m=1;
  for (long long i=0;i<26;i++) {
    m *= c.at(i);
    m = m % 1000000007;
  }
  
  if (m==0) {
    m = 1000000007;
  }
  
  cout << m-1 << endl;
}

Measured memory_bytes: 512
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

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

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

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

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

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

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"100
" => r"ABC100",

r"425
" => r"ABC425",

r"999
" => r"ABC999"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: i32,
    }

    format!("{}{}", "ABC", n.to_string())
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#define MAX_K (10010)
#define MAX_N (2000010)

void CountingSort( int A[], int B[], int k );

int n;

int A[MAX_N];
int B[MAX_N];
int C[MAX_K + 1];

int main()
{
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	scanf("%d", &A[i]);
    }

    CountingSort( A, B, MAX_K );
    for ( int i = 0; i < n; i++ ) {
	printf("%d%c", B[i], (i == n - 1) ? '\n' : ' ');
    }

    return 0;
}



void CountingSort( int A[], int B[], int k )
{
    memset( C, 0, (k + 1) * sizeof(int) );

    for ( int i = 0; i < n; i++ ) {
	C[A[i]]++;
    }

    for ( int i = 1; i <= k; i++ ) {
	C[i] = C[i] + C[i-1];
    }

    for ( int i = n - 1; i >= 0; i-- ) {
	B[C[A[i]] - 1] = A[i];
	C[A[i]]--;
    }
}

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

using namespace std;

int a[4];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    long long q, h, s, d, n, ans = 0;
    cin >> q >> h >> s >> d >> n;
    a[0] = 8 * q;
    a[1] = 4 * h;
    a[2] = 2 * s;
    a[3] = d;
    sort(a, a + 4);
    ans += a[0] * (n / 2);
    n %= 2;
    if(a[0] == d)
    ans += (a[1] / 2) * n;
    else
    ans += (a[0] / 2) * n;

    cout << ans;

	return 0;
}


Measured memory_bytes: 256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  string a, b;
  int m;
  rd(a);
  rd(b);
  rd(m);
  const int MOD = 10 ^^ 4;

  int solve(string n) {
    auto memo = new short[][][][][][](n.length + 1, 2, 4, 10, 3, m);
    afill(memo, (-1).to!(short));
    int f(size_t i, bool less, int foo, int pre, int sgn, int modm, int k) { // sgn 1=>up, 2=>down
      if (i == n.length) {
        return modm == 0;
      } else {
        if (memo[i][less][foo][pre][sgn][modm] >= 0) {
          return memo[i][less][foo][pre][sgn][modm];
        }
        short ret = 0;
        auto digit = less ? 9 : n[i] - '0';
        for (int d = 0; d <= digit; d++) {
          auto l = less || (d < digit);
          auto bar = min(3, foo + (foo == 0 ? (d > 0) : 1));
          auto p = d;
          auto s = d - pre;
          if (s > 0) {
            s = 1;
          } else if (s < 0) {
            s = 2;
          }
          if (bar < 2 || (bar == 2 && s != 0) || ((sgn == 1 && s == 2) || (sgn == 2 && s == 1))) {
            (ret += f(i + 1, l, bar, p, s, (modm * 10 + d) % m, k * 10 + d)) %= MOD;
          }
        }
        return memo[i][less][foo][pre][sgn][modm] = ret;
      }
    }

    return f(0, 0, 0, 0, 0, 0, 0);
  }

  bool zigzag(string n) {
    if (n.length == 1) {
      return true;
    } else {
      for (int i = 1, sgn = 0; i < n.length; i++) {
        if (i == 1) {
          sgn = n[i - 1] - n[i];
        } else {
          auto s = n[i - 1] - n[i];
          if (sgn * s >= 0) {
            return false;
          } else {
            sgn = s;
          }
        }
      }
    }
    return true;
  }

  auto res = (solve(b) - solve(a) + MOD) % MOD;
  if (zigzag(a)) {
    res++;
  }
  writeln(res % MOD);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}

void afill(Range, Type)(Range r, Type value) {
  static if (is(typeof(r) == Type[])) {
    foreach (ref elem; r)
      elem = value;
  } else {
    foreach (ref arr; r)
      afill(arr, value);
  }
}



Measured memory_bytes: 258184
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001

int main() {
  int n, m;
  cin >> n >> m;
  vector<bitset<10>> ss(m);
  for (int i = 0; i < m; i++) {
    //cout << i << endl;
    bitset<10> bit ("0000000000");
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int p;
      cin >> p;
      bit.set(p-1);
    }
    //cout << bit << endl;
    ss[i] = bit;
  }

  //cout << "h" << endl;
  int cnt = 0;

  vector<int> ps(m);
  for (int i = 0; i < m; i++) cin >> ps[i];

  //bitset<10> mx ("1111111111");
  for (int i = 0; i < (1 << n); i++) {
    bitset<10>cmb(i);
    //cout << cmb << endl;
    for (int j = 0; j < m; j++) {
      bitset<10> b = ss[j];
      if ((int)(cmb & b).count() % 2 != ps[j]) break;
      if (j == m-1) {
        //cout << cmb << endl;
        cnt++;
      }
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Point {
    double x;
    double y;
};

double distance(Point p, Point q) {
    return sqrt(pow((p.x - q.x), 2) + pow((p.y - q.y), 2));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    Point p, q;

    cin >> p.x >> p.y >> q.x >> q.y;
    cout << fixed << setprecision(10) << distance(p, q) << endl; 
}


Measured memory_bytes: 3300
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(int a, int b)
{
  if ( a > b )
    return 1;
  if ( a == b )
    return 0;
  return 0;
}

int doiLaN;
vector <int> s(1 << 18), goodSlimes, viz(1 << 18, 0);

int checkFather()
{
    int length = goodSlimes.size(), weAreGoodHere = 0;
    int poz = 0, nr = 0, n = doiLaN;
    //cout << length << " " << n << "\n";

    for (int i = n - 1; i >= 0; i--)
    {
        //cout << viz[i] << " " << i << "\n";
        if (viz[i] == 0)
        {
            if (goodSlimes[poz] > s[i])
            {
                viz[i] = 1; poz++;
                goodSlimes.push_back(s[i]);
            }

            if (poz == length)
                return 1;
            // {
            //     sort(goodSlimes.begin(), goodSlimes.end(), descrescator);
            //     return 1;
            //     i = n + 1;
            // }
        }

        if (i == 0)
          return 0;

    }
    //cout << "\n";
    //if (nr == length)
      //  weAreGoodHere = 1;
    return 1;
}

int main()
{
    int n;

    cin >> n;

    doiLaN = (1 << n);

    for (int i = 0; i < doiLaN; i++)
    {
        cin >> s[i];
    }
    //cout << s[0] << " ";

    sort(s.begin(), s.begin() + doiLaN);

    //cout << s[0];
    int poz = 0;
    goodSlimes.push_back(s[doiLaN - 1]);
    viz[doiLaN - 1] = 1;

    while(poz < n)
    {
        if (checkFather() == 0)
            {
                cout << "No\n";
                return 0;
            }
        poz++;
        sort ( goodSlimes.begin(), goodSlimes.end(), cmp);
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int n;
	cin >> n;
	for (int i = 1; i <= 50005; i++) {
		int x = i * 1.08;
		if (x == n) {
			cout << i << endl;
			return 0;
		}
	}
	for (int i = 1; i <= 50005; i++) {
		//int x = i * 1.08;
		if (i * 108 == n * 100) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(\n";
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

constexpr ll max_digits = 45;

ll dp[max_digits][2];

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

    ll N, K;
    cin >> N >> K;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < max_digits; i++) {
        dp[i][0] = dp[i][1] = -1;
    }
    dp[0][0] = 0;

    for (int i = 0; i < max_digits; i++) {
        ll mask = 1LL << (max_digits - 1 - i);
        ll num0 = 0, num1 = 0;
        for (int j = 0; j < N; j++) {
            if (A[j] & mask)
                ++num1;
            else
                ++num0;
        }
        ll cost0 = mask * num1;
        ll cost1 = mask * num0;

        if (dp[i][0] != -1) {
            if (K & mask)
                dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + cost1);
            else
                dp[i + 1][0] = max(dp[i + 1][0], dp[i][0] + cost0);
        }

        if (dp[i][0] != -1) {
            if (K & mask)
                dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + cost0);
        }

        if (dp[i][1] != -1)
            dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + max(cost0, cost1));
    }

    cout << max(dp[max_digits][0], dp[max_digits][1]) << endl;

    return 0;
}

Measured memory_bytes: 1024
# import sys
# input = sys.stdin.readline
import re

def main():
    n = input()
    p = re.compile('[a-z]+')
    if p.fullmatch(n):
        print('a')
    else:
        print('A')

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

def input_list():
    return list(map(int, input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    main()


Measured memory_bytes: 68092
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Jan 19 13:29:47 2019
//
package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	if A <= C && C <= B {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (d, sougou) = get!(usize, i32);
    let mut v: Vec<(usize, i32)> = Vec::new();
    for _ in 0..d {
        v.push(get!(usize, i32));
    }
    v.reverse();
    let n = v.len();
    let mut tekazu = i32::max_value();
    for i in 0..1 << n {
        let mut t_sougou = sougou;
        let mut t_tekazu = 0;
        'aaa: for j in 0..n {
            if (i >> j) & 1 == 1 {
                for k in 0..v[j].0 {
                    t_tekazu += 1;
                    t_sougou -= (d as i32 - j as i32) * 100;
                    if k == v[j].0 - 1 {
                        t_sougou -= v[j].1;
                    }
                    if t_sougou <= 0 {
                        break 'aaa;
                    }
                }
            }
        }
        if t_tekazu < tekazu && t_sougou <= 0 {
            //eprintln!("t_tekazu: {}", t_tekazu);
            tekazu = t_tekazu;
        }
    }
    println!("{}", tekazu);
}


Measured memory_bytes: 4352
# coding: utf-8

n = int(input())

x = 0
for i in range(1, n + 1, 2):
    m = 0
    for j in range(1, n + 1, 2):
        if i % j == 0:
            m = m + 1
    if m == 8:
        x = x + 1
print(x)


Measured memory_bytes: 2940