akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int length, no_of_moves;
    string S;
    cin >>  length >> no_of_moves >> S; //cout << S<< endl;

    int current_length = 0;
    vector <int> segment_lengths;
    for(int i = 0; i < length; i++)
    {
        if(i == 0 || S[i] == S[i - 1])
        {
            current_length++;
        }
        else
        {
            segment_lengths.push_back(current_length);

            current_length = 1;
        }
    }

    segment_lengths.push_back(current_length);

    vector <int> happiness_till(segment_lengths.size(), 0);
    happiness_till[0] = segment_lengths[0] - 1; //cout << happiness_till[0] << endl;
    for(int i = 1; i < segment_lengths.size(); i++)
        happiness_till[i] = happiness_till[i - 1] + segment_lengths[i] - 1; //cout << happiness_till[i] << endl;}

    vector <int> happiness_from(segment_lengths.size(), 0);
    happiness_from[segment_lengths.size() - 1] = segment_lengths[segment_lengths.size() - 1] - 1;
    for(int i = segment_lengths.size() - 2; i > 0; i--)
        happiness_from[i] = happiness_from[i + 1] + segment_lengths[i] - 1;

    int segment_length = 2*no_of_moves + 1;
    int sum_here = 0, best_sum = 0, remaining_sum = 0;

    for(int i = 0; i < segment_lengths.size(); i++)
    {
        if(i < segment_length)
        {
            sum_here += segment_lengths[i];
        }
        else
        {
            sum_here += segment_lengths[i] - segment_lengths[i - segment_length];
        }

        remaining_sum = 0;

        if(i - segment_length - 1 >= 0)
            remaining_sum += happiness_till[i - segment_length - 1];

        if(i + 1 < segment_lengths.size())
                remaining_sum += happiness_from[i + 1]; //cout << "I = " << i << " sum = " << sum_here - 1 + remaining_sum << endl;

        best_sum = max(best_sum, sum_here - 1 + remaining_sum);
    }

    cout << best_sum;
    return 0;
}


Measured memory_bytes: 1656
def make_divisors(n:int) -> list:
    """約数を列挙"""
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

import math
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

A, B = map(int, input().split())
div_A = make_divisors(A)
div_B = make_divisors(B)
cd = (set(div_A) & set(div_B))
ans = 0
for n in cd:
    if isPrime(n):
        ans += 1
print(ans)

Measured memory_bytes: 11004
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{

    struct Pool
    {
        public int left;
        public int area;
    }

    
    class Program
    {

        

        static void Main(string[] args)
        {
            //入力1(L)
            string S = Console.ReadLine();

            int sum_area = 0;           
            Stack<int> st = new Stack<int>();
            Stack<Pool> pool_st = new Stack<Pool>();
            
            for(int i = 0; i < S.Length; i++)
            {
                if(S[i] == '\\')
                {
                    st.Push(i);
                }
                else if(S[i] == '/')
                {
                    //対応する/があるので\と/の間に水がある
                    if(st.Count() != 0)
                    {
                        int j = st.Pop();
                        sum_area += (i - j);
                        int add_area = i - j;
                        while (pool_st.Count > 0 && j < pool_st.Peek().left)
                        {
                            add_area += pool_st.Pop().area;
                        }
                        pool_st.Push(new Pool() { left = j, area = add_area });
                    }
                    
                }
            }

            Console.WriteLine(sum_area);
            Console.Write($"{pool_st.Count}");
            foreach(var s in pool_st.Reverse())
            {
                Console.Write($" {s.area}");
            }
            Console.WriteLine();
        }
    }

}


Measured memory_bytes: 20756
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  vector<pair<ll, ll>> dpm(n+1), dps(n+1);
  dpm[0] = {1000, 0};
  dps[0] = {0, 1000};
  for (int i = 1; i <= n; i++) {
    dpm[i] = dpm[i-1];
    dps[i] = dps[i-1];
    ll stock, money;
    tie(stock, money) = dps[i-1];
    chmax(dpm[i], {money+stock*a[i-1], 0});
    tie(money, stock) = dpm[i-1];
    chmax(dps[i], {stock+money/a[i-1], money%a[i-1]});
  }
  cout << dpm[n].first << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,A[1000];
  cin >>n;
  for(int i=0; i<n; i++){
    cin >>A[i];}
  for(int i=(n-1); i>=0; i--){
    cout <<A[i];
    if(i==0) break;
    else cout<<" ";}
  cout <<endl;
}


Measured memory_bytes: 3096
#include <iostream>

int main(){
	int b1,b2,b3;
	std::cin>>b1>>b2>>b3;
	if(b1==b2 && b1==1 || b3==1)std::cout<<"Open"<<std::endl;
	else std::cout<<"Close"<<std::endl;
	return 0;
}

Measured memory_bytes: 1156
import math

N,M = map(int,input().split())

factors = []

for i in range(1,int(math.sqrt(M))+10):
	if M % i == 0:
		factors.append(i)
		factors.append(M//i)

ans = 1
for i in factors:
	if N <= M // i:
		ans = max(i,ans)
print(ans)
	

Measured memory_bytes: 3060
def primes(n):
	is_prime = [True] * (n+1)
	is_prime[0] = False
	is_prime[1] = False
	for i in range(2, int(n**0.5)+1):
		if not is_prime[i]:
			continue
		for j in range(i*2, n+1, i):
			is_prime[j] = False
	return [i for i in range(n+1) if is_prime[i]]

N=int(input())
ans=[]
prime_numbers=primes(55555)
while True:
    cnt=0
    for n in prime_numbers:
        if n%5==1:
            ans.append(n)
            cnt+=1
        if cnt==N:
            break
    break
print(*ans)

Measured memory_bytes: 3572
#include<iostream>
#include<math.h>
using namespace std;
bool n[1000000]={0};
bool prime(int n){
	for(int i=2;i<=sqrt ((double)n);i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	for(int k=2;k<=999999;k++){
		if(prime(k))n[k]=true;
	}


	int a,sum=0;
	while(cin>>a){
	for(int j=2;j<=a;j++){
		if(n[j])sum++;
	}
	cout<<sum<<endl;
	sum=0;
	}
}

Measured memory_bytes: 1844
n = int(input())
numbers = list(map(int,input().split()))
 
def aaa(numbers):
    if len(numbers) > 1:
        numbers.sort()
        new_number = (numbers[0] + numbers[1]) / 2
        n_0 = numbers[0]
        n_1 = numbers[1]
        numbers.remove(n_0)
        numbers.remove(n_1)
        numbers.append(new_number)
        aaa(numbers)
    else:
        return numbers[0]
      
aaa(numbers)
print(aaa(numbers))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<double,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;


int main(){
    LL N;
    cin >> N;
    for(LL h=1;h<=3500;h++){
        for(LL w=1;w<=3500;w++){
            LL t=N*w*h;
            if(4*h*w-N*w-N*h<=0) continue;
            if(t%(4*h*w-N*w-N*h)==0){
                cout << h << " " << w << " " << t/(4*h*w-N*w-N*h) << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#include <iomanip>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }


int main(){
int A,B;
cin >> A >> B;
if(A>=13)cout << B << endl;
else if(A>=6&&A<=12)cout << B/2 << endl;
else cout << 0 << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  std::string S;
  std::cin >> S;
  bool ans = false;
  for (int i=0; i<S.length(); i++){
    if (S[i]=='7'){
      ans = true;
    }
  }
  printf("%s\n", ans?"Yes":"No");
  return 0;
}


Measured memory_bytes: 3040
#include<stdio.h>
int main(void)
{
	int h,i,j,k,n,b,f,r,v,room[4+1][3+1][10+1];
	scanf("%d",&n);
	for(i=1;i<=4;i++) {
		for(j=1;j<=3;j++) {
			for(k=1;k<=10;k++) {
				room[i][j][k]=0;
			}
		}
	}
	for(h=1;h<=n;h++) {
		scanf("%d %d %d %d",&b,&f,&r,&v);
		room[b][f][r]+=v;
	}
	for(i=1;i<=4;i++) {
		for(j=1;j<=3;j++) {
			for(k=1;k<=10;k++) {
				if(k!=10) {
					printf(" %d",room[i][j][k]);
				}
				else {
					printf(" %d\n",room[i][j][k]);
				}
			}
		}
		if(i!=4) {
			printf("####################\n");
		}
	}
	return 0;
}

Measured memory_bytes: 608
/*
 * main.c
 *
 *  Created on: 2019/03/09
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int H, W, h, w;
	int remain = 0;
	scanf("%d %d", &H, &W);
	scanf("%d %d", &h, &w);

	remain = H * W;
	remain -= (W * h);
	remain -= ((H - h) * w);
	printf("%d\n",remain);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;

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

    int maxv = -1000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;
    return 0;
}



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

#define COUT(x) cout << #x << " = " << (x) << ", "
typedef long long ll;
const int MOD = 1000000007;

int N;
struct node{
  int num;
  int rank;
  int amt;
  struct node* ptr;
};
vector<node> G;

void init(){
  for(int i = 0; i < N; i++){
    G[i].num = i;
    G[i].ptr = NULL;
    G[i].rank = 1;
    G[i].amt = 1;
  }
}

int idx(int x){
  if(G[x].ptr == NULL){
    return x;
  }
  int tmp = idx(G[x].ptr->num);
  G[x].ptr = &G[tmp];
  return tmp;
}

int amount(int x){
  return G[idx(x)].amt;
}

void unite(int x, int y){
  if(idx(x) == idx(y)){
    return;
  }
  if(G[idx(x)].rank > G[idx(y)].rank){
    int a = amount(x);
    int b = amount(y);
    G[idx(x)].ptr = &G[idx(y)];
    G[idx(y)].amt = a + b;
    G[idx(x)].amt = a + b;
  }else if(G[idx(x)].rank == G[idx(y)].rank){
    int a = amount(x);
    int b = amount(y);
    G[idx(x)].ptr = &G[idx(y)];
    G[idx(y)].amt = a + b;
    G[idx(x)].amt = a + b;
    G[idx(y)].rank++;
  }else{
    int a = amount(x);
    int b = amount(y);
    G[idx(y)].ptr = &G[idx(x)];
    G[idx(y)].amt = a + b;
    G[idx(x)].amt = a + b;
  }
  // cout << "unite" << x << " " << y << " " << idx(x) << " " << idx(y) << endl;
  return;
}

int main(){
  int M,K;
  cin >> N >> M >> K;
  G.resize(N);
  vector<int> F[N];
  init();
  for(int i = 0; i < M; i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    F[a].push_back(b);
    F[b].push_back(a);
    unite(a, b);
  }
  vector<int> B[N];
  for(int i = 0; i < K; i++){
    int c,d;
    cin >> c >> d;
    c--; d--;
    B[c].push_back(d);
    B[d].push_back(c);
  }
  for(int i = 0; i < N; i++){
    int tmp = amount(i);
    tmp -= F[i].size();
    for(auto x: B[i]){
      if(idx(x) == idx(i)){
	tmp--;
      }
    }
    tmp--;
    cout << tmp << " ";
  }
  cout << endl;
}


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


int main(){

    int N;
    cin >> N;


    vector<int> S;
    
    do{
        if( N%(-2) == 0 || N%(-2) == 1 ){
            S.push_back( N%(-2) );
            N /= -2;
        }else if( N%(-2) == -1 ){
            S.push_back( N%(-2) + 2 );
            N = N/(-2) + 1;
        }
    }while( N != 0 );
    
    for( int i = S.size()-1; i >= 0; i-- ) cout << S[i];
    cout << endl;

    return 0;

}

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  int n;
  cin >> n;
  puts(n/3)
}


Measured memory_bytes: 256
N=int(input())
S=input()
n=[0]*(N+1)
for i in range(N):
    if S[i]=='#':
        n[i+1]=n[i]+1
    else:
        n[i+1]=n[i]
ans=min(n[-1],N-n[-1])
for i in range(N):
    ans=min(ans,N-i-(n[-1]-n[i])+n[i])
print(ans)

Measured memory_bytes: 11144
object Main extends App {
	override def main(args: Array[String]) = {
		val sc = new java.util.Scanner(System.in)
		
		val n = sc.nextInt
		
		val sb:StringBuilder = new StringBuilder("")
		(1 to n).filter(check).foreach{ x => print(" " + x )}
		println()
	}
	
	def check(x : Int):Boolean = {
		check_mod3(x) ||
		check_contains3(x)
	}
	
	def check_mod3(x :Int):Boolean = {
		x % 3 == 0
	}
	def check_contains3(x : Int):Boolean = {
		val mod = x % 10
		if(mod == 3){
			return true
		}
		if(x / 10 > 0){
			return check_contains3(x/10)
		}
		return false
	}
}

Measured memory_bytes: 47008
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
const ll INF = 1 << 30;
#define mod 1000000007
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
int n, k;
int arr[100005];
int dp[1000005];
int rec(int x){
	if(dp[x] != -1)return dp[x];
	int check = 0;
	for(int i = 0; i < n; i++){
		if(x + arr[i] <= k){
			if(rec(x + arr[i]) == 0)check = 1;
		}
	}
	return dp[x] = check;
}
int main(){

cin>>n>>k;
for(int i = 0 ; i<n ; i++)cin>>arr[i];
for(int i = 0 ; i<=k ; i++)dp[i]=-1;
if(rec(0)==1){
    cout<<"First";
}
else{
    cout<<"Second";
}
return 0 ;
}




Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace std;
const int N=2e5+5,mod=(int)1e9+7;
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    int n,a[105]= {};
    cin>>n;
    lp(i,1,n)
    cin>>a[i];
    int fans=10000000;
    lp(j,-100,100)
    {   
        int ans=0;
        lp(i,1,n)
        ans+=((a[i]-j)*(a[i]-j));
        fans=min(ans,fans);
    }
    cout<<fans<<"\n";
    return 0;
}

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

int func(int x){
  if(x%2 != 0)
    return 0;
  return func(x/2) + 1;
}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    ans += func(a);
  }
  
  cout << ans << endl;
  
  return 0;
  
}
  
  


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		String s = fs.next();
		int cnt = 0;
		for(int i=0;i<n-2;i++) {
			if(s.substring(i,i+3).equals("ABC"))cnt++;
		}
		System.out.println(cnt);
	}
}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

ll powmod(ll x, ll n) {
    ll res = 1;
    if (n > 0) {
        res = powmod(x, n / 2);
        if (n % 2 == 0) {
            res = (res * res) % MOD;
        } else {
            res = (((res * res) % MOD) * x) % MOD;
        }
    }

    return res;
}

int main() {
    int M, N; cin >> M >> N;

    cout << powmod(M, N) << endl;
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s; cin>>s;
	int ln=s.length();
	int res=0,carry=0;
	for(int i=ln-1;i>=0;i--){

		int c=s[i]-'0';

		if(carry){
			c+=1;
			carry=c/10;
			c%=10;
		}

		if(c>=6){
			res+=(10-c);
			carry=1;
		}

		else if(c==5){
			if(i-1>=0&&s[i-1]>='5'){
				res=res+(10-c);
				carry=1;
			}
			else
				res+=c;
		}
		else
			res+=c;

	}
	cout<<res+carry;
}


Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int x, y; cin >> x >> y;
	cout << x * y << endl;

	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,flag,i,dflag;
  cin >> N;

  flag = 0;
  dflag = 0;
   vector<int> vec(N);
for (i = 0; i < N; i++) {
  cin >> vec.at(i);
}
    for(i = 0; i < N; i++){
        if((vec.at(i) % 2) == 0){
            if((vec.at(i) % 3) == 0 || (vec.at(i) % 5) == 0 ){
                flag++;
            } else if((vec.at(i) % 3) != 0 && (vec.at(i) % 5) != 0){
                dflag++;
            }
        }
    }
    if((flag >= 0) && (dflag == 0)){
      cout << "APPROVED";
    } else{
        cout << "DENIED";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    string s;
    int i=0;
    cin>>s;
    string days[7]={"SUN","MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for(i=0;i<7;i++){
        if(s==days[i]){
            break;
        }
    }
    cout<<7-i;   
    return 0;
}

Measured memory_bytes: 256
q,h,s,d = [int(x) for x in input().split()]
n = int(input())
print(min(d,s<<1,h<<2,q<<3)*((n<<2)>>3)+min(s,h<<1,q<<2)*(((n<<2)&((1<<3)-1))>>2)+min(h,q<<1)*(((n<<2)&((1<<2)-1))>>1)+q*((n<<2)&((1<<1)-1)))


Measured memory_bytes: 38384
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int tmp = 0;
		int tmpsum = 0;
		int sum = 0;
		for(int i = 1; i <= n; i++){
			tmpsum = 0;
			tmp = i;
			for(int t = 0; t <= 4; t++){
				tmpsum = tmpsum + (tmp % 10);
				tmp = tmp/10;
			}
			if((tmpsum >= a) && (tmpsum <= b)){
				sum = sum + i;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 22228
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  for(j = 2; j <= n; j++){
    	key = A[j];
    for(i = j -1; i >= 1; i--){ 

	if(key < A[i]){
	A[i+1] = A[i];
	A[i] = key;
      }
    }
    trace(A, n);
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    for (auto &e : p) cin >> e;

    int ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (i + 1 == p[i]) {
            swap(p[i], p[i + 1]);
            ++ans;
        }
    }
    ans += p.back() == n;

    cout << ans << endl;
}



Measured memory_bytes: 3744
def find_divisor(x):
    Divisors = []
    for i in range(1, int(x**0.5) + 1):
        if x % i == 0:
            Divisors.append(i)
            if i != x // i:
                Divisors.append(x // i)
    return Divisors

n = int(input())
ways = len(find_divisor(n-1)) - 1
Div = find_divisor(n)
for i in range(1, len(Div)):
    quo = n
    while quo % Div[i] == 0:
        quo = quo // Div[i]
    if quo % Div[i] == 1:
        ways += 1
print(ways)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int N = 0;
int A[1000] = {0};
int flag = 1;

int chk_even(int a){
    if( (a%2) == 0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int chk_3(int a){
    if( (a%3) == 0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int chk_5(int a){
    if( (a%5) == 0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int main(void) {
    
    cin >> N;
  
  	for(int i=0; i<N; i++)
    {
        cin >> A[i];
    }
    
    for(int i=0; i<N; i++)
    {
        if(chk_even(A[i]) == 0 ) continue;
        
        if( (chk_3(A[i]) == 0) && (chk_5(A[i]) == 0) )
        {
            flag = 0;
        }
    }
    
    if( flag == 1 )
    {
        cout << "APPROVED";
    }
    else
    {
        cout << "DENIED";
    }
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(10);
    cout << pow((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2), 0.5) << endl;
}


Measured memory_bytes: 3408
#include <iostream>
#include <string>
using namespace std;
string st;
int main(){
	int i,j,k,n;
	cin>>st;
	n=st.length();
	for(i=0;i<n;i++){
		if(st[i]=='e'){
			if(st[i+1]=='r'&&st[i+2]=='a'&&st[i+3]=='s'&&st[i+4]=='e'){
				if(st[i+5]=='r')i+=5;
				else i+=4;
			}
		}
		else if(st[i]=='d'){
			if(st[i+1]=='r'&&st[i+2]=='e'&&st[i+3]=='a'&&st[i+4]=='m'){
				if(st[i+5]=='e'&&st[i+6]=='r'&&st[i+7]=='a'&&st[i+8]=='s'&&st[i+9]=='e')i+=4;
				else if(st[i+5]=='e'&&st[i+6]=='r')i+=6;
				else i+=4;
			}
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 512
A, B = map(int, input().split())
S = input()

ans = "Yes"
if len(S) != A+B+1:
  ans = "No"
for i, s in enumerate(S):
  if i == A:
    if s != '-':
      ans = "No"
  else:
    if not '0' <= s <= '9':
      ans = "No"
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
#include<cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pii> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}

bool warp[5][5];
int maze[3010][3010];
int cnt[3010][3010];
int h,w;
vector<string> s;
int c;
void dfs(int y,int x){
    cnt[y][x]=c;
    for(int i=0;i<4;++i){
        int ny=y+dy[i],nx=x+dx[i];
        if(!(ny>=0&&ny<h&&nx>=0&&ny<w)) continue;
        if(s[ny][nx]=='#') continue;
        if(cnt[y][x]>0) continue;
        dfs(ny,nx);
    }
}
int main(){
    int n,m,k;cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    for(int i=0;i<n;++i) cin>>a[i];
    for(int j=0;j<m;++j) cin>>b[j];
    for(int i=1;i<n;++i) a[i]+=a[i-1];
    for(int j=1;j<m;++j) b[j]+=b[j-1];
    int ans=0;
    for(int i=-1;i<n;++i){
        if(i!=-1&&a[i]>k) continue;
        int t=k-(i==-1?0:a[i]);
        int j=(int)(upper_bound(b.begin(),b.end(),t)-b.begin());
        ans=max(ans,i+j+1);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6396
n,k=gets.split.map &:to_i
a=gets.split.map &:to_i
dir=[]
if a.index(0)
  pt0=a.index(0)
  k-=1
else
  if a[0]>0
    pt0=0
    a.insert(0,0)
  elsif a[n-1]<0
    pt0=n
    a.insert(n,0)
  else
    (n-1).times do|i|
      if a[i]<0&&a[i+1]>0
        pt0=i+1
        a.insert(i+1,0)
        break
      end
    end
  end
  n+=1
end
n.times do|i|
  if i<pt0
    if pt0-i==k
      dir<<(-a[i])
    elsif pt0-i<k&&k+i<n
      dir<<(-a[i]*2+a[k+i])
    end
  elsif i>pt0
    if i-pt0==k
      dir<<a[i]
    elsif i-pt0<k&&i-k>0
      dir<<a[i]*2-a[i-k]
    end
  else
    k==0&&dir<<0
  end
end
puts dir.min


Measured memory_bytes: 11028
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    //cout << fixed << setprecision(0);
    int h,w,n;
    cin>>h>>w>>n;
    h=max(h,w);
    cout<<ceil(n/(1.0*h))<<endl;
}


Measured memory_bytes: 256
n, x, m = map(int, input().split())
A = []
al = [-1]*(m+1)
cnt = 0
for i in range(n):
    if al[x%m] >= 0:
        break
    al[x%m] = cnt
    A.append(x)
    cnt += 1   
    x = x**2 % m

if n <= al[x]:
    print(sum(A[:al[x]]))
    exit()

lena = len(A)
loop = A[al[x]:]
lenl = cnt-al[x]
n -= al[x]
cnt = n//lenl
print(sum(A[:al[x]]) + sum(loop)*cnt + sum(loop[:n%lenl]))

Measured memory_bytes: 14024
// fibonacci
#include<iostream>
#define MAX 50
long f(long);
long F[MAX],n;
int main(){
  long i;
  std::cin >> n;
  for(i=0; i<MAX; i++) F[i] = -1;
  std::cout << f(n) << "\n";
  return 0;
}
long f(long n){
  if(n == 1 || n == 0) return F[n] = 1;
  if(F[n] != -1) return F[n];
  return F[n] = f(n - 2) + f(n - 1);
}

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

#define rep(i, x, y) for (int i = (x), _ = (y); i <= _; ++i)
#define down(i, x, y) for (int i = (x), _ = (y); i >= _; --i)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define bin(x) (1 << (x))
//#define LX_JUDGE

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

template<typename T> inline void upmax(T &x, T y) { x < y ? x = y : 0; }
template<typename T> inline void upmin(T &x, T y) { x > y ? x = y : 0; }

const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;

int main() {
#ifdef LX_JUDGE
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 0;
	static int a[202];
	for (int i = 0; i < n * 2; ++i) {
		cin >> a[i];
	}
	sort(a, a + n * 2);
	for (int i = 0; i < n * 2; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){

	long long N,Enum,mini,gen;
	string S;

	cin >>N >> S;

	Enum=0;

	for(int i=0; i<N; i++){
		if(S[i] == 'E') Enum++;


	}

	gen=0;
	mini=999999999;

	gen = Enum;



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

		
		
		if(S[i] =='E')		mini =min(gen-1,mini);

		else mini =min(gen,mini);
//cout <<i <<" "<<mini <<endl;

		if(   S[i] == 'E'){

			gen--;

		}

		else gen++;

		

	}

	cout <<mini <<endl;


}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
int main(){
	int n,k,s;
	cin>>n>>k>>s;
	ifor(k)cout<<s<<" ";
	if(s<1000000000){
		n=n-k;
		ifor(n)cout<<s+1<<" ";
	}
	else{
		n=n-k;
		ifor(n)cout<<s-1<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
const int MAXN = 1e5 + 2;
vector<int> adj[MAXN*3];
int ans[MAXN*3];

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v+N);
        adj[u+N].push_back(v+2*N);
        adj[u+2*N].push_back(v);
    }
    int S, T; cin >> S >> T;
    memset(ans, -1, sizeof(ans));
    queue<int> q;
    ans[S] = 0;
    q.push(S);
    while (q.size()) {
        int u = q.front(); q.pop();
        for (auto x : adj[u]) {
            if (ans[x] != -1)  continue;
            ans[x] = ans[u]+1;
            q.push(x);
        }
    }
    cout << (ans[T] == -1 ? -1 : ans[T] / 3) << endl;
    return 0;
}


Measured memory_bytes: 21120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

signed main() {
    string S;
    cin >> S;
    
    set<char> T;
    rep(i, 4) T.insert(S[i]);
    if (T.size() != 2) {
        cout << "No" << endl;
        return 0;
    }
    int cnt = 0;
    rep(i, 4) if (S[0] == S[i]) ++cnt;
    if (cnt == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

X = lines[0][0]
Y = lines[0][1]
Z = lines[0][2]
K = lines[0][3]

def min(x,y)
  if x > y then
    return y
  else
    return x
  end
end

cake1 = lines[1].sort.reverse
cake2 = lines[2].sort.reverse
cake3 = lines[3].sort.reverse

cand = []
for i in 1..X do
  for j in 1..Y do
    cand.push(cake1[i-1] + cake2[j-1])
  end
end

cand.sort!.reverse!

cand2 = []
for i in 1..min(K,X*Y) do
  for j in 1..Z do
    cand2.push(cand[i-1] + cake3[j-1])
  end
end
  
cand2.sort!.reverse!
  
for i in 1..K do
  puts cand2[i-1]
end

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

double P, E, T;
 
double solve( int K, double R, double L ) {
  double H = ( R + L ) / 2.0;
  if ( K == 0 ) {
    if ( fabs( T - H ) < E )
      return 1.0;
    else
      return 0.0;
  }
 
  if ( R < T - E || T + E < L )
    return 0.0;
  else if ( T - E <= L && R <= T + E )
    return 1.0;
 
  if ( H <= T )
    return P * solve( K - 1, H, L) + ( 1.0 - P ) * solve( K - 1, R, H );
  else
    return P * solve( K - 1, R, H) + ( 1.0 - P ) * solve( K - 1, H, L);
}
 
int main() {
  int K;
  double R, L;
  cin >> K >> L >> R >> P >> E >> T;
 
  cout << fixed << setprecision(6) << solve( K, R, L ) << endl;
   
  return 0;
}

Measured memory_bytes: 3280
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstring>
using namespace std;
stack<int>s;
int main(){
	char ch;
	int ans=0;
	while(cin>>ch){
		ans++;
		if(ch=='S') s.push(1);
		else if(!s.empty()) s.pop(),ans-=2;
	}
	cout<<ans<<endl;
	return 0;
}


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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define fset(arr,n,val) for(int i=0;i<n;++i) arr[i] = val
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b) for(int i=a;i<=b;i++)
#define frepj(a,b) for(int j=a;j<=b;j++)
// --------------------------------------------------------------------------------

void solve_main()
{
    int n;cin>>n;
    if(n%1000==0)
    {
    	cout<<"0\n";
    	return;
    }
    n = n%1000;
    cout<<1000-n<<"\n";
}

int main()
{

	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif

    int t=1;
    // cin>>t;
    while(t--)
    {
    	solve_main();
    }
    //for(int caset=1;caset<=t;++caset)
    //{
    //    solve_main();
    //}
    
}

Measured memory_bytes: 3544
from collections import Counter
n = int(input())
A = [int(i) for i in input().split()]
S = [0]*(n+1)
for i in range(n):
    S[i+1] = S[i] + A[i]
def hello(data):
    dt = Counter()
    for i in data:
        dt[str(i)] += 1
    return dt
num = hello(S)
out = [i*(i-1)//2 for i in num.values() if i>1]
print(sum(out))

Measured memory_bytes: 52624
#include<iostream>
#include<math.h>
using namespace std;
const long long MAXFACT = (long long) 1e9+7;

int main(){
    long long N;
    cin >> N;
    long long A[N];
    long long ans;
    for( long long i=0; i<N; i++ ){
        cin >> A[i];
    }

    ans=0;
    for( long long i=0; i<60; i++ ){
        long long count;
        count = 0;
        long long a=1;
        for(long long ii=1; ii<=i; ii++){
            a *= 2;
        }

        for( long long j=0; j<N; j++ ){
            if( (A[j] & a) == a ){
                count ++;
            }
        }
        //cout << "i count " << i << " " << count << endl;
        long long aa = a%MAXFACT;
        long long bb = count*( N-count )%MAXFACT;
        ans+= bb * aa % MAXFACT;
        ans %= MAXFACT;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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 (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */


int a, b;
void in(){
    cin >> a >> b;
}

void solve(){
    
    printf("%0.9f\n", 1.0 * a / b );

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}


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

typedef  long long ll;
typedef long double ld;
using namespace std;
const int N=1e5+5;

#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define point complex<double>
ll mod=1e9+7;
ll inf=2e18;
double eps=1e-10;
double pi=acos(-1);
double dot(point a, point b)
{
    return (conj(a)*b).real();
}
double cross(point a, point b)
{
    return (conj(a)*b).imag();
}

int arr[N];
int main()
{
    ll n,k;
    cin>>n>>k;
    n--,k--;
    ll ans=n/k+(n%k!=0);
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n, q;
    cin >> n;
    vector<ll> a(n);
    vector<ll> count(100001, 0);
    rep(i, n) {
        cin >> a.at(i);
        count.at(a.at(i))++;
    }
    cin >> q;
    vector<ll> b(q);
    vector<ll> c(q);
    rep(i, q) cin >> b.at(i) >> c.at(i);
    ll sum = 0;
    rep(i, 100001) {
        sum += i * count.at(i);
    }
    rep(i, q) {
        sum -= count.at(b.at(i)) * b.at(i);
        sum += count.at(b.at(i)) * c.at(i);
        count.at(c.at(i)) += count.at(b.at(i));
        count.at(b.at(i)) = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 6428
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

int a[100010];
int main(){
	int n,c,k;
	int ans=0;
	cin>>n>>c>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0,j=0;i<n;i++){
	    if(i-j>=c || a[i]-a[j]>k)j=i,ans++;
	
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
c = list(map(int, input().split()))
mod = 10**9+7
c.sort(reverse=True)
ans = 0
for k, num in enumerate(c):
    ans += (k+2)*num
    ans %= mod

for _ in range(2*n-2):
    ans *= 2
    ans %= mod

print(ans)

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

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

bool mat[1005][1005];
bool vis[1005][1005];
int n, m;


bool valid (int r, int c) {
    return (r >= 0 && r < n && c >= 0 && c < m);
}



void solve () {
    cin >> n >> m;
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	--a; --b; --c; --d;
	
	for (int i = 0; i < n; i++) {
	    string s;
		cin >> s;
		for (int j = 0; j < m; j++) {
			mat[i][j] = (s[j] == '.');
		}
	}
	deque<pair<pair<int, int>, int>> q;
	
	q.push_front({{a, b}, 0});
	
	
	while (!q.empty()) {
		pair<pair<int, int>, int> x = q.front();
		q.pop_front();
		
		pair<int, int> pos = x.first;
		
		if (vis[pos.first][pos.second]) continue;
		vis[pos.first][pos.second] = 1;
		

		if (pos.first == c && pos.second == d) {
			cout << x.second << '\n';
			return;
		}
		
		for (int d = 0; d < 4; d++) {
			int nr = pos.first + dx[d];
			int nc = pos.second + dy[d];
			
			if (valid(nr, nc) && mat[nr][nc] && !vis[nr][nc]) {
				q.push_front({{nr, nc}, x.second});
			}
		}
		
		for (int dr = -2; dr <= 2; dr++) {
			for (int dc = -2; dc <= 2; dc++) {
				int nr = pos.first + dr;
				int nc = pos.second + dc;
				
				if (valid(nr, nc) && mat[nr][nc] && !vis[nr][nc]) {
					q.push_back({{nr, nc}, x.second + 1});
				}
			}
		}
	}
	cout << -1 << '\n';
}

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

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

int count(int x,int c){
   if(x>=500){
       return count(x-500,c+1);
   }
   if(x>=100){
       return count(x-100,c+1);
   }
   if(x>=50){
       return count(x-50,c+1);
   }
   if(x>=10){
       return count(x-10,c+1);
   }
   if(x>=5){
       return count(x-5,c+1);
   }
   if(x==0){
       return c;
   }
   else{
       return count(x-1,c+1);
   }
}
int main(void){
   int x;
   while(true){
       cin >> x;
       if(x==0){
           break;
       }
       cout << count(1000-x,0)<< endl;
   }
}


Measured memory_bytes: 3084
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a==b) {
      System.out.print("Draw");
    }else if(a==1){
      System.out.print("Alice");
    }else if(b==1){
      System.out.print("Bob");
    }else if(a>b){
      System.out.print("Alice");
    }else{
      System.out.print("Bob");
    }
  }
}

Measured memory_bytes: 35852
def read_input():
    s = list(map(int, list(str(input()))))
    n = len(s)

    return n, s


# 桁数nでtスタートの数列を作成する
def make_answers(n, t):
    curr  = t

    result = []
    for i in range(n):
        result.append(curr)

        if curr == 1:
            curr = 0
        else:
            curr = 1

    return result


# aとbを要素比較して異なる部分を数える
def diff_num_seq(a, b):
    return sum([1 for ae, be in zip(a, b) if ae != be])


if __name__ == '__main__':
    n, s = read_input()

    answer0 = make_answers(n, 0)
    answer1 = make_answers(n, 1)

    diff0 = diff_num_seq(s, answer0)
    diff1 = diff_num_seq(s, answer1)

    answer = min(diff0, diff1)

    print(answer)

Measured memory_bytes: 6168