akhauriyash/Code-Regression huggingface dataset:
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int k;
    cin>>k;

    ll ans=0;
    rep1(a,k)rep1(b,k)rep1(c,k){
        ans += __gcd(a, __gcd(b,c));
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
typedef long long ll;
using namespace std;

int main(){
  string even,odd;
  getline(cin,odd);
  getline(cin,even);
  int j = max(even.length(),odd.length());
  rep(i,j){
    if(odd.length() > i) printf("%c",odd[i]);
    if(even.length() > i) printf("%c",even[i]);
  }
  puts("");
  return 0;
}

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

const int INF = 1 << 30;
int cnt = 0;

class Vertex{
public:
    int i;
    int d;
};

void createList(int n, Vertex *list, int *record);
void push(Vertex *q, Vertex vertex);
Vertex pop(Vertex *q);
void buildMinHeap(Vertex *a, int i);
void minHeapify(Vertex *a, int i);
void displayAnswer(int *a, int n);

int main() {

    int n;
    cin>>n;
    
    Vertex list[501000];
    int record[10001];
    createList(n, list, record);
    
    //printf("-----");

    Vertex priorityQueue[501000];
    for(int i = record[0]; i < record[1]; i++) {
        push(priorityQueue, list[i]);
    }

    int answer[10001];
    for (int i = 0; i <= 10001; i++) {
        answer[i] = INF;
    }
    
    for (int i = 0; i < n-1;) {
        Vertex min = pop(priorityQueue);
        
        if(answer[ min.i ] == INF) {
            answer[ min.i ] = min.d;
            for(int j = record[min.i]; j < record[min.i+1]; j++) {
                if(list[j].i == 0) continue;
                list[j].d += min.d;
                push(priorityQueue, list[j]);
            }
            i++;
        }
    }
    
    displayAnswer(answer, n);
    return 0;
}

void createList(int n, Vertex *list, int *record) {
    int sumRecord = 0;
    for(int i = 0; i < n; i++) {
        int u, k;
        cin>>u>>k;
        record[i] = sumRecord;
        sumRecord += k;
        for(int j = record[i]; j < sumRecord; j++) {
            int c, v;
            cin>>c>>v;
            list[j].i = c;
            list[j].d = v;
        }
    }
    record[n] = sumRecord;
}

void push(Vertex *q, Vertex vertex) {
    cnt++;
    q[cnt] = vertex;
    buildMinHeap(q, cnt);
}

Vertex pop(Vertex *q) {
    Vertex min = q[1];
    q[1] = q[cnt];
    cnt--;
    minHeapify(q, 1);
    return min;
}

void buildMinHeap(Vertex *list, int i) {
    if (i >= 1 && list[i].d < list[i/2].d) {
        Vertex tmp = list[i];
        list[i] = list[i/2];
        list[i/2] = tmp;
        buildMinHeap(list, i/2);
    }
}

void minHeapify(Vertex *list, int i) {
  int l = i*2;
  int r = i*2+1;

  int smallest = i;
  if(l <= cnt && list[l].d < list[smallest].d )  smallest = l;
  if(r <= cnt && list[r].d < list[smallest].d ) smallest = r;

  if(smallest != i) {
    Vertex tmp = list[i];
    list[i] = list[smallest];
    list[smallest] = tmp;
    minHeapify(list, smallest);
  }
}

void displayAnswer(int *a, int n) {
    cout<<0<<' '<<0<<endl;
    for(int i = 1; i < n; i++) {
        cout<<i<<' '<<a[i]<<endl;
    }
}



Measured memory_bytes: 10868
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    set<int> a = {1,2,3};
    int x,y;
    cin >> x >> y;
    a.erase(x);
    a.erase(y);
    cout << *a.begin();
}

Measured memory_bytes: 256
'use strict';

const main = input => {
  input = input.split('\n');
  const N = Number(input[0]);
  const A = input[1].split(' ').map(Number);
  // console.log(A.join(' '));
  insertionSort(A, N);
};

// const insertionSort = (A, N) => {
//   for (let i = 1; i < N; ++i) {
//     const tmp = A[i];
//     let j = i - 1;
//     while (j >= 0 && A[j] > tmp) {
//       // Replace orders
//       A[j + 1] = A[j];
//       A[j] = tmp;
//       --j;
//     }
//     console.log(A.join(' '));
//   }
//   return A;
// };

function insertionSort(A, N) {
  for (let i = 0; i < N; ++i) {
    const tmp = A[i];
    for (let j = 0; j < i; ++j) {
      if (A[j] > tmp) {
        A.splice(i, 1);
        A.splice(j, 0, tmp);
        break;
      }
    }
    console.log(A.join(' '));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 16556
#include<iostream>
#include<set>
#include<string>

using namespace std;

#define NMAX 20

int main(){

	set<char> l;
	string in;

	l.insert('q');
	l.insert('w');
	l.insert('e');
	l.insert('r');
	l.insert('t');
	l.insert('a');
	l.insert('s');
	l.insert('d');
	l.insert('f');
	l.insert('g');
	l.insert('z');
	l.insert('x');
	l.insert('c');
	l.insert('v');
	l.insert('b');

	while(1){
		cin>>in;
		if(in=="#") break;
		int aa;
		int ans=0;
		if(l.find(in[0])!=l.end()) aa=1;
		else aa=-1;
		for(int i=1;i<in.size();i++){
			if(l.find(in[i])!=l.end()){
				if(aa==-1) ans++;
				aa=1;
			}
			else{
				if(aa==1) ans++;
				aa=-1;
			}
		}
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll d,n;
  cin>>d>>n;
  ll ans=(ll)pow(100,d)*n;
  if(d==0&&n==100)ans+=1;
  if(d==1&&n==100)ans+=100;
  if(d==2&&n==100)ans+=10000;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3760
nums = input()
op_cnt = len(nums) - 1

for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    formula = ""
    for p_n, p_o in zip(nums, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n,a[1000001];
    cin>>n;
    int b[1000001]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    int z=a[0];
    for(int i=1;i<n;i++)
    {
        z=__gcd(z,a[i]);
        if(z==1)
            break;
    }
    if(z!=1)
    {
        cout<<"not coprime"<<endl;
        return 0;
    }
    bool k[1000001]= {0};
    for(int i=2; i<1000001; i+=1)
    {
        if(k[i])
            continue;
        z=b[i];
        for(int j=i+i; j<1000001; j+=i)
            z+=b[j];
        if(z>1)break;
    }
    if(z<=1)
        cout<<"pairwise coprime"<<endl;
    else
        cout<<"setwise coprime"<<endl;
    return 0;
}


Measured memory_bytes: 11380
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int a, b, c;
  char d;
  int r = 0, l = 0;

  while ( cin >> a >> d >> b >> d >> c )
    {
      if ( a * a + b * b == c * c )
        {
          if ( a != b ) ++r;
        }
      else
        {
          if ( a == b ) ++l;
        }
    }

  cout << r << endl;
  cout << l << endl;
  
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  int a[n],b[n],c[n];
  for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
  int k=n/2,INF=1<<20;
  int dp[2][500][500];
  for(int i=0;i<500;i++)
    for(int j=0;j<500;j++)
      dp[0][i][j]=dp[1][i][j]=INF;
  for(int i=0;i<(1<<k);i++){
    int ta=0,tb=0,tc=0;
    for(int j=0;j<k;j++){
      if(i>>j&1){
	ta+=a[j];tb+=b[j];tc+=c[j];
      }
    }
    //cout<<ta<<" "<<tb<<" "<<tc<<endl;
    dp[0][ta][tb]=min(dp[0][ta][tb],tc);
  }
  for(int i=0;i<(1<<(n-k));i++){
    int ta=0,tb=0,tc=0;
    for(int j=k;j<n;j++){
      if(i>>(j-k)&1){
	ta+=a[j];tb+=b[j];tc+=c[j];
      }
    }
    //cout<<ta<<" "<<tb<<" "<<tc<<endl;
    dp[1][ta][tb]=min(dp[1][ta][tb],tc);
  }
  int ans=INF;
  for(int i=0;i<500;i++){
    for(int j=0;j<500;j++){
      if(dp[0][i][j]==INF) continue;
      for(int x=0;x<500;x++){
	if(i+x==0) continue;
	if((mb*(i+x)-ma*j)<0||(mb*(i+x)-ma*j)%ma) continue;
	int y=(mb*(i+x)-ma*j)/ma;
	if(y>=500) continue;
	//cout<<i+x<<" "<<j+y<<":"<<dp[0][i][j]+dp[1][x][y]<<endl;
	ans=min(ans,dp[0][i][j]+dp[1][x][y]);
      }
    }
  }
  cout<<(ans<INF?ans:-1)<<endl;
  return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // 入力
            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            var T = int.Parse(input[0]);
            var A = int.Parse(input[1]);
            var list = new List<int>();
            list.AddRange(Console.ReadLine().Split(' ').Select(int.Parse));

            // 計算
            var list2 = list
                .Select(x => T - (x * 0.006))
                .Select(x => Math.Abs(x - A));

            var index = list2
                .ToList()
                .IndexOf(list2.Min());

            Console.WriteLine(index + 1);
        }
    }
}

Measured memory_bytes: 11408
import kotlin.math.pow

fun main(args: Array<String>) {
	readLine()
	val aList = readLine()?.split(" ")?.map {it.toLong()} ?: return
	
	var result: Long = 0
	val mod = ((10.0.pow(9)+7).toLong())
	var sum: Long = aList.sum() % mod
	for (a in aList) {
		sum -= a
		if (sum < 0) sum += mod
		result += a * sum
		result %= mod
	}
	
	println(result)
}

Measured memory_bytes: 65152
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
	int n,k;
	double ans = 0;
	
	cin >> n >> k;
	int a = 1,ind = 0;
	for(int i = 1;i<=n;i++){
		while(i*a<=k-1){
			a*=2;
			ind++;
		}
		while(i*pow(2,ind-1)>k-1&&ind){
			ind--;
		}
		ans+=(1.0/(n*pow(2,ind)));
	}
	cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<set>
using namespace std;
typedef long long ll;

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

	set<ll> xs;
	xs.insert(s);
	ll a = s;
	int ans = 1;
	while(true){
		ans++;
		ll b;
		if(a%2==0) b = a/2;
		else b = 3*a+1;
		if(xs.find(b)!=xs.end()) break;
		xs.insert(b);
		a = b;
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from math import factorial


def combination(n, r):  # n個からr個選ぶ場合の数
    if n < r:
        return 0
    else:
        return factorial(n)//(factorial(r) * factorial(n-r))


class UnionFind():
    def __init__(self, n):
        self.nodes = [-1] * n  # nodes[x]: 負なら、絶対値が木の要素数

    def get_root(self, x):
        # nodes[x]が負ならxが根
        if self.nodes[x] < 0:
            return x
        # 根に直接つなぎ直しつつ、親を再帰的に探す
        else:
            self.nodes[x] = self.get_root(self.nodes[x])
            return self.nodes[x]

    def unite(self, x, y):
        root_x = self.get_root(x)
        root_y = self.get_root(y)
        # 根が同じなら変わらない
        # if root_x == root_y:
        # pass
        if root_x != root_y:
            # 大きい木の方につないだほうが計算量が減る
            if self.nodes[root_x] < self.nodes[root_y]:
                big_root = root_x
                small_root = root_y
            else:
                small_root = root_x
                big_root = root_y
            self.nodes[big_root] += self.nodes[small_root]
            self.nodes[small_root] = big_root


def main():
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(M):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
    uf = UnionFind(N+1)
    get_root, unite, nodes = uf.get_root, uf.unite, uf.nodes
    uncomfort = (combination(N, 2))
    ans = [uncomfort]
    for i in reversed(range(M)):
        if get_root(A[i]) != get_root(B[i]):
            uncomfort -= abs(nodes[get_root(A[i])] * nodes[get_root(B[i])])
        ans.append(uncomfort)
        unite(A[i], B[i])
    # print(ans)
    print('\n'.join(map(str, ans[-2::-1])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 24236
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    string s[n];
    map<string,int> ms;
    int max=0;
    rep(i,n){cin>>s[i];ms[s[i]]++;if(max<ms[s[i]])max=ms[s[i]];}
    for(auto iter=ms.begin();iter!=ms.end();iter++){
        if(iter->second==max)cout<<iter->first<<endl;
    }
    return 0;
}




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

int main(){
  int x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << x2-(y2-y1) << " " << y2+(x2-x1) << " " <<  x2-(y2-y1)-(x2-x1) << " " << y2+(x2-x1)-(y2-y1) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int l = Integer.parseInt(sc.next());
        long[][] a = new long[n][m];
        long[][] b = new long[m][l];
        long[][] c = new long[n][l];
        
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                a[i][j] = Integer.parseInt(sc.next());
        
        for (int i = 0; i < m; i++)
            for (int j = 0; j < l; j++)
                b[i][j] = Integer.parseInt(sc.next());
        
        for (int i = 0; i < n; i++)
            for (int j = 0; j < l; j++)
                for (int k = 0; k < m; k++)
                    c[i][j] += a[i][k] * b[k][j];
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                pw.print(c[i][j]);
                if (j < l-1) pw.print(" ");
            }
            pw.println();
        }
        
        pw.flush();
    }
}


Measured memory_bytes: 46936
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz size
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int a;
	cin>>a;
	cout<<(a + a*a + a*a*a)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,x;
  cin >> n >> x;
  if(x>n-x) x=n-x;
  ll ans=x;
  ll b1=n-x,b2=x;
  ll c1,c2;
  while(1){
    ans+=b1+b2;
    if(b1==b2) break;
    c1=b1;c2=b2;
    b1=c2;
    b2=c1-c2;
    /*
    while(b1<b2){
      ans+=b1*2;
      b2-=b1;
    }
    */
    //cout << b1 << ":" << b2 << endl;
    ans+=(b2/b1)*b1*2;
    b2%=b1;
    if(b2==0) break;
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt[26] = {};
    for(char c : s){
        cnt[c-'a']++;
    }
    int d[10] = {};
    for(int i = 0; i < 26; i++) d[cnt[i]]++;
    int ko = 0, ans = 0;
    for(int i = 1; i <= 9; i++){
        if(d[i] == 0)   continue;
        if(d[i] == 1){
            ko++, ans += 3-(i==1)*2;
        }else{
            ko++, ans += (i!=1)*4+(2*d[i]-1);
        }
    }
    ans += ko-1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    map<char,bool>Map;
	for (char c : S) {
		Map[c] = true;
	}
	if ((Map['N'] == Map['S']) && (Map['E'] == Map['W'])) {
        cout << "Yes" << endl;
    }
	else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
from collections import Counter
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N, *A = map(int, read().split())

    t = Counter(A)
    A.sort()
    table = [True] * (A[-1] + 1)
    n = len(table)

    seen = set()
    for a in A:
        if a in seen:
            continue
        for i in range(2*a, n, a):
            table[i] = False
        seen.add(a)

    ans = 0
    for k, v in t.items():
        if v > 1:
            continue
        else:
            if table[k]:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 50808
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N;cin>>N;
    ll ans = 0;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    if(N%2==1){
        for(int i=N/2;i<N-1;i++){
            ans += A[i];
        }
        for(int i=N/2+1;i<N;i++){
            ans += A[i];
        }
    }else{
        for(int i=N/2;i<N;i++){
            ans += A[i];
        }
        for(int i=N/2;i<N-1;i++){
            ans += A[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int a = (n-1)*(n-2)/2;
    int b = a-k;

    if(a < k) {
        cout << -1 << endl;
        return 0;
    }

    cout << (n-1) + b << "\n";

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

    int cnt = 0;
    for(int i = 1; i < n-1; i++) {
        for(int j = i+1; j < n; j++) {
            if(cnt == b) {
                return 0;
            }
            cout << i << " " << j << "\n";
            cnt++;
        }
    }

    return 0;
}

Measured memory_bytes: 256
/** 以下のような、たてH cm よこ W cm の枠を描くプログラムを作成して下さい。
##########
#........#
#........#
#........#
#........#
##########


上図は、たて 6 cm よこ 10 cm の枠を表しています。

 */

/*sucannerクラス使うためにインポート*/
import java.util.Scanner;

class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 処理を繰り返す
		while (true) {
			// ２つの数字を受け取る
			int intH = sc.nextInt();
			int intW = sc.nextInt();
			// 受け取った数字が二つとも０の場合処理を終了する
			if (intH == 0 && intW == 0) {
				break;
			}
			// 受け取った縦の数字の?２回数改行する
			for (int i = 0; i < intH; i++) {
				// 受けとった横の数字の?２個数分・を表示する
				for (int j = 0; j < intW; j++) {
					if (i == 0 || j == 0 || i == intH - 1 || j == intW - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				// 表示完了後改行する。
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 24608
s = input()
F, T = False, True
ans = {(F, F): 'NA', (F, T): 'YYMM', (T, F): 'MMYY', (T, T): 'AMBIGUOUS'}
print(ans[1 <= int(s[:2]) <= 12, 1 <= int(s[2:]) <= 12])

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

using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> pii;

mat mul(mat &A,mat &B){
    mat C(A.size(),vec(B[0].size()));
    for(int i = 0 ; i < (int)A.size() ; i++){
        for(int k = 0 ; k < (int)B.size() ; k++){
            for(int j = 0 ; j < (int)B[0].size() ; j++){
                C[i][j] = (C[i][j] + A[i][k]*B[k][j]);
            }
        }
    }
    return C;
}

mat pow(mat A,int n){
    mat B(A.size(),vec(A.size()));
    for(int i = 0 ; i < (int)A.size() ; i++){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B,A);
        A = mul(A,A);
        n >>= 1;
    }
    return B;
}

int main(){
    int N,M,Z,s,t;
    while(cin >> N >> M >> Z, N){
        vector<pii> v;
        v.push_back(pii(0,0));
        for(int i = 0 ; i < M ; i++){
            cin >> s >> t;
            s--; t--;
            v.push_back(pii(s,t));
            v.push_back(pii(t,s));
        }
        int size = 2*M+1;
        mat A(size,vec(size,0));
        for(int i = 0 ; i < size ; i++){
            int n1 = v[i].second,p1 = v[i].first;
            for(int j = 0 ; j < size ; j++){
                if(i == j || j == 0) continue;
                int n2 = v[j].second,p2 = v[j].first;
                if(n2 == p1) continue;
                if(n1 == p2) A[i][j] = 1;
            }
        }
        bool ok = false;
        mat res = pow(A,Z);
        for(int i = 0 ; i < size ; i++){
            int now = v[i].second;
            ok |= (now == N-1 && res[0][i] != 0);

        }
        cout << (ok ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1380
def chmax(a,b):
    if(a>b):
        return a
    return b


N = int(input())

A = []
B = []
C = []
dp = [[0,0,0]]
INF = 0

for i in range(0,N):
    a,b,c = map(int,input().split(" "))
    A.append(a)
    B.append(b)
    C.append(c)
    dp.append([INF,INF,INF])

ABC = [A,B,C]


for i in range(0,N):
    for r in range(0,3):
        ls = [0,1,2]
        ls.remove(r)
        f1 = ls[0]
        f2 = ls[1]

        dp[i][r] = max(dp[i-1][f1],dp[i-1][f2]) + ABC[r][i]
    

print(max(dp[N-1]))

Measured memory_bytes: 34680
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

int top, S[1000];

int push(int x){
    top ++;
    S[top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    int x;
    char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
        a = pop();
        b = pop();
        push(a+b);
    } else if ( s[0] == '-' ){
        b = pop();
        a = pop();
        push(a-b);
    } else if ( s[0] == '*' ){
        a = pop();
        b = pop();
        push(a*b);
    } else {
        push(atoi(s));
    }
  }
  
  printf("%d\n", pop());
  return 0;
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define mi(N) int N; cin >> N;
#define ms(s) string s; cin >> s;
#define md(d) double d; cin >> d;
#define mv(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 998244353

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

void Yay(bool b) {
	if (b)say("Yay!");
	else say(":(");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

signed main() {
	mi(a);
	mi(b);
	mi(t);
	say(t / a * b);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  int x;
  for(int i = 0;i < n;i++){
    if(i == 0){
      cin >> a[i];
      x = a[i];
    }else{
      cin >> a[i];
      x ^= a[i];
    }
  }
  for(int i = 0;i < n;i++){
    cout << to_string(a[i]^x) << " ";
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
const long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}
long long sq(long long a){return a*a%mod;}
long long pw(long long a,long long n)
{
  return n==0?1ll:sq(pw(a,n/2))*(n%2==1?a:1ll)%mod;
}
long long iv(long long a){return pw(a,mod-2);}

int main()
{
  int n;
  scanf("%d",&n);
  long long h[110],X[110];
  X[0]=0;
  for(int i=0;i<n;i++){
    scanf("%lld",h+i);
    X[i+1]=h[i];
  }
  sort(X,X+n+1);
  int r[110];
  for(int i=0;i<n;i++){
    r[i]=lower_bound(X,X+n+1,h[i])-X;
  }
  long long dp[110][110];
  for(int j=0;j<=r[0];j++){
    dp[0][j]=(j==0?1ll:2ll)*pw(2ll,X[r[0]]-X[j])%mod;
  }
  for(int i=1;i<n;i++){
    if(r[i-1]<=r[i]){
      for(int j=0;j<=r[i-1];j++){
	dp[i][j]=(dp[i-1][j]+dp[i-1][r[i-1]])%mod*pw(2ll,X[r[i]]-X[r[i-1]])%mod;
      }
      for(int j=r[i-1]+1;j<=r[i];j++){
	dp[i][j]=2ll*dp[i-1][r[i-1]]%mod*pw(2ll,X[r[i]]-X[j])%mod;
      }
    }
    else{
      for(int j=0;j<=r[i];j++){
	dp[i][j]=(dp[i-1][j]+dp[i-1][r[i]])%mod;
      }
    }
  }
  printf("%lld\n",dp[n-1][0]);
  return 0;
}

      


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 1000000007;
vel kai(200001, 1);
vel ink(200001, 1);
int le = (1 << 20) + 1;
vel BIT(le, 0);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	list = ql;
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 200000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 200001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
signed main() {
	int a, p; cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;;
	return 0;
}


Measured memory_bytes: 11600
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]
A.append(N+1)
m=0
if A[0] != 1:
    s=[1,1]
else:
    s = [1,0]
    m = 1

for i in range(2,N+1):
    if A[m] == i:
        s.append(0)
        m += 1
    else:
        s.append(s[i-2]+s[i-1])


print(s[N]%1000000007)

Measured memory_bytes: 460020
while True:
    row_num = int(input().strip())
    if row_num == 0:
        break

    user1, user2 = 0, 0
    for i in range(row_num):
        cards = [int(x) for x in input().strip().split(' ')]
        if cards[0] > cards[1]:
            user1 += sum(cards)
        elif cards[0] < cards[1]:
            user2 += sum(cards)
        else:
            user1 += cards[0]
            user2 += cards[1]
    print(user1, user2)

Measured memory_bytes: 7660
//NEVER LOSE HOPE 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define vc vector<char>
#define pi pair<int,int>
#define si set<int>
#define mi map<int,int>
#define um unordered_map<int,int>
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(),v.end()
#define gi greater<int>()
#define cont continue
#define mp make_pair
#define endl "\n"
#define lb lower_bound //a,a+n,4 -a==index of 4  // returns pointer to the "first position of num" if number is present in the container. Returns pointer to the "position of next higher number greater than num" if num is not present.   
#define ub upper_bound // returns pointer to the "first position of the next higher number than last occurence of num" if num is present in the container. Returns pointer to the position of next higher number than num if container does not contain occurence of num.
#define REP(i,n) for(int i=0;i<n;i++)
#define REPM(i,n) for(int i=0;i<n-1;i++)
#define REPE(i,n) for(int i=1;i<=n;i++)
#define REPA(i,a,n) for(int i=a;i<n;i++)
 
#define ip(a) int n;cin>>n;int a[n];REP(i,n)cin>>a[i];
#define op(v) for(auto x:v) cout<<x<<" ";cout<<endl;
#define opp(a)  REP(i,n)cout<<a[i]<<" "; cout<<endl;
   
#define vs(s)  cout<<v.size()<<" "; 
//next_permutation(s.begin(),s.end())
//*max_element(a,a+n)
#define mod 1000000007
using namespace std;

// bool isPrime(int n)
// {if(n==1)return false;
// for(int i=2;i*i<=n;i++)
// {if(n%i==0)return false;}
// return true;
// } 

// int gcd(int a,int b)
// {
//     if(b==0)return a;
//     return gcd(b,a%b);
// }
// int lcm(int a,int b)
// {
//     return a/gcd(a,b)*b;
 
// }  
 void CSK(){
          int n;cin>>n;
          if(n>=30)
          {
            cout<<"Yes"<<endl;
          }
          else
          {
            cout<<"No"<<endl;
          }
















}
  
  
  
 

 
 
 
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif 
    fastio;
    cout<<fixed;
    cout.precision(10);
    int __TESTCASES=1;
    //cin>>__TESTCASES;
    while(__TESTCASES--){
    CSK();  
}
 
}

Measured memory_bytes: 3648
n = int(input())
h = list(map(int,input().split()))

ans = 0
tmp = 0

for i in range(n-1):
  if h[i] >= h[i+1]:
    tmp += 1
  else:
    if tmp > ans:
      ans = tmp
    tmp = 0

if tmp > ans:
  ans = tmp

print(ans)



Measured memory_bytes: 63984
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 998244353;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 3e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;


const int N = nmax;
int tree[4*N], a[N]; /// be careful with overflow

void build (int cn,int b,int e) {
    if (b == e) {
        tree[cn] = a[b];
        return ;
    }
    int lc = 2*cn, rc = lc+1, mid = (b+e)/2;
    build(lc,b,mid);
    build(rc,mid+1,e);
    tree[cn] = max(tree[lc],tree[rc]);
}

void upd (int cn , int b , int e , int i, int add) {
    if (b > i or e < i) {
        return;
    }
    int lc = 2*cn , rc = lc + 1 , mid = (b+e)/2;
    if (b >= i and e <= i) {
        tree[cn] = add;
        return;
    }
    upd(lc,b,mid,i,add);
    upd(rc,mid+1,e,i,add);
    tree[cn] = max(tree[lc],tree[rc]);
}

int query (int cn , int b , int e , int i ,int j) {
    if (b > j or e < i) return -inf;
    if (b >= i and e <= j) {
        return tree[cn];
    }
    int lc = 2*cn, rc = lc + 1, mid = (b+e)/2;
    return max(query(lc,b,mid,i,j), query(rc,mid+1,e,i,j));
}

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

    int lim = 300000;

    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int &x : v) cin>>x;
    for(int x : v){
        int bam = max(0, x-k), dan = min(lim, x+k);
        int boro = query(1,0,lim, bam, dan);
        upd(1,0,lim, x, boro+1);
    }
    cout<<query(1,0,lim, 1,lim)<<endl;
}
/*
*/


Measured memory_bytes: 8520
#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 a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    if (a+b <= 2*c) {
        cout << x*a + y*b << endl;
        return 0;
    }

    int ans = 2 * c * min(x,y);
    if (x <= y) {
        if (b <= 2*c) {
            ans += (y-x) * b;
        }
        else {
            ans += (y-x) * 2 * c;
        }
        cout << ans << endl;
        return 0;
    }

    if (a <= 2*c) {
        ans += (x-y) * a;
    }
    else {
        ans += (x-y) * 2 * c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
input1 = input().split()
input2 = input().split()
input3 = input()

if input3 == input1[0]:
    input2[0] =  int(input2[0]) - 1
else:
    input2[1] =  int(input2[1]) - 1

print(str(input2[0]) + " " + str(input2[1]))

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int n,x[10000],y[10000],h[10000],w[10000],i,a;
	long long z;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		z=0;
		for(i=0;i<n;i++){
			scanf("%d %d %d %d",&x[i],&y[i],&h[i],&w[i]);
			a=x[i]+y[i]+h[i];
			if(w[i]<3 && a<61) z=z+600;
			else if(w[i]<6 && a<81) z=z+800;
			else if(w[i]<11 && a<101) z=z+1000;
			else if(w[i]<16 && a<121) z=z+1200;
			else if(w[i]<21 && a<141) z=z+1400;
			else if(w[i]<26 && a<161) z=z+1600;
		}
		printf("%lld\n",z);
	}
	return 0;
}

Measured memory_bytes: 2760
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  int M[100][100];
  int p[100], c[100], v[100];
  int key, u;

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(i = 0; i < n; i++){
    p[i] = -1;
    c[i] = INFTY;
    v[i] = 0;
    }

  c[0] = 0;

  while(1){
    key = INFTY;
    u = -1;

    for(i = 0; i < n; i++){
      if(key > c[i] && v[i] == 0){
	u = i;
	key = c[i];
      }
    }

    if(u == -1) break;

    v[u] = 1;

    for(j = 0; j < n; j++){
      if(M[u][j] < c[j] && v[j] == 0){
	p[j] = u;
	c[j] = M[u][j];
      }
    }
  }

  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  printf("%d\n", sum);

  return 0;
}

Measured memory_bytes: 640
arr = list(map(int, input().rstrip().split()))
arr2 = list(map(int, input().rstrip().split()))
m = arr[1]
sum_arr2 = sum(arr2)
len_arr2 = len(arr2)
count = 0
popular = sum_arr2/(4*m)
i = 0
while i < len_arr2 and count < m:
    if arr2[i] >= popular:
        count += 1
    i += 1

if count >= m:
    print("Yes")
else:
    print("No")

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

int H, W, K;
vector <vector <int> > hcuts;
vector <vector <int> > v;

void find_hcuts() {
	int p = pow(2, H - 1);
	hcuts.resize(p);
	for (int i = 0; i < p; ++i) {
		vector <int> rec;
		rec.push_back(0);
		int tmp = i;
		int cnt = 1;
		while (tmp != 0) {
			if (tmp % 2 == 1) {
				rec.push_back(cnt);
			}
			cnt++;
			tmp /= 2;
		}
		rec.push_back(H);
		hcuts[i] = rec;
	}
}

bool cut(const vector <int> &vi) {
	for (int i = 0; i < vi.size(); ++i) {
		if (vi[i] > K) {
			return true;
		}
	}
	return false;
}

int find_ans() {
	int Min = 100000;
	for (int i = 0; i < hcuts.size(); ++i) {
		int cntcut = 0;
		bool cont = true;
		vector <int> cntwhite;
		cntwhite.resize(hcuts[i].size() - 1);
		for (int j = 0; j < W; ++j) {
			vector <int> add;
			add.resize(hcuts[i].size() - 1);
			for (int k = 0; k < hcuts[i].size() - 1; ++k) {
				for (int idx = hcuts[i][k]; idx < hcuts[i][k + 1]; ++idx) {
					if (v[idx][j] == 1) {
						add[k]++;
					}
				}
			}
			for (int k = 0; k < hcuts[i].size() - 1; ++k) {
				if (add[k] > K) {
					cont = false;
					break;
				}
				cntwhite[k] += add[k];
			}
			if (!cont) {
				cntcut = 100000;
				break;
			}
			if (cut(cntwhite)) {
				cntcut++;
				cntwhite = add;
			}
		}
		Min = min(Min, cntcut + (int)hcuts[i].size() - 2);
	}
	return Min;
}

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

	cin >> H >> W >> K;
	v.resize(H);
	for (int i = 0; i < H; ++i) {
		v[i].resize(W);
		for (int j = 0; j < W; ++j) {
			char c;
			cin >> c;
			v[i][j] = c - '0';
		}
	}

	find_hcuts();

	cout << find_ans() << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstring>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

bool check(string s){
	string alt=s.substr(s.size()/2);
	if(s==alt+alt)return true;
	else return false;
}

int main(){
	string s;
	cin>>s;
	int n=s.size();
	bool ans=false;
	rep(i,n){
		s.erase(s.size()-1);
		if(check(s)){
			ans=true;
			break;
		}
	}
	cout<<s.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>

typedef long long int64;

int main(void) {
  int n;
  std::cin >> n;
  std::map<std::string, int> smap;
  for (int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    smap[s]++;
  }

  int max = 0;
  for (auto el : smap) {
    int cnt = el.second;
    max = std::max(max, cnt);
  }

  for (auto el : smap) {
    if (el.second == max) {
      std::cout << el.first << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  for(int x = 0; x <= K; x ++){
    for(int y = 0; y <= K; y ++){
      	int z = S - x - y;
        if(0 <= z && z <= K) count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
g = [[] for _ in range(n+1)]
d = [0]*(n+1)
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)
for _ in range(q):
    p,x = map(int,input().split())
    d[p] += x
ans = [0]*(n+1)
seen = [False]*(n+1)
from collections import deque
q = deque([(1,d[1])])
while q:
    s,cost = q.popleft()
    seen[s] = True
    ans[s] += cost
    for e in g[s]:
        if not seen[e]:
            q.append((e,cost+d[e]))
# def helper(s,cost):
#     seen[s] = True
#     ans[s] += cost
#     for e in g[s]:
#         if not seen[e]:
#             helper(e,cost+d[e])
# for i in range(1,n+1):
#     if not seen[i]:
#         helper(i,d[i])
res = []
for a in ans[1:]:
    res.append(str(a))

print(' '.join(res))

Measured memory_bytes: 139160
s = input()
k = int(input())

if len(s) == 1:
    print(k//2)
    exit()
if s.count(s[0]) == len(s):
    print(len(s)*k//2)
    exit()

count = 0
flag = True
for i in range(1, len(s)):
    if not flag:
        flag = True
        continue
    if s[i] == s[i-1]:
        count += 1
        flag = False

count2 = 0
flag = True
s = s*2
for i in range(1, len(s)):
    if not flag:
        flag = True
        continue
    if s[i] == s[i-1]:
        count2 += 1
        flag = False
# 連結部分の数を加える
print(count * k + (count2-count*2)*(k-1))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main()
{
	int a,b,c,d,e,k;
	int ans=0;
	cin >> a >> b >> c >> d >> e >> k;

	// vector<int> vec(N, INF);
	// rep(i,n) cin >> vector.at(i);
	//cout << e << endl;
	if(e-a <= k) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}


Measured memory_bytes: 256
import math
N = int(input())
#距離の箱を作成
kyori = []
kyori2 = []
kyori3 = []
sumation = 0
for i in range(N):
    #N回繰り返す
    kyori.append(list(map(int,input().split())))
#x間の距離、y間の距離を算出
#ここで、2→1と1→2などは同じ距離なので計算しない
x_distance = 0
y_distance = 0
for i in range(0,N):
    for j in range(i+1,N):
        x_distance = (kyori[i][0]-kyori[j][0])**2
        y_distance = (kyori[i][1]-kyori[j][1])**2
        #xとyの距離を計算(sqrt導出)
        Kyorixy = math.sqrt(x_distance + y_distance)
        kyori2.append(Kyorixy)
if len(kyori2) == 1:
    print(kyori2[0])
else:
  goukei = sum(kyori2)*2/N
  print(goukei)
   

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long n, std::vector<long long> p){
	int res = 0;
	for (int i = 0; i + 3 <= n; ++i) {
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]
			|| p[i] > p[i + 1] && p[i+ 1] > p[i + 2]) {
			++res;
		}
	}
	cout << res<< endl;
}

signed main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> p(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&p[i]);
    }
    solve(n, std::move(p));
    return 0;
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
using namespace std;
map<ll,ll> m;

int main()
{
    IOS;
    ll n;
    cin>>n;
    cout<<n*n;
}


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

int main(){
  int N,count=1;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-1;i++){
    if(S.at(i)!=S.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
}
    

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

int main() {
    int N, K, X, Y;

    scanf("%d", &N);
    scanf("%d", &K);
    scanf("%d", &X);
    scanf("%d", &Y);

    int total;

    if (N < K) { 
        total = X*N;
    } else {
        total = X*K + Y*(N-K);
    }

    printf("%d\n", total);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 128