akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vi b(m);
    rep(i, m) cin >> b[i];
    rep(i, m) {
        a.emplace_back(b[i]);
    }
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    rep(i, a.size()) {
        cout << a[i] << '\n';
    }
}


Measured memory_bytes: 6276
#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+1 ;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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define PI 3.14159265359

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    double r;
    cin >> r;
    cout << fixed;
    cout <<setprecision(10) << 2* r * PI<< endl;


}
 

Measured memory_bytes: 3792
'''
Created on 2020/09/15
 
@author: harurun
'''
import sys
pin=sys.stdin.readline
 
N,K=map(int,pin().split())
h=list(map(int,pin().split()))
dp=[0]*N
for i in range(1,N):
  dp[i]=dp[i-1]+abs(h[i-1]-h[i])
  for j in range(1,K+1):
    if i-j>=0:
      dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]))
print(dp[N-1])
# print(dp)
#解説AC

Measured memory_bytes: 84968
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int z = n%10;
  if(z == 2 || z == 4 || z == 5 || z == 7 || z == 9){
    cout << "hon" << endl;
  }
  else if(z == 3){
    cout << "bon" << endl;
  }
  else{
    cout << "pon" << endl;
  }
}

Measured memory_bytes: 3544
N, M, X = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
ans = float('inf')

for i in range(2**N):
    c = [0] * M
    a = 0

    idx = 0
    while i:
        if i % 2:
            a += A[idx][0]
            
            for j in range(1, M+1):
                c[j-1] += A[idx][j]
        
        i //= 2
        idx += 1
        
    f = True
    
    for cc in c:
        if cc < X:
            f = False
            break
    if f: ans = min(ans, a)
    
if ans == float('inf'): ans = -1
print(ans)


Measured memory_bytes: 9212
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			max = Math.max(max, a);
			min = Math.min(min, a);
		}

		System.out.println(max - min);


		sc.close();

	}

}

Measured memory_bytes: 35488
void main()
{
    long n = rdElem;
    Job[] job = n.rdCol!Job;

    job.sort!"a.b < b.b";
    long t;
    foreach (x; job)
    {
        if (t + x.a <= x.b)
        {
            t += x.a;
        }
        else
        {
            "No".writeln;
            return;
        }
    }

    "Yes".writeln;
}

struct Job
{
    long a, b;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 5884
using System;

class sample6{
    static void Main(string[] args){

            string[] str_number = Console.ReadLine().Split(' ');
            int[] sort_number = new int[3];

            for(int i = 0 ; i < 3 ; i++ ){
                
                sort_number[i] = int.Parse(str_number[i]);
            }
                Array.Sort(sort_number);
                Console.WriteLine("{0} {1} {2}", sort_number[0], sort_number[1], sort_number[2]);
    }
}


Measured memory_bytes: 17956
#include <bits/stdc++.h>
using namespace std;
 
long long n, a, b, ans, minn=1e14, flag=1; 
 
int main()
{
	scanf("%lld", &n);
	for(int i=1; i<=n; i++)
	{
		scanf("%lld%lld", &a, &b);
		if(a!=b) flag=0;
		ans+=a;
		if(a>b) minn=min(b, minn);
	}
	ans-=minn;
	if(!flag) printf("%lld\n", ans);
	else printf("0\n");
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	var prob float64
	prob = 0.0
	fmt.Scanf("%d %d", &n, &k)

	for i := 1; i <= n; i++ {
		tmpV := i
		for j := float64(1.0); ; j /= 2.0 {
			if tmpV >= k {
				prob += ((float64(1.0) / float64(n)) * j)
				break
			}
			tmpV *= 2
		}
	}

	fmt.Print(prob)

}


Measured memory_bytes: 512
// 173

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long int;
#define NUM 1000000007

vector<bool> func(int x, int len){
    vector<bool> v(len, false);
    int i=0;
    for(int i=0; x!=0; i++){
        if(x%2 == 0) v.at(i) = false;
        else if(x%2 == 1) v.at(i) = true;
        x /= 2;
    }
    reverse(v.begin(), v.end());
    return v;
}

int main(){
    int h, w, k, ans=0;
    cin >> h >> w >> k;
    string c;
    vector<vector<bool>> v(h, vector<bool>(w));
    for(int i=0; i<h; i++){
        cin >> c;
        for(int j=0; j<w; j++){
            if(c.at(j) == '#') v.at(i).at(j) = true;
            else if(c.at(j) == '.') v.at(i).at(j) = false;
        }
    }
    int h_2 = pow(2, h), w_2 = pow(2, w);
    for(int i=0; i<h_2; i++){
        for(int j=0; j<w_2; j++){
            int count = 0;
            auto h_bit = func(i, h), w_bit = func(j, w);
            for(int x=0; x<h; x++){
                for(int y=0; y<w; y++){
                    if(!h_bit.at(x) && !w_bit.at(y) && v.at(x).at(y)) count++;
                }
            }
            if(count == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N; cin >> N;
  bool have_odd = false;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a % 2 == 1) have_odd = true;
  }
  if (have_odd) cout << "first" << endl;
  else cout << "second" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n; cin >> n;
    int ans = 0;
    loop1(i, n)
        ans += i * (n - i + 1);
    loop(i, n - 1) {
        int u, v;
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        ans -= u * (n - v + 1);
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    string A, B;
    cin >> A >> B;

    if (A.length() > B.length()) {
        cout << "GREATER" << endl;
    } else if (A.length() < B.length()) {
        cout << "LESS" << endl;
    } else {
        if (A == B) {
            cout << "EQUAL" << endl;
        } else {
            REP(i,A.length()) {
                if (A[i] != B[i]) {
                    if (A[i] > B[i]) {
                        cout << "GREATER" << endl;
                    } else {
                        cout << "LESS" << endl;
                    }
                    break;
                }
            }
        }
    }
}


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back

const int MAXN = 2009;
vector<int> g[MAXN];
int n, k;

int dfs(int v, int pr, int len, int cur)
{
    int ans = 0;
    if (cur > len)
        ans++;
    for (int to : g[v])
    {
        if (to != pr)
            ans += dfs(to, v, len, cur + 1);
    }
    return ans;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    int ans = n - 1;
    for (int i = 0; i < n; i++)
        ans = min(ans, dfs(i, -1, k / 2, 0));
    for (int i = 0; i < n; i++)
    {
        for (int to : g[i])
            ans = min(ans, dfs(i, to, (k - 1) / 2, 0) + dfs(to, i, (k - 1) / 2, 0));
    }
    cout << ans;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  n--;
  string ans = "";
  while (0 <= n) {
    ll r = n % 26;
    ans += (char)(r + 'a');
    n = n / 26;
    n--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int N,X;
vector<int> m;
vector<bool> ma(10000,0);

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

	m=vector<int>(N);

	for(int i=0;i<N;i++){
		cin>>m[i];
	}

	sort(m.begin(),m.end());
	int ans=0;
	int i=0;
	for(int i=0;i<N;i++){
		X-=m[i];
		if(X<0){
			cout<<ans<<endl;
			return 0;
		}
		ans++;
	}

	ans+=X/m[0];

	cout<<ans<<endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}


int main(int argc, const char * argv[]) {
    long long N = inputValueLongLong();
    long long K = inputValueLongLong();

    long long i=0;
    long long amari = N;
    while(true){
        if(amari<K){
            i++;
            cout << i << endl;
            break;
        }else{
            amari = amari / K;
            i++;
        }
    }

    return 0;
}

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

signed main(void){ 
  int N,K; cin >> N >> K;
  vector<int> P(N);
  for(int i = 0; i < N; i++){ cin >> P[i];}
  
  vector<int> a(N,0); 
  vector<int> sum(N,0);
  
  for(int i = 1; i < N; i++){ 
    if( P[i] > P[i-1] ){ a[i]++;}
  }
  
  for(int i = 1; i < N; i++){ 
    sum[i] = sum[i-1]+a[i];
  }
  
  bool sorted = (sum[K-1]==K-1);
  
  set<int> S;
  
  for(int i = 0; i < K; i++){ S.insert(P[i]);}
  
  int cnt = !sorted;
  
  // P[i]~P[i+K-1]とP[i+1]~P[i+K]を比較して異なるかを調べる
  
  for(int i = 0; i < N-K; i++){ 
    // P[i]が出て行って、P[i+K]が入ってくる
    
    bool l = (*S.begin() == P[i] );
    S.erase(P[i]);
    S.insert(P[i+K]);
    bool r = (*S.rbegin() == P[i+K]);
    
    if( sum[i+K]-sum[i+1] == K-1 ){ sorted = true;}
    else{ 
      if( !(l&&r) ){ //この時、２つは異なる
        cnt++; 
      }
    }
  }
  
  cout << cnt+sorted << endl;
  
  return 0;
}
    

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

int main(void) {
    int n;
    string s;

    cin >> n;
    cin >> s;

    if (n % 2 != 0) {
        cout << "No";
        return 0;
    }

    for (int i = 0; i < n / 2; i++) {
        if(s[i] != s[i + n / 2]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

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

#define ll long long
#define INF 2147483647
#define Inf 9223372036854775807
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=105;
int n,base,mn=INF;
ll sum;
int a[maxn],nxt[maxn*5],level[maxn*5];
class EDGE{
public:
	int to,cap,rev;
};
vector<EDGE>edge[maxn*5];

void add_edge(int from,int to,int cap){
	edge[from].pb((EDGE){to,cap,(int)edge[to].size()});
	edge[to].pb((EDGE){from,0,(int)edge[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	level[s]=0;
	queue<int>q;
	q.push(s);
	while(!q.empty()){
		int x=q.front();q.pop();
		rep(i,edge[x].size()){
			EDGE &y=edge[x][i];
			if(y.cap&&level[y.to]<0){
				level[y.to]=level[x]+1;
				q.push(y.to);
			}
		}
	}
}

int dfs(int s,int t,int f){
	if(s==t)return f;
	for(int &i=nxt[s];i<edge[s].size();i++){
		EDGE &x=edge[s][i];
		if(x.cap&&level[x.to]==level[s]+1){
			int d=dfs(x.to,t,min(f,x.cap));
			if(d){
				x.cap-=d;
				edge[x.to][x.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

ll max_flow(int s,int t){
	ll flow=0;
	while(true){
		bfs(s);
		if(level[t]<0)return flow;
		memset(nxt,0,sizeof(nxt));
		int f;
		while(f=dfs(s,t,INF))flow+=f;
	}
}

int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d",&a[i]);
		mn=min(mn,a[i]);
	}
	if(mn>0)base=0;
	else base=-mn;
	REP(i,n){
		a[i]+=base;
		sum+=a[i];
	}
	REP(i,n){
		add_edge(0,i,INF);
		add_edge(i,i+n,a[i]);
		add_edge(i+2*n,3*n+1,base);
		for(int j=i;j<=n;j+=i){
			add_edge(j+n,i+2*n,INF);
		}
	}
/*	rep(i,3*n+2){
		cout<<i<<endl;
		rep(j,edge[i].size())cout<<edge[i][j].to<<" "<<edge[i][j].cap<<endl;
		cout<<endl;
	}*/
	printf("%lld",sum-max_flow(0,3*n+1));
	return 0;
}

/*
Input:
-----------------
Output:
*/

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


int main() {
	
	string s;
	cin >> s;
	long sum = 0;
	
	for ( int bit=0; bit < ( 1 << (s.size()-1) ); bit++ ) {
		vector<string> s1(10,"");
		int tgt = 0;
		
		for(int i=0; i < s.size(); i++){
			s1.at(tgt) += s.at(i);
			if ( bit & (1<<i) ) tgt++;
		}
		
		for (int j=0; j<10; j++){
			if ( !s1.at(j).empty() ) sum += stol( s1.at(j) );
		}
		
	}
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    if x not in p:
        print(x)
    else:
        i = 1
        while True:
            if x-i not in p:
                print(x-i)
                break
            elif x+i not in p:
                print(x+i)
                break
            i += 1

Measured memory_bytes: 61640
//@author yash
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
char reVal(int num) 
{ 
    if (num >= 0 && num <= 9) 
        return (char)(num + '0'); 
    else
        return (char)(num - 10 + 'A'); 
}
int f(char res[], int base, int inputNum) 
{ 
    int index = 0;  // Initialize index of result 
  
    // Convert input number is given base by repeatedly 
    // dividing it by base and taking remainder 
    while (inputNum > 0) 
    { 
        res[index++] = reVal(inputNum % base); 
        inputNum /= base; 
    } 
    res[index] = '\0'; 
  
    // Reverse the result 
    //strev(res); 
  int cnt=0;
    for(int i=0;res[i]!='\0';i++)
	cnt++; 
	return cnt;
} 
int main()
{
	fast();
	int n,k;
	char res[1000000];
	cin>>n>>k;
	cout<<f(res,k,n)<<endl;	
}



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

int main(){
	int N;
	cin >> N;
	map <string, int> S;
	int num_str = 0;
	for (int i = 0; i < N; i++){
		string tmp;
		cin >> tmp;
		auto itr = S.find(tmp);
		if (itr != S.end()) S[tmp]++;
		else S.insert(make_pair(tmp, 1));
		num_str = max(num_str, S[tmp]);
	}
	for (auto x : S){
		if (x.second == num_str) cout << x.first << endl;
	}
}


Measured memory_bytes: 25248
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  a--;
  b--;
  c--;
  d--;
  string s;
  cin >> s;
  bool ans = true;
  for (int i = a + 1; i < max(c, d); i++)
  {
    if (s[i] == '#' && s[i + 1] == '#')
    {
      ans = false;
      break;
    }
  }

  if (d < c)
  {
    bool check = false;
    for (int i = b - 1; i < d; i++)
    {
      if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
      {
        check = true;
        break;
      }
    }
    ans = ans && check;
  }

  cout << (ans ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 640
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long N;
        static long K;
        static long[] A;
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            Sort(A);
            //Reverse(A);

            long sum = 0;
            var ans = 0;
            for (int i = 0; i < N - 1; i++)
            {
                sum += A[i];
                if (2*sum >= A[i+1])
                {

                }
                else
                {
                    ans = i + 1;
                }
            }
            


            Console.WriteLine(N-(ans));
        }

        static bool check(double mid)
        {
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                ans += (long)(A[i] / mid);
            }

            return ans <= K;
        }
    }


}


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

int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for(int i=0; i<M; i++){
    cin >> A.at(i);
  }
  int east = 0;
  int west = 0;
  for(int i=0; i<M; i++){
    if(A.at(i)<X) east+=1;
    if(A.at(i)>X) west+=1;
  }
  cout << min(east, west) << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int main() {
    char* s;
    int n, k;
    string ans;

    cin>>n>>k;
    s = (char*)calloc(n,sizeof(char));
    cin>>s;
    
    s[k-1] = s[k-1] + 32;

    cout<<s<<endl;

    delete s;

    return 0;
}

Measured memory_bytes: 256
Indata = [int(i) for i in input().split()]
W,H,x,y,r = [int(i) for i in Indata]
x_right = x+r
x_left = x-r
y_on = y+r
y_under = y-r

if x_right>W or x_left<0 or y_on>H or y_under<0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5604
N, M = map(int,input().split())
P=list(map(int,input().split()))

Group=[i for i in range(N+1)]


Swap=[None]*M
for i in range(M):
    Swap[i]=sorted(map(int,input().split()))

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

for i in range(M):
    if find(Swap[i][1]) != find(Swap[i][0]):
        Group[find(Swap[i][1])]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[find(Swap[i][0])]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[Swap[i][1]]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[Swap[i][1]]=min(find(Swap[i][1]),find(Swap[i][0]))

count=0

for i in range(N):
    if find(P[i])==find(i+1):
        count+=1


print(count)


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

int main(){
    int X,A,B;
    cin>>X>>A>>B;
    if(A>=B){
        cout<<"delicious"<<endl;
    }
    else if(B-A<=X){
        cout<< "safe" <<endl;
    }
    else {
        cout<< "dangerous" <<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N, A, B, X, Y;

	while (true)
	{
		cin >> N; A = 0; B = 0;

		if (N == 0) { break; }

		for (int i = 0; i < N; i++)
		{
			cin >> X >> Y;

			if (X > Y) { A += X + Y; }
			if (X < Y) { B += X + Y; }
			if (X == Y) { A += X; B += Y; }
		}

		cout << A << ' ' << B << endl;
	}

	return 0;
}

Measured memory_bytes: 3092
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		a[0]=sc.nextInt();
		a[1]=sc.nextInt();
		a[2]=sc.nextInt();
		swap(a,0,1);
		swap(a,0,2);
		System.out.println(a[0]+" "+a[1]+" "+a[2]);
		sc.close();
	}

	private void swap(int a[], int i, int j) {
		int tmp =a[i];
		a[i]=a[j];
		a[j]=tmp;
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPN(i,n) for(int i=1;i<=(n);i++)
#define REPV(i,b,n) for(int i=(b);i<=(n);i++)
using namespace std;
int gdc(int a,int b)
{
	int t;  
    if(a<b)  
    {  
        t=a;  
        a=b;  
        b=t;  
    }  
    while(t=a%b)  
    {  
        a=b;  
        b=t;  
    }  
    return b;  
}
int main()
{
	int a,b,c,k,f;
	ll sum=0;
	cin>>k;
	REPN(a,k)
	{
		REPN(b,k)
		{
			REPN(c,k)
			{
				f=gdc(a,b);
				f=gdc(f,c);
				sum+=f;
			}
		}
	}
	cout<<sum<<endl;
	return 0;	
} 

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> ball(N+1,1);
  vector<bool> red(N+1,false);
  red.at(1)=true;
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    ball.at(x)--;
    ball.at(y)++;
    if(red.at(x)){
      red.at(y)=true;
    }
    if(ball.at(x)==0){
      red.at(x)=false;
    }
  }
  int64_t ans=0;
  for(int i=1;i<=N;i++){
    if(red.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	
    string a,b;
    cin>>a >> b;
    int n = a.length();
    bool k = true;
    for(int i=0;i<n;i++)
    {
        if(a[i] != b[i])
        {
            k = false;
            break;
        }
    }
    
    if(k)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
	return 0; 
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG



int main(void){

    long num;
    cin >> num;

    // 1のときは0を出力
    if (num == 1) {
      cout << 0 << endl;
      return 0;
    }

    //素因数分解して、各底の指数をカウントする
    int count = 0;
    long i = 2;
    map<long, int> Factor;
    vector<long> check(0);

    while(num >= i * i){

        if (num % i == 0) {
            count++;
            check.push_back(i);
            Factor[i] = count;
            num /= i;
        }

        else {
            count = 0;      
            i++;
        }
    }

    check.push_back(num);
    Factor[num] += 1; //最後に余ったのは素因数



    //各素因数の指数に対して答えを計算していく
    int result = 0;
    int A;

    for(long c : check){
        A = 0;

        if(Factor[c] <= 0){
            continue;
        }
        while(1){
          A++;
          Factor[c] -= A;
          if (Factor[c] < 0){
              break;
          } 
          result++;
          
            
        }
    }

    if(result == 0){
        cout << 1 << endl;
    }

    else {
        cout << result << endl;
    }

}

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

bool cmp(int a,int b){
	return a>b;
}

int main(){
	int n;
	cin>>n;
	
	int a[200005],b[200005];
	
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	
	sort(a+1,a+n+1,cmp);
	
	for(int i=1;i<=n;i++){
		if(b[i]==a[1]) cout<<a[2]<<endl;
		else cout<<a[1]<<endl;
	}
	return 0;
}

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

char a[10001], b[10001], data[100001];

void solve(int n, int m) {
  bool isHit;
  for(int i = 0; i < m; ++i) {
	isHit = 0;
	for(int j = 0; j < n; ++j) {
	  if(data[i] == a[j]) {
		printf("%c", b[j]);
		isHit = 1;
		break;
	  }
	}
	if(!isHit) {
	  printf("%c", data[i]);
	}
  }
  printf("\n");
}

int main() {
  int n, m;
  while(scanf("%d", &n) && n) {
	for(int i = 0; i < n; ++i) {
	  scanf(" %c %c", &a[i], &b[i]);
	}
	scanf("%d", &m);
	for(int i = 0; i < m; ++i) {
	  scanf(" %c", &data[i]);
	}
	solve(n, m);
  }
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include <queue>
#include <stack>

using namespace std;
using ll = long long;

int main(){

	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i+=2) {
		cout << s[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(S: str):
    return sum([S == "RRR", "RR" in S, "R" in S])


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(f'{solve(S)}')


if __name__ == '__main__':
    main()


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

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

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int ans = (n+1)/2;
		System.out.println(ans);
	}
}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 21204
#include<stdio.h>
struct Card{
  char suit;
  int value;
int key;
};
struct Card A[100001];
 
int Partition(int p,int r){
  int i,j;
  struct Card key,x;
   
  x=A[r];
  i=p-1;
   
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i=i+1;
      key=A[i];
      A[i]=A[j];
      A[j]=key;
    }
  }
   
  key=A[i+1];
  A[i+1]=A[r];
  A[r]=key;
   
  return i+1;
}
void Quicksort(int p,int r){
  int q;
  if(p<r){
    q = Partition(p, r);
    Quicksort(p,q-1);
    Quicksort(q+1,r);
  }
}
 
int main(){
  int n,i,j,count=0;
  char ch,ch2;
   
  scanf("%d%c",&n,&ch);
  for(i=1;i<=n;i++){    
    scanf("%c%c%d%c",&A[i].suit,&ch2,&A[i].value,&ch);
    A[i].key=i;   
  }
  
  
  Quicksort(1,n);
	
 for(i=1;i<n;i++){
 	if(A[i].value==A[i+1].value && A[i].key>A[i+1].key){
 		count=1;
 break;}
}
  if(count!=1) printf("Stable\n");
  else printf("Not stable\n");
   
  for(i=1;i<=n;i++) printf("%c %d\n",A[i].suit,A[i].value);
   
  return 0;
}

Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
//========================
#define gc getchar_unlocked
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long int
#define ull unsigned long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x), greater<int>())
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ss second
#define setbits(x) _builtin_popcount(x)
#define parity(x) _builtin_parity(x)
#define leadzero(x) __builtin_clz(x)
#define trailzero(x) __builtin_ctz(x)
#define endl "\n"
#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define CHRONO srand(chrono::high_resolution_clock::now().time_since_epoch().count())

// =======================
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef map<int, int> mii;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
    uniform_int_distribution<int> uid(0, lim - 1);
    return uid(rang);
}
int mpow(int base, int exp);
void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
// =======================
int n;
vpii d;
void input()
{
    cin >> n;
    d.resize(n);
    fo(i, n)
    {
        cin >> d[i].F >> d[i].S;
    }
}

void solve()
{
    int flag = 0;
    for (int i = 0; i <= n - 3; i++)
    {
        if (d[i].F == d[i].S && d[i + 1].F == d[i + 1].S && d[i + 2].F == d[i + 2].S)
        {
            flag = 1;
            break;
        }
    }
    if (flag)
        cout << "Yes";
    else
        cout << "No";
}

int main()
{
    FAST;
    CHRONO;
    int t = 1;
    //cin >> t;
    while (t--)
    {
        input();
        solve();
    }
    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    char c;
    cin >> c;
    cout << char(c + 1) << endl;
    
    return 0;
}



Measured memory_bytes: 256
n,x,y = map(int, input().split())

x -= 1
y -= 1
out = [0]*n
for i in range(n-1):
  for j in range(i+1,n):
    out[min(j-i, abs(i-x)+1+abs(j-y))] += 1
    
for i in range(1,n):
  print(out[i])

Measured memory_bytes: 3444
def check(DR):
    D = 0
    for dr in DR[::-1]:
        dmin, d = dr
        if D + dmin < 0:
            return False
        D += d
    return True

def main():
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())

    DR1 = []
    DR2 = []
    total = 0
    for s in S:
        d = 0    # ["(" の数]  - [")" の数]
        d_min = 0 # ")" が最も深くなるときの ")" の数
        # d_min <= d
        for lr in s:
            if lr == '(':
                d += 1
            else:
                d -= 1
                d_min = min(d, d_min)
        total += d
        if d > 0:
            DR1.append((d_min, d))
        else:
            DR2.append((d_min - d, -d))

    # d_minの大きい順に並べ替える
    DR1.sort()
    DR2.sort()
    if check(DR1) and check(DR2) and sum([d[1] for d in DR1]) == sum([d[1] for d in DR2]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 95644
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<=s.size()-2;i++)
	{
		if(s[i]=='A'&&s[i+1]=='C') 
		{
			cout<<"Yes";
			return 0;
		}  
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
/*
 * a.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

bool as[MAX_N][MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    u--;

    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      v--;
      as[u][v] = true;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) putchar(' ');
      printf("%d", as[i][j]);
    }
    putchar('\n');
  }

  return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3 && b%3 && (a+b)%3) cout << "Impossible" << endl;
    else cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,m,ans=m;
  std::cin>>n>>m;

  std::vector<std::vector<ll>> need(n,std::vector<ll>(m));
  rep(i,0,n){
    rep(j,0,m){
      std::cin>>need[i][j];
      need[i][j]--;
    }
  }

  while(1){
    std::vector<ll> count(m,0);
    rep(i,0,n){
      count[need[i][0]]++;
    }
    ll max=0;
    rep(i,0,m)max=std::max(max,count[i]);
    ans=std::min(ans,max);
    rep(i,0,m){
      if(count[i]==max){
        rep(j,0,n){
          auto itr=need[j].begin();
          while(*itr!=i)itr++;
          need[j].erase(itr);
        }
      }
    }

    if(need[0].empty())break;
  }

  std::cout<<ans;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<int> A;
  for(int i = 1; i < n+1; i++){
    if(i % 3 != 0 && i % 5 != 0) A.push_back(i);
  }
  
  ll ans = 0;
  for(int i = 0; i < A.size(); i++) ans += A[i];
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7292
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int s=a+b;
	int y=a-b;
	int x=a*b;
	if(s<y)
	swap(s,y);
	if(s<x)
	swap(s,x);
	cout<<s;
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    sort(a, a+n);

    int flag = 1;
    rep(i, n-1){
        if (a[i] == a[i+1]) flag = 0;
    }

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;





}





//              g++ -std=c++1z

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void sort(int array[], int array2[], int left, int right){
        if(left <= right){
            int p = array[(left + right) >>> 1];
            int l = left;
            int r = right;
            while(l <= r){
                while (array[l] < p){
                    l++;
                }
                while (array[r] > p){
                    r--;
                }
                if (l <= r){
                    int tmp = array[l];
                    array[l] = array[r];
                    array[r] = tmp;
                    
                    int tmp2 = array2[l];
                    array2[l] = array2[r];
                    array2[r] = tmp2;
                    l++;
                    r--;
                }
            }
            Main.sort(array, array2, left, r);
            Main.sort(array, array2, l, right);
        }
    }
    
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int c[] = new int[26];
        int s[][] = new int[n][26];
        int ind[] = new int[26];
        
        for(int i = 0; i < 26; i++){
            c[i] = stdIn.nextInt();
            ind[i] = i;
        }
        
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 26; j++){
                s[i][j] = stdIn.nextInt();
            }
        }
        
        Main.sort(c, ind, 0, 25);
        
        int rev[] = new int[26];
        
        for(int i = 25; i >= 0; i--){
            rev[i] = ind[25 - i] + 1;
        }
        
        int count = 0;
        boolean endFlag = false;
        
        while(true){
            for(int i = 15; i < 26; i++){
                System.out.println(rev[i % 26]);
                count++;
                if(count == 365){
                    endFlag = true;
                    break;
                }
            }
            
            if(endFlag){
                break;
            }

            
            for(int i = 0; i < 26; i++){
                System.out.println(rev[i % 26]);
                count++;
                if(count == 365){
                    endFlag = true;
                    break;
                }
            }
            
            if(endFlag){
                break;
            }
        }
        //System.out.println("XXXXXXXX");
    }
}


Measured memory_bytes: 46712
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] d = new int[n];

    for (int i = 0; i < n; i++) {
      d[i] = sc.nextInt();
    }

    Arrays.sort(d);

    System.out.println(d[n / 2] - d[(n / 2) - 1]);

  }
}

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

char mas[100][101];
int w,h;
int grx[4]={0,1,0,-1},gry[4]={1,0,-1,0};
char tmp;

void dfs(int,int);

int main(){
  int cnt;
  while(1){
    cin >> h >> w;
    cnt = 0;
    if(w == 0 && h == 0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mas[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(mas[i][j] == '#' || mas[i][j] == '*' || mas[i][j] == '@'){
	  tmp = mas[i][j];
	  dfs(j,i);
	  cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
}

void dfs(int x,int y){
  mas[y][x] = '0';
  for(int i=0;i<4;i++){
    int nx = x + grx[i];
    int ny = y + gry[i];
    if(nx >= 0 && nx < w && ny >= 0 && ny < h && mas[ny][nx] == tmp){
      dfs(nx,ny);
    }
  }
}

Measured memory_bytes: 1480
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (ll)1e9+7
#define LLINF (ll)1e30
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,h[100010],dp[100010]={};
    cin>>n;
    rep(i,n) cin>>h[i];
    dp[1]=abs(h[0]-h[1]);
    rep2(i,2,n){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

int main(void)
{
 
  long long a, b, r, x, tmp;
  std::cin >> a >> b;
 
  x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最小公倍数を出力 */
  std::cout << x/b << std::endl;
//   printf("最小公倍数 = %d\n", x/b);
 
  return 0;
}


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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  
  for(int i = 0; i < s.length(); i++){
  
  	s[i] = (s[i] - 'A' + n)%26 + 'A';
  
    cout << s[i];
  }
  
  cout << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 200010;
//const int MAXM = 100010;
const int MAXK = 30;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int B = 31;
const int MOD = 1000000007;
//const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

#define rep(i,a,b) for (int i = (a), I = (b); i <= I; ++ i)

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y)
{
	return y%4 == 0 && y%100 != 0 || y%400 == 0;
}

void solve()
{
	ld a, b, x;
	cin >> a >> b >> x;
	if (x == a*a*b)
	{
		ld ans = 0;
		printf("%.12f\n", ans);
		return;
	}
	ld t1 = atan(2*x/a/b/b);
	ld t2 = atan(a*a*a/2/(a*a*b-x));
	ld ans;
	if (a/tan(t2) <= b)
		ans = t2;
	else
		ans = t1;
	printf("%.12f\n", 90-ans*180/pi);
}

int main()
{
	
	int T;
	T = 1;
	//scanf("%d", &T);
	while (T --)
	solve();
	
	return 0;
}


Measured memory_bytes: 256