akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

const int boardw = 3;

struct BOARD {
    int map[boardw][boardw];
};
 
bool check(BOARD &b) {
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            if (b.map[i][j] == 0) continue;
            int tgt = i * boardw + j + 1;
            if (b.map[i][j] != tgt) {
                return false;
            }
        }
    }
    return true;
}

int dfs(BOARD &b, int depth, int dir) {
    if (depth == 0) {
        if (check(b)) {
            return 1;
        } else {
            return -1;
        }
    }

    int px, py;
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            if (b.map[i][j] == 0) {
                px = j;
                py = i;
            }
        }
    }
    int est = 0;
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            if (i * j == boardw * boardw) continue;
            for (int k = 0; k < boardw; ++k) {
                for (int l = 0; l < boardw; ++l) {
                    if (i * boardw + j + 1 == b.map[k][l]) {
                        est += std::abs(k - i) + std::abs(l - j);
                    }
                }
            }
        }
    }
    if (est > depth) {
        return -1;
    }
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    for (int k = 0; k < 4; k++) {
        if (dir != -1 && k == (dir + 2) % 4) {
            continue;
        }
        int tx = px + dx[k];
        int ty = py + dy[k];
        if (tx < 0 || tx >= boardw || ty < 0 || ty >= boardw) continue;
        int temp = b.map[py][px];
        b.map[py][px] = b.map[ty][tx];
        b.map[ty][tx] = temp;
        
        int ret = dfs(b, depth - 1, k);
        
        temp = b.map[py][px];
        b.map[py][px] = b.map[ty][tx];
        b.map[ty][tx] = temp;
        if (ret != -1) return ret;
    }
    return -1;
}
 
int main(int argc, char const *argv[]) {
    BOARD b;
    for (int i = 0; i < boardw; ++i) {
        for (int j = 0; j < boardw; ++j) {
            cin >> b.map[i][j];
        }
    }
    if (check(b)) {
        cout << 0 << endl;
        return 0;
    }
    int i = 0;
    while(++i) {
        int ret = dfs(b, i, -1);
        if (ret == 1) {
            cout << i << endl;
            return 0;
        }
    }
 
    return 0;
}

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

#define N 105

using namespace std;

int a,b;
string s; 

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	cin>>s;
	read(a);
}

int main(){
	init();
	if(a==1){
		cout<<s<<endl;
	}
	else{
	for(register int i=0;i<s.size();i++)
	if((i+1)%a==1)
	putchar(s[i]);
	puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
struct Trie {
    Trie *nxt[26];
    int cnt[26];
    Trie() {
        fill(nxt, nxt + 26, nullptr);
        fill(cnt, cnt + 26, 0);
    }
};
void insert(string &s, Trie *r) {
    for (int i = 0; i < s.size(); i++) {
        int c = (s[i] - 'a');
        if (!r->nxt[c]) {
            r->nxt[c] = new Trie;
        }
        r->cnt[c]++;
        r = r->nxt[c];
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> s(n);
    Trie *t = new Trie;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        insert(s[i], t);
    }
    vector<int> pre(n);
    vector<vector<vector<int>>> f(n, vector<vector<int>>(26, vector<int>(26)));
    for (int i = 0; i < n; i++) {
        Trie *nt = t;
        for (int j = 0; j < s[i].size(); j++) {
            int c = s[i][j] - 'a';
            for (int k = 0; k < 26; k++) {
                if (k != c) {
                    f[i][c][k] += nt->cnt[k];
                }
            }
            nt = nt->nxt[c];
        }
        for (int k = 0; k < 26; k++) {
            pre[i] += nt->cnt[k];
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int k;
        cin >> k;
        --k;
        string p;
        cin >> p;
        int res = n - pre[k];
        for (int i = 0; i < 26; i++) {
            for (int j = i + 1; j < 26; j++) {
                res -= f[k][p[i] - 'a'][p[j] - 'a'];
            }
        }
        cout << res << endl;
    }
}

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


int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) {
    cin >> a[i];
  }

  int l = 0;
  int r = n - 1;
  bool useL = true;
  for (int i = n - 1; i >= 0; --i) {
    if (useL) {
      b[l] = a[i];
      l++;
      useL = false;
    } else {
      b[r] = a[i];
      r--;
      useL = true;
    }
  }

  rep(i, n) {
    if (i != 0) printf(" ");
    printf("%lld", b[i]);
  }

  printf("\n");
  
  return 0;
}

Measured memory_bytes: 6348
#include <stdio.h>
int main()
{
  int a, b;
  char op;
  while(1)
    {
      scanf("%d %c %d", &a, &op, &b);
      if ( op == '+'){
	printf("%d\n", a + b);
      }
      else if (op == '-'){
	printf("%d\n", a - b);
      }
      else if (op == '*'){
	printf("%d\n", a * b);
      }
      else if (op == '/'){
	printf("%d\n", a / b);
      }
      else {break;}
    }
  return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		int[][] map = new int[14][14];
		int[][][] ink = {
				{{0,0,0,0,0},{0,0,1,0,0},{0,1,1,1,0},{0,0,1,0,0},{0,0,0,0,0},},
				{{0,0,0,0,0},{0,1,1,1,0},{0,1,1,1,0},{0,1,1,1,0},{0,0,0,0,0},},
				{{0,0,1,0,0},{0,1,1,1,0},{1,1,1,1,1},{0,1,1,1,0},{0,0,1,0,0},},
		};
		for(;sc.hasNext();){
			String buf = sc.next().replace(',', ' ');
//			if(buf.equals("a")) break;
			Scanner sc2 = new Scanner(buf);
			
			int x = sc2.nextInt()+2;
			int y = sc2.nextInt()+2;
			int size = sc2.nextInt() -1;
			for(int i = 0;i<5;i++){
				for(int j=0;j < 5;j++){
					map[i+x-2][j+y-2] += ink[size][i][j]; 
				}
			}
		}
		int max = 0;
		int count = 0;
		for(int i=2;i<12;i++){
			for(int j=2;j<12;j++){
				if(map[i][j] == 0){
					count++;
				}
				if(max < map[i][j]){
					max = map[i][j];
				}
			}
		}
		System.out.println(count);
		System.out.println(max);
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i=0; i<n; i++) cin>>a[i];
  for (int i=0; i<n; i++) cin>>b[i];
  
  long long minus=0;
  vector<int> plus(0);
  int ans=0;  
  for (int i=0; i<n; i++){
    if (b[i]>a[i]){
      minus+=b[i]-a[i];
      ans+=1;
    }
    else plus.push_back(a[i]-b[i]);
  }
  
  if (minus==0){
    cout<<0<<endl;
    return 0;
  }
  
  sort(plus.begin(),plus.end());
  reverse(plus.begin(),plus.end());
  for (auto d : plus){
    ans+=1;
    minus-=d;
    if (minus<=0){
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

using namespace std;

typedef long long int ll;

int main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
    ll arr[110], n;
    ll sum = 0, ans = LLONG_MAX;
    ll x = 0, y = -1111;
    
    cin >> n;
    for(int i = 0; i < n; i++){
    	cin >> arr[i];
    	sum += arr[i];
    	x = max(x, arr[i]);
    	y = min(y, arr[i]);
	}
	
	for(int i = y; i <= x; i++){
		sum = 0;
		for(int j = 0; j < n; j++){
			sum += abs(arr[j] - i) * abs(arr[j] - i);
		}
		ans = min(ans, sum);
	}
   
   	cout << ans << endl;
   
    return 0;
}

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

#define ll long long

using namespace std;

int main() {

    int n, k;
    cin >> n >> k;
    
    ll arr[n];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    
    ll dp[n];
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(arr[i - 1] - arr[i]);
        for(int j = 2; j <= k; j++)
            if(i >= j)
                dp[i] = min(dp[i], dp[i - j] + abs(arr[i - j] - arr[i]));
    }
    
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
N=int(input())
array=map(int,input().split())
A=[]
for i in array:
    A.append(i)

dict_num={i:0 for i in range(100050)}
Q=int(input())
matrix=[]
for i in range(Q):
    matrix.append(list(map(int,input().split())))

#全数値の合計計算
sum=0
#各数字の出現回数の計測
for i in range(N):
    dict_num[A[i]]+=1
    sum+=A[i]

#合計の再計算 & 数字の出現回数の再計算
for i in matrix:
    sum+=(i[1]-i[0])*dict_num[i[0]]
    dict_num[i[1]]+=dict_num[i[0]]
    dict_num[i[0]]=0
    print(sum)

Measured memory_bytes: 39932
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define mp make_pair
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

signed main() 
{
    speed;
    //freopen("input.tXt","r",stdin);
    //freopen("output.tXt","w",stdout);

    string a,b;
    cin>>a>>b;
    int m=a.size(),n=b.size();

    int A[m+1][n+1]={};
    rep(i,1,m)
    {
        rep(j,1,n)
        {
            if(a[i-1]==b[j-1]) A[i][j]=1+A[i-1][j-1];
            else A[i][j]=max(A[i-1][j],A[i][j-1]);
        }
    }
    string ans="";
    int i=m,j=n;
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            ans+=a[i-1];
            i--;
            j--;
        }
        else if(A[i-1][j]>=A[i][j-1]) i--;
        else j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}   

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int a,b,n;
    cin>>a>>b>>n;
    if(n>=b-1){
    	cout<<(a*(b-1))/b<<endl;
    }
    else 
    	cout<<(a*n)/b<<endl;
}


Measured memory_bytes: 3636
n = int(input())
s = input()

r_total = s.count("R")
g_total = s.count("G")
b_total = s.count("B")

r_c = []
g_c = []
b_c = []

for moji in s:
  if moji == "R":
    r_total -= 1
  if moji == "G":
    g_total -= 1
  if moji == "B":
    b_total -= 1
  r_c.append(r_total)
  g_c.append(g_total)
  b_c.append(b_total)

color_dic = {"R": r_c, "G": g_c, "B": b_c}
#print(color_dic)
  
from itertools import combinations as cmb
counter = 0
RGB = set(["R", "G", "B"])
for i, j in cmb(list(range(n)), 2):
  #print(i, j, s[i], s[j])
  if s[i] != s[j]:
    rest_color = list(RGB - set([s[i], s[j]]))[0]
    #print(rest_color)
    counter += color_dic[rest_color][j]
    try:
      if s[2 * j - i] == rest_color:
        counter -= 1
    except IndexError:
      pass
print(counter)

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

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

    vector<int> ball(200010);
    int a;
    for(int i=0;i<N;i++){
        cin >> a;
        ball[a]++;
    }
    sort(ball.rbegin(),ball.rend());

    int num=0;
    for(int i=0;i<K;i++){
        num+=ball[i];
    }
    cout << N-num << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
int main(){
    std::string s;std::cin>>s;
    std::deque<char>deq;
    for(char c:s)deq.push_back(c);
    int q;std::cin>>q;
    bool rev=false;
    while(q--){
        int t;std::cin>>t;
        if(t==1)rev^=1;
        if(t==2){
            int f;char c;std::cin>>f>>c;
            if((f==1)==(!rev))deq.push_front(c);
            else deq.push_back(c);
        }
    }
    if(rev)std::reverse(deq.begin(),deq.end());
    for(char c:deq)std::cout<<c;
    std::cout<<std::endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    long long int sum = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    sort(a.begin(), a.end());
    cout << a.at(0) << " " << a.at(n-1) << " " << sum << endl;
}


Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int a, b;
int main() {
    cin>>a>>b;
    if (a>b){
        for(int i = 0; i<a; i++){
            cout<<b;
        }
    } else if (b>a){
        for(int i = 0; i<b; i++){
            cout<<a;
        }
    }
    else{
        for(int i = 0; i<b; i++){
            cout<<a;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{  int N;
   cin>>N;
    long long int  count_pairs = 0; 
    for (int i = 1; i <= sqrt(N - 1); ++i) { 
        for (int j = i; j * i < N; ++j) 
            ++count_pairs; 
    } 
    count_pairs *= 2; 
    count_pairs -= (long long int)(sqrt(N - 1)); 
  
cout<<count_pairs;
}

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

int main(){

 int n;
 cin>>n;
 
  for(int i=0;i<n;i++){
  
   int Y,M,D,S;
   cin>>Y>>M>>D;
  
   if(Y%3==0){
    if(M%2==0){
    Y=Y/3-1;
    M=M/2-1;
    S=196471-Y*590-390-M*40-20-D;
    cout<<S<<endl;
    }
    else{
    Y=Y/3-1;
    M=M/2;
    S=196471-Y*590-390-M*40-D;
    cout<<S<<endl;
    }
   }
   else if(Y%3==1){
    if(M%2==0){
    Y=Y/3;
    M=M/2-1;
    S=196471-Y*590-M*39-20-D;
    cout<<S<<endl;
    }
    else{
    Y=Y/3;
    M=M/2;
    S=196471-Y*590-M*39-D;
    cout<<S<<endl;
    }
   }
   else if(Y%3==2){
    if(M%2==0){
    Y=Y/3;
    M=M/2-1;
    S=196471-Y*590-195-M*39-20-D;
    cout<<S<<endl;
    }
    else{
    Y=Y/3;
    M=M/2;
    S=196471-Y*590-195-M*39-D;
    cout<<S<<endl;
    }
   }
  }
}


Measured memory_bytes: 3108
import numpy as np
a, b, h, m = map(int, input().split())
h_deg = (h*60+m)/720
m_deg = m/60
deg = max(h_deg-m_deg, m_deg-h_deg)
deg = 1.0-deg if deg > 0.5 else deg
if deg == 0.5:
    print('{:.20f}'.format(a+b))
else:
    print('{:.20f}'.format(np.sqrt(a**2+b**2-(2*a*b*np.cos(2*np.pi*deg)))))

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

int main() {
  int n, h, prev = 1;
  cin >> n;
  rep(i, n) {
    cin >> h;
    // cerr << i << ' ' << prev << ' ' << h << endl;
    if (prev < h) {
      h--;
    } else if (prev > h) {
      cout << "No" << endl;
      return 0;
    }
    prev = h;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
ans_list = []
while True:
    input_item = input().split()
    a = int(input_item[0])
    op = input_item[1]
    b = int(input_item[2])

    if op == "?":
        break

    if op == "+":
        ans_list.append(a + b)
    if op == "-":
        ans_list.append(a - b)
    if op == "*":
        ans_list.append(a * b)
    if op == "/":
        ans_list.append(a // b)

for ans in ans_list:
    print(ans)


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a[] = new int[n+2];
		for(int i=0;i<n;i++)a[i+1] = fs.nextInt();
		long sum = 0;
		for(int i=0;i<n+1;i++) {
			sum += (Math.abs(a[i+1] - a[i]));
		}
		for(int i=0;i<n;i++) {
			long ans = sum - Math.abs(a[i+1] - a[i]) - Math.abs(a[i+2] - a[i+1])  + Math.abs(a[i+2] - a[i]);
			System.out.println(ans);
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 53056
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int count = 0;
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if((i+1)%(j+1) == 0) count++;
            }
            if(count == 8 && !((i+1)%2 == 0))ans++;
            count = 0;
        }
        System.out.println(ans);
    }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    double ret=0;
    for(int i=1;i<=n;i++){
        double tmp=1.0/n;
        int now = i;
        while(now<k){
            now*=2;
            tmp/=2;
        }
        ret+=tmp;
    }
    printf("%.12f\n", ret);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define SE second
#define maxn 10000000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

bool np[maxn+5]={1,1};
int p[maxn+5],d[maxn+5],facnum[maxn+5];


int main()
{
    facnum[1]=1;
    int p_num=0;
    rep(i,2,maxn)
    {
        if(!np[i])
        {
            p[++p_num]=i;
            d[i]=1;
            facnum[i]=2;
        }
        rep(j,1,p_num)
        {
            ll v=1ll*i*p[j];
            if(v>maxn) break;
            np[v]=1;
            if(i%p[j]==0)
            {
                d[v]=d[i]+1;
                facnum[v]=facnum[i]/(d[i]+1)*(d[v]+1);
                break;
            }
            d[v]=1;
            facnum[v]=facnum[i]*2;
        }
    }
    int n;
	cin>>n;
    ll ans=0;
    rep(i,1,n) ans+=1ll*facnum[i]*i;
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 94108
// Vicfred
// https://atcoder.jp/contests/abc162/tasks/abc162_c
// math
import std.conv;
import std.stdio;
import std.string;

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

long gcd(long a, long b, long c) {
    return gcd(a,gcd(b,c));
}

void main() {
    int K = readln.chomp.to!int;

    long sum = 0;

    for(int i = 1; i <= K; i++)
        for(int j = 1; j <= K; j++)
            for(int k = 1; k <= K; k++)
                sum += gcd(i,j,k);

    sum.writeln;
}



Measured memory_bytes: 2700
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
//#define Se second
#define Fi first

ll mymul(ll a, ll b) {
	if (LL_INF / b < a) return LL_INF;
	else return min(LL_INF, a*b);
}

vector <pll> Vu1;
vector <pll> Vu2;
int main() {
	int Q;
	scanf("%d", &Q);
	while (Q--) {
		ll A, B, i, j;
		scanf("%lld %lld", &A, &B);

		ll st = 1, en = 1e12, mi, rv = 0;
		while (st <= en) {
			mi = (st + en) / 2;
			if (mi == 2) {
				mi = mi;
			}
			Vu1.clear();
			Vu2.clear();
			if (mi < A) Vu1.emplace_back(1, mi);
			else {
				if(A-1 != 0) Vu1.emplace_back(1, A - 1);
				if(mi-A+1 != 0) Vu1.emplace_back(A + 1, mi - A + 1);
			}
			if (mi < B) Vu2.emplace_back(mi, mi);
			else {
				if(mi-B+1 != 0) Vu2.emplace_back(mi + 1, mi - B + 1);
				if(B-1 != 0) Vu2.emplace_back(B - 1, B - 1);
			}

			bool ans = true;
			int p1 = 0, p2 = 0;
			while (p1 != Vu1.size()) {
				ll c = min(Vu1[p1].second, Vu2[p2].second);
				
				ll s1 = Vu1[p1].first, e1 = Vu2[p2].first;

				ll v1, v2;
				if (e1 % 2 == s1 % 2) {
					v1 = v2 = (e1 - s1) / 2;
				}
				else {
					v1 = (e1 - s1 - 1) / 2;
					v2 = (e1 - s1 + 1) / 2;
				}

				ll mx = -LL_INF;
				if (0 <= v1 && v1 < c) mx = max(mx, mymul(s1 + v1, e1 - v1));
				if (0 <= v2 && v2 < c) mx = max(mx, mymul(s1 + v2, e1 - v2));
				mx = max(mx, mymul(s1, e1));
				mx = max(mx, mymul(s1 + c - 1, e1 - c + 1));
				if (mx >= A*B) {
					ans = false;
					break;
				}
				Vu1[p1].first += c;
				Vu2[p2].first -= c;
				Vu1[p1].second -= c;
				Vu2[p2].second -= c;
				if (Vu1[p1].second == 0) p1++;
				if (Vu2[p2].second == 0) p2++;
			}
			if (ans) {
				rv = mi;
				st = mi + 1;
			}
			else en = mi - 1;
		}
		printf("%lld\n", rv);
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <deque>

using ll = long long;
using ull = unsigned long long;

using namespace std;

template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    ll n;
    cin >> n;

    vec<ll> ans(10001);

    for (ll x = 1; x * x <= n; ++x)
        for (ll y = 1; y * y <= n; ++y)
            for (ll z = 1; z * z <= n; ++z)
            {
                auto f = x * x + y * y + z * z + x * y + y * z + z * x;
                if (f <= n)
                    ans[f]++;
            }
    
    for (int i = 1; i <= n; ++i)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    int n,m;
    cin>>n>>m;

    int MIN=1e5+1,MAX=0;

    rep(i,m){
        int a,b;

        cin>>a>>b;
        if(a>MAX)MAX=a;
        if(b<MIN)MIN=b;
    }

    if(MIN<MAX)cout<<0<<endl;
    else cout<<MIN-MAX+1<<endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

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

int main(){
  int n;
  cin >> n;
  map<string,int> table;
  string s;
  for(int i=0;i<n;i++){
    cin >> s;
    table[s]++;
  }
  int ref = -1;
  for(auto itr=table.begin();itr!=table.end();itr++){
    ref = max(ref,itr->second);
  }
  for(auto itr=table.begin();itr!=table.end();itr++){
    if(itr->second == ref) cout << itr->first << endl;
  }
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
string s;
int N;
int ans[100100];
int main(){
	cin >> s;
	N = s.size();
	int ch = 0;
	int pre = 0;
	for(int i=0;i<=s.size();i++){
		if((i==s.size())||(i>0&&(s[i-1]!=s[i]))){
			ch++;
		}
		if(ch==2){
			int l=0,r=0;
			for(int j=pre;j<i;j++){
				if(s[j]=='L')l++;
				else r++;
			}
			
			//cout << l << ' ' << r << endl;
			ans[pre+r-1] += (r+1)/2;
			//cout << pre+r-1 << ',' << (r+1)/2  << endl;
			ans[pre+r] += (r)/2;
			//cout << pre+r << ',' << r/2  << endl;
			ans[pre+r-1] += (l)/2;
			//cout << pre+r-1 << ',' << l/2  << endl;
			ans[pre+r] += (l+1)/2;
			//cout << pre+r << ',' << (l+1)/2  << endl;
			pre = i;
			ch = 0;
		}
	}

	for(int i=0;i<N;i++){
		cout << ans[i];
		if(i+1<N)cout << ' ';
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

ll dp[55][55][3000];

int main() {
    ll n, a; cin >> n >> a;
    rep(i, 55) rep(j, 55) rep(k, 3000) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    rep(i, n) {
        ll x; cin >> x;
        rep(j, n+1) {
            rep(k, n*a) {
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+x] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    Rep(i, 1, n+1) ans += dp[n][i][i*a];
    cout << ans << endl;
}


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



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

    vector<int> a(N,0);

    for (int i = 0; i < N; ++i)
    {
        int tmp;
        cin >> tmp;
        a.at(i) = tmp;
    }

    long long int dp[N+1][N+1] = {};

    for(int len = 1; len <= N; ++len)
    {
        for(int i = 0; i + len <=N; ++i)
        {
            int j = i + len;

            // 先手
            if((N - len) % 2 == 0)
            {
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
            }
            else
            {
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);                
            }
        }
    }

    cout << dp[0][N] << endl;

    return 0;
}



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

using namespace std;
typedef long long ll;

ll N, A, B;

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N >> A >> B;
    if (A % 2 == B % 2)
    {
        cout << abs (A - B) / 2 << "\n";
    }
    else
    {
        ll av = (A - 1) + (B - 1) + 1;
        ll bv = (N - A) + (N - B) + 1;
        cout << min (av, bv) / 2 << "\n";
    }
}

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

using namespace std;

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

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

const ll MOD = 1000000007;

ll h, w, a, b;
ll fact[200001];

ll pow(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res = res * x % MOD;
		x = x * x % MOD;
		y /= 2;
	}
	return res;
}

ll inv(ll n) {
	return pow(n, MOD - 2);
}

ll comb(ll n, ll r) {
	return fact[n] * inv(fact[r] * fact[n - r] % MOD) % MOD;
}

int main(int argc, char **argv) {
	cin >> h >> w >> a >> b;
	fact[0] = 1;
	REP(i, 200000) fact[i + 1] = fact[i] * (i + 1) % MOD;
	ll res = 0;
	FOR(i, b, w) {
		res = (res + comb(i + h - 1 - a, i) * comb(w - 1 - i + a - 1, w - 1 - i) % MOD) % MOD;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
ll dfs(vll v[],ll e[],ll q)
{
    if(e[q]!=-1)
        return(e[q]);
    ll x=-1,y=-1;
    e[q]=0;
    for(auto i:v[q])
    {
        y=dfs(v,e,i);
        if(y>x)
            x=y;
    }
    e[q]=x+1;
    return (e[q]);
}
int main()
{  
    FAST
    ll n,m;
    cin>>n>>m;
    vll v[n+1];
    ll x,y;
    for(ll i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
    }
    ll e[n+1];
    for(ll i=0;i<=n;i++)
    {
        e[i]=-1;
    }
    for(ll i=1;i<=n;i++)
    {
        if(e[i]==-1)
            dfs(v,e,i);
    }
    ll ans=0;
    for(ll i=0;i<=n;i++)
    {
        if(e[i]>ans)
            ans=e[i];
    }
    cout<<ans;
}

Measured memory_bytes: 9216
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion


bool f(ll trial);
template <class T>
T bin_search(T ok, T ng) {
  T c;
  while (abs(ok - ng) > 1) {
    c = (ok + ng) / 2;
    if (f(c)) {
      ok = c;
    } else {
      ng = c;
    }
  }

  return ok;
}

int N, K;
vector<int> A;

bool f(int trial) {
  int k = 0;
  rep(i, N) {
    k += (A[i] + trial - 1) / trial - 1;
  }
  return k <= K;
}

signed main() {
  cin >> N >> K;
  A = vector<int>(N);
  rep(i, N) {
    cin >> A[i];
  }

  int ans = bin_search(INF, 0ll);
  cout << ans << endl;
}

Measured memory_bytes: 4732
#include<iostream>

using namespace std;

int main(){
  int n, t, mn=1001;
  cin >> n >> t;
  bool ans=true;
  for(int i=0;i<n;i++){
    int c , tmp;
    cin >> c >> tmp;
    if(tmp<=t){
      mn = min(mn, c);
      ans=false;
    }
  }
  if(ans){
    cout << "TLE" <<endl;
  }
  else{
    cout << mn << endl;
  }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  for(int i=1; i*i<n; i++){
    for(int j=1; j*j<n; j++){
      for(int k=1; k*k<n; k++){
        int t = i*i + j*j + k*k + i*j + j*k + k*i;
        mp[t]++;
      }
    }
  }
  FOR(i,1,n+1){
    PRINT(mp[i]);
  }
}



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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 100;
int N, W;
ll w[MAX_N];
int v[MAX_N];

int main() {
  cin >> N >> W;
  rep(i,N) cin >> w[i] >> v[i];

  vector<int> vs[4];
  for (int i = 0; i < N; ++i) {
    if (w[i] == w[0]) {
      vs[0].push_back(v[i]);
    } else if (w[i] == w[0]+1) {
      vs[1].push_back(v[i]);
    } else if (w[i] == w[0]+2) {
      vs[2].push_back(v[i]);
    } else if (w[i] == w[0]+3) {
      vs[3].push_back(v[i]);
    }
  }

  sort(all(vs[0]), greater<int>());
  sort(all(vs[1]), greater<int>());
  sort(all(vs[2]), greater<int>());
  sort(all(vs[3]), greater<int>());

  int ans = 0;
  int a = vs[0].size(), b = vs[1].size(), c = vs[2].size(), d = vs[3].size();
  vector<int> sum[4];
  for (int i = 0; i < a; ++i) {
    if (i == 0) sum[0].push_back(vs[0][0]);
    else sum[0].push_back(sum[0][i-1]+vs[0][i]);
  }
  for (int i = 0; i < b; ++i) {
    if (i == 0) sum[1].push_back(vs[1][0]);
    else sum[1].push_back(sum[1][i-1]+vs[1][i]);
  }
  for (int i = 0; i < c; ++i) {
    if (i == 0) sum[2].push_back(vs[2][0]);
    else sum[2].push_back(sum[2][i-1]+vs[2][i]);
  }
  for (int i = 0; i < d; ++i) {
    if (i == 0) sum[3].push_back(vs[3][0]);
    else sum[3].push_back(sum[3][i-1]+vs[3][i]);
  }


  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        for (int l = 0; l <= d; ++l) {
          if (i*w[0] + j*(w[0]+1) + k*(w[0]+2) + l*(w[0]+3) <= W) {
            int t = 0;
            if (i != 0) t += sum[0][i-1];
            if (j != 0) t += sum[1][j-1];
            if (k != 0) t += sum[2][k-1];
            if (l != 0) t += sum[3][l-1];
            ans = max(t, ans);
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;

}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}

vector<ll>ans(33,0);
void solve(ll x){
	if(x==0) return;
	if(x<0){
		ll i=-1;
		ll tmp=0;
		while(tmp>x){
			i+=2;
			tmp-=pw2[i];
		}
		ans[i]=1;
		solve(x+pw2[i]);
	}
	else{
		ll i=-2;
		ll tmp=0;
		while(tmp<x){
			i+=2;
			tmp+=pw2[i];
		}
		ans[i]=1;
		solve(x-pw2[i]);
	}
}

//a,b x
int main(){
	ll N; cin>>N;
	ll tmp=N;
	while(tmp>=0 && tmp%7!=0){
		tmp-=4;
	}
	if(tmp<0) cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 256
package main
 
import (
  "fmt"
  "strings"
)
 
func main() {
  var s string
  fmt.Scanf("%s", &s)
  
  ans := "No"
  if strings.Index(s, "C") < strings.LastIndex(s, "F") {
    ans = "Yes"
  }
  if strings.Index(s, "C") < 0 {
    ans = "No"
  }
  
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1836
while 1:
	n=input()
	if n==0:break
	s=[map(int,raw_input().split()) for i in range(n)]
	r=map(int,raw_input().split())
	flag=0
	for i in s:
		if i[1]<=r[0] and i[2]<=r[1] and i[3]<=r[2] and 4*(i[1]+i[3])+9*i[2]<=r[3]:
			print i[0]
			flag=1
	if flag==0:print "NA"

Measured memory_bytes: 4488
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
#print(A)

ans = N
NG = [0 for _ in range(M)]
while(sum(NG)<M):
  COUNT = [0 for _ in range(M)]
  for i in range(N):
    for j in range(M):
      if NG[A[i][j]-1] == 0:
        COUNT[A[i][j]-1] += 1
        break
  maxcount = 0
  maxi = 0
  for i in range(M):
    if maxcount < COUNT[i]:
      maxcount = COUNT[i]
      maxi = i
  #print(maxcount,COUNT)
  ans = min(ans,maxcount)
  NG[maxi] = 1
print(ans)

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

int main() {
  int N,temp,Max,sum;
  cin >> N; // 12, 57, 148
  temp = N;

  sum = 0;
  Max = 1; // Nの桁
  while(Max*10 < N) { // Max=10, 10, 100
    Max = Max * 10;
  }
  
  while (Max >= 1) {
    sum += temp / Max; // それぞれの桁の数字を取り出して和を計算
    temp %= Max; // 桁を1/10
    Max /= 10; // それに合わせて割る数も1/10
  }

  if (!(N%sum)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

void solve(std::string S, std::string T) {
    int ans = 0;
    rep(i,S.size()) {
        if (S[i] != T[i]) ans += 1;
    }
    cout << ans << endl;
}

int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define fdiv(a, b) ((a) + (b) - 1) / (b)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, A;
signed main() {
    cin >> H >> A;
    cout << fdiv(H, A) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int a[100000];
vector<int> b[100000];
int ans=0;
int n,m;

int dfs(int now,int prev){
  int num=1;
  rep(i,b[now].size() ){
    num=max(num,dfs(b[now][i],now));
  }
  if(num==m && prev!=0){
    ans++;
    //cout<<now<<"! "<<1<<endl;
    return 1;
  }
  else{
    //cout<<now<<" "<<num<<endl;
    return num+1;
  }
}
    


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  
  cin>>n>>m;
  
  //int ans=0;
  
  rep(i,n){
    cin>>a[i];a[i]--;
    if(i!=0) b[a[i]].push_back(i);
  }
  if(a[0]!=0) ans++;
  dfs(0,0);
  //cout<<dfs(0)<<endl;
  cout<<ans<<endl;
  
  
  
  
  return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>
int main(void)
{
	int Q,i,y,c,a,n,t;
	scanf("%d",&Q);
	for(i=0;i!=Q;i++){
		t=0;
		scanf("%d%d%d",&c,&a,&n);
		while(1){
			if(c>0&&a>0&&n>0){
				t++;
				c-=1;
				a-=1;
				n-=1;
			}
			else if(c>1&&a>0){
				t++;
				c-=2;
				a-=1;
			}
			else if(c>2){
				t++;
				c-=3;
			}
			else{
			break;
			}
		}
	printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 1028
n = int(input())
hlist = [int(h) for h in input().split()]


hmax = -1
for h in hlist:
    hmax = max(hmax, h)


count = 0

while hmax > 0:

    prev_max = False

    for h in hlist:
        if h >= hmax and not prev_max:
            count += 1
            prev_max = True
        if h < hmax:
            prev_max = False

    hmax -= 1


print(count)



Measured memory_bytes: 3060