akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int num[3];
  num[0]=a;
  num[1]=b;
  num[2]=c;
  sort(num,num+3);
  if(num[1]==c) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <deque>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cmath>
#include<list>
#include <cstdlib>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 8;
#define MOD 1046527
int n;
char H[maxn][15];

int getChar(char ch)
{
    return ch -'A' + 1;
}
ll getValue(char t[])
{
    int len = strlen(t);
    ll sum = 0, p = 1, i;
    for(i = 0; i < len;  ++i){
        sum += p * getChar(t[i]);
        p *= 5;
    }
    return sum;
}
ll h1(ll k)
{
    return k % MOD;
}
ll h2(ll k)
{
    return 1 + (k % (MOD - 1));
}
int solve_insert(char c[])
{
    ll key,i,h;
    key = getValue(c);
    i = 0;
    while(true)
    {
        h = (h1(key) + i * h2(key)) % MOD;
        if(strcmp(H[h],c) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h],c);
            return 0;
        }
        i++;
    }
}
int solve_find(char c[])
{
    ll key, i, h;
    i = 0;
    key = getValue(c);
    while(true)
    {
        h = (h1(key) + i * h2(key)) % MOD;
        if(strcmp(H[h],c) == 0) return 1;
        else if(strlen(H[h]) == 0){
            return 0;
        }
        i++;
    }
}
int main()
{
    scanf("%d",&n);
    char s[15],t[15];
    for(int i = 0; i < n; ++i){
        scanf("%s%s",s,t);
        if(s[0] == 'i'){
            solve_insert(t);
        }else{
            if(solve_find(t))printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 18392
import java.util.*;
public class Main{
  public static void main(String[] args){
    int i,tmp;
    long ans=0l;
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int[] b=new int[n];
    for(i=0;i<n;i++){
      a[i]=sc.nextInt();
      b[i]=sc.nextInt();
    }
    for(i=n-1;i>=0;i--){
      tmp=(int)(((long)a[i]+ans)%(long)b[i]);
      if(tmp!=0)ans+=(long)(b[i]-tmp);
    }
    System.out.println(ans);
  }
}


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

const int INF = 1000000008;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int c[20], a[20][20];
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++) cin >> a[i][j];
    }
    int ans = INF;
    for(int i = 0; i < (1 << n); i++){
        int d[20]{0};
        int s = 0;
        for(int j = 0; j < n; j++){
            if(!((i >> j) & 1)) continue;
            s += c[j];
            for(int k = 0; k < m; k++) d[k] += a[j][k];
        }
        bool f = true;
        for(int j = 0; j < m; j++){
            if(d[j] < x) f = false;
        }
        if(f) ans = min(ans, s);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FASTIO
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();

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


int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;
    string S;
    cin >> S;

    bool mode1 = false;
    for (int i = 0; i < N; i++) {
        if (S[i] == '2') {
            mode1 = true;
            break;
        }
    }

    if (mode1) {
        // 2を含む
        int r = 0;
        for (int i = 0; i < N; i++) {
            if (S[i] == '2') {
                r += (N - 1 == (i | (N - 1 - i)));
            }
        }
        if (r % 2) {
            cout << 1 << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    else {
        // 1, 3のみ
        int r = 0;
        for (int i = 0; i < N; i++) {
            if (S[i] == '3') {
                r += (N - 1 == (i | (N - 1 - i)));
            }
        }
        if (r % 2) {
            cout << 2 << endl;
        }
        else {
            cout << 0 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1948
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>


int main(){
  int N;
  scanf("%d", &N);
  std::map<int, int > mp;
  std::vector<int> A(N), order(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
    mp[A[i]]=i;
  }
  int cnt = 0;
  for (auto entry : mp){
    order[entry.second] = cnt;
    cnt++;
  }
  int diff0=0;
  int diff1=0;
  for (int i=0; i<N; i++){
    //printf("i=%d, order=%d\n", i, order[i]);
    if (i%2==0){
      if (order[i]%2==1) diff0++;
    } else {
      if (order[i]%2==0) diff1++;
    }
  }
  std::cout << diff0 << std::endl;
  return 0;
}


Measured memory_bytes: 8404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef tuple<int, int, int> ti;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int n = 1;
    while(1<<n < N+1) n++;
    cout << n << endl;
    vector<ti> vec;
    rep2(i, 1, n-1){
        vec.pb(ti(i, i+1, 0));
        vec.pb(ti(i, i+1, 1<<(i-1)));
    }
    int now = 1<<(n-1);
    N -= now;
    while(N > 0){
        int i = 1;
        while(1<<i < N+1) i++; 
        vec.pb(ti(i, n, now));
        N -= 1<<(i-1);
        now += 1<<(i-1);
    }
    cout << vec.size() << endl;
    rep(i, vec.size()){
        ti e = vec[i];
        int a, b, c;
        tie(a, b, c) = e;
        cout << a << ' ' << b << ' ' << c << endl;
    }
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s;
    cin>>s;
    if(s=="Sunny")
    cout<<"Cloudy";
    else if(s=="Cloudy")
    cout<<"Rainy";
    else
    cout<<"Sunny";

     

  return 0;
    
}
    



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

using namespace std;


int main(){
    //bool ans=false;
    long long t,a,k;

    cin>>t>>a>>k;

    if(a+t<=k){
        t=0;
        a=0;
    }
    else if(t<=k){
        a=a-(k-t);
        t=0;
    }
    else{
        t=t-k;
    }

    cout<<t<<" "<<a<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;

struct Node{
	Node(){
		brother = parent = -1;
		height = depth = num_of_children = 0;
	}
	int parent,brother,depth,num_of_children,height;
	vector<int> children;
};

void calcDepth(Node nodes[],int root_id){
	for(int i = 0;i < nodes[root_id].num_of_children;i++){
		nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
		calcDepth(nodes,nodes[root_id].children[i]);
	}
}

void calcHeight(Node nodes[],int height,int parent){
	nodes[parent].height = max(nodes[parent].height,height+1);
	if(nodes[parent].parent != -1) calcHeight(nodes,height+1,nodes[parent].parent);
}

int main(){
	int n,id,left_id,right_id,root_id;
	scanf("%d",&n);
	Node nodes[n];

	for(int i = 0; i < n; i++){
		scanf("%d %d %d",&id,&left_id,&right_id);
		if(left_id != -1){
			nodes[id].children.push_back(left_id);
			nodes[id].num_of_children++;
			nodes[left_id].parent = id;
		}
		if(right_id != -1){
			nodes[id].children.push_back(right_id);
			nodes[id].num_of_children++;
			nodes[right_id].parent = id;
		}
		if(left_id != -1 && right_id != -1){
			nodes[left_id].brother = right_id;
			nodes[right_id].brother = left_id;
		}
	}

	for(root_id = 0; root_id < n; root_id++){
		if(nodes[root_id].parent == -1) break;
	}

	if(n > 1){
		calcDepth(nodes,root_id);

		for(int i = 0; i < n; i++){
			if(nodes[i].num_of_children == 0) calcHeight(nodes,0,nodes[i].parent);
		}
	}

	for(int i = 0; i < n; i++){
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,"
				,i,nodes[i].parent,nodes[i].brother,nodes[i].num_of_children,nodes[i].depth,nodes[i].height);
		if(nodes[i].parent == -1){
			printf(" root\n");
		}else if(nodes[i].num_of_children == 0){
			printf(" leaf\n");
		}else{
			printf(" internal node\n");
		}

	}
}

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

int main(){
  int n,m;
  int order;
  string str;
  int x,y;
  
  while(1){
    int cnt = 0;
    int a[20+1][20+1]={};
    
    cin >> n;
    if(n == 0) break;

    for(int i=0;i < n;i++){
	cin >> x >> y;
	a[21-y-1][x-1] = 1;
    }
    x=10;
    y=10;
    
    cin >> m;
    for(int i=0;i < m;i++){
      cin >> str >> order;
      
      for(int j=0;j < order;j++){
	if(str == "N"){
	  y++;
	}
	else if(str == "S"){
	  y--;
	}
	else if(str == "E"){
	  x++;
	}
	else if(str == "W"){
	  x--;
	}
	if(a[21-y-1][x-1] == 1){
	  a[21-y-1][x-1] = 0;
	  cnt++;
	}
      }
    }
    if(cnt == n) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3100
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = list(input())

if "7" in n:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 10532
while True:
    try:
        (h,w)=map(int,raw_input().split())
        if h==0 and w==0: break
        for i in xrange(h):
            if i==0 or i==h-1:
                print ''.join(['#' for j in xrange(w)])
            else:
                print '#'+(''.join(['.' for j in xrange(w-2)]))+"#"
        print
    except EOFError: break

Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define int long long int 

int32_t main()
{
  int w,a,b;
  cin>>w>>a>>b;
  if(a>b)
  {
      int temp=a;
      a=b;
      b=temp;
  }
  if(w+a>=b)
    cout<<0<<endl;
  else
    cout<<abs(w+a-b)<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end() 
using namespace std;
typedef long long ll;

int n, m;
vector<int> id;

map<pair<int, int>, int> mp;

int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> n >> m;
   for(int i=0; i<m; ++i) {
       int a, b;
       cin >> a >> b;
       --a, --b;
       mp[{a, b}] = 1;
       mp[{b, a}] = 1;
   }
   id.resize(n);
   iota(all(id), 0);
   int res = 0;
   do {
        if(id[0]) continue;
        int flag = 0;
        for(int i=0; i<n-1; ++i) {
            if(!mp[{id[i], id[i+1]}]) {
                flag = 1;
                break;
            }
        }
        if(!flag) ++res;
   }while(next_permutation(all(id)));
   cout << res << "\n";
   return 0;
} 


Measured memory_bytes: 256
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        a: [usize;n]
    }

    let mut max_nums = vec![];

    for &i in &a {
        match bin_search(&max_nums, i) {
            MAX => {
                max_nums.insert(0, i);
            }
            num => {
                max_nums[num] = i;
            }
        }

        //println!("{:?}", max_nums);
    }

    println!("{}", max_nums.len());
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet
// 二分探索 vは単調増加 v[x] <= aとなる最小のxを返す
fn bin_search(v: &[usize], a: usize) -> usize {
    if v.is_empty() || a <= v[0] {
        return MAX;
    }
    let mut min = 0;
    let mut max = v.len();
    while max - min > 1 {
        let mid = (min + max) / 2;
        if v[mid] < a {
            min = mid;
        } else {
            max = mid;
        }
    }
    min
}


Measured memory_bytes: 10620
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	long long int a,b,i,d,res=0;
	
	cin>>a;
	vector<int> c(a);
	for(i=0;i<a;i++){
		cin>>c[i];
		c[i]-=i;
	}
	sort(c.begin(),c.end());
	b=c[a/2];
	for(i=0;i<a;i++)res+=abs(c[i]-b);
	cout<<res;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,T;
    cin >> N >> T;
    int ans = INF;
    for(int i = 0; i < N; i++) {
        int c,t;
        cin >> c >> t;
        if(t <= T) {
            ans = min(ans,c);
        }
    }
    if(ans == INF) {
        cout << "TLE" << endl;
    }
    else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K;
	cin >> N >> K;
	vector<int> p;
	for(int i=0;i<N;i++){
		int x;
		cin >> x;
		p.push_back(x);
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for(int i=0;i<K;i++){
		ans += p[i];
	}
	cout << ans << endl;
}


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

#define int long long

int n, m, k;

void solve(vector<int> &con, int depth, int sum){
  if(depth == n){
    con[sum]++;
    return ;
  }
  for(int i = 1; i <= m; i++){
    solve(con,depth+1,sum+i);
  }
  
}
signed main(){

  cout<<fixed<<setprecision(8);
  while(true){
    double ans = 0, temp;
    vector<int> con;
    
    cin>>n>>m>>k;

    if(!n&&!m&&!k) break;

    con.resize(n*m+2);
    
    solve(con, 0, 0);

    temp = pow(m,n);
    
    for(int i = n; i <= n*m; i++){
      ans += max(1ll, i-k)*con[i];
      //cout<<i<<" "<<con[i]<<endl;
    }

    ans /=temp;

    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
const int M=200010;
int n,m,a[M],b[M],f[N];
vector<int>e[N];
bool vis[N],vis1[N][N],vis2[N][N];
void dfs1(int u,int s){
	if(vis1[s][u]) return;
	vis1[s][u]=1;
	for(int i=0;i<e[u].size();i++){
		dfs1(e[u][i],s);
	} 
}
void dfs2(int u,int s,int typ,int k){
	if(vis[u]) return;
	vis[u]=1;
	if(!typ) f[u]=k;
	else vis2[s][u]=(k!=f[u]);
	for(int i=0;i<e[u].size();i++){
		dfs2(e[u][i],s,typ,k);
	} 
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a[i],&b[i]);
		e[a[i]].push_back(b[i]);
	}
	for(int i=1;i<=n;i++){
		dfs1(i,i);
	}
	for(int s=1;s<=n;s++){
		for(int i=1;i<=n;i++){
			vis[i]=0;
		}
		vis[s]=1;
		for(int i=0;i<e[s].size();i++){
			dfs2(e[s][i],s,0,i);
		}
		for(int i=1;i<=n;i++){
			vis[i]=0;
		}
		vis[s]=1;
		for(int i=e[s].size()-1;i>=0;i--){
			dfs2(e[s][i],s,1,i);
		}
	}
	for(int i=1;i<=m;i++){
		printf(vis1[b[i]][a[i]]^vis2[a[i]][b[i]]?"diff\n":"same\n");
	}
}
	

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

int main() {
  ll n;
  cin >> n;
  if (n%2==0) {
    cout << n/2 << endl;
  } else {
    cout << n/2+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int N;
	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	vector<int> given;

	cin >> N;
	int subordinate[N]={0};

	for(i=0;i<N-1;i++){
		cin >> tmp;
		given.push_back(tmp);
	}

	for(i=0;i<N;i++){
		subordinate[given[i]-1]++;
	}

	for(i=0;i<N;i++){
		cout << subordinate[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 5060
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 1e5+20;

ll f[N];

int main(){

	fastio;
	ll n,k;
	cin >> n >> k;
	fill(f,0);
	for(int i = 0; i < n; ++i){
		int a,b;
		cin >> a >> b;
		f[a] += b;
	}

	int ans;
	for(ans = 1; k > f[ans]; ++ans){
		k -= f[ans];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
N = int(input())

dic = {}

for i in range(N):
	key = input()
	if key not in dic:
		dic[key] = 1
	else:
		dic[key] +=1

maxnum = max(dic.values())
#print(maxnum)
#print(dic)

keys = list(dic.keys())
for key in sorted(keys):
	if dic[key] == maxnum:
		print(key)




Measured memory_bytes: 33116
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;
 
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=0;i<(n);++i)
#define fill(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
 
const LL INF = 1e10 + 7;
 
int n,tot;
map<LL,int> cnt;
map<LL,LL> cp;
LL p[4][3000];
 
void init()
{
	tot = 0;
	for(int i=2;;++i)
	{
		if(1LL*i*i*i >= INF) break;
		if(p[0][i]) continue;
		p[1][tot] = i;
		p[2][tot] = i*i;
		p[3][tot++] = 1LL*i*i*i;
		for(int j=i;;j+=i)
		{
			if(1LL*j*j*j >= INF) break;
			p[0][j] = 1;
		}
	}
}
 
int main()
{
	//freopen("test.txt","r",stdin);
	init();
	scanf("%d",&n);	
	int ans = 0,fi = 1;
	R(i,n)
	{
		LL s,x,y;
		scanf("%lld",&s);
 
		x = y = 1;
		R(j,tot)
		{
			while(s%p[3][j] == 0)
			{
				s /= p[3][j];
			}
			if(s%p[2][j] == 0)
			{
				x *= p[2][j];
				y *= p[1][j];
				if(y > INF) y = INF;
			}
			else if(s%p[1][j] == 0)
			{
				x *= p[1][j];
				y *= p[2][j];
				if(y > INF) y = INF;
			}
		}
		s /= x;
		if(s != 1)
		{
			int t = sqrt(s),r = -1;
			F(j,max(1,t-1),t+1)
				if(1LL*j*j == s)
				{
					r = j;
					break;
				}
			if(r != -1)
			{
				if(y < INF) y *= r;
			}
			else
			{
				if(INF/s/s < y) y = INF;
				else y *= 1LL*s*s;
			}
		}
		if(y >= INF)
		{
			++ans;
			continue;
		}
 
		s *= x;
 
		if(s == 1)
		{
			if(fi)
			{
				fi = 0;
				++ans;
			}
			continue;
		}
 
		cnt[s]++;
		cp[s] = y;
	}
	for(auto it = cnt.begin();it != cnt.end(); ++it)
	{
		LL gf = cp[it->fi];
		if(it->fi < gf || cnt.find(gf) == cnt.end()) ans += max(it -> se,cnt[gf]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 20864
from bisect import bisect
inf = float('inf')

# 広義単調増加
def LIS(arr):
    N = len(arr)
    dp = [inf] * N
    res = 0
    for a in arr:
        pos = bisect(dp,a)
        dp[pos] = a
        res = max(res, pos + 1)
    return res

N = int(input())
A = [int(input()) for _ in range(N)]

ans = LIS(A[::-1])
print(ans)

Measured memory_bytes: 8608
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/22/20 21:00:03
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  map<int, int> cards;
  for (int i = 0; i < n; i++) {
    int a; cin>>a;
    cards[a]++;
  }
  priority_queue<int, vector<int>, greater<>> cq;
  for (auto p:cards)
    cq.push(p.first);

  for (int i = 0; i < m; i++) {
    int b,c; cin>>b>>c;
    auto cb = b;
    while (cb>0) {
      auto num = cq.top();
      if (num >= c) break;
      auto consume = min(cb, cards[num]);
      cards[num] -= consume;
      if (cards[num] == 0) {
        cq.pop();
      }
      cb -= consume;
    }
    if (b-cb > 0)
      cq.push(c);
    cards[c] += b-cb;
  }
  ll ans = 0;
  for (auto p:cards)
    ans += (ll)p.first*p.second;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9980
s = str(input())
count = 0
ansFlg = 0

if s[0] == "A":
    s = "a" + s[1:]
    ansFlg += 1

for i in range(2, len(s)-1):
    if s[i] == "C":
        s = s[:i] + "c" + s[i + 1:]
        count += 1
if count == 1:
    ansFlg += 1

if s.islower():
    ansFlg += 1

if ansFlg == 3:
    print("AC")
else:
    print("WA")


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int Solve(ll mid, ll n, ll m){
    ll c = mid / 2ll, rem;
    rem = m - c * 2ll;
    if(n + rem / 2ll >= c){
        return 1;
    }
    return 0;
}

int main(){
    ll n = lin(), m = lin();

    ll ans = 0, low = 0, high = m, mid;
    while(low <= high){
        mid = (low + high) / 2ll;
        if(Solve(mid, n, m)){
            ans = mid / 2ll;
            low = mid + 1ll;
        }else {
            high = mid - 1ll;
        }
    }

    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin>>N;
  int64_t k=0;
  for(int i=0; ;i++){
  int64_t x=(pow(26,k+1)-1)/25;
    if(N<x){int64_t X=(pow(26,k)-1)/25; N-=X;break;}
    k++;
  }vector<int>A(k,0);
  for(int i=k-1;0<=i;i--){
  int64_t a=N%26;
    A.at(i)+=a;
    N/=26;
  }string s="";
  for(int i=0;i<k;i++){
  char b='a'+A.at(i);
    s+=b;
  }cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,T; cin>>N>>T;
    vector<int> t(N),s(N,0);
    long long sum=T;
    for(int i=0; i<N; i++){
        cin>>t.at(i);
        if(i>=1){
            s.at(i)=t.at(i)-t.at(i-1);
            sum+=min(T,s.at(i));
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    string S;
    cin >> S;
    if (S.find("AC") != string::npos){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

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

 long long s=0;
for(int i=1;i<=n;i++){
    if(i%3==0||i%5==0) continue;
    s+=i;
}
printf("%lld",s);
return 0;
}



Measured memory_bytes: 3744
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

void test_case(){
	int h,w,k;
	cin >> h >> w >> k;
	vector<string> grid(h);
	for(int i=0;i<h;i++) cin >> grid[i];

	int cnt=0;

	for(int Rmask=0 ; Rmask < (1<<h) ; Rmask++){
		for(int Cmask=0; Cmask < (1<<w) ; Cmask++ ){
			int black=0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if( (1<<i)&Rmask ) continue;
					if( (1<<j)&Cmask ) continue;
					if(grid[i][j] == '#') black++;
				}
			}
			if(black == k) cnt++;
		}
	}

	cout << cnt << endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}


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


int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    int i=0;
    while(i<k){
        if(i%2==0){
            if(a%2!=0){
                a--;
                b+=a/2;
                a-=a/2;
                
            }
            else{
                b+=a/2;
                a-=a/2;
            }
        }
        else{
            if(b%2!=0){
                b--;
                a+=b/2;
                b-=b/2;
            }
            else{
                a+=b/2;
                b-=b/2;
            }
        }
        i++;
    }
    cout<<a<<" "<<b<<endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int ans = nextInt();
  REP(i, N-1) {
    ans = __gcd(ans, nextInt());
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
fast;
ll n;
cin>>n;
ll ans=0;
for(ll i=1;i<=n;i++)
{
    ll x=i;
    ll cnt=0;
    while(x>0)
    {
        x=x/10;
        cnt++;
    }
    if(cnt&1)
    {
        ans++;
    }
}
cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
n=int(input())
if n>2 and n%2!=0:
    n-=1
cnt=1
ans=n
for i in range(1,n+1)[::-2]:
    j=i
    tmp=0
    while j>0 and j%2==0:
        tmp+=1
        j=j//2
    if tmp > cnt:
        cnt=tmp
        ans=i
print(ans)

Measured memory_bytes: 9160
#include<cstdio>
#include<cstdlib>

#define int long long

const int MAXN=1e5;

int opt[MAXN+5],stp[MAXN+5];
char str[3];

inline bool compare(const char a[],const char b[]){
	if(a[0]==b[0] && a[1]==b[1])return true;
	return false;
}

int n;

inline void print_path(){
	puts("Yes");
	for(int i=1;i<=n;++i){
		if(stp[i]==1)puts("A");
		else if(stp[i]==2)puts("B");
		else puts("C");
	}
}

void dfs(const int i,const int a,const int b,const int c){
	if(a<0 || b<0 || c<0)return;
	if(i==n+1){
		print_path();
		exit(0);
	}
	if(opt[i]==1){
		stp[i]=1;
		dfs(i+1,a+1,b-1,c);
		stp[i]=2;
		dfs(i+1,a-1,b+1,c);
	}
	else if(opt[i]==2){
		stp[i]=1;
		dfs(i+1,a+1,b,c-1);
		stp[i]=3;
		dfs(i+1,a-1,b,c+1);
	}
	else{
		stp[i]=2;
		dfs(i+1,a,b+1,c-1);
		stp[i]=3;
		dfs(i+1,a,b-1,c+1);
	}
}

int a,b,c;

signed main(){
	scanf("%lld %lld %lld %lld",&n,&a,&b,&c);
	for(int i=1;i<=n;++i){
		scanf("%s",str);
		if(compare(str,"AB"))opt[i]=1;
		else if(compare(str,"AC"))opt[i]=2;
		else opt[i]=3;
	}
	dfs(1,a,b,c);
	puts("No");
	return 0;
}

Measured memory_bytes: 12500
import sys
# from collections import defaultdict
from collections import Counter
# from queue import Queue
# sys.setrecursionlimit(2000000)

def main():
    N = int(input())
    As = [int(s) for s in input().split()]

    i_plus_As = [(i+1)+As[i] for i in range(N)]
    counter = Counter(i_plus_As)

    ans = 0
    for i in range(N):
        i_value = ( i + 1 )- As[i]
        if i_value <= 0:
            continue

        ans += counter[i_value]

    print(ans)

    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 42716
#include <stdio.h>
#define len(arr) sizeof(arr) / sizeof(*arr)

void swap (long int *x, long int *y) {
  long int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (long int array[], long int left, long int right) {
  long int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (long int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}





int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    long int h[n];
    for (int i = 0; i < n; i++){
        scanf("%ld", &h[i]);
    }

    long int ans;
    if (k >= n){
        ans = 0;
    }
    else {
        quick_sort(h, 0, len(h) - 1);
        long int sum = 0;
        for (int i = 0; i < n - k; i++){
            sum += h[i];
        }
        ans = sum;
    }
    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <queue>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  int V[H][W] = {0};
  char tmp;
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {1, 0, -1, 0};
  queue<int> q1;
  queue<int> q2;
  queue<int> q3;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      cin >> tmp;
      if (tmp=='#'){
        V[i][j] = 1;
        q1.push(i);
        q2.push(j);
        q3.push(0);
      }
    }
  }
  
  int max_n, i, j, n, ni, nj;
  while (!q1.empty()){
    i = q1.front();
    j = q2.front();
    n = q3.front();
    q1.pop();
    q2.pop();
    q3.pop();
    max_n = n;
    for (int idx=0;idx<4;idx++){
      ni = i + dx[idx];
      nj = j + dy[idx];
      if (ni>=0 && ni < H && nj>=0 && nj<W){
        if (V[ni][nj] == 0){
          V[ni][nj] = 1;
          q1.push(ni);
          q2.push(nj);
          q3.push(n+1);
        }
      }
    }
    
  }
  cout << max_n << endl;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<vector<ll>> dp(N, vector<ll>(N + 1, -1));
  for (int i = 0; i < N; i++) {
    dp[i][0] = 0;
    dp[i][1] = H[i];
    for (int j = 2; j <= i + 1; j++) {
      for (int k = j - 2; k < i; k++) {
        if (dp[i][j] == -1) {
          dp[i][j] = dp[k][j - 1] + max(0, H[i] - H[k]);
        } else {
          dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0, H[i] - H[k]));
        }
      }
    }
  }
  ll res = dp[N - 1][N - K];
  for (int i = 1; i < N; i++) {
    if (dp[i][N - K] != -1)
      res = min(res, dp[i][N - K]);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
const int maxn=100005;
char s[maxn];
int len;
int ans;
int main()
{
  scanf("%s",s);
  len=strlen(s);
  char last=s[0],now;
  for(int i=0;i<len;i++){
    now=s[i];
	if(now!=last){
	  ans++;
	  last=now;
	}
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 10000;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> menu(n, 0);
    for (int i = 0; i < k; ++i) {
        int a, b;
        cin >> a >> b;
        menu[a-1] = b;
    }
    auto dp = make_v(n+1, 4, 4, 0);
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        if(menu[i-1]){
            for (int j = 0; j < 4; ++j) {
                for (int l = 0; l < 4; ++l) {
                    if(j == menu[i-1] && j == l) continue;
                    (dp[i][j][menu[i-1]] += dp[i-1][l][j]) %= MOD;
                }
            }
        }else {
            for (int m = 1; m < 4; ++m) {
                for (int j = 0; j < 4; ++j) {
                    for (int l = 0; l < 4; ++l) {
                        if(j == m && j == l) continue;
                        (dp[i][j][m] += dp[i-1][l][j]) %= MOD;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 1; i < 4; ++i) {
        for (int j = 1; j < 4; ++j) {
            (ans += dp[n][i][j]) %= MOD;
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    vector<int> x(5);
    rep(i, 5) cin >> x.at(i);
    for (size_t i = 0; i < 5; i++) {
        if (x.at(i) == 0) {
            cout << (i + 1);
            return 0;
        }
    }
}

Measured memory_bytes: 3628
K = int(input())

KList = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(KList[K - 1])

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,k,q;cin>>n>>k>>q;
  vector<ll>a(q);
  rep(i,0,q){
    cin>>a[i];
    a[i]--;
  }
  vector<ll>b(n);
  rep(i,0,q){
    b[a[i]]++;
  }
  rep(i,0,n){
    ans1(k-q+b[i]>0);
  }
  return 0;
}

Measured memory_bytes: 2176
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll MOD = MODBASE;

ll binPowMod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll sub(ll a, ll b) {
    return (a - b + MOD) % MOD;
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

int n, k;
ll dp[100010];

ll solve(int u) {
    int g = k / u;
    ll res = binPowMod(g, n);
    for (int p = u * 2; p <= k; p += u) {
        res = sub(res, dp[p]);
    }
    return dp[u] = res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    ll res = 0;
    
    FORE(i,k,1) res = add(res, mul(i, solve(i)));
    cout << res;
    return 0;
}


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

int main(){
    int N; cin>>N;
    
    vector<int> f(N+1,0);
    for(int x=1; x*x<N; x++){
        for(int y=1; y*y<N; y++){
            for(int z=1; z*z<N; z++){
                if(x*x + y*y + z*z + x*y + y*z + z*x > N) break;
                f[x*x + y*y + z*z + x*y + y*z + z*x]++;           
                // if(x*x + y*y + z*z + x*y + y*z + z*x == n){
                //     ans++;
                // }
            }
        }
    }
    
    for(int i=1; i<=N; i++){
        cout << f[i] << endl;
    }

}


Measured memory_bytes: 3672
// https://qiita.com/e869120/items/eb50fdaece12be418faa

#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

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

    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];

    vector<int> v(n);
    iota(v.begin(), v.end(), 1);

    int a, b;

    int d = 0;
    do {
        d++;
        bool ok_p = true;
        bool ok_q = true;
        rep(i, n) {
            if (v[i] != p[i]) ok_p = false;
            if (v[i] != q[i]) ok_q = false;
        }
        if (ok_p) a = d;
        if (ok_q) b = d;
    } while(next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int num,r,s=0;
    scanf("%lld",&num);
    long long int res = num;
    while(num>0)
    {
        r=num%10;
        s+=r;
        num=num/10;
    }

   long long int rem = res%s;
   if(rem==0)
   {
       printf("Yes\n");
   }
   else
   {
       printf("No\n");
   }
    return 0;
}


Measured memory_bytes: 1644
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    String S;

    private void solve() {
        N = nextInt();
        S = next();

        int ans = 0;
        for(int i = 1;i < N;i++) {
            String a = S.substring(0,i);
            String b = S.substring(i,N);

            int[] aCnt = new int[26];
            int[] bCnt = new int[26];
            for(char c : a.toCharArray()) {
                aCnt[c - 'a']++;
            }

            for(char c : b.toCharArray()) {
                bCnt[c - 'a']++;
            }

            int kind = 0;
            for(int j = 0;j <26;j++) {
                if (aCnt[j] > 0 && bCnt[j] > 0) {
                    kind++;
                }
            }

            ans = Math.max(ans,kind);
        }
        out.println(ans);
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


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

const int N = 300010;

int num[N], n;

inline bool check(int l, int r) {
	if (num[l] == l) l++;
	if (num[r] == r) r--;
	if (l > r) return true;
	for (int i = l + 1; i <= r; i += 2) 
		if (num[i] != i) return false;
	for (int i = l; i <= r; i += 2)
		if (num[i] == i) return false;
	int mn = 1e9, mx = 0;
	for (int i = l; i <= r; i++) 
		mn = min(mn, num[i]), mx = max(mx, num[i]);
	if (mn != l || mx != r) return false;
	for (int i = l, a = 0, b = 0; i <= r; i += 2) {
		if (num[i] < i) {
			if (a > num[i]) return false;
			a = num[i];
		} else {
			if (b > num[i]) return false;
			b = num[i];
		}
	} 
	return true;
}

int fuck[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) 
		scanf("%d", &num[i]), fuck[i] = num[i] == i;
	int ls = 1;
	for (int i = 1; i <= n; i++) {
		if (fuck[i] && fuck[i - 1]) {
			if (!check(ls, i - 2)) return puts("No"), 0;
			ls = i + 1;
		} else if (!fuck[i] && !fuck[i - 1]) {
			if (!check(ls, i - 1)) return puts("No"), 0;
			ls = i;
		} 
	}
	if (!check(ls, n)) return puts("No"), 0;
	puts("Yes");
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n; cin >> n;
	vector<int> d(n);
	rep(i, n)cin >> d[i];

	int sum = 0;
	rep(i, n-1) {
		for (int j = i+1; j < n; j++)
		{
			sum += d[i] * d[j];
         // printf("%d %d\n",d[i],d[j]);
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] x = new double[n];
		double ave=0;
		int sum=0;
		
		for(int i=0;i<n;i++) {
			x[i]=sc.nextInt();
			ave+=x[i];
		}
		
		long p=0;
		
		p=Math.round(ave/n);
		
		for(int i=0;i<n;i++) {
			sum+=(Math.pow((x[i]-p), 2));
		}
		
		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 36100