akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int N, K;
    cin >> N >> K;
    int A[N];
    rep(i,N) cin >> A[i];
    int dp[100][2];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    for(int d=0;d<50;d++){
        int mask = (int)1<<(49-d);

        // 配列A[]でd桁目にbitが立っているものの個数
        int num = 0;
        rep(i,N){
            if(A[i] & mask) num++;
        }

        // X の d 桁目を 0, 1にしたときのコスト
        int cost0 = mask * num;
        int cost1 = mask * (N - num);

        // smaller -> smaller
        if(dp[d][1] != -1){
            dp[d+1][1] = max(dp[d+1][1], dp[d][1] + max(cost0, cost1)); // 好きな方を取る
        }


        if(dp[d][0] != -1){
            if(K & mask){  
                dp[d+1][1] = max(dp[d+1][1], dp[d][0] + cost0); // exact -> smaller   K の d桁目が 1だったら0にする。
                dp[d+1][0] = max(dp[d+1][0], dp[d][0] + cost1); // exact -> exact  K の d桁目が 1だったら1にする。
            }
            else{
                dp[d+1][0] = max(dp[d+1][0], dp[d][0] + cost0); // exact -> exact  K の d桁目が 0だったら1にする。
            }
        }
    }
    cout << max(dp[50][1], dp[50][0]) << endl; 

}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <valarray>
#include <cmath>

using namespace std;

int main() {
    cout << setprecision(20) << fixed;

    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (auto i = std::size_t(0); i < W; ++i) {
            cout << "#";
        }
        cout << "\n";
        
        for (auto i = std::size_t(1); i < H - 1; ++i) {
            cout << "#";
            for (auto j = std::size_t(1); j < W - 1; ++j) {
                cout << ".";
            }
            cout << "#\n";
        }
        for (auto i = std::size_t(0); i < W; ++i) {
            cout << "#";
        }
        cout << "\n";
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 3020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int gcd(int a, int b) {
    a = abs(a); b = abs(b);
    if(a < b) gcd(b, a);
    int r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int main(){
    int n, X;
    cin >> n >> X;
    int x[n];
    rep(i,n) cin >> x[i];
    rep(i,n) x[i] -= X;
    int gcd_num = x[0];
    rep(i,n){
        gcd_num = gcd(gcd_num,x[i]);
    }

    cout << gcd_num << endl;
    return 0;
}


Measured memory_bytes: 640
class Dice:
    rmap = [[2,3,5,4,2],
            [1,4,6,3,1],
            [1,2,6,5,1],
            [5,6,2,1,5],
            [3,6,4,1,3],
            [4,5,3,2,4] ]

    def __init__(self,list):
        self.num = list

    def lookup_right_side(self,u,s):
        index_upside = self.num.index(u)
        map_arr = self.rmap[index_upside]
        map_arr_dice_val = [ self.num[i-1] for i in map_arr ]
        index_next_map = map_arr_dice_val.index(s) + 1
        index_rightside = map_arr[index_next_map]
        return self.num[index_rightside-1]

spots = map(int,raw_input().split())
n = input()
questions = [ map(int,raw_input().split()) for _ in range(n) ]

dice = Dice(spots)
for i in questions:
    print dice.lookup_right_side(i[0],i[1])

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, X, T;
  cin >> N >> X >> T;
  
  int x, n;
  n = N;
  x = 0;
  
  while ( n > 0 ) {
    n -= X;
    x += T;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int N; //attending count 
  int R; //external rating
  int I; //internal rating
  
  cin >> N >>R;
  if(N <= 10){
    I = (R+100*(10-N));
    cout << I;
  }else{
    cout << (R);
  }
  return 0;
}



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

using namespace std;

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

    map<long long, int> a;
    for (int i = 0; i < n; i++) {
        int aa;
        cin >> aa;
        a[aa]++;
    }

    for (int i = 0; i < m; i++) {
        int b;
        long long c;
        cin >> b >> c;

        for (map<long long, int>::iterator j = a.begin(); j != a.end() && j->first < c; ) {
            if (j->second <= b) {
                b -= j->second;
                a[c] += j->second;
                j = a.erase(j);
            } else {
                j->second -= b;
                a[c] += b;
                b = 0;
                break;
            }
        }
    }

    long long sum = 0;
    for (map<long long, int>::iterator i = a.begin(); i != a.end(); i++) {
        sum += i->first * i->second;
    }

    cout << sum << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

typedef struct node{
	int self,left,right;
	node(){};
	node(int s, int l, int r):self(s),left(l),right(r){};
}node;

void printVector(vector<int> a){
	for(auto x:a)cout<<" "<<x;
	cout<<endl;
}

vector<int> preorder, inorder, postorder;
vector<node> g;

void dfs(node x){
	preorder.push_back(x.self);
	if(x.left>=0)dfs(g[x.left]);
	inorder.push_back(x.self);
	if(x.right>=0)dfs(g[x.right]);
	postorder.push_back(x.self);
	return;
}

int main()
{
	int n;
	cin>>n;
	g.resize(n);
	rep(i,n){
		int x,l,r;
		cin>>x>>l>>r;
		g[x]=node(x,l,r);
	}

	int root=-1;
	vector<int> used(n,0);
	rep(i,n){
		if(g[i].left>=0)used[g[i].left]=1;
		if(g[i].right>=0)used[g[i].right]=1;
	}
	rep(i,n)if(used[i]==0)root=i;

	dfs(g[root]);

	cout<<"Preorder"<<endl;
	printVector(preorder);
	cout<<"Inorder"<<endl;
	printVector(inorder);
	cout<<"Postorder"<<endl;
	printVector(postorder);

	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  int x;
  cin >> x;

  if(x<1200) {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  string s;
  priority_queue<int> pq;
  while(1){
    cin >> s;
    if(s == "end") {
      break;
    } else if(s == "extract"){
      cout << pq.top() << endl;
      pq.pop();
    } else if(s == "insert"){
      cin >> n;
      pq.push(n);
    }
  }
  return 0;
}



Measured memory_bytes: 7016
#include "bits/stdc++.h";
using namespace std;
typedef long long ll;

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    const int dx[] = {0,-1,0,1}, dy[] = {1,0,-1,0};
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') continue;
            vector<vector<int>> dist(h, vector<int>(w, -1));
            queue<pair<int,int>> que;
            que.push({i,j});
            dist[i][j] = 0;
            while (!que.empty()) {
                auto p = que.front(); que.pop();
                int nx = p.first, ny = p.second;
                for (int i = 0; i < 4; i++) {
                    int x = nx + dx[i], y = ny + dy[i];
                    if (x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '.' && dist[x][y] == -1) {
                        que.push({x,y});
                        dist[x][y] = dist[nx][ny] + 1;
                        ans = max(ans, dist[x][y]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n,ans=0;
int a[100005],dp[100005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (a[i-1]<a[i])  dp[i]=0;
		else dp[i]=dp[i-1]+1;
	}
	for (int i=1;i<=n;i++)  ans=max(ans,dp[i]);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
using namespace std;
int z[200005];
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int a, b, i;
    long long c;
    while (cin >> a >> b)
    {
        for (i = 0;i < a;i++)
            cin >> z[i];
        c = 0;
        if (b >= a)
        {
            cout << c << '\n';
            continue;
        }
        sort(z, z + a);
        for (i = 0;i < a - b;i++)
            c += (long long)z[i];
        cout << c << '\n';
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double n;
  cin>>n;
  double r1=ceil(n/1.08);
  double r2=floor(n/1.08);
  if(floor(r1*1.08)==n)
    cout<<r1<<endl;
  else if(floor(r2*1.08)==n)
    cout<<r2<<endl;
  else
    cout<<":(\n";
}


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

long sum_formula(string s){
  if(s.size() == 1)
    return stol(s);
  else{
    long sum = stol(s);
    for(int i = 1; i < s.size(); i++){
      sum += stol(s.substr(0,i))*pow(2,s.size()-i-1) + sum_formula(s.substr(i));
    }
    return sum;
  }
}
  
int main(){
  string s;
  cin >> s;
    
  cout << sum_formula(s) << endl;
}


Measured memory_bytes: 256
from math import sqrt, gcd
def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    dic = dict()
    n = int(sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] = count
    if k != 1: #sqrt(k)までチェックしてもkが1になっていない --> kが素因数
        dic[k] = 1
    return dic

N = int(input())
A = list(map(int, input().split()))
A.sort()

from collections import defaultdict
from bisect import bisect_left

n = bisect_left(A, 1.5) # 1の数

dic = defaultdict(int)

if N <= 10 ** 5 + n:
    count = 0
    for a in A[max(0, n - 1):]:
        tmp = factoring(a)
        for i in tmp:
            dic[i] = max(tmp[i], dic[i])
            count += tmp[i]

    tmp = 0
    for i in dic:
        tmp += dic[i]

    if count == tmp:
        print ('pairwise coprime')
        exit()

GCD = A[0]
for a in A:
    GCD = gcd(GCD, a)
    if GCD == 1:
        break

if GCD == 1:
    print ('setwise coprime')
else:
    print ('not coprime')



Measured memory_bytes: 197052
fun main(arg: Array<String>) {
    val (H, W, K) = listOfInt()
    val S = Array(H) { next().map { it - '0' }.toIntArray() }
    val INF = 1001001001
    var ans = INF
    for (div in 0 until (1 shl (H - 1))) {
        var G = 0
        val id = IntArray(H)
        for (h in 0 until H) {
            id[h] = G
            if (((div shr h) and 1) == 1) G += 1
        }
        G += 1
        val c = Array(G) { IntArray(W) }
        for (h in 0 until H) for (w in 0 until W) c[id[h]][w] += S[h][w]
        var num = G - 1
        val now = IntArray(G)
        fun add(w: Int): Boolean {
            for (g in 0 until G) now[g] += c[g][w]
            for (g in 0 until G) if (now[g] > K) return false
            return true
        }
        for (w in 0 until W) {
            if (!add(w)) {
                num += 1
                for (g in 0 until G) now[g] = 0
                if (!add(w)) {
                    num = INF
                    break
                }
            }
        }
        ans = Math.min(ans, num)
    }
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 50400
N = int(input())
A = list(map(int,input().split()))

sign = 1
for i in range(N):
    if A[i] < 0:
        sign *= -1
    elif A[i] == 0:
        sign *= 0

A = [abs(a) for a in A]
A.sort()

if sign < 0:
    print(sum(A)-2*A[0])
else:
    print(sum(A))

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

int main(){
  int x,y;
  
  while(1){
    cin >> x >> y;
    if(x==0 && y==0)break;
    if(x<y){
      cout << x << ' ' << y << endl;
    }else{
      cout << y << ' ' << x << endl;
    }
  }
  
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  sort(a.rbegin(), a.rend());
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += a[i / 2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4032
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>

struct BinaryNode{
    int parent, left, right;
};
const int NIL = -1;

int setHeight(BinaryNode T[], int H[], int u){
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL){
        h1 = setHeight(T, H, T[u].left) + 1;
    }
    if(T[u].right != NIL){
        h2 = setHeight(T, H, T[u].right) + 1;
    }
    H[u] = max(h1, h2);
    return H[u];
}
void setDepth(BinaryNode T[], int D[], int u, int p){
    D[u] = p;
    if(T[u].left != NIL){
        setDepth(T, D, T[u].left, p+1);
    }
    if(T[u].right != NIL){
        setDepth(T, D, T[u].right, p+1);
    }
}
int returnSibling(BinaryNode T[], int u){
    int parent_u = T[u].parent;
    if(parent_u == NIL) return NIL;
    else if(T[parent_u].left == u) return T[parent_u].right;
    else return T[parent_u].left;
}
int returnDegree(BinaryNode T[], int u){
    int degree = 0;
    if(T[u].left != NIL) degree++;
    if(T[u].right != NIL) degree++;
    return degree;
}
string judgeNode(BinaryNode T[], int u){
    if(T[u].parent == NIL) return "root";
    else if(T[u].left == NIL && T[u].right == NIL) return "leaf";
    else return "internal node";
}
void printNode(BinaryNode T[], int D[], int H[], int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << returnSibling(T, u) << ", ";
    cout << "degree = " <<  returnDegree(T, u) <<  ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    cout << judgeNode(T, u) << endl;
}

int main(){
    int n;
    scanf("%d", &n);
    BinaryNode T[n];
    int D[n], H[n];
    for(int i=0; i<n; i++){ T[i].parent = T[i].left = T[i].right = NIL;}
    for(int i=0; i<n; i++){
        int u, left, right;
        scanf("%d %d %d", &u, &left, &right);
        T[u].left = left;
        T[u].right = right;
        if(left != NIL){
            T[left].parent = u;
        }
        if(right != NIL){
            T[right].parent = u;
        }
    }
    int r;
    for(int i=0; i<n; i++){
        if(T[i].parent == NIL) r = i;
    }
    setDepth(T, D, r, 0);
    int rootheight = setHeight(T, H, r);
    for(int i=0; i<n; i++){
        printNode(T, D, H, i);
    }
    
    return 0;
}


Measured memory_bytes: 3244
"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

let input_stdin = '';
let chunks = '';

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.stdin.on('end', function () {
    chunks = input_stdin.split('\n');
    start();    
});

function start() {
	const a = chunks.shift().split(' ').map(Number);
    const n = a[0], k = a[1];
	let array = chunks[0].split(' ').map(Number);

	const dp = Array(n).fill(Infinity);
  
  	dp[0] = 0;

	for (let i = 0; i < n; i++) {
		for (let j = i + 1; j <= i + k && j < n; j++) {
			dp[j] = Math.min(dp[j], dp[i] + Math.abs(array[i] - array[j]));
          	
		}
	}

	console.log(dp[n - 1]);
}


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

int w, h, x, y, ans;
int mp[52][52];
int visited[52][52];
int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy[8] = {-1, 1, 1, -1, 0, 1, -1, 0};


void bfs(int x, int y){
  int i;
  visited[y][x] = 1;
  for(i = 0; i < 8; i++){
    if(visited[y + dy[i]][x + dx[i]] == 0 && mp[y + dy[i]][x + dx[i]] == 1){
      bfs(x + dx[i], y + dy[i]);
    }
  }
}

int main(void){
  while(1){
    cin >> w >> h;
    if(w == 0) break;

    for(y = 0; y < h + 2; y++){
      if(y == 0 || y == h + 1){
        for(x = 0; x < w + 2; x++) mp[y][x] = 0;
      }else{
        for(x = 0; x < w + 2; x++){
          if(x == 0 || x == w + 1){
            mp[y][x] = 0;
          }else{
            cin >> mp[y][x];
          }
        }
      }
    }
    for(y = 0; y < h + 2; y++){
      for(x = 0; x < w + 2; x++){
        visited[y][x] = 0;
      }
    }
    ans = 0;
    for(y = 1; y < h + 1; y++){
      for(x = 1; x < w + 1; x++){
        if(mp[y][x] == 1 && visited[y][x] == 0){
          ans++;
          bfs(x, y);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}



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

using namespace std;

int main() {
	int x, y;

	while (cin >> x >> y, x | y) {
		if (x > y) {
			cout << y << " " << x << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}

	return 0;
}


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

#define int long long
#define pb emplace_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

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

	int a[n];
	f(i,0,n)    cin >> a[i];
	int temp = 0;

	for(int i=0 ; i<n ; i++)
	{
		temp = temp^ a[i];
	}
//	if((a[n-1]^ a[1]) != a[0])    chk = true;
//	if((a[n-2] ^ a[0]) != a[n-1]) chk = true;

	if(temp != 0 ) cout << "No";
	else    cout << "Yes";
}







Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
times = 0

flag = True

while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            A[i], A[i-1] = A[i-1], A[i]
            times += 1
            flag = True

print(" ".join(map(str, A)))
print(times)


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

int main(){
    int n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    vector<char> d(n);
    rep(i,n){
        if(t.at(i) == 'r') d.at(i) = 'p';
        if(t.at(i) == 's') d.at(i) = 'r';
        if(t.at(i) == 'p') d.at(i) = 's';
    }
    ll ans = 0;
    rep(i,n){
        if(i >= k && d.at(i-k) == d.at(i)) {
            d.at(i) = '#';
            continue;
        }
        if(d.at(i) == 'r') ans += r;
        if(d.at(i) == 's') ans += s;
        if(d.at(i) == 'p') ans += p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3800
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)
#define MOD (ll)(1e9+7)
 
#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)
 
//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;
 
 
ll n, a, b, c, d;

void solve() {
    cin >> n >> a >> b >> c >> d;
    n--; b-=a;
    if (abs(b) > d*n) {
        cout << "NO" << endl;
        return;
    }

    b += d*n;
    ll m = c+d;
    b %= m;

    if (b <= (d-c)*n) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	cin >> n;
	long long ans = 0;
	for (int i = 1; 1LL * i * i <= n; ++ i) {
		if ((n - i) % i == 0) {
			if ((n - i) / i <= i) continue;
			ans += (n - i) / i;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MAXN=2e5+51;
ll n,m,sum,res;
ll x[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
int main()
{
	n=read(),m=read();
	for(register int i=0;i<n;i++)
	{
		sum+=(x[i]=read());	
	}	
	for(register int i=0;i<n;i++)
	{
		if(4*x[i]*m>=sum)
		{
			res++;
		}
	}
	puts(res>=m?"Yes":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool Query(int i)
{
    printf("%d\n", i);
    fflush(stdout);
    char ss[10];
    scanf("%s", &ss);
    if (ss[0] == 'V')
        exit(0);
    return (ss[0] == 'M');
}
int main()
{
    int n;
    scanf("%d", &n);
    int le = 0, ri = n - 1, md;
    bool w = Query(0); Query(n - 1);
    while (ri - le > 2)
    {
        md = (le + ri) >> 1;
        if ((md - le) & 1)
            md ++;
        if (Query(md) == w)
            le = md;
        else
            ri = md;
    }
    Query(le + 1);
}

Measured memory_bytes: 852
#include<cstdio>
#include<cstring>
int main()
{
	int n,m,i,f=0,len;
	char str[20];
	scanf("%d %d",&n,&m);
	scanf("%s",str);
	len=strlen(str);
	if(len!=n+m+1)
	{
		f=1;
	}
	else if(str[n]!='-')
	{
		f=1;
	}
	else
	{
		for(i=0;i<n;i++)
		{
			if(!(str[i]>='0'&&str[i]<='9'))
			{
				f=1;
			}
		}
		for(i=n+1;i<n+m+1;i++)
		{
			if(!(str[i]>='0'&&str[i]<='9'))
			{
				f=1;
			}
		}
	}
	if(f==1)
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}
}

Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

struct dice{
	int a[6];
	void rotx(){ int tmp=a[0]; a[0]=a[4]; a[4]=a[5]; a[5]=a[2]; a[2]=tmp; }
	void roty(){ int tmp=a[0]; a[0]=a[1]; a[1]=a[5]; a[5]=a[3]; a[3]=tmp; }
	void rotz(){ int tmp=a[1]; a[1]=a[4]; a[4]=a[3]; a[3]=a[2]; a[2]=tmp; }
};

vector<dice> get_all(dice D){
	vector<dice> res;
	rep(i,6){
		rep(j,4){
			res.push_back(D);
			D.rotz();
		}
		if(i%2==0) D.rotx();
		else       D.roty();
	}
	return res;
}

int top[3][3],front[3][3];

vector<int> ans;
vector<dice> S;

dice D[3][3][3];
void dfs(int z,int y,int x){
	if(z==3){
		int sum=0;
		rep(i,3) rep(j,3) sum+=D[i][j][2].a[3];
		ans.push_back(sum);
		return;
	}
	if(y==3) return dfs(z+1,0,0);
	if(x==3) return dfs(z,y+1,0);

	rep(i,S.size()){
		D[z][y][x]=S[i];
		bool ok=true;
		if(x>0 && D[z][y][x-1].a[3]+D[z][y][x].a[1]!=7) ok=false;
		if(y>0 && D[z][y-1][x].a[2]+D[z][y][x].a[4]!=7) ok=false;
		if(z>0 && D[z-1][y][x].a[5]+D[z][y][x].a[0]!=7) ok=false;
		if(z==0 && top  [y][x]!=0 && top  [y][x]!=D[z][y][x].a[0]) ok=false;
		if(y==2 && front[z][x]!=0 && front[z][x]!=D[z][y][x].a[2]) ok=false;
		if(ok) dfs(z,y,x+1);
	}
}

int main(){
	int T; scanf("%d",&T);
	while(T--){
		rep(i,3) rep(j,3) scanf("%d",top[i]+j);
		rep(i,3) rep(j,3) scanf("%d",front[i]+j);

		S=get_all((dice){1,4,2,3,5,6});

		ans.clear();
		dfs(0,0,0);

		sort(ans.begin(),ans.end());
		ans.erase(unique(ans.begin(),ans.end()),ans.end());

		rep(i,ans.size()) printf("%d%c",ans[i],i+1<ans.size()?' ':'\n');
		if(ans.empty()) puts("0");
	}

	return 0;
}

Measured memory_bytes: 1196
H,W=map(int,input().split())

mat=[]
mat.append([False]*(W+2))
for i in range(H):
  line=input()
  row=[False]
  for j in line:
    if j=="#":
      row.append(False)
    else:
      row.append(True)
  row.append(False)
  mat.append(row)
mat.append([False]*(W+2))
#print(mat)

max_depth=0
for i in range(1,H+1):
  for j in range(1,W+1):
    if not mat[i][j]:
      continue
    
    bfs_mat=[]
    for ii in range(H+1):
      bfs_mat.append([99]*(W+1))
      
    #print(bfs_mat)
    max_dist=0
    bfs_queue=[(i,j,0)]
    while(len(bfs_queue)>0):
      new_queue=set()
      for (ii,jj,dist) in bfs_queue:
        #print((ii,jj,dist))
        bfs_mat[ii][jj]=dist
        max_dist=dist
        if mat[ii-1][jj] and bfs_mat[ii-1][jj]==99:
          new_queue.add((ii-1,jj,dist+1))
        if mat[ii+1][jj] and bfs_mat[ii+1][jj]==99:
          new_queue.add((ii+1,jj,dist+1))
        if mat[ii][jj-1] and bfs_mat[ii][jj-1]==99:
          new_queue.add((ii,jj-1,dist+1))
        if mat[ii][jj+1] and bfs_mat[ii][jj+1]==99:
          new_queue.add((ii,jj+1,dist+1))

      bfs_queue=new_queue
      #print(bfs_queue)

    #print((i,j,max_dist))
    if max_dist>max_depth:
      max_pos=(i,j)
      max_depth=max_dist

#print(max_pos)
print(max_depth)

Measured memory_bytes: 3188
s=input()
g,p,ans=0,0,0
for i in range(len(s)):
  if s[i]=="p":
    if g==p:
      g+=1
      ans-=1
    else:
      p+=1
  elif g==p:
    g+=1
  else:
    p+=1
    ans+=1
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char *argv[]){
	int n, count = 0;
	vector<int> rabbits;
	// vector<bool> checked(n, false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		rabbits.push_back(temp - 1);
	}
	for (int i = 0; i < n; i++) {
		// if (!checked[i] && !checked[rabbits[i]] && rabbits[rabbits[i]] == i) {
		if (i < rabbits[i] && rabbits[rabbits[i]] == i) {
			count ++;
			// checked[rabbits[i]] = true;
		}
		// checked[i] = true;
	}

	cout << count << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif


//
int main()
{
	GO
	//fioe();
	ll h,w;
	cin>>h>>w;
	ll val=h/w;
	if(h%w==0){
		cout<<val<<endl;
	}
	else{
		cout<<val+1<<endl;
	}
	time();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main() {
    int N, M, X;
    scanf("%d%d%d", &N, &M, &X);
    int count = 0;
    for(int i = 0; i < M; ++i) {
        int A;
        scanf("%d", &A);
        if(A < X) ++count;
    }
    if(count <= M/2) printf("%d\n", count);
    else printf("%d\n", M-count);
    return 0;
}


Measured memory_bytes: 128
s = gets.chomp
a = [s[-1]]
n = s.size
if n < 26
    print s
    t = "abcdefghijklmnopqrstuvwxyz"
    26.times do |i|
        f = true
        n.times do |j|
            f = false if t[i] == s[j]
        end
        if f
            puts t[i]
            exit
        end
    end
end            
(n-2).downto(0) do |i|
    if s[i] > s[i+1]
        a << s[i]
    else
        a.sort!
        print s[0..i-1] if i != 0
        a.size.times do |j|
            if a[j] > s[i]
                puts a[j]
                break
            end
        end
        exit
    end
end
puts "-1"

Measured memory_bytes: 1788
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

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

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int r;
  cin >> r;
  string ans = "";
  if (r < 1200) {
    ans = "ABC";
  } else if (r < 2800) {
    ans = "ARC";
  } else {
    ans = "AGC";
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
t="abcdefghijklmnopqrstuvwxyz"
h,w=map(int,input().split())
a=[list(input())for _ in range(h)]
b=[0]*26
for i in a:
  for j in i:b[t.index(j)]+=1
x,y,z=(h//2)*(w//2),(h%2)*(w//2)+(h//2)*(w%2),(h%2)*(w%2)
for i in b:
  j=i
  while x and j>3:
    x-=1
    j-=4
  while y and j>1:
    y-=1
    j-=2
  z-=j
if not(x==y==z==0):print("No")
else:print("Yes")
"""#一例出力、問題誤読して実装した
c=[w*[0]for _ in range(h)]
fi=ti=0
for i in range(27):
  while b[i]:
    if b[i]>=4:
      j,k=fi//(w//2),fi%(w//2)
      c[j][k]=c[j][w-k-1]=c[h-j-1][k]=c[h-j-1][w-k-1]=t[i]
      fi+=1
      b[i]-=4
    if b[i]==2:
      if ti<h//2 and w%2:c[ti][w//2]=c[h-ti-1][w//2]=t[i]
      else:c[h//2][ti]=c[h//2][w-1-ti]=t[i]
      ti+=1
      b[i]-=2
    if b[i]==1:
      c[h//2][w//2]=t[i]
      b[i]-=1
for i in c:print("".join(i))
"""

Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    int w[n];
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        if (i) w[i] += w[i-1];
    }

    int ans = 1 << 30;
    for (int i = 0; i < n-1; i++) {
        int diff = abs(w[i] - w[n-1] + w[i]);
        ans = min(ans, diff);
    }

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

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

constexpr int maxn = 1e5 + 10, inf = 1e8;
int n, m;
vector<int> g[maxn];
int d[maxn][3];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0, u, v; i < m; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
  }
  int s, t;
  scanf("%d%d", &s, &t);
  for (int i = 1; i <= n; ++i) {
    d[i][0] = d[i][1] = d[i][2] = inf;
  }
  d[s][0] = 0;
  queue<pair<int, int>> q;
  q.emplace(s, 0);
  while (q.size()) {
    int x = q.front().first;
    int t = q.front().second;
    q.pop();
    for (int y : g[x]) {
      int &tmp = d[y][(t + 1) % 3];
      if (tmp == inf) {
        tmp = d[x][t] + 1;
        q.emplace(y, (t + 1) % 3);
      }
    }
  }
  printf("%d\n",  (d[t][0] != inf) ? d[t][0] / 3 : -1);
  return 0;
}



Measured memory_bytes: 6912
#include<cstdio>
using namespace std;
int main(){
    int x,y;
    char z;
    while(1){
      scanf("%d %c %d",&x,&z,&y);
    if(z=='?'){
        return 0;
    }
    else if (z=='+'){
      printf("%d\n",x+y);
 
    }
    else if (z=='-'){
      printf("%d\n",x-y);
      
    }
    else if (z=='/'){
      printf("%d\n",x/y);
      
    }
    else if (z=='*'){
      printf("%d\n",x*y);
     
    }
    
    }
return 0;
    
}


Measured memory_bytes: 2708
#include <iostream>

using namespace std;

int main() {
    int S, hour, min, sec;
    cin >> S;
    sec = S % 60;
    int temp = (S - sec) / 60;
    min = temp % 60;
    hour = (temp - min) / 60;

    cout << hour << ":" << min << ":" << sec << endl;
    return 0;
}

Measured memory_bytes: 3092
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int a,b;
	cin >> a >> b;
	

	cout << a*a-b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);

bool ok(int a,int b,int c){
	if(a==0 && b==0 && c==0){
		return true;
	}else{
		return false;
	}
}

int main(){
	ll A[3][3];
	set<ll> se;
	FOR(i,0,3)FOR(j,0,3) cin >> A[i][j];
	ll N;
	cin >> N;
	FOR(i,0,N){
		ll a;
		cin >> a;
		se.insert(a);
	}
	FOR(i,0,3)FOR(j,0,3){
		if(se.count(A[i][j])){
			A[i][j] = 0;
		}
	}

	if(ok(A[0][0],A[0][1],A[0][2])){
		cout << "Yes" << endl;
	}else if(ok(A[1][0],A[1][1],A[1][2])){
		cout << "Yes" << endl;
	}else if(ok(A[2][0],A[2][1],A[2][2])){
		cout << "Yes" << endl;
	}else if(ok(A[0][0],A[1][0],A[2][0])){
		cout << "Yes" << endl;
	}else if(ok(A[0][1],A[1][1],A[2][1])){
		cout << "Yes" << endl;
	}else if(ok(A[0][2],A[1][2],A[2][2])){
		cout << "Yes" << endl;
	}else if(ok(A[0][0],A[1][1],A[2][2])){
		cout << "Yes" << endl;
	}else if(ok(A[0][2],A[1][1],A[2][0])){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}


}



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

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long[] h = new long[N];
        for(int n=0; n<N; n++) h[n]=sc.nextLong();

        long[] cost = new long[N];
        Arrays.fill(cost, 5000000000000000L);
        cost[0]=0;

        for(int n=1; n<N;n++){
            for(int k=1;k<=K;k++) if(n-k>=0) {
                cost[n] = Math.min(cost[n], cost[n-k]+Math.abs(h[n]-h[n-k]));
            }
        }

        System.out.println(cost[N-1]);
    }
}


Measured memory_bytes: 58096
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> x(N+1);
  x[0] = X;
  for(int i=1; i<=N; i++){
    cin >> x[i];
  }
  sort(x.begin(),x.end());
  vector<int> A(N);
  for(int i=0; i<N; i++){
    A[i] = x[i+1] - x[i];
  }
  int ans = A[0];
  for(int i=1; i<N; i++){
    ans = gcd(ans,A[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = br.readLine();
			StringTokenizer st = new StringTokenizer(buf);
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			if (a<b && b<c) System.out.println("Yes");
			else System.out.println("No");
		} catch (IOException e) {
			System.out.println("IOException!");
		}
	}
}

Measured memory_bytes: 17048
#include<bits/stdc++.h>
using namespace std;
long long Q,H,S,D,N,ans,k,kk,kkk;
int main()
{
    cin>>Q>>H>>S>>D>>N;
    k=min(Q*4,min(H*2,S));
    if(k*2<=D)
    {
        cout<<k*N<<endl;
    }
    else
    {
        cout<<((N%2)*k)+N/2*D<<endl;
    }
    return 0;
}

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

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

    int sum = 0;
    for(int i = 0; i < n; i++) sum += l + i;

    int diff;
    if(l >= 0) diff = l;
    else if(l < 0 && abs(l) >= n) diff = l + n - 1;
    else if(l < 0 && abs(l) < n) diff = 0;

    cout << sum - diff << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int a[100000];

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

    int res = 0;

    for (int i = 0; i < n; ++i) {
        if (a[i] - 1 == i) {
            res++;
            i++;
        }
    }

    cout << res << "\n";
}


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

int main(){
  int N;
  cin >> N;
  int A[N-1];
  for(int i=0;i<N-1;i++){
    cin >> A[i];
  }
  int B[N];
   for(int l=0;l<N;l++){
    B[l] =0;
  }

  for(int j=0;j<N-1;j++){
    B[A[j]-1]++;
  }
for(int k=0;k<N;k++){
  cout << B[k] << endl;
}
  }

Measured memory_bytes: 5196
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    int s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>

#define val const auto &

using namespace std;

int test(char c)
{
    return c == 'A' || c == 'T' || c == 'C' || c == 'G';
}

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

    int result = 0;
    int current = 0;
    for (val c : s)
    {
        if (!test(c)) {
            result = max(result, current);
            current = 0;
            continue;
        }
        current++;
    }
    result = max(result, current);

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

a, b, h, m = map(int, input().split())


def calc_rad(base, time):
    try:
        return 2 * np.pi * ((time) % base) / base
    except ZeroDivisionError:
        return 0


rad_a, rad_b = calc_rad(720, 60 * h + m), calc_rad(60, m)
ans = np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(rad_a - rad_b))
print("{:.20f}".format(ans))

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


int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  int xgap,ygap;
  xgap = tx - sx;
  ygap = ty - sy;
  
  int cx = xgap;
  int cy = ygap;
  
  while(cx){
    cout << 'R';
    cx--;
  }
  while(cy){
    cout << 'U';
    cy--;
  }
  
  while(xgap-cx){
    cout << 'L';
    cx++;
  }
  
  while(ygap-cy){
    cout << 'D';
    cy++;
  }
  
  cout << 'D';
  while(cx+1){
    cout << 'R';
    cx--;
  }
  while(cy+1){
    cout << 'U';
    cy--;
  }
  
  cout << 'L' << 'U';
  
  while(xgap-cx){
    cout << 'L';
    cx++;
  }
  
  while(ygap-cy){
    cout << 'D';
    cy++;
  }  
  cout << 'R' << endl;
}

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

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

dp = [[0]*5 for _ in range(N+1)]

for i, a in enumerate(A):
    b = a%2 if a > 0 else 2
    dp[i+1][0] = dp[i][0] + a
    dp[i+1][1] = min(dp[i][1], dp[i][0]) + b
    dp[i+1][2] = min([dp[i][2], dp[i][1], dp[i][0]]) + (a+1)%2
    dp[i+1][3] = min([dp[i][3], dp[i][2], dp[i][1], dp[i][0]]) + b
    dp[i+1][4] = min(dp[i]) + a

ans = min([dp[N][4], dp[N][3], dp[N][2]])
print(ans)

Measured memory_bytes: 112888
# include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;

int D,M,d,q;
int c[30];
int s[400][30];
int type[400];
int last[29];
ll satis_level[400];

ll calc_score(){
  rep(i,0,D+3) satis_level[i] = 0;
  rep(j,1,27) last[j]=0;
  ll down_satis;
  rep(i,1,D+1){
    down_satis=0;
    last[type[i]] = i;
    satis_level[i] += s[i][type[i]];
    rep(j,1,27) down_satis += c[j]*(i-last[j]);
    satis_level[i] -= down_satis;
    satis_level[i+1] += satis_level[i];
  }
  return satis_level[D];
}

int main(){
  map<int,int, std::greater<int>> mp;
  cin >> D;
  rep(i,1,27){
    cin >> c[i];
    mp[c[i]]=i;
  }
  rep(i,1,D+1){
    rep(j,1,27){
      cin >> s[i][j];
    }
  }
  
  int j=1;
  for(auto i=mp.begin();j<=D;++i,j++) {
    type[j] = mp[i->first];
  }
  
  ll pre_score,new_score;
  int d,q,pq;
  pre_score = calc_score();
  random_device rnd; 
  mt19937 mt(rnd());
  uniform_int_distribution<> rand_d(1,D); 
  uniform_int_distribution<> rand_q(1,26); 
  rep(i,1,15000){
    d = rand_d(mt);
    q = rand_q(mt);
    pq = type[d];
    type[d] = q;
    new_score = calc_score();
    if(pre_score > new_score) type[d] = pq;
    else pre_score = new_score;
    //cout << pre_score << '\n';
  }
  
  rep(i,1,D+1) cout << type[i] << '\n';
  return 0;
}


Measured memory_bytes: 3700
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

struct mint {
  ll x;
  mint(ll x = 0) : x(x % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, T;
  cin >> n >> T;
  priority_queue<ll, vl, greater<ll>> que;
  rep(i, n) {
    ll c, t;
    cin >> c >> t;
    if (t <= T) {
      que.push(c);
    }
  }
  if (que.size() > 0) {
    cout << que.top() << endl;
  } else {
    cout << "TLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> str;
  n = str.size();
  for(int i = 0; i < n; i++) {
    if(i % 2 == 1 && str[i] == 'R')
      a++;
    if(i % 2 == 0 && str[i] == 'L')
      a++;
  }
  cout << (a ? "No" : "Yes");
}

Measured memory_bytes: 2304
import java.util.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
 
        BigDecimal a = new BigDecimal(A);
        BigDecimal b = new BigDecimal(B);
 System.out.println(a.multiply(b).toBigInteger());
    }
}

Measured memory_bytes: 35964
N=int(input())
while N!=0:
    data=[]
    for i in range(N):
        data.append(int(input()))
    data.sort()
    Sum=0
    Count=0
    for i in range(N-2):
        Sum+=data[i+1]
        Count+=1
    print(Sum//Count)
    N=int(input())



Measured memory_bytes: 5596
n,m = map(int,input().split())
a_list = list(map(int,input().split()))

a_sum= sum(a_list)

count = 0
for i in range(len(a_list)):
    if a_list[i] >= a_sum / (4 * m):
        count += 1
if count >= m:
    print('Yes')
else:
    print('No')

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end()); 
  sum = sum + p.at(N-1)/2;
  for(int i = 0; i < N-1; i++) {
    sum = sum + p.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
typedef long long int ll;
using namespace std;
#define maxN 200007
#define mod 1000000007

ll n,m;

ll cal(int a,int b){
	ll temp = b-(a-1);
	return (a+b)*temp/2;
}

ll solve() {
	ll ans=0;
	if(n+1==m){
		return 1;
	}
	for(int i=m;i<=n+1;i++){
		ll low = cal(0,i-1);
		ll high = cal(n-(i-1),n);
		//cout<<low<<" "<<high<<endl;
		ans+=(high-low)+1;
		if(ans>mod){
			ans%=mod;
		}
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin>>n>>m;
	cout<<solve()<<endl;
	
}

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

using namespace std;

typedef long long ll;

int main()
{
    int a, b, c, g;
    cin>>a>>b>>c;
    g=a+b;
    if(c+g<=21)
    {
        cout<<"win";
    }
    else
    {
        cout<<"bust";
    }
    return 0;
}


Measured memory_bytes: 256