akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll _pow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; b >> i; i++) {
		if ((b >> i) & 1) ans *= a;
		a *= a;
	}
	return ans;
}
char jpy[] = "JPY", btc[] = "BTC";
int main(void) {
	int n; scanf("%d", &n);
	double x; char coin[5];
	double ans = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lf", &x);
		scanf("%s", coin);
		if (!strcmp(coin, jpy)) {
			ans += x;
		}
		else {
			ans += x * 380000;
		}
	}
	printf("%lf\n", ans);
	return 0;
}



	

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_35_Marblue_And_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
double ans=0; 

int I_Love_35_Marblue_And_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>n;
	FOR(i,0,n){
		double x;
		cin>>x;
		string u;
		cin>>u;
		if(u=="JPY")ans+=x;
		else ans+=380000*x;
	}
	printf("%.10lf\n",ans);
	
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for i in range(n):
    a.append([int(i) for i in input().split()])
maxn=0
for i in range(8):
    vec=[]
    for j in range(n):
        s=0
        for k in range(3):
            if(int(i/(1<<k))%2==0):
                s+=a[j][k]
            else:
                s-=a[j][k]
        vec.append(s)
    ans=0
    vec.sort(reverse=True)
    for j in range(m):
        ans+=vec[j]
    maxn=max(maxn,ans)
print(maxn)

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	char W[10];
	char T[1000];
	char word[1000];
	char endoftext[12] = "END_OF_TEXT";
	int i;
	int cnt = 0;

	//文字列を初期化する
	for (i = 0; i < 10; i++)
	{
		W[i] = '\0';
	}
	for (i = 0; i < 1000; i++)
	{
		T[i] = '\0';
	}
	endoftext[11] = '\0';

	//文字列Wに単語を入力する
	scanf("%s", W);

	//入力された文字列がEND_OF_TEXTでない間
	while (1)
	{
		scanf("%s", T);

		if (strcmp(T, endoftext) == 0)
		{
			break;
		}

		for (i = 0; T[i] != '\0'; i++)
		{
			word[i] = tolower(T[i]);
		}
		word[i] = '\0';

		if (strcmp(W, word) == 0)
		{
			cnt++;
		}

		//printf("W : %s %d\nword : %s %d\nend_of_text : %s\ncnt : %d\n\n", W, strlen(W), word, strlen(word), endoftext, cnt);
	}

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

	return 0;
}





Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
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,t;
cin >> s >> t;

// dp[i+1][j+1]:= s[i]までとt[j]までの最長共通部分列の長さ
vvi dp(s.size()+1,vi(t.size()+1,0));

for(int i = 0; i < s.size(); ++i) {
    for(int j = 0; j < t.size(); ++j) {
        if(s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
        chmax(dp[i+1][j+1], dp[i+1][j]);
        chmax(dp[i+1][j+1], dp[i][j+1]);
    }
}

// 復元
string ans = "";
int i = s.size(); int j = t.size();
while(i > 0 && j > 0) {
    if(dp[i][j-1] == dp[i][j]) --j;
    else if(dp[i-1][j] == dp[i][j]) --i;
    else {
        ans = s[i-1] + ans;
        --i;--j;
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
int n,m;
cin>>n>>m;
int accnt=0,wacnt=0;
int wa[100005];
bool ac[100005];
REP(i,100005){
    wa[i]=0;
    ac[i]=false;
}
while(m--){
    int p=0;
    string s;
    cin>>p>>s;
    if(ac[p]) continue;
    if (s=="AC")
    {
        /* code */
        ac[p]=true;
        accnt++;
        wacnt+=wa[p];
    }
    else
    {
        wa[p]++;
    }
    
    

}
cout<<accnt<<" "<<wacnt<<endl;


}


Measured memory_bytes: 768
package main

/*
   N
*/
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	// evenn,oddn:=numsplit(n)
	fmt.Println(sum2(n))
}
func sum2(a int) int {
	if a%2 == 0 {
		k := int(a/2) - 1
		return int(k*(k+1)) + int(a/2)
	} else {
		k := int((a - 1) / 2)
		return int(k * (k + 1))
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
using lint=long long;
using namespace std;

int main()
{
	lint N,K;
	lint cnt=0;
	lint ans=0;
	
	cin >> N >> K;
	
	for(lint i=1;i<=N;i++)
		if(i%K==0)cnt++;
	
	ans+=pow(cnt,3);
	
	if(K%2==0)
	{
		cnt=0;
		for(lint i=1;i<=N;i++)
			if(i%K==K/2)cnt++;
		ans+=pow(cnt,3);
	}
	
	cout << ans << endl;
	return 0;
}


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

int main(void)
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> c(H, vector<int>(W));
    for (int h = 0; h < H; h++)
    {
        for (int w = 0; w < W; w++)
        {
            char inc;
            cin >> inc;
            if (inc == '#')
            {
                // black
                c[h][w] = 1;
            }
            else
            {
                // white
                c[h][w] = 0;
            }
        }
    }

    int patterns = 0;
    for (uint8_t h_selec = 0; h_selec < (1 << H); h_selec++)
    {
        for (uint8_t w_selec = 0; w_selec < (1 << W); w_selec++)
        {
            int blackCnt = 0;

            for (int h = 0; h < H; h++)
            {
                for (int w = 0; w < W; w++)
                {
                    if(((h_selec >> h) & 1) || ((w_selec >> w) & 1)) continue;
                    if(c[h][w]) blackCnt++;
                }
            }

            if (blackCnt == K) patterns++;
        }
    }

    cout << patterns << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main()
{
   long a,b;
   long i,j,k;
   long f;
   long n;
   long cnt = 0;
   long h;
   long left,right,mid;
   long ans = 0;
   static char str[102][1003];
   char s[9];
   char p[1003];
   char tmp;
   int end = 0;
   scanf("%ld",&a);
   printf("%ld\n",a*a*a);


   return 0;
}

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

using namespace std;


int UsedData[10];
int PuzzleData[9][9];
bool judgeResult[9][9];

void checkDataByRow(int row) {
	
	for (int t = 1; t < 10; t++) {
		if (UsedData[t] == 1) {
			continue;
		}
		for (int j = 0; j < 9; j++) {
			if (PuzzleData[row][j] == t) {
				judgeResult[row][j] = true;
			}
		}
	}
}

void checkDataByCol(int col) {
	
	for (int t = 1; t < 10; t++) {
		if (UsedData[t] == 1) {
			continue;
		}
		for (int j = 0; j < 9; j++) {
			if (PuzzleData[j][col] == t) {
				judgeResult[j][col] = true;
			}
		}
	}
}

void checkDataBySquare(int startI, int startJ) {

	memset(UsedData, 0, sizeof(UsedData));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			UsedData[PuzzleData[startI + i][startJ + j]]++;
		}
	}

	for (int t = 1; t < 10; t++) {
		if (UsedData[t] == 1) {
			continue;
		}
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (PuzzleData[startI + i][startJ + j] == t) {
					judgeResult[startI + i][startJ + j] = true;
				}
			}
		}
	}
}

void show() {
	
	for (int i = 0; i < 9; i++) {
		for (int j = 0; j < 9; j++) {
			
			cout << (judgeResult[i][j] ? "*" : " ") << PuzzleData[i][j];
		}
		cout << endl;
	}
}

int main() {
	int n;

	cin >> n;
	while (n--) {
		memset(judgeResult, false, sizeof(judgeResult));
		for (int i = 0; i < 9; i++) {
			memset(UsedData, 0, sizeof(UsedData));
			for (int j = 0; j < 9; j++) {
				cin >> PuzzleData[i][j];
				UsedData[PuzzleData[i][j]]++;
			}
			checkDataByRow(i);
		}
		for (int i = 0; i < 9; i++) {
			memset(UsedData, 0, sizeof(UsedData));
			for (int j = 0; j < 9; j++) {
				UsedData[PuzzleData[j][i]]++;
			}
			checkDataByCol(i);
		}
		for (int i = 0; i < 7; i += 3) {
			for (int j = 0; j < 7; j += 3) {
				checkDataBySquare(i, j);
			}
		}

		show();
		if (n != 0) {
			cout << endl;
		}
	}



	return 0;
}


Measured memory_bytes: 3112
C = [[int(hoge) for hoge in input().split()] for i in range(3)]
B = C[0]
A = [0,C[1][0] - C[0][0],C[2][0] - C[0][0]]
if C[1] == [A[1] +B[0],A[1]+B[1],A[1] + B[2]] and C[2] ==[A[2] +B[0],A[2]+B[1],A[2] + B[2]]:
    print("Yes")
else:print("No")

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <cmath>
#include <cstdio>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif


void solve() {
    int A, B;
    cin >> A >> B;
    int answer = 0;
    for (int i = A; i <= B; ++i) {
        string x = to_string(i);
        auto n = x.size();
        bool ok = true;
        for (size_t p = 0; p < n / 2; p++) {
            if (x[p] != x[n - p - 1]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            answer++;
        }
    }
    cout << answer << '\n';
}


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(i,low,up) for(register int i = low;i <= up; ++i)
#define nfr(i,low,up) for(register int i = low;i >= up; --i)
typedef long long ll;
const int N = 1e5+100;
int n,q;
ll m;

int fa[N];
inline int find(int x){
   return fa[x] == x ? x : fa[x] = find(fa[x]);
}

struct query{
   int u,v,c;
   bool operator < (const query &b) const {
      return c < b.c;
   }
}t[N];

int vis[N];
int bel[N];

int main(){
   scanf("%d%lld%d",&n,&m,&q);
   fr(i,1,q){
      scanf("%d%d%d",&t[i].u,&t[i].v,&t[i].c);
      ++t[i].u; ++t[i].v;
   }
   fr(i,1,n)fa[i] = i;
   sort(t+1,t+q+1);
   fr(i,1,q){
      if(t[i].c == 0){
         if(find(t[i].u) == find(t[i].v))continue ;
         fa[find(t[i].u)] = find(t[i].v);
      } else {
         if(find(t[i].u) == find(t[i].v)){
            puts("No"); return 0;
         }
         vis[find(t[i].u)] = vis[find(t[i].v)] = 1;
      }
   }
   int cnt = 0,cnt2 = 0;
   fr(i,1,n){
      if(!bel[find(i)])++cnt,bel[fa[i]] = 1;
      if(vis[i])++cnt2;
   }
   m -= n-cnt;
   if(cnt == 2 && cnt2 == 2){
      puts("No"); return 0;
   } else if(cnt2 == 2){
      cnt2 = 3;
   }
   if(m < cnt2){
      puts("No"); return 0;
   } else if(m > 1LL*cnt*(cnt-1)/2){
      puts("No"); return 0;
   }
   puts("Yes"); return 0;
}


Measured memory_bytes: 2560
alf=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
C=input()
counter=1
for i in alf:
    if i==C:
        ans=alf[counter]
    counter=counter+1
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n+1];
        for (int i=1;i<=n;i++)a[i]=sc.nextInt();
        int[] steps = new int[n+1];
        int cur=1 , d=1;
        while (k>0){
            int next = a[cur];
            if (steps[cur]>0){
                int m = d - steps[cur];
                k = (k-1)%m+1;
            }
            steps[cur]=d++;
            k--;
            cur = next;
        }
        System.out.println(cur);
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	string s;cin>>s;
	int cw=0,ce=0;
	int sumw[n],sume[n];
	mem(sumw,0);mem(sume,0);
	if(s[0]=='W'){
		sumw[0]=1;
		sume[0]=0;
	}
	else{
		sumw[0]=0;
		sume[0]=1;
	}
	rep(i,n){
		if(s[i]=='W'){
			cw++;
		}
		else {ce++;}
	}
	for(int i=1;i<n;++i){
		if(s[i]=='W'){
			sumw[i]=sumw[i-1]+1;
			sume[i]=sume[i-1];
		}
		else{
			sumw[i]=sumw[i-1];
			sume[i]=sume[i-1]+1;
		}
	}
	int ans=1000000;
	rep(i,n){
		if(i==0){
			ans=min(ans,ce-sume[0]);
		}
		ans=min(ce-sume[i]+sumw[i-1],ans);
		if(i==n-1){
			ans=min(ans,sumw[i-1]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std ;
const int A_MAX = 1000005 ; 

int main() {
  int N ; 
  cin >> N ; 
  vector<int> A(A_MAX+1) ;
  vector<int> C(A_MAX+1), cnt(A_MAX+1); 
  
  for(int i = 1 ; i <= N ; i++) {
    cin >> A.at(i) ; 
    C.at(A.at(i))++ ; 
  } 
  
  int ans = 0 ; 

  for(int i = 1 ; i <= A_MAX ; i++){
    for(int j = i ; j <= A_MAX ; j += i ){
      cnt.at(j) += C.at(i)   ;
    }
  }
  
  for(int i = 1 ; i <= A_MAX ; i++ ){
    if(cnt.at(i) == 1 && C.at(i) ){
      ans += C.at(i) ; 
    }
  }
  
  cout << ans << endl ; 
  
}

Measured memory_bytes: 14868
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h, w, m = LI()
bomb = defaultdict(lambda : 0)
cnt_h = [0] * h
cnt_w = [0] * w
for _ in range(m):
    H, W = LI()
    bomb[(H-1, W-1)] = 1
    cnt_h[H-1] += 1
    cnt_w[W-1] += 1

m_h = max(cnt_h)
m_w = max(cnt_w)
H_l = defaultdict(int)
W_l = defaultdict(int)
for i in range(h):
    if cnt_h[i] == m_h:
        H_l[i] = 1

for i in range(w):
    if cnt_w[i] == m_w:
        W_l[i] = 1

ans = m_h + m_w

for i in H_l.keys():
    for j in W_l.keys():
        if bomb[(i, j)] == 0:
            print(ans)
            quit()

print(ans-1)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    string s;
    cin >> s;
    int year = stoi(s.substr(0,4));
    int month = stoi(s.substr(5,6));
    int day = stoi(s.substr(8,9));
    if(year < 2019 || year == 2019 && month <= 4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
nm = input().split()
n = int(nm[0])
m = int(nm[1])
lr = [input().split() for i in range(m)]
l = [int(lr[i][0]) for i in range(m)]
r = [int(lr[i][1]) for i in range(m)]
a = min(r) -max(l) + 1
if a >= 0:
  print(a)
else:
  print(0)

Measured memory_bytes: 40164
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;

typedef long double ld;

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll H,W;
    cin>>H>>W;
    
    ll d = H*W;
    
    if(H==1 || W==1)
    {
		cout<<1<<endl;return 0;
	} 
    d++;
    cout<<(d/2)<<endl;
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());

        if(n % 2 == 0)
        {
            Console.WriteLine("-1");
        }
        else
        {
            var ans = 0;
            var rem = 0;
            var current = 0;
            var currentDigit = 1;
            for (var i = 1;i <= 1000000; i++)
            {
                if(currentDigit == 1)
                {
                    if(7 % n == 0)
                    {
                        ans = 1;
                        break;
                    }
                    current = 7 % n;
                    currentDigit += 1;
                    rem = 7 % n;
                }
                else
                {
                    if ((rem + ((current * (10 % n))) % n) % n == 0)
                    {
                        ans = currentDigit;
                        break;
                    }
                    rem = (rem + ((current * (10 % n))) % n) % n;
                    current = (current * (10 % n)) % n;
                    currentDigit += 1;
                }
            }
            if(ans == 0)
            {
                ans = -1;
            }

            Console.WriteLine(ans);
        }



        Console.ReadLine();
    }


}




Measured memory_bytes: 17688
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n,k; cin >> n >> k;
    vector<double> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int ans = 100000000000000;

    sort(a.begin(),a.end(),greater<int>());

    int count;

    int l = 1,r = a.at(0) + 1;
    int mid;
    while(l != r){
        count = 0;
        mid = (l+r) / 2;
        for(int i = 0;i < n;i ++){
            int tmp = ((a.at(i)/(double)mid)-0.000000000001);
            count += tmp;
            //cout << mid << " " << ((a.at(i)/(float)mid)-0.000000000001) << endl;
        }

        if(count <= k){
            ans = min(ans,mid);
        }

        if(count <= k) r = mid;
        else l = mid + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
//#include <bits/stdc++.h>
using namespace std;
double pi=3.14159265358979323846264338;

const int dx[4]={0,-1,1,0};
const int dy[4]={-1,0,0,1};
int ty[4];
int tx[4];
bool ok[4];
long long ans,ans2,ind,ind2;
int n,m;
const int ad='A'-'a';
bool issqt(int k){
	if(k==1)return true;
	int s=(int)(sqrt(k)+0.00001);
	if(s*s==k)return true;
	return false;
}
string s;

int arr[20001];

int cnt;
void dfs(int cur){
	for(int i=0;i<n;i++){
		if(arr[i]==0){
			arr[i]=cur;
			
			dfs(cur+1);
			arr[i]=0;
			return;
		}
		if(issqt(arr[i]+cur)){
			int l=arr[i];
			arr[i]=cur;
			
			
			dfs(cur+1);
			arr[i]=l;
		}
	}
	cnt=max(cnt,cur-1);
	return;
}
int main() {
	int n;
	cin>>n;
	for(int i=0;i<20001;i++)arr[i]=0;
	for(int a=2;a<120;a++)
		for(int b=a;b<120;b++){
			if(a*a+b*b>20000)break;
			for(int c=b;c<120;c++){
				int cur=a*a+b*b+c*c;
				if(cur>20000)break;
				if((a+b+c)%2==1)continue;
				if(a+b<c+2)continue;
				if(a==b&&b==c){
					arr[cur]++;
					continue;
				}
				if(a==b||b==c){
					arr[cur]+=3;
					continue;
				}
				arr[cur]+=6;
			}
		}
	for(int i=2;i<=2*n;i+=2)cout<<arr[i]<<endl;
  return 0;
}




Measured memory_bytes: 3600
#include <stdio.h>

int main(void)
{
	int i, n;
	int a, b, c, d, e, f, g, h, j;
	
	n = 1;
	a = 1;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 1, n, a);
		n++;
		a += 1;
	}
	
	n = 1;
	b = 2;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 2, n, b);
		n++;
		b += 2;
	}
	
	n = 1;
	c = 3;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 3, n, c);
		n++;
		c += 3;
	}
	
	n = 1;
	d = 4;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 4, n, d);
		n++;
		d += 4;
	}
	
	n = 1;
	e = 5;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 5, n, e);
		n++;
		e += 5;
	}
	
	n = 1;
	f = 6;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 6, n, f);
		n++;
		f += 6;
	}
	
	n = 1;
	g = 7;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 7, n, g);
		n++;
		g += 7;
	}
	
	n = 1;
	h = 8;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 8, n, h);
		n++;
		h += 8;
	}
	
	n = 1;
	j = 9;
	
	for (i = 0; i < 9; i++){
		printf("%dx%d=%d\n", 9, n, j);
		n++;
		j += 9;
	}
	
	return (0);
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> h(N, 0);
  REP(i, N){
    cin >> h[i];
  }
  int ans = 0;
  while(1){
    int m = 101, cnt = 0, start = 0;
    REP(i, N){
      if(h[i] != 0){
        m = min(m, h[i]);
      }
      if(h[i] == 0 || i == N-1){
        ans += (m == 101 ? 0 : m);
        cnt++;
        for(int j = start; j < i+1; j++){
          h[j] = (h[j] - m < 0 ? 0 : h[j] - m);
        }
        start = i+1;
        m = 101;
      }
    }
    if(cnt == N) break;
  }
  cout << ans << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << "( (L" << __LINE__ << ")" << endl;
using namespace std;

#define ll long long

ll n,m;
string s;
int main() {
    priority_queue<ll> q;
    cin >> n;
    cout << fixed << n + n*n + n*n*n;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    rep(i, N) {
        cin >> S[i];
        if (S[i] == "AC") {
            ac += 1;
        } else if (S[i] == "WA") {
            wa += 1;
        } else if (S[i] == "TLE") {
            tle += 1;
        } else if (S[i] == "RE") {
            re += 1;
        }
    }
    cout << "AC" << " " << "x" << " " << ac << endl;
    cout << "WA" << " " << "x" << " " << wa << endl;
    cout << "TLE" << " " << "x" << " " << tle << endl;
    cout << "RE" << " " << "x" << " " << re << endl;
    return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

	ll n;
	cin>>n;
	ll a[n] = {0};
	map<ll, ll> mp;
	for(int i=1;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<mp[i]<<"\n";
	}
	
	return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int len=s.length(),f=0;
    for(int i=0;i<len;i++)
    {
        if(s[i]=='U'||s[i]=='D')
            continue;
        else
        {
            if((i+1)%2==0 && s[i]!='L')
            {
                f=1;
                break;
            }
            if((i+1)%2!=0 && s[i]!='R')
            {
                f=1;
                break;
            }
        }
    }
    if(f)
        cout<<"No"<<'\n';
    else
        cout<<"Yes"<<'\n';

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr ll BIG = 1e16;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N;
    cin >> N;
    vll A(N+1);
    for (int i=0;i<=N;i++) cin >> A[i];

    vll caps(N+1, 0);
    caps[0] = 1 - A[0];
    if(caps[0] < 0) {
        cout << -1 << endl;
        return 0;
    }
    for (int i=1;i<=N;i++) {
        caps[i] = 2*caps[i-1] - A[i];
        if (caps[i] > BIG) caps[i] = BIG;
        if (caps[i] < 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll numv = 0;
    vll lsizes(N+1, 0);
    for (int i=N;i>=0;i--) {
        lsizes[i] = A[i];
    }

    for (int i=N;i>=0;i--) {
        if (i > 0) {
            lsizes[i-1] += min(lsizes[i], caps[i-1]);
        }
    }
    lsizes[0] = 1;
    for (int i=0;i<=N;i++) numv += lsizes[i];

    // for (int i=0;i<=N;i++) cout << lsizes[i] << " ";
    // cout << endl;

    cout << numv << endl;


    return 0;
}

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

public class Main {
    public static void main(String args[]) throws IOException{
        process();
    }
    public static void process() throws IOException{
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        int k=Integer.parseInt(in.readLine());
        String str=in.readLine();
        int n=str.length();
        if(n<=k)
            System.out.println(str);
        else
            System.out.println(str.substring(0,k)+"...");
    }
}


Measured memory_bytes: 25376
#include<stdio.h>
#include<string.h>

void irekae(int n,char s[]);

int main(void)
{
        int n,i,j;
        char s[102],t[102];

        scanf("%s",s);
        scanf("%s",t);

        n = strlen(s);

        for(i=0;i<n;i++){
                if(s[i]!=t[i])
                        break;
        }
        if(i==n){
                printf("Yes\n");
                return 0;
        }

        for(i=0;i<n;i++){
                irekae(n,s);
                for(j=0;j<n;j++){
                        if(s[j]!=t[j])
                                break;
                }
                if(j==n){
                        printf("Yes\n");
                        return 0;
                }
        }

        printf("No\n");
        return 0;
}
void irekae(int n,char s[])
{
        int i;
        char tmp,tmpp,a;
        a = s[n-1];

        tmp = s[0];
        for(i=1;i<n;i++){
                tmpp = s[i];
                s[i] = tmp;
                tmp = tmpp;
        }

        s[0] = a;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}



const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    int x,y;
    cin >> x >> y;
    bool flag = false;
    if (2*x<=y&&4*x>=y&&y%2==0) {
        flag = true;
    }
    Yes(flag);
}


Measured memory_bytes: 3576
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int X = line[0];
            int t = line[1];
            Console.WriteLine(X >= t ? X - t : 0);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

int main(void){
	int card[15],cards[5];
	int a[5];
	int b;
	bool y=false;
	while(~scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])){
		for(b=0;b<=14;b++){
			card[b]=0;
		}
		for(b=0;b<=4;b++){
			cards[b]=0;
		}
		y=false;
		for(b=0;b<=4;b++){
			card[a[b]]+=1;
		}
		for(b=0;b<14;b++){
			cards[card[b]]+=1;
		}
		if(cards[4]==1)cout << "four card" << endl;
		else if(cards[3]==1 && cards[2]==1)cout << "full house" << endl;
		else if(cards[3]==1)cout << "three card" << endl;
		else if(cards[2]==2)cout << "two pair" << endl;
		else if(cards[2]==1)cout << "one pair" << endl;
		else{
			if(card[1]==1 && card[10]==1 && card[11]==1 && card[12]==1 && card[13]==1)cout << "straight" << endl,y=true;
			for(b=1;b<=9;b++){
				if(card[b]==1 && card[b+1]==1 && card[b+2]==1 && card[b+3]==1 && card[b+4]==1){
					cout << "straight" << endl;
					y=true;
				}
			}
			if(y==false)cout << "null" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
vector<pair<long long, pair<long long, long long>>> quotient_ranges(long long N){
  vector<pair<long long, pair<long long, long long>>> ans;
  for (long long i = 1; i * i <= N; i++){
    ans.push_back(make_pair(N / i, make_pair(i, i)));
  }
  for (long long i = N / ((long long) sqrt(N) + 1); i >= 1; i--){
    ans.push_back(make_pair(i, make_pair(N / (i + 1) + 1, N / i)));
  }
  return ans;
}
int main(){
  long long N;
  int K;
  cin >> N >> K;
  vector<pair<long long, pair<long long, long long>>> A = quotient_ranges(N);
  int cnt = A.size();
  vector<vector<long long>> dp(K, vector<long long>(cnt, 0));
  for (int i = 0; i < cnt - 1; i++){
    dp[0][i] = A[i].first - A[i + 1].first;
  }
  dp[0][cnt - 1] = 1;
  for (int i = 0; i < K - 1; i++){
    int k = cnt - 1;
    long long sum = 0;
    for (int j = 0; j < cnt; j++){
      if (k >= 0){
        while ((long long) A[j].first * A[k].first <= N){
          sum += dp[i][k];
          sum %= MOD;
          k--;
          if (k < 0){
            break;
          }
        }
      }
      dp[i + 1][j] += sum * dp[0][j];
      dp[i + 1][j] %= MOD;
    }
  }
  long long ans = 0;
  for (int i = 0; i < cnt; i++){
    ans += dp[K - 1][i];
  }
  ans %= MOD;
  cout << ans << endl;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

int n, k;
int a[222222];
pair<long long, int> b[222222];
int bit[222222];

int que(int x){
	int an = 0;
	for(int i = x; i > 0; i -= (i & -i))
		an += bit[i];
	return an;
}

void upd(int x){
	for(int i = x; i <= n + 1; i += (i & -i))
		++bit[i];
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&k);
	for(int i = 0; i < n; ++i) scanf("%d",&a[i]);
	b[0].second = 1;
	for(int i = 1; i <= n; ++i){
		b[i].second = i + 1;
		b[i].first = b[i - 1].first - k + a[i - 1];
	}
	sort(b, b + n + 1);
	long long an = 0;
	for(int i = 0; i <= n; ++i){
		an += que(b[i].second - 1);
		upd(b[i].second);
	}
	printf("%lld",an);
	return 0;
}

Measured memory_bytes: 4992
def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    min = 1000

    for i in range(-50, 150):

        if i in p:
            continue

        elif min > abs(x - i):
            result = i
            min = abs(x - i)

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
#include<iostream>
using namespace std;
int main(){
  long long sum=0;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
  }
  cout<<sum<<endl;
  return(0);
}

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

namespace abc175_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = CIn.ReadLong();
            var K = CIn.ReadLong();
            var D = CIn.ReadLong();
            var x = Math.Abs(X);
            if(x / D >= K )
            {
                Console.WriteLine(x - K * D);
            }
            else
            {
                if(K % 2 == x / D % 2)
                {
                    Console.WriteLine(Math.Abs(x % D));
                }
                else
                {
                    Console.WriteLine(Math.Abs(x % D - D));
                }
            }
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


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

int main()
{
long int H,N;
  cin>>H>>N;
  long int A[N],i,tot=0;
  for(i=0;i<N;++i)
  {
    cin>>A[i];
    tot+=A[i];
  }
  if(tot>=H)
  {
  cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int N;
    string ans = "";
    cin >> N;
    vector <int> a(N+1, 0);

    for (int i = 1; i <= N; i++) cin >> a[i];

    if (N % 2){
        for (int i = N; i >= 1; i-=2) {
            cout << a[i] << " ";
        }
        for (int i = 2; i <= N-1; i+=2){
            cout << a[i] << " ";
        }
        cout << endl;
    }
    else{
        for (int i = N; i >= 2; i-=2) {
            cout << a[i] << " ";
        }
        for (int i = 1; i <= N; i+=2) {
            cout << a[i] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc2(char c, int k, string s) {
    int n = cast(int)s.length;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            if (i > 0 && s[i-1] == 'L') ans++;
        }
        else if (s[i] == 'R') {
            if (i + 1 < n && s[i + 1] == 'R') ans++;
        }
    }

    int[] ss;
    int[] t;
    for (int i = 0; i < n; i++) {
        if (s[i] == c) {
            if (i == 0) {
                t ~= 0;
            }

            if (i == n - 1) {
                t ~= 0;
            }

            if (i > 0 && s[i - 1] != c) t ~= 1;
            if (i + 1 < n && s[i + 1] != c) t ~= 1;

            if (t.length == 2) {
                ss ~= t.sum;
                t = [];
            }
        }
    }

    ss.sort();
    ss.reverse();
    return ss.take(k).sum + ans;
}

int calc(int k, string s) {
    int n = cast(int)s.length;
    return max(calc2('L', k, s.dup), calc2('R', k, s.dup));
}

void main() {
    int n, k; scan(n, k);
    string s = read!string;
    writeln(calc(k, s));
}


Measured memory_bytes: 3324
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    ll mod = pow(10, 9) + 7;
    string s;
    cin >> s;
    ll dp[s.size()][4] = {};

    if (s[0] == 'A') {
        dp[0][0] = 1;
        dp[0][1] = 1;
    } else if (s[0] == '?') {
        dp[0][0] = 3;
        dp[0][1] = 1;
    } else {
        dp[0][0] = 1;
    }
    rep(j, 4) { dp[0][j] %= mod; }

    repd(i, 1, s.size()) {
        dp[i][0] = dp[i - 1][0];
        dp[i][1] = dp[i - 1][1];
        dp[i][2] = dp[i - 1][2];
        dp[i][3] = dp[i - 1][3];
        if (s[i] == 'A') {
            dp[i][1] += dp[i - 1][0];
        }
        if (s[i] == 'B') {
            dp[i][2] += dp[i - 1][1];
        }
        if (s[i] == 'C') {
            dp[i][3] += dp[i - 1][2];
        }
        if (s[i] == '?') {
            dp[i][0] = dp[i - 1][0] * 3;
            dp[i][1] = dp[i - 1][1] * 3 + dp[i - 1][0];
            dp[i][2] = dp[i - 1][2] * 3 + dp[i - 1][1];
            dp[i][3] = dp[i - 1][3] * 3 + dp[i - 1][2];
        }

        rep(j, 4) { dp[i][j] %= mod; }
    }

    cout << dp[s.size() - 1][3] << endl;
    return 0;
}

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

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

int main()
{
	string str;
	int ans = 0;

	while (cin >> str){
		int num = 0;
		for (int i = 0; i < str.size(); i++){
			if ('0' <= str[i] && str[i] <= '9'){
				num *= 10;
				num += str[i] - '0';
			}
			else {
				ans += num;
				num = 0;
			}
		}
		ans += num;
	}

	cout << ans << endl;

	return (0);
}

Measured memory_bytes: 1184
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;

void main()
{
    long n = to!long(readln().chomp());
    long[] a = readln().split().map!(to!long).array;
    for (long i = 0; i < a.length; ++i)
    {
        a[i] -= i + 1;
    }
    // stderr.writeln(a);
    // auto c = a.dup;
    // sort(c);
    // c = c.uniq.array;
    // foreach (b; c)
    // {
    //     stderr.writeln(b, ":", a.map!(e => abs(e - b)).sum);
    //     m = min(m, a.map!(e => abs(e - b)).sum);
    // }
    // int[int] mode;
    // foreach (e; a)
    // {
    //     auto l = e in mode;
    //     if (l)
    //     {
    //         ++mode[e];
    //     }
    //     else
    //     {
    //         mode[e] = 1;
    //     }
    // }
    // auto r = mode.byKeyValue.array.sort!((a, b) => a.value < b.value);
    // auto maxCount = r[0].value;
    // foreach (e; r)
    // {
    //     auto b = e.key;
    //     if (e.value < maxCount)
    //     {
    //         break;
    //     }
    //     stderr.writeln(b, ":", a.map!(e => abs(e - b)).sum);
    //     m = min(m, a.map!(e => abs(e - b)).sum);
    // }
    long m = long.max;
    sort(a);
    if (a.length % 2 == 0)
    {
        double median = (a[to!long(floor(a.length / 2.0))] + a[to!long(ceil(a
                .length / 2.0))]) / 2.0;
        long downer = to!long(floor(median));
        long upper = to!long(ceil(median));
        long b = downer;
        m = min(m, a.map!(e => abs(e - b)).sum);
        b = upper;
        m = min(m, a.map!(e => abs(e - b)).sum);
    }
    else
    {
        long b = a[to!long(floor(a.length / 2.0))];
        m = min(m, a.map!(e => abs(e - b)).sum);
    }
    // sort(a);
    // long b = a[n / 2];
    writeln(m);
}


Measured memory_bytes: 11608
#include <iostream>
#include <fstream>
#include <queue>

using namespace std;

int main()
{
#ifdef LOCAL
    ifstream cin("input.txt");
    ofstream cout("output.txt");
#else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#endif // LOCAL
    string s;
    cin >> s;
    vector<char> q;
    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == 'T' && q.size() != 0 && q.back() == 'S')
        {
            q.pop_back();
        }
        else
        {
            q.push_back(s[i]);
        }
    }
    cout << q.size();
    cout << "\n";
#ifdef LOCAL
    cin.close();
    cout.close();
#endif // LOCAL
    return 0;
}


Measured memory_bytes: 788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<(n*(n+1))/2<<endl;
}


Measured memory_bytes: 256