akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int gcd(int x, int y) { return x ? gcd(y % x, x) : y; }

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;
  }

  ll v = list[0];

  for (ll i = 1; i < N; i++) {
    v = gcd(v, list[i]);
  }
  cout << v << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,k; cin>>a>>b>>k;
    int x = 0;
    if(b-a+1 > k*2) x = k*2;
    else{
        FOR(i,a,b+1) OUT(i);
        return 0;
    }
    FOR(i,a,a+k) OUT(i);
    FOR(i,b-k+1,b+1) OUT(i);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T>void chkmin(T &x,const T &y){
    if(y<x){
        x=y;
    }
}
template<class T>void chkmax(T &x,const T &y){
    if(y>x){
        x=y;
    }
}
template<class T>void sort(vector<T> &a){
    sort(a.begin(),a.end());
}
template<class T>void reverse(vector<T> &a){
    reverse(a.begin(),a.end());
}
void reverse(string &a){
    reverse(a.begin(),a.end());
}
template<class T,class Cmp>void sort(vector<T> &a,Cmp cmp){
    sort(a.begin(),a.end(),cmp);
}
template<class T>void unique(vector<T> &a){
    a.resize(unique(a.begin(),a.end())-a.begin());
}
int readInt(){
    int x=0;
    bool sign=false;
    char c=getchar();
    while(!isdigit(c)){
        sign=c=='-';
        c=getchar();
    }
    while(isdigit(c)){
        x=x*10+c-'0';
        c=getchar();
    }
    return sign?-x:x;
}
ll readLong(){
    ll x=0;
    bool sign=false;
    char c=getchar();
    while(!isdigit(c)){
        sign=c=='-';
        c=getchar();
    }
    while(isdigit(c)){
        x=x*10+c-'0';
        c=getchar();
    }
    return sign?-x:x;
}
string readString(){
    string s;
    char c=getchar();
    while(isspace(c)){
        c=getchar();
    }
    while(!isspace(c)){
        s+=c;
        c=getchar();
    }
    return s;
}
void solve_single_test(int test_id=1){
    int n=readInt();
    int dp[100001][3]={};
    int arr[100001][3]={};
    for (int i = 0; i <n; ++i)
    {
        for (int j= 0; j<3; ++j)
        {cin>>arr[i][j];
            /* code */
        }
        /* code */
    }
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];

    for (int i = 1; i <n; ++i)
    {
        for (int j= 0; j<3; ++j)
        {dp[i][j]=max(dp[i-1][(j+1)%3]+arr[i][j],dp[i-1][(j+2)%3]+arr[i][j]);
            /* code */
        }
        /* code */
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);

}
void solve_multiple_tests(){
    int n_tests=readInt();
    for(int i=1;i<=n_tests;++i){
        solve_single_test(i);
    }
}
int main(){
    solve_single_test();
    return 0;
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[][] arr = new int[2][3];
        String[] input = br.readLine().split(" ");
        arr[0][0] = Integer.parseInt(input[0]);
        arr[0][1] = Integer.parseInt(input[1]);
        arr[0][2] = Integer.parseInt(input[2]);
        for (int i = 1; i < n; i++) {
            input = br.readLine().split(" ");
            arr[i % 2][0] = Math.max(arr[(i - 1) % 2][1], arr[(i - 1) % 2][2]) + Integer.parseInt(input[0]);
            arr[i % 2][1] = Math.max(arr[(i - 1) % 2][0], arr[(i - 1) % 2][2]) + Integer.parseInt(input[1]);
            arr[i % 2][2] = Math.max(arr[(i - 1) % 2][0], arr[(i - 1) % 2][1]) + Integer.parseInt(input[2]);
        }
        int max = 0;
        for (int i = 0; i < 3; i++) {
            if (arr[(n - 1) % 2][i] > max) max = arr[(n - 1) % 2][i];
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 48388
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] != s[s.size()-1-i]){
            s[i] = s[s.size()-1-i];
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String num1 = br.readLine();
        String[] num2 = num1.split(" "); 

        int x = Integer.parseInt(num2[0]);
        int y = Integer.parseInt(num2[1]);

        int area = x * y;
        int length = 2 * (x + y);

        System.out.println(area + " " + length);
    }
}

Measured memory_bytes: 24192
import math

inp = input().split(" ")
# print(str(inp))

## 時間の針
A = int(inp[0])
## 分の針
B = int(inp[1])
## 時間
H = int(inp[2])
## 分
M = int(inp[3])

H_theta = 30*H + 0.5*M
M_theta = 6*M

C = math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(H_theta - M_theta)))

print(str(C))

Measured memory_bytes: 9516
s=input()
#ls=len(s)
t=input()
#lt=len(t)
#print(s,t)
s=[ord(i) for i in s]
s.sort()
#print(s)
t=[ord(i) for i in t]
t.sort()
#print(t)

flag=0
for i in range(len(s)):
  for j in range(len(t)):
    if s[i] < t[j]:
      flag=1
    elif len(s) < len(t) and s==t[:len(s)]:
      flag=1
      
print('Yes' if flag==1 else 'No')

Measured memory_bytes: 3064
from collections import defaultdict
N, M = map(int, input().split())

counts = defaultdict(int)
numbers = {}

cities = []
for i in range(M):
    p, y = map(int, input().split())
    cities.append([i, p, y])

sorted_cities = sorted(cities, key=lambda x: x[2])
for city in sorted_cities:
    i, p, y = city
    counts[p] += 1
    numbers[i] = '{:06}{:06}'.format(p, counts[p])

for city in cities:
    print(numbers[city[0]])

Measured memory_bytes: 47324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> vec(n,-1);
  bool can = true;
  rep(i,m){
    cin >> t1 >> t2;
    t1--;
    if(vec[t1] == -1){
      vec[t1] = t2;
    }else if(vec[t1] == t2){

    }else{
      can = false;
    }
  }
  ll ans = 0;
  if(n == 1 && (vec[0] == 0 || vec[0] == -1)){
    cout << 0 << endl;
    return 0;
  }

  rep(i,n){
    ans *= 10;
    if(vec[i] == -1){
      if(i != 0){
        ans += 0;
      }else{
        ans += 1;
      }
    }else{
      if(vec[i] == 0 && i == 0){
        can = false;
      }else{
        ans += vec[i];
      }
    }
    //cout << ans << endl;
  }
  if(can){

  }else{
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*input
3
2 4 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=200005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    ll sum=0;
    REP(i,n){
        cin>>arr[i],sum+=arr[i];
    }
    ll pref=0;
    ll ans=INF64;
    REP(i,n){
        pref+=arr[i];
        MNTO(ans,abs(2*pref-sum));
        
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];
  sort(H.rbegin(), H.rend());
  ll ans = 0;
  for (int i = K; i < N; i++)
  {
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 500001
 
void MaxHeap(int*, int, int);
 
int main(void){
  int i, n;
  int A[MAX];
 
  scanf("%d", &n);
  for(i=1; i<n+1; i++) scanf("%d", &A[i]);
 
  for(i=n/2; i>0; i--) MaxHeap(A, i, n);
 
  for(i=1; i<n+1; i++) printf(" %d", A[i]);
  printf("\n");
 
  return 0;
}
 
void MaxHeap(int *A, int i, int n){
  int left, right, largest, tmp;
 
  left = i*2;
  right = i*2+1;
 
  if(left <= n && A[left] > A[i]) largest = left;
  else largest = i;
 
  if(right <= n && A[right] > A[largest]) largest = right;
 
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    MaxHeap(A, largest, n);
  }
 
  return;
}

Measured memory_bytes: 2552
def m():
    N = int(input())
    S = [input() for _ in range(N)]
    import collections
    c = collections.Counter(S)
    print('AC x', c.get('AC', 0))
    print('WA x', c.get('WA', 0))
    print('TLE x',c.get('TLE', 0))
    print('RE x', c.get('RE', 0))

m()

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void) {
	long long N, K, A,tmp;


	cin >> N >> K;

	vector<long long> light(N), light_tmp(N+1, 0), reset(N, 0);

	for (long long i = 0; i < N; i++) {
		cin >> A;
		light[i] = A;

	}

	for (long long i = 0; i < min(K,(long long) 41 ); i++) {
		light_tmp = reset;
		for (long long j = 0; j < N; j++) {

			// for (long long s = j - light[j]; s <= j + light[j] + 0.5; s++) {
			// 	if (s < 0) { continue; }
			// 	if (s >= N ) { continue; }

			// 	light_tmp[s]++;
			// }
            tmp = max((long long)0,j - light[j]);
            light_tmp[tmp]++;

            tmp=min(j + light[j]+1,N+1);
            light_tmp[tmp]--;
		}
		
        light[0]=light_tmp[0];
        for(long long j=1;j<N;j++){
            light[j] = light[j-1] + light_tmp[j] ;
        }
	}


	for (long long i = 0; i < N - 1; i++) {
		cout << light[i] << " ";
	}
	cout << light[light.size() - 1] << endl;



	return 0;
}



Measured memory_bytes: 7996
import sys

def dijkstra(nodes, start, goal, matrix):
  defnode = [False] * (nodes+1)
  cost = [sys.maxint] * (nodes+1)
  cost[start] = 0
  node = start
  while True:
    defnode[node] = True
    for i in xrange(1, nodes+1):
      if defnode[i]:
        continue
      if matrix[node][i] == sys.maxint:
        continue
      cost[i] = min(cost[i], cost[node]+matrix[node][i])
    minnode = sys.maxint
    mincost = sys.maxint
    for i in xrange(1, nodes+1):
      if defnode[i]:
        continue
      if cost[i] < mincost:
        minnode = i
        mincost = cost[i]
    if minnode == goal:
      return cost[goal]
    node = minnode

n = int(raw_input())
m = int(raw_input())
matrix = [[sys.maxint]*(n+1) for i in xrange(n+1)]
for i in xrange(m):
  a, b, c, d = map(int, raw_input().split(","))
  matrix[a][b] = c
  matrix[b][a] = d
s, g, V, P = map(int, raw_input().split(","))
answer = V - P - dijkstra(n, s, g, matrix) - dijkstra(n, g, s, matrix)
print answer

Measured memory_bytes: 6312
#include<stdio.h>


 int P[41],I[41],Po[41],n,s,next=0;

 int find(int c){
       int i;
       for(i=0;i<n;i++){
                if(I[i]==c)return i;
                }
       return 0;
       }

 void rec(int l,int r){
       int m,c;
       if(l>=r)return;
       c=P[next++];
       m=find(c);
       rec(l,m);
       rec(m+1,r);
       Po[s++]=c;
       }

 int main(){
       int i;
       scanf("%d",&n);
       for(i=0;i<n;i++){
               scanf("%d",&P[i]);
               }
       for(i=0;i<n;i++){
               scanf("%d",&I[i]);
               }
       rec(0,n);
       for(i=0;i<n-1;i++){
               printf("%d ",Po[i]);
               }
       printf("%d\n",Po[i]);
       return 0;
       }




Measured memory_bytes: 2124
// Vivek Rai
// Blazer_007

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll          long long
#define int         long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define ppi         pair<ll,pii>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define bit(x, y)   (((x)>>(y))&1)
#define bpt(x)      (__builtin_popcount(x))
#define bptl(x)     (__builtin_popcountll(x))
#define loop(i,a,b)  for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)

using namespace std;
using namespace __gnu_pbds;

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int> > minHeap;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(index) -> value at given index or Kth smallest element in set
// order_of_key(X) -> number of elements strictly less than X
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cout << name << " : " << arg1 << endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif


istream &operator>>(istream &in, vector<int> &arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cin >> arr[i];
    return in;
}

ostream &operator<<(ostream &os, vector<int> arr)
{
    for(int i = 0 ; i < arr.size() ; i++)
        cout << arr[i] << " ";
    cout << endl;
    return os;
}

void solution()
{
    int n, x, t;
    cin >> n >> x >> t;
    int ans = (n/x) * t;
    if (n%x)
        ans += t;
    cout << ans << endl;
}

signed main()
{
    fastio

    ll t = 1;
    // cin >> t;
    loop(i, 1, t + 1)
    {
        //cout<<"Case #"<<i<<": ";
        solution();
    }
}


    

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define INF 10000000
const int maxn = 2e5+ 5;

int n;
int a[110];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0);
    cin>>n;
    for(int i=n;;i+=n)
    if(i%2==0)
    {
        cout<<i;
        exit(0);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 1000000007ll

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n, 0);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(ALL(v), greater<int>());
    int sum = 0;
    rep(i, 1,v.size()) sum += v[i];
    if (v[0] < sum)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n;
   cin>>n;
   
   vector<int> a(n,0);
   ll sum=0;
   rep(i,n){
      cin>>a[i];
      sum+=a[i];
   }
   sort(a.begin(),a.end());

   rep(i,n){
      if(sum%10!=0) {
         cout<<sum;
         return 0;
      }
      else {
         bool f=false;
         rep(j,n){
            if(a[j]%10!=0){
               sum-=a[j];
               f=true;
               break;
            }
         }
         if(f==false) {
            sum=0;
            cout<<sum;
            return 0;
         }
      }
      }
return 0;
}



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

int main()
{
    const int MOD = 1000000007, Max = 200000;
    int N;
    cin >> N;
    int M;
    int beforecur[N + 1];
    for (int i = 0; i <= N; i++)
    {
        beforecur[i] = 0;
    }
    {
        int e[N + 1];
        for (int i = 0; i <= N; i++)
        {
            e[i] = 0;
        }
        int count = 1;
        for (int i = 1; i <= N; i++)
        {
            int tmp;
            cin >> tmp;
            if (i != 1)
            {
                if (e[count] != tmp)
                {
                    count++;
                }
            }
            e[count] = tmp;
        }
        M = count;
        int colortoiti[Max + 1];
        for (int i = 0; i <= Max; i++)
        {
            colortoiti[i] = 0;
        }
        for (int i = 1; i <= M; i++)
        {
            if (colortoiti[e[i]] == 0)
            {
                colortoiti[e[i]] = i;
            }
            else
            {
                beforecur[i] = colortoiti[e[i]];
                colortoiti[e[i]] = i;
            }
        }
    }
    int dp[M + 1];
    for (int i = 0; i <= M; i++)
    {
        dp[i] = 0;
    }
    dp[M] = 1;
    for (int i = M; i > 1; i--)
    {
        dp[beforecur[i]] += dp[i];
        dp[beforecur[i]] %= MOD;
        dp[i - 1] += dp[i];
        dp[i - 1] %= MOD;
    }
    cout << dp[1] << endl;
    return 0;
}


Measured memory_bytes: 2560
ABCD = int(input())
a = int(ABCD//10e2)
b = int((ABCD-a*10e2)//10e1)
c = int((ABCD-a*10e2-b*10e1)//10)
d = int(ABCD-a*10e2-b*10e1-c*10)
if a+b+c+d == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a-b+c+d == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a+b-c+d == 7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a+b+c-d == 7:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a-b-c+d == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a-b+c-d == 7:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a+b-c-d == 7:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a-b-c-d == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const ll maxn = 2e5 + 5;
pair<ll,ll> p[maxn];
int main(int argc, char const *argv[])
{
	ll n;
	cin>>n;
	for(ll i = 0;i < n; ++i)
	{
		scanf("%lld%lld",&p[i].second,&p[i].first);
	}
	sort(p,p + n);
	ll now = 0;
	for(ll i = 0;i < n; ++i)
	{
		now += p[i].second;
		if(now > p[i].first)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>

int ABS(int N){
    if (N<0) return -N;
    return N;

}

using namespace std;

int final[2000];
int main(){
    int n, x, y;
    cin >>n>> x >> y; 
    x --;
    y --;
    for (int i = 0;i<n-1;i++)
        for (int j = i + 2;j < n;j++){
            int dist = 0;
            if (j < x || i > y) dist = j - i;
            else{
                dist = j-i;
                if (dist > ABS(x-i)+1+ABS(y-j)) dist = ABS(x-i)+1+ABS(y-j);
                if (dist > ABS(y-i)+1+ABS(x-j)) dist = ABS(y-i)+1+ABS(x-j); 
            }
            final[dist-1] ++;
        }
    final[0] = n;
    for (int i = 0; i<n-1;i++) cout<<final[i]<<endl;
    return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int cnt[27];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s; cin >> s;

    for(auto i : s)
        ++cnt[i - 'a'];

    long long tot = 1;

    for(int i = 0; i < s.size(); ++i){
        --cnt[s[i] - 'a'];
        tot += (s.size() - i - 1) - cnt[s[i] - 'a'];
    }

    cout << tot << "\n";


    return 0;

}


Measured memory_bytes: 720
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD=1000000007;

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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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


int main(int argc, char**argv){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> b[i];
    }

    vector<int> sum_a(n+1, 0), sum_b(n+1, 0);
    for (int i = 0; i < n; i++){
        sum_a[i+1] = a[i] + sum_a[i];
        sum_b[i+1] = b[i] + sum_b[i];
    }

    int ans = 0;
    for (int i = 0; i < n; i++){
        int val = (sum_a[i+1] - sum_a[0]) + (sum_b[n] - sum_b[i]);
        ans = max(ans, val);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
t = int(input())
arr = [int(x) for x in input().split()]
n = 1
flag = True
if 0 in arr:
    print(0)
else:
    for i in range(t):
        n *= arr[i]
        if n > 10**18:
            flag = False
            break
    if flag:
        print(n)
    else:
        print(-1)


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

#define MAX_SIZE 10000
bool isPrime[MAX_SIZE + 1];

int main() {
    fill_n(isPrime, MAX_SIZE, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 4; i <= MAX_SIZE; i += 2) {
        isPrime[i] = false;
    }
    for (int i = 3; i * i <= MAX_SIZE; i += 2) {
        if (isPrime[i] == true) {
            for (int j = i * 2; j <= MAX_SIZE; j += i) {
                isPrime[j] = false;
            }
        }
    }

    int n;
    while (cin >> n) {
        int resulst = 0;
        for (int i = 1; i <= n; i++) {
            if (isPrime[i] == true && isPrime[n + 1 - i] == true) {
                resulst++;
            }
        }
        cout << resulst << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;

int a[510][510];
int dp[510][510];
int dir[4][2] = {0, 1, 1, 0, -1, 0, 0, -1};
int P[250010];
queue <pii> q;

int main () {
	int n; scanf("%d", &n);
	for (int i = 0; i < n * n; i++) {
		scanf("%d", &P[i]);
		P[i]--;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			a[i][j] = 1;
			dp[i][j] = min(min(i + 1, n - i), min(j + 1, n - j));
		}
	}
	int ans = 0;
	for (int i = 0; i < n * n; i++) {
		int x = P[i] / n, y = P[i] % n;
		a[x][y] = 0;
		dp[x][y]--;
		ans += dp[x][y];
		q.push(mp(x, y));
		while (!q.empty()) {
			pii t = q.front(); q.pop();
			int x = t.fi, y = t.se;
			for (int i = 0; i < 4; i++) {
				int xx = x + dir[i][0], yy = y + dir[i][1];
				if (xx < 0 || yy < 0 || xx >= n || yy >= n) continue;
				int ndp = dp[x][y] + a[xx][yy];
				if (ndp < dp[xx][yy]) {
					dp[xx][yy] = ndp;
					q.push(mp(xx, yy));
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
int main() 
{
   int N;
   cin >> N;

   int s_p = 0;
   int s_w = 0;
   int s_g = 0;
   int s_y = 0;

    rep(i, N) 
    {
        string S;
        cin >> S;

//        cout << S << endl;
     
      if (S == "P") s_p ++;
      else if (S == "W") s_w ++;
      else if (S == "G") s_g ++;
      else if (S == "Y") s_y ++;

//     cout << "s_p:" << s_p << endl;
//     cout << "s_w:" << s_w << endl;
//     cout << "s_g:" << s_g << endl;
//     cout << "s_y:" << s_y << endl;      
    }
  
    if (s_p > 0 && s_w > 0 && s_g > 0)
    {
      if (s_y > 0) cout << "Four" << endl;
      else  cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    char[][] c = new char[h][w];
    for(int i=0;i<h;i++){
      String s = sc.next();
      for(int j=0;j<w;j++){
        c[i][j] = s.charAt(j);
      }
    }
    int ans = 0;
    for (int i=0;i<Math.pow(2,h);i++) {
      for (int j=0;j<Math.pow(2,w);j++) {
         int bCount=0;
         for(int l=0;l<h;l++){
           for(int m=0;m<w;m++) {
             if (((i>>l&1)==1) || ((j>>m&1)==1)) {
               continue;
             }else{
               if(c[l][m]=='#') {
                 bCount++;
               }
             }
           }
         }
        if (bCount==k) {
          ans++;
        }
      }
    }
    System.out.println(ans);           
  }
}

Measured memory_bytes: 35816
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#define llint long long

using namespace std;

llint m, n;
bool prime[10000005];

int main(void)
{
	while(1){
		cin >> m >> n;
		if(m == 0 && n == 0) break;
		
		for(int i = 1; i < 10000005; i++) prime[i] = false;
		for(int i = m; i < 10000005; i++){
			if(n == 0) break;
			if(prime[i]) continue;
			n--;
			for(int j = i; j < 10000005; j+=i) prime[j] = true;
		}
		
		for(int i = m; i < 10000005; i++){
			if(!prime[i]){
				cout << i << endl;
				break;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 12848
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
k = ii()

now = 1
for i in range(n):
    if now < k:
        now *= 2
    else:
        now += k
print(now)

Measured memory_bytes: 3064
import math
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	i = a.index(min(a)) + 1
	if k - 1 > i:
		v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1
	else:
		v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1))
	print(v)
resolve()

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


int main(){
 int n;cin >> n;
 ll ans = 1;
 for(int i = 1;i<=n;i++){
     ans *= i;
     ans = ans % 1000000007;
 }
 cout << ans << endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k;
  int s[100],b[100][100];
  int i,j,sum,flg=0;
  while(scanf("%d %d",&n,&k)&&(n||k)){
    for(i=0;i<k;i++) scanf("%d",&s[i]);
    for(i=0;i<n;i++) for(j=0;j<k;j++) scanf("%d",&b[i][j]);
    flg=0;
    for(i=0;i<k;i++){
      sum=0;
      for(j=0;j<n;j++) sum+=b[j][i];
      if(sum>s[i]){
         flg=1;
         break;
      }
    }
    if(flg==1){
      puts("No");
      continue;
    }
    puts("Yes");
  }
  return 0;
}

Measured memory_bytes: 424
def main():
    s = input()
    rem = [0] * 2019  # the count of the each remainder: 0 ~ 2018
    rem[0] = 1  # why? can't understand.

    temp = 0
    digit = 1
    for c in s[::-1]:
        # No time to pow.
        temp += int(c) * digit
        rem[temp % 2019] += 1
        digit *= 10
        digit %= 2019

    return sum(c * (c - 1) // 2 for c in rem)


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,a;
  long q;
 
  
  cin >> n >> k >> q;
  
  vector<int> vec(n);
  
  for(int i=0;i<q;++i){
    cin >> a;
    vec.at(a-1) += 1;
  }
  
  for(int j=0;j<n;++j){
    if(k-q+vec.at(j)>0){
      cout << "Yes" << endl;
    }
      else cout << "No" << endl;
  }
  
  
  
}

Measured memory_bytes: 1024
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for (ll i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }

int main(void) {
	string S, T;
	cin >> S >> T;
	string ans = "No";
	REP(i, S.size() + 1) {
		if (S == T) {
			ans = "Yes";
		}
		S = S.back() + S.substr(0, S.size() - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 10000
int isPrime(int);

int main(){
  int x,i,j,u,c=0,count=0;
  int s[N];
    scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&s[i]);
  }
  for(i=0;i<x;i++){
    u = isPrime( s[i] );
    if(u == 1) count++;
  }

  printf("%d\n",count);
  
  return 0;
}

int isPrime(int x){
  int i;

  if(x==2) return 1;
  if( x<2 || x%2==0) return 0;

  i = 3;
  while(i<= sqrt(x) ){
    if( x % i ==0 ) return 0;
    i = i + 2;
  }

  return 1;
}

Measured memory_bytes: 628
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b=a;
        double menseki = b * b  *Math.PI;
        double enshuu = 2*b*Math.PI;
        System.out.printf("%f %f",menseki,enshuu);
    }
}

Measured memory_bytes: 27924
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, C;

  cin >> N >> M >> C;
  vector<int> B(M);
  vector<int> A(M);
  int count = 0;

  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A.at(j);
    }
    int sum = 0;
    for (int j = 0; j < M; j++) {
      sum += B.at(j) * A.at(j);
    }
    if (sum + C > 0) {
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int n;
    cin>>n;
    dunk(n/2+n%2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, h, w) for (int i = 0; i < h; i++, cout << endl) for (int j = 0; j < w; j++) cout << a[i][j] << ' ';
#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = 1e13;
const int mmod = 1000000007;

int32_t main()
{
	int n, k, q;
	cin >> n >> k >> q;
	int a[n];
	for (int i = 0; i < n; i++) a[i] = k;
	int b[n];
	memset(b, 0, sizeof b);
	for (int i = 0; i < q; i++) {
		int x;
		cin >> x;
		--x;
		b[x]+=1;
	}
	int sum = accumulate(b, b+n, 0ll);
	for (int i = 0; i < n; i++) {
		if (a[i] + b[i] - sum <= 0) cout << "No" << endl;
		else cout << "Yes" << endl; 
	}
}



Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        for (int i = 0 ; i <= x ; i++) {
            if (i * 2 + (x - i) * 4 == y) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 35836
from copy import copy
from collections import Counter
from scipy.special import comb

n = int(input())
A = list(map(int,input().split()))

C = Counter(A)
S = 0
for i in range(1,n+1):
  S += comb(C[i],2,exact=True)

for k in range(n):
  p = A[k]
  ans = S - comb(C[p],2,exact=True) + comb(C[p]-1,2,exact=True)
  print(ans)

Measured memory_bytes: 65768
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    ll N; cin >> N;

    vector<ll > dp(N+19, INF);

    dp[0] = 0;

    for(ll i = 0; i < N; i++){

        if(dp[i] == INF) continue;

        dp[i + 1] = min(dp[i] + 1, dp[i + 1]);

        ll cn = 0;
        while(true){
            if(i + pow(6, cn) > N){
                break;
            }
            dp[i + pow(6, cn)] = min(dp[i] + 1, dp[i + pow(6, cn)]);
            cn++;
        }
        cn = 0;
        while(true){
            if(i + pow(9, cn) > N){
                break;
            }
            dp[i + pow(9, cn)] = min(dp[i] + 1, dp[i + pow(9, cn)]);
            cn++;
        }
    }

    cout << dp[N] << endl;

}

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

using namespace std;

int main(){
    int num;
    scanf("%d", &num);
    vector <int> arr(num+1), dp(num+1);
    for(int i = 1; i <= num; i++){
        scanf("%d", &arr[i]);
    }
    dp[1] = 0;
    dp[2] = abs(arr[2] - arr[1]);
    for(int i = 3; i <= num; i++){
        int tempA = abs(arr[i] - arr[i-1]) + dp[i-1];
        int tempB = abs(arr[i] - arr[i-2]) + dp[i-2];
        dp[i] = min(tempA, tempB);
    }

    printf("%d\n", dp[num]);    
}

Measured memory_bytes: 4028
#include <stdio.h>
//nをm回右シフトして、一桁目が1かどうか
#define bit(n,m)(((n)>>(m))&1)


char s[9][9];
int main(){
	int h,w,k;
	scanf("%d%d%d",&h,&w,&k);
	for(int i=0;i<h;i++)scanf(" %s",s[i]);
	
	int ans=0;
  // h = 3 , hh 000~111 7通り　000ー＞全部塗らない　101→1行目と3行目を赤く塗る
	for(int hh=0;hh<(1<<h);hh++)for(int ww=0;ww<(1<<w);ww++){
		int cnt=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
      //i行j列目が黒 かつ　i行目が赤で塗られない かつ j列目が赤で塗られない　ならカウント
      if( s[i][j]=='#' && !bit(hh,i) && !bit(ww,j) )cnt++;
    }
		if(cnt==k)ans++;
	}

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


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

using namespace std;


signed main(){
    vector<string> s = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string t;
    cin >> t;
    cout << 7 - distance(s.begin(), find(s.begin(), s.end(), t)) << endl;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <algorithm>
using namespace std;
using iL = long long;
using iUL = unsigned long long;
using dL = long double;
#define rep( NAME, NUM ) for( int NAME = 0; NAME < ( NUM ); ++NAME )
#define brep( NAME, NUM ) for( int NAME = ( NUM ) - 1; NAME >= 0; --NAME )

int main()
{
    //----------------
    int a, b;
    cin >> a >> b;
    cout << a + b / 2 << endl;

    //----------------
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    double ans = v[0];
    rep1(i, n-1) ans = (ans + v[i]) / 2;
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

template <class T>
inline void eraque(std::vector<T>& vec) {
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  return;
}

template <class T>
inline int lower_position(const std::vector<T>& vec, T val) {
  return static_cast<int>(std::distance(
      vec.begin(), std::lower_bound(vec.begin(), vec.end(), val)));
}

template <class T>
inline int upper_position(const std::vector<T>& vec, T val) {
  return static_cast<int>(std::distance(
      vec.begin(), std::upper_bound(vec.begin(), vec.end(), val)));
}

template <class T>
inline std::string to_binary(T n) {
  assert(n > 0);
  std::string ret = "";
  while (n) ret += (n & 1) ? '1' : '0', n >>= 1;
  std::reverse(ret.begin(), ret.end());
  return ret;
}

template <class T>
inline void println(T val) {
  std::cout << val << '\n';
}

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

template <class T, class U>
std::istream& operator>>(std::istream& is, std::pair<T, U>& p) {
  return is >> p.first >> p.second;
}

template <class Tuple, std::size_t... Is>
void tuple_in(std::istream& is, Tuple& tp, std::index_sequence<Is...>) {
  ((is >> std::get<Is>(tp)), ...);
}

template <class... Args>
std::istream& operator>>(std::istream& is, std::tuple<Args...>& tp) {
  tuple_in(is, tp, std::index_sequence_for<Args...>{});
  return is;
}

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

  int n; int64 k; cin >> n >> k;
  vector<int> a(n); cin >> a;

  if (k == 0) {
    cout << *max_element(all(a)) << endl; return 0;
  }

  int high = (int)1e9 + 1, low = 0;

  while (high - low > 1) {
    int mid = (high + low) >> 1;
    int64 need = 0;
    for (int e : a) need += (int64)((e + mid - 1) / mid - 1);

    if (need > k) {
      low = mid;
    } else {
      high = mid;
    }
  }

  cout << high << endl;

  return 0;
}


Measured memory_bytes: 3940
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <stdlib.h>
 
using namespace std;
 
int main(void){
	
	int n;
	cin >> n;

	for( int i = 0; i < n; i++ ) {
		int outs = 0, runner = 0, pts = 0;
		while( outs < 3 ) {
			string evt;
			cin >> evt;
			if( evt == "HIT" ) {
				if( runner < 3 ) {
					runner ++;
				} else {
					pts ++;
				}
			} else if( evt == "OUT" ) {
				outs ++;
			} else {
				pts += runner + 1;
				runner = 0;
			}
		}
		cout << pts << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    vector<string> ans;

    while(1){
        string str;
        cin >> str;
        if(str == "-") break;
        int n;
        cin >> n;
        loop(i, n){
            int v;
            cin >> v;
            string str1 = str.substr(0, v);
            string str2 = str.substr(v);
            str = str2 + str1;
        }

        ans.push_back(str);
    }

    loop(i, ans.size()) cout << ans[i] << endl;

    return 0;
}



Measured memory_bytes: 3196
S = str(input())

checker = True
for i in range(len(S)):
    if i%2 == 0: #odd
        if S[i] == "L":
            print("No")
            checker = False
            break
    else:
        if S[i] == "R":
            print("No")
            checker = False
            break

if checker:
    print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define xx first
#define yy second
using namespace std;
int dis[101][101];
typedef pair<int, int>pi;
queue<pi>q;
int dirx[]= {0, 1};
int diry[]= {1, 0};
char str[101][101];
int main()
{
    int h, w;
    scanf("%d %d", &h, &w);
    for(int i=1; i<=h; i++)
    scanf("%s", str[i]+1);
    for(int i=1; i<=h; i++)
    for(int j=1; j<=w; j++)
    dis[i][j]= h+w;
    dis[1][1]= (str[1][1]=='#');
    q.push({1, 1});
    while(!q.empty())
    {
        int x= q.front().xx;
        int y= q.front().yy;
        q.pop();
        for(int i=0; i<2; i++)
        {
            int x1= x+dirx[i];
            int y1= y+diry[i];
            if(x1>=1 && x1<=h && y1>=1 && y1<=w)
            {
                if(str[x1][y1]=='.')
                {
                    if(dis[x1][y1]>dis[x][y])
                    dis[x1][y1]= dis[x][y], q.push({x1, y1});
                }
                else
                {
                    if(dis[x1][y1]>dis[x][y]+(str[x][y]=='.'))
                    dis[x1][y1]= dis[x][y]+(str[x][y]=='.'), q.push({x1, y1});
                }
            }
        }
    }
    printf("%d\n", dis[h][w]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void){
    int i,j,n;double m[6],d;
    scanf("%d",&n);
    int res[n];
    for(i=0;i<n;i++){
        for(j=0;j<6;j++){scanf("%lf",m+j);}
        d=sqrt((m[0]-m[3])*(m[0]-m[3])+(m[1]-m[4])*(m[1]-m[4]));
        if (d>m[2]+m[5]){res[i]=0;}
        else if (d<=m[2]+m[5] && d>=fabs(m[2]-m[5])){res[i]=1;}
        else if (d<fabs(m[2]-m[5])){res[i]=(m[2]<m[5])? -2:2;} 
    }
    for(i=0;i<n;i++){printf("%d\n",res[i]);}
    return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int R;
    cin >> R;
    printf("%f\n", 2 * R * 3.14159265359);
    return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        --a[i];
    }
    int ans = 0;
    rep(i, n){
        if(i < a[i] && a[a[i]] == i){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640