akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ans = 0LL;
    rep(i, N+1) rep(j, N+1) {
        ll sum = i * R + j * G;
        if(sum > N) break;
        ll d = N - sum;
        if(d%B == 0) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define irep(i,n)  for(int i=0;i<(n);i++)
#define irepy(i,n) for(int i=1;i<=(n);i++)
#define jrep(j,n)  for(int j=0;i<(n);j++)
#define jrepy(j,n) for(int j=1;i<=(n);j++)

int main(){
  int64_t  n;
  cin >> n;
  int64_t  ans=0;
  for(int64_t i = sqrt(n)+1;i>= 1 ;i--){
    int64_t y = n / i;
      if(n%i==0){
	ans=(i-1)+(y-1);
	break;
      }
    }
  
  cout<< ans <<endl;

  return 0;


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int h, w;
    cin >> h >> w;
    char pic[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> pic[i][j];
        }   
    }   

    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }   
    cout << endl;
    for (int i = 0; i < h; i++) {
        cout << "#";
        for (int j = 0; j < w; j++) {
            cout << pic[i][j];
        }   
        cout << "#" << endl;;
    }   
    for (int i = 0; i < w + 2; i++) {
        cout << "#";
    }   
    cout << endl;
}




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

int card[255][14] = {{0}};

int main(void){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        char c; //　文字コードは0~255
        int num;
        cin >> c >> num;
        card[(int)c][num]=1; //　発見
    }
    /*　Sを探す　*/
    for(int i=1;i<=13;i++){
        if(card[(int)'S'][i] == 0){
            cout << "S" << ' ' << i <<endl;
        }
    }
    /*　Hを探す　*/
    for(int i=1;i<=13;i++){
        if(card[(int)'H'][i] == 0){
            cout << "H" << ' ' << i <<endl;
        }
    }
    /*　Cを探す　*/
    for(int i=1;i<=13;i++){
        if(card[(int)'C'][i] == 0){
            cout << "C" << ' ' << i <<endl;
        }
    }
    /*　Dを探す　*/
    for(int i=1;i<=13;i++){
        if(card[(int)'D'][i] == 0){
            cout << "D" << ' '<< i <<endl;
        }
    }
}


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

using namespace std;

long long x, y, z;
long long a, b, c, d, e, f;

int main()
{
	
	cin >> x >> y >> z;
	if(x%2==0 && y%2==0 && z%2==0){
		cout << 0;
	}
	if(x%2 == 0 && y%2 == 0 && z%2 == 1){
		cout << x*y;
	}
	if(x%2 == 0 && y%2 == 1 && z%2 == 0){
		cout << x*z;
	}
	if(x%2 == 1 && y%2 == 0 && z%2 == 0){
		cout << z*y;
	}
	if(x%2 == 1 && y%2 == 0 && z%2 == 1){
		cout << 0;
	}
	if(x%2 == 0 && y%2 == 1 && z%2 == 1){
		cout << 0;
	}
	if(x%2 == 1 && y%2 == 1 && z%2 == 0){
		cout << 0;
	}
	if(x%2 == 1 && y%2 == 1 && z%2 == 1){
		if(max({x, y, z}) == x){
			cout << y*z;
			return 0;
		}
		if(max({x, y, z}) == y){
			cout << x*z;
			return 0;
		}
		if(max({x, y , z}) == z){
			cout << x*y;
			return 0;
		}
	}
	
}



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

int main() {
  char p;
  cin >> p;
  if (p == 'a' || p == 'i' || p == 'u' || p == 'e' || p == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    print min(B/A, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
#include <iostream>

using namespace std;

int main()
{
    int n, a, b, c, d;

    cin >> n >> a >> b >> c >> d;

    int an = 0, cn = 0;
    int tmp = n;

    while (tmp > 0) {
        an += b;
        tmp -= a;
    }

    tmp = n;

    while (tmp > 0) {
        cn += d;
        tmp -= c;
    }

    cout << (an < cn ? an : cn) << endl;

}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  int n,k;
  cin>>n>>k;
  n=(n+1)/2;
  cout<<(n>=k?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(dead_code)]
use std::io::*;

fn main(){
    let n: usize = read();
    let mut a: Vec<i32> = (0..n).map(|_| read()).collect();
    for i in 0..n{
        a[i] *= -1;
    }
    let mut b: Vec<i32> = vec![];
    for i in a{
        let t = upper_bound(&b, &i);
        match t{
            Some(j) =>{
                b[j] = i;
            },
            None => b.push(i),
        }
    }
    println!("{}", b.len());
}

fn upper_bound(a: &Vec<i32>, x: &i32) -> Option<usize>
{
    let mut ok: isize = a.len() as isize;
    let mut ng: isize = -1;
    if ok == 0 || a[ok as usize - 1] <= *x{
        None
    }else{
        while (ng - ok).abs() > 1{
            let mid = (ok + ng) / 2;
            if a[mid as usize] > *x{
                ok = mid;
            }else{
                ng = mid;
            }
        }
        Some(ok as usize)
    }
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
char a;

int main() {
  //
  cin >> a;
  if ('A' <= a && a <= 'Z') {
    cout << "A";
  } else {
    cout << "a";
  }
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  int64_t amount = 0;
  for(int i = 1; i <= N; i++){
    if(i % 3 == 0 || i % 5 == 0 ){
      continue;
    }else{
      amount += i;
    }
  }
  
  cout << amount << endl;
  
  return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

char a,b;

int main()
{
	scanf("%c %c",&a,&b);
	puts(a==b?"H":"D");
}


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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();
        
        if(input.ToLower() == input)
        {
            Console.WriteLine("a");
        }
        else
        {
            Console.WriteLine("A");

        }

        Console.Read();
    }
}

Measured memory_bytes: 17404
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a, b, c, sum;
    scanf("%d %d %d", &a, &b, &c);
    if ((a == 1 && b == 1 && c == 0) || (a == 0 && b == 0 && c == 1)) printf("Open\n");
    else printf("Close\n");
    return 0;
}



Measured memory_bytes: 2624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		int C[] = new int[N - 1];
		int answer = 0;

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

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
			answer += B[i];
		}

		for (int i = 0; i < N - 1; i++) {
			C[i] = sc.nextInt();
		}

		for (int i = 1; i < N; i++) {
			if (A[i - 1] + 1 == A[i]) {
				answer += C[A[i - 1] - 1];
			}
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23636
#include <stdio.h>

int main (){

int N, M;
scanf ("%d %d",&N, &M);

int x =0;
 
for (int a=1; a<N; a++){
x += a;
}

int y =0;
for (int b=1; b<M ; b++){
y += b;
}

if (N + M >=2){
	printf ("%d\n",x+y);
}
else printf ("0\n");

return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <string>

using namespace std;

string even (string s )
{
  string ans;

  for ( int i = 0; i < s.size(); i += 2 ) ans += s[i];

  return ans;
}

int main()
{
  string s;

  cin >> s;

  cout << even(s) << "\n";
}


Measured memory_bytes: 704
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

int lcm(int a, int b)
{
  return (a * b) / __gcd(a, b);
}  
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
  while (tc--)
  {
    int n, k;
    cin >> n >> k;
    int m = min(n, k);
    n = max(n, k);
    for (int i = 0; i < n;i++)
      cout << m;
  }

  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();

  vector<int> used(26, 0);
  rep(i, n) used[s[i] - 'a'] = 1;

  string ans = "";
  if (n < 26) {
    rep(i, 26) if (used[i] == 0) {
      ans = s + (char)(i + 'a');
      break;
    }
  } else {
    for (int i = n-1; i >= 0; --i) {
      for (char c = s[i] + 1; c <= 'z'; ++c) {
        if (used[c-'a'] == 0) {
          rep(j, i) ans += s[j];
          ans += c;
          break;
        }
      }
      if (ans != "") break;
      used[s[i] - 'a'] = 0;
    }
  }
  if (ans == "") cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll Mod;

VVI matproduct(VVI a,VVI b){
  if(a[0].size()!=b.size()) cout<<a[0].size()<<" "<<b.size()<<endl;
    VVI w(a.size(),VI(b[0].size(),0));
    for(ll i=0;i<a.size();i++){
      for(ll j=0;j<b[0].size();j++){
        for(ll k=0;k<a[0].size();k++){
          w[i][j]+=(a[i][k]%Mod)*(b[k][j]%Mod);
          w[i][j]%=Mod;
        }
      }
    }
    return w;
}

VVI square(VVI a){
  return matproduct(a,a);
}

int main(){
  ll i,j;
  ll l,a,b,m;
  cin>>l>>a>>b>>m;

  Mod=m;

  ll k=1;
  ll d[19];
  ll ke[19];
  ke[0]=1;
  for(i=1;i<19;i++){
    d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
    k*=10;
    ke[i]=(ke[i-1]*10)%Mod;
  }

  for(i=1;i<19;i++){
    if(d[i]<l) l-=d[i];
    else {
      d[i]=l;
      l=0;
    }
  }

  VVI ans(1,VI(3));
  ans[0][0]=0;
  ans[0][1]=a%Mod;
  ans[0][2]=1;

  for(i=1;i<19;i++){
      VVI w(3,VI(3,0));

      w[0][0]=ke[i];
      w[1][0]=1;
      w[1][1]=1;
      w[2][1]=b%Mod;
      w[2][2]=1;

      for(j=0;j<62;j++){
        if((d[i]>>j)&1) ans=matproduct(ans,w);
        w=square(w);
      }
  }

  cout<<ans[0][0]<<endl;

  return 0;
}

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

int main()
{
    int k = 'A', cnt = 0;
    string s;

    cin >> s;
    
    for( int i = 0; i < s.size(); i++ )
    {
        if( k >= s[i] )
            cnt++;
        k = s[i];
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();

			long[][] d = new long[n][n];
			long[][] input = new long[n][n];

			for (int from = 0; from < n; from++) {
				for (int to = 0; to < n; to++) {
					long a = in.nextLong();
					d[from][to] = a;
					input[from][to] = a;
				}
			}

			warshallFloyd(d);

			for (int from = 0; from < n; from++) {
				for (int to = 0; to < n; to++) {
					if (d[from][to] != input[from][to]) {
						out.println(-1);
						return;
					}
				}
			}

			long cost = 0;
			for (int from = 0; from < n; from++) {
				for (int to = from + 1; to < n; to++) {
					for (int middle = 0; middle < n; middle++) {
						if (middle == from || middle == to) {
							continue;
						}
						if (d[from][middle] + d[middle][to] == d[from][to]) {
							input[from][to] = -1;
						}
					}
				}
			}

			for (int from = 0; from < n; from++) {
				for (int to = from + 1; to < n; to++) {
					if (input[from][to] != -1) {
						cost += input[from][to];
					}
				}
			}
			out.println(cost);
		}

	}

	static void warshallFloyd(long[][] d) {
		int INF = Integer.MAX_VALUE;
		int len = d.length;
		for (int i = 0; i < len; i++) {
			for (int j = 0; j < len; j++) {
				if (d[j][i] == INF) continue;
				for (int k = 0; k < len; k++) {
					if (d[i][k] == INF) continue;
					d[j][k] = Math.min(d[j][k], d[j][i] + d[i][k]);
				}
			}
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 35480
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	static Scanner  in = new Scanner (System.in);
	public static void main (String[] args) throws java.lang.Exception
	{
	    int n=in.nextInt();
	    if(n<1200){
	    	System.out.println("ABC");
	    }
	    else if(n<2800){
	    	System.out.println("ARC");
	    }
	    else{
	    	System.out.println("AGC");
	    }
	}
	
}

Measured memory_bytes: 21844
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy
 
def main():
    d,t,s = map(int, input().split())
    if d <= t*s:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a;  i ++)
int main(void){
  int n;
  while(cin>>n){
    n = n % 39;
    if(!n)n = 39;
    if(n>=10)
      cout<<"3C"<<n<<endl;
    else
      cout<<"3C0"<<n<<endl;
  }
}

Measured memory_bytes: 1160
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
  println!("{}",if read::<i32>()%read::<i32>()>0{1}else{0});
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String N = sc.next();
        
        int sum = 0;
        for (char c : N.toCharArray()) {
        	sum += Character.getNumericValue(c);
        }
        
        System.out.println(Integer.parseInt(N) % sum == 0 ? "Yes" : "No");
    }
    
}

Measured memory_bytes: 22996
#python3

def main():
    a = []
    for _ in range(3):
        x, y, z = map(int, input().split())
        a.append((x, y, z))
    n = int(input())
    b = []
    for _ in range(n):
        b.append(int(input()))

    g = [[0 for _ in range(3)] for _ in range(3)]

    for k in range(n):
        
        for i in range(3):
            for j in range(3):
                if b[k] == a[i][j]:
                    g[i][j] = 1


    bingo = False
    #横
    for i in range(3):
        if sum(g[i]) == 3:
            bingo = True
    #縦
    if g[0][0]+g[1][0]+g[2][0] == 3:
        bingo = True
    if g[0][1]+g[1][1]+g[2][1] == 3:
        bingo = True
    if g[0][2]+g[1][2]+g[2][2] == 3:
        bingo = True 
    #斜め
    if g[0][0]+g[1][1]+g[2][2] == 3:
        bingo = True
    if g[0][2]+g[1][1]+g[2][0] == 3:
        bingo = True
    
    if bingo:
        print('Yes')
    else:
        print('No')
main()

Measured memory_bytes: 3188
#include <cstdio>
#include <cmath>

int main()
{
  int x, h;
  while (~scanf("%d %d", &x, &h)) {
    if ((x|h) == 0)
      break;
    printf("%.6f\n", x*x + x*sqrt(static_cast<double>(4*h*h+x*x)));
  }
  return 0;
}

Measured memory_bytes: 0
N, K = map(int,input().split())
x = [int(i) for i in input().split()]




if x[0] <= 0 <= x[-1]:
    ans = []
    for i in range(N-K+1):
        left = x[i]
        right = x[i+K-1]
        if left <= 0 <= right:
            cost = abs(right - left) + min(abs(right),abs(left))
            ans.append(cost)
        else:
            pass
    print(min(ans))

else:
    ans = []
    for i in range(N-K+1):
        left = x[i]
        right = x[i+K-1]
        cost = abs(right - left) + min(abs(right),abs(left))
        ans.append(cost)
    print(min(ans))


Measured memory_bytes: 14480
#include <iostream>
#include <cstring>
using namespace std;
const int MAXN = 2e5 + 10;
typedef long long LL;
char s[MAXN][20];
int tot[21][21];
int X[MAXN] , Y[MAXN];
int MID = 10;
int main(){
	int n;
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++ i)
		scanf("%s" , s[i]);
	for(int i = 1 ; i <= n ; ++ i){
		int pos = -1 , len = strlen(s[i]);
		for(int j = 0 ; j < len ; ++ j)
			if(s[i][j] == '.'){
				pos = j;
				break;
			}
		//cout << ".pos : " << pos << endl;
		if(pos == -1){
			int v = 0;
			for(int j = 0 ; j < len ; ++ j)
				v = v * 10 + s[i][j] - '0';
			int c1 = MID , c2 = MID;
		//	cout << v << endl;
			while(v % 2 == 0){
				c1 ++;
				v /= 2;
			}
			while(v % 5 == 0){
				c2 ++;
				v /= 5;
			}
			X[i] = c1;
			Y[i] = c2;
		//	cout << c1 - MID << " " << c2 - MID << endl;
			tot[c1][c2] ++;
		}
		else{
			int w = len - pos - 1;
			int c1 = MID - w , c2 = MID - w;
			LL v = 0;
			for(int j = 0 ; j < len ; ++ j)
				if(s[i][j] != '.')
					v = v * 10 + s[i][j] - '0';
		//	cout << v << endl;
			while(v && v % 2 == 0){
				c1 ++;
				v /= 2;
			}
			while(v % 5 == 0){
				c2 ++;
				v /= 5;
			}
		//	cout << c1 - MID << " " << c2 - MID << endl;
			X[i] = min(c1 , 20);
			Y[i] = min(c2 , 20);
			tot[X[i]][Y[i]] ++;
		}
	}
//	for(int i = 1 ; i <= n ; ++ i)
//		cout << X[i] << " " << Y[i] << endl;
	long long ans = 0;
	for(int i = 1 ; i <= n ; ++ i){
		tot[X[i]][Y[i]] --;
		int x = 20 - X[i];
		int y = 20 - Y[i];
		for(int j = x ; j <= 20 ; ++ j)
			for(int k = y ; k <= 20 ; ++ k)
				ans += tot[j][k];
	//	cout << i << " " << ans << endl;
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#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 all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int h, w, n;
map<pair<int, int>, int> r;

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> h >> w >> n;
	rep(iter,0,n) {
		int y, x;
		cin >> y >> x;
		y--;
		x--;
		for(int i=y-2; i<=y; ++i) {
			for(int j=x-2; j<=x; ++j) {
				if(i < 0 || j < 0) continue;
				if(i+2 >= h || j+2 >= w) continue;
				pair<int, int> key = mp(i,j);
				if(r.find(key) != r.end()) {
					r[key]++;
				} else {
					r[key] = 1;
				}
			}
		}
	}
	vl ret(10);
	ll total = 0;
	for(auto e : r) {
		ret[(e.S)]++;
		total++;
	}
	ret[0] = (ll)(h-2) * (w-2) - total;
	rep(i,0,sz(ret)) {
		cout << ret[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 56576
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    final int MOD = 2019;
    long answer = 0;
    String s = sc.next();

    int len = s.length();
    int[] powmods = new int[len];
    int[] modcnt = new int[MOD];
    powmods[0] = 1;
    for (int i = 1; i < len; i++) {
      powmods[i] = powmods[i - 1] * 10 % MOD;
    }
    int mod2019 = 0;
    modcnt[0]++;
    for (int i = 0; i < len; i++) {
      int num = (s.charAt(len - 1 - i) - '0') * powmods[i] % MOD;
      mod2019 = (mod2019 + num) % MOD;
      modcnt[mod2019]++;
    }
    for (int i = 0; i < MOD; i++) {
        if (modcnt[i] > 1) {
            answer += (modcnt[i] * (modcnt[i] - 1) / 2);
        }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 41332
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    readln.chomp.count!"a == '1'".writeln;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

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 sum =0;
		for(int i = 1; i <= n;i++){
			int x = 0;
			for(char c : String.valueOf(i).toCharArray()){
				x += Character.getNumericValue(c);
			}
			if(a <= x && x <= b) sum += i;
		}
		System.out.println(sum);
	}
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long> R(N);

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

    long base = R.at(0);
    long profit = -10000000000;
    for(int i = 1; i < N; i++){
	long r = R.at(i);
	profit = max(profit, r - base);
	base = min(base, r);
    }
    cout << profit << endl;
}



Measured memory_bytes: 4428
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int N;
		cin >> N;

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

		bool b = all_of( a.begin(), a.end(), []( int x ) { return x%2 == 0; } );
		cout << (b ? "second" : "first") << endl;
	}
};

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


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


//const int nish=100007;
int all[200005];
long long int dp[200007];
int main()
{
    int t,k;
    cin>>t>>k;
    for(int i=0;i<t;i++)
    {
        int input;
        cin>>input;
        all[i]=input;
    }
    
    
   for(int i=0;i<t+3;i++)
   {
       dp[i]=1000000007;
   }
  
  
    dp[1]=0;
    dp[2]=abs(all[1]-all[0]);
    
    
   // cout<<dp[3]<<endl;
    for(int i=3;i<=t;i++)
    {
        
        for(int j=1;j<=k;j++){
        if(i-j-1>=0){    
        dp[i]=min(dp[i],(dp[i-j]+(abs(all[i-j-1]-all[i-1]))));
        }
    }
    }
    
    
    cout<<dp[t]<<endl;
    
    //cout << "Hello World!" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <sstream>
#include <deque>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
const int M = 1e9 + 7;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;

//insta  -------  __ansh7
//MSDIAN

// Basic Template

int main()
{
    fastio

string s1,s2;
cin>>s1;
cin>>s2;

ll count=0;

for(ll i=0;i<s1.length();i++)
{
    if(s1[i]!=s2[i])
    {
        count++;
    }
}

cout<<count<<"\n";


 

        return 0;
    }

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

using namespace std;

int main() {
    int n, c = 1;
    cin >> n;
    vector<int>v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int g = v[0];
    for (int i = 1; i < n; i++) {
        if(v[i] < g) {
            c++;
            g = v[i];
        }
    }
    cout << c << endl;
    return 0;

}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,K = inputIL()
A = inputIL()

flag = [False for i in range(N)]
route = [0]

now = 0
flag[0] = True
while True:
  n = A[now]-1
  if flag[n] == True:
    loop_point = n
    break
  route.append(n)
  flag[n] = True
  now = n

p = route.index(loop_point)
path = route[:p]
loop = route[p:]

if K <= len(path)-1:
  print(path[K]+1)
else:
  k = K-len(path)
  k = k%len(loop)
  print(loop[k]+1)

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

using namespace std;
int a[100005]; 
int main(){
	int n;
	cin>>n;
	int k=0;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	k=unique(a,a+n)-a;
	if(k%2==0)cout<<k-1<<endl;
	else cout<<k<<endl; 
	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> vi;
vi primes;

int get_primes(int max){
	int n = (max+1)/2;
	int root = (int)(pow(n, 0.5));
	vector <bool> numbers(n, true);
	numbers[0]=false;

	if (max>1) primes.push_back(2);
	for (int i=1; i<root; i++){
		int tmp = i*2+1;
		if (numbers[i]){
			primes.push_back(tmp);
			for (int j=i+tmp; j<n+1; j+=tmp){
				numbers[j]=false;
			}
		}
	}
	for (int i=root; i<n+1; i++){
		if(numbers[i]){
			primes.push_back(2*i+1);
		}
	}
	return 0;
}

int main(void){
	vi n;
	int nmax=0;
	while (true){
		int tmp;
		cin>>tmp;
		if (cin.eof()) break;

		n.push_back(tmp);
		if (tmp>nmax) nmax=tmp;
	}

	get_primes(nmax);
	for (int i=0; i<n.size(); i++){
		cout<<upper_bound(primes.begin(), primes.end(), n[i]) - primes.begin()<<endl;
	}
	return 0;
} 

Measured memory_bytes: 1776
n = int(input())

l = len(str(n))
# if n < 10:
#     ans = n
# else:
ans1 = 9 * (l-1) + int(str(n)[0]) - 1
ans2 = sum([int(x) for x in list(str(n))])
ans = max(ans1, ans2)
# print(ans1, ans2)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<climits>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<utility>
#include<iomanip>
//#include<ext/pb/ds/assoc_container.hpp>

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef long long int lld;
typedef long double real;

lld mod = 1e9+7;

template<typename T>
void input_vector(vector<T>& v, lld n, lld start=0) {
	for(lld i=start; i<n; ++i) 
		cin>>v[i];
}

template<typename T>
void display_vector(vector<T> v, lld start=0, string sep=" ") {
	for(lld i=start; i<v.size(); ++i)
		cout<<v[i]<<sep;
	cout<<"\n";
}

void fillPrimes(vector<lld>& sieve, vector<lld>& primes) {
	lld i, j;
	
	for(i=2*2; i<sieve.size(); i+=2) 
		sieve[i]=0;
	
	j=3;
	while(j<sieve.size()) {
		for(i=j*j; i<sieve.size(); i+=(2*j)) {
			sieve[i]=0;
		}
		
		// get next prime
		for(i=j+1; i<sieve.size(); ++i)
			if(sieve[i]) {
				j=i;
				break;
			}
		if(i==sieve.size())
			break;
	}
	
	for(i=2; i<sieve.size(); ++i) {
		if(sieve[i])
			primes.push_back(i);
	}
}

vector<pair<lld, lld>> factorize(lld n, vector<lld> primes) {
	vector<pair<lld, lld>> factors;
	lld tmp=n;
	for(lld i=0; primes[i]*primes[i]<=n; ++i) {
		if(tmp%primes[i]==0){
			pair<lld, lld> pr = {primes[i], 0};
			while(tmp%primes[i]==0) {
				pr.second++;
				tmp /= primes[i];
			}
			factors.push_back(pr);
		}
	}
	if(tmp>1)
		factors.push_back({tmp, 1});
	return factors;
}

void solve(string t) {
	lld i, n=t.length(), score=0;
	if(t[0]=='?') {
		if(n==1 || t[1]=='P') {
			t[0]='D';
		}
		else { // t[1] = ? or D
			t[0]='P';
		}
	}
	
	for(i=1; i<n-1; ++i) {
		if(t[i]=='?') {
			t[i]='D';
			if(t[i-1]!='P' && (t[i+1]=='D' || t[i+1]=='?')) {
				t[i]='P';
			}
		}
	}
	
	if(t[n-1]=='?') {
		t[n-1]='D';
	}
	
	for(i=0; i<n; ++i) {
		if(t[i]=='D')
			score++;
		if(i>0 && t[i-1]=='P')
			score++;
	}
	
	cout<<t<<"\n";
	//cout<<score<<"\n";
}

int main() {
	lld t=1;
	//cin>>t;
	
	for (lld cs=1; cs<=t; ++cs) {
		string t;
		cin>>t;
		solve(t);
	}
	
	return 0;
}

Measured memory_bytes: 3920
S=input()
# Python3 program to Split string into characters 
def split(word): 
    return [char for char in word]  
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
      
      
# Driver code 
word = S
splits=split(S)
Q=int(input())
flipcounter=0
prestring=[]
poststring=[]
for i in range(0,Q):
  inputforround=input()
  if inputforround=='1':
    flipcounter=flipcounter+1
  else:
    T,F,C=map(str,inputforround.split())
    if (int(F)+flipcounter)%2==1:
      prestring.append(C)
    else:
      poststring.append(C)
 
prestring.reverse()
for j in splits:
  prestring.append(j)
for k in poststring:
  prestring.append(k)
if flipcounter%2==1:
  prestring.reverse()
ans=convert(prestring)
print(ans)

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

int main(){
    string A,B,C;
    cin >> A >> B >>C;
    int cnt = 0;

    if (A==B) cnt ++;
    if (B==C) cnt ++;
    if (C==A) cnt ++;

    if (cnt ==1) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = n;
		int sum = 0;
		while(n >= 1) {
			sum += n % 10;
			n /= 10;
		}
		
		if(m % sum == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}

Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(){
 	long long a,b,c,d,cnt=0;
  	cin>>a>>b>>c>>d;
  	long long n;
  	cin>>n;
  	n=n*4;
  	if(a*2<b)b=2*a;
  	if(a*4<c)c=4*a;
  	if(a*8<d)d=8*a;
  	if(b*2<c)c=2*b;
  	if(b*4<d)d=4*b;
  	if(c*2<d)d=2*c;
  	if(n>=8){
     	cnt+=n/8*d;
      	n=n%8;
    }
  	if(n>=4){
     	cnt+=n/4*c;
      	n=n%4;
    }
  	if(n>=2){
      	cnt+=n/2*b;
      	n=n%2;
    }
  	if(n>=1){
      	cnt+=n/1*a;     
    }
  	cout<<cnt;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char S[200010];
int n;

int fail[200010];

void Fail(){
	n=strlen(S);
	for(int i=1;i<n/2;++i){
		int j=fail[i-1];
		while(j && S[j]!=S[i]) j=fail[j-1];
		if(S[j]==S[i]) ++j;
		fail[i]=j;
	}
}

ll len[100];
vector<ll> cnt[100];

vector<ll> work(ll to){
	if(!to) return vector<ll>(26);
	vector<ll> ret(26);
	while(to){
		int i=0;
		for(i=0; len[i]; ++i) if(to < len[i]) break;
		if(!i){
			for(int j=0; j<to; ++j) ret[S[j]-'a']++;
			break;
		}
		for(int j=0; j<26; ++j) ret[j]+=cnt[i-1][j];
		to -= len[i-1];
	}
	return ret;
}

int main()
{
	scanf("%s", S);
	Fail();
	len[0] = n/2; cnt[0].resize(26);
	for(int i=0; i<n/2; ++i) cnt[0][S[i]-'a']++;
	cnt[1] = cnt[0]; len[1] = len[0] + n/2-fail[n/2-1];
	for(int i=0; i<n/2-fail[n/2-1]; ++i) cnt[1][S[i]-'a']++;
	
	for(int i=2;;++i){
		len[i] = len[i-1] + len[i-2];
		if(len[i] > ll(1e18)) break;
		cnt[i].resize(26);
		for(int j=0; j<26; ++j) cnt[i][j]=cnt[i-1][j]+cnt[i-2][j];
	}
	
	ll L, R;
	read(L, R);
	auto vl = work(L-1), vr = work(R);
	for(int i=0; i<26; ++i) printf("%lld ", vr[i]-vl[i]);
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i){
        if(i % 2 == 0){ // odd
            if(s.at(i) == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s.at(i) == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,minmun,i,a;
	scanf("%d %d\n%d",&n,&x,&minmun);
	x-=minmun;
	for(i=1;i<n;i++)
	{
		scanf("%d",&a);
		minmun=min(a,minmun);
		x-=a;
	}
	n+=x/minmun;
	printf("%d",n);
	return 0;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		int cnt = 0;
		for (int i = Math.min(a, b); i > 0; i--) {
			if (a % i == 0 && b % i == 0) {
				cnt++;
			}
			
			if (cnt == k) {
				pr.println(i);
				break;
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21972
import java.math.BigInteger;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] x = new long[n];
		long[] y = new long[m];
		for(int i = 0; i < n; i++)
			x[i] = sc.nextLong();
		for(int i = 0; i < m; i++)
			y[i] = sc.nextLong();
		
		BigInteger sum1 = BigInteger.valueOf(0);
		BigInteger sum2 = BigInteger.valueOf(0);
		for(int i = 0; i < n; i++){
			sum1 = sum1.add(BigInteger.valueOf((2 * i + 1 - n) * x[i]));
		}
		for(int i = 0; i < m; i++){
			sum2 = sum2.add(BigInteger.valueOf((2 * i + 1 - m) * y[i]));
		}
		
		BigInteger result = sum1.multiply(sum2).remainder(BigInteger.valueOf(1000000007));
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 94192
using System;

namespace abc155_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = Convert.ToInt32(input[i]);
            }

            int NG = 0;
            foreach (var a in A)
            {
                if (a % 2 == 0)
                {
                    if (a % 3 == 0 || a % 5 == 0)
                    {

                    }
                    else
                    {
                        NG++;
                    }
                }

            }

            if (NG == 0)
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }
        }
    }
}


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

typedef struct { int left, right, c; } T;

int main(int argc, char** argv) {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int lb = 0, ans = n;
    while (ans - lb > 1) {
        vector<T> st(200100);
        int p = 0;
        st[0] = {1, a[0], 1};
        int k = (ans + lb) / 2;
        bool ok = true;
        for (int i = 1; i < n; i++) {
            if (a[i-1] < a[i]) st[++p] = {a[i-1]+1, a[i], 1};
            else {
                while (st[p].left > a[i]) p--;
                if (st[p].c < k) {
                    T t = st[p];
                    if (t.left < a[i]) st[p++] = {t.left, a[i]-1, t.c};
                    st[p] = {a[i], a[i], t.c+1};
                } else {
                    while (p >= 0 && st[p].c == k) p--;
                    if (p < 0) { ok = false; break; }
                    T t = st[p];
                    if (t.left < t.right) st[p++] = {t.left, t.right-1, t.c};
                    st[p++] = {t.right, t.right, t.c+1};
                    if (t.right < a[i]) st[p] = {t.right+1, a[i], 1};
                }
            }
            // for (int i = 0; i < p; i++) { auto x = st[i]; cerr << x.left << ' ' << x.right << ' ' << x.c << endl; }
        }
        if (ok) ans = k; else lb = k;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3412
while True:
    H,W = map(int, input().split())
    if H == 0:
        break
    for i in range(H):
        S = ''
        for j in range(W):
            if (i+j) % 2 == 0:
                S += '#'
            else:
            
            
                S += '.'
        print(S)
    print()




Measured memory_bytes: 5612
def main():
    n,k=map(int,input().split())
    r,s,p=map(int,input().split())
    t=list(input().strip())
    ans=0
    for i in range(n):
        if i>=k:
            if t[i]==t[i-k]:
                t[i]='x'
        if t[i]=='r':
            ans+=p
        elif t[i]=='s':
            ans+=r
        elif t[i]=='p':
            ans+=s
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 49392
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, bb;
	cin >> a >> b;
	bb = b;
	while (a > 0) {
		a--;
		b *= 100;
	}
	if (bb == 100) b = b / 100 * 101;
	cout << b << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

constexpr static int MAXN = 1e6;

int n;
int64_t A[MAXN];
vector <int> adj[MAXN];

int p[MAXN];
int64_t cnt[MAXN];

void dfs(int u, int prv) {
    p[u] = prv;
    for (int v : adj[u])
        if (v != prv)
            dfs(v, u);
}

bool calc(int u) {
    if (adj[u].size() == 1) {
        cnt[u] = A[u];
        return true;
    }

    vector <int64_t> vals;
    for (int v : adj[u])
        if (p[v] == u) {
            if (!calc(v))
                return false;
            vals.push_back(cnt[v]);
        }

    int64_t total = 0;
    int64_t maxval = 0;
    for (int64_t val : vals) {
        total += val;
        maxval = max(maxval, val);
    }
    int64_t maxpairs = total / 2;
    if (total - maxval < maxval)
        maxpairs = total - maxval;
    if (vals.size() == 1)
        maxpairs = 0;

    // x + y == A[u]
    // 2*x + y == total
    // x = total - A[u]
    int64_t npairs = total - A[u];
    if (npairs < 0 || npairs > maxpairs)
        return false;
    int64_t nextra = A[u] - npairs;
    if (nextra < 0)
        return false;
    cnt[u] = nextra;
    //cout << "u: " << cnt[u] << endl;
    return true;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    if (n == 2) {
        cout << (A[0] == A[1] ? "YES" : "NO") << endl;
        return 0;
    }

    int r = 0;
    while (adj[r].size() == 1)
        r++;

    dfs(r, -1);
    if (calc(r) && cnt[r] == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 36736
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) a[i] = in() - 1;

    VI dp(n);
    REP(i,n){
        if (a[i] == 0) dp[a[i]] = 1;
        else{
            dp[a[i]] = dp[a[i] - 1] + 1;
        }
    }

    int ans = n;
    REP(i,n){
        ans = min(ans, n - dp[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std ;

int main(){
    using ld = long double ;
    ld a,b,angle ;
    cin >> a >> b >> angle ;
    ld pi = acos(-1) ;
    ld s = a*b*sin(angle*pi/180)/2 ;
    ld l = sqrt(a*a+b*b-2*a*b*cos(angle*pi/180)) ;
    l += a+b ;
    ld h = s*2/a ;
    cout << fixed << setprecision(10) << s << endl ;
    cout << l << endl ;
    cout << h << endl ;
}


Measured memory_bytes: 3512
n,k = map(int,input().split())
point = 0
for b in range(1,n+1):
    kaisu = n//b
    kosuu = max(0,b-k)
    point += kaisu*kosuu
    point += max(0,n%b+1-k)
if k == 0:
    point -= n
print(point)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> arr(N);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    sort(arr.begin(), arr.end());
    double s = arr[0];
    for (int i = 1; i < N; i++) {
        s += arr[i];
        s /= 2;
    }
    cout << setprecision(10) << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A,B,C,D,i,j;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    
    if(A>C)
    i=A;
    else i=C;
    if(B>D)
    j=D;
    else j=B;
    
    if(j-i<0)
    printf("0");
    else
    printf("%d",(j-i));
    
    return 0;
}


Measured memory_bytes: 1668
def main():
    N = int(input())
    S = input()
    ones = [0]*10 
    twos = [[0]*10 for i in range(10)]
    threes = [[[0]*10 for i in range(10)] for j in range(10)]
    for c in S:
        dig = int(c)
        for i in range(10):
            for j in range(10):
                if twos[i][j] == 1:
                    threes[i][j][dig] = 1
        for i in range(10):
            if ones[i] == 1:
                twos[i][dig] = 1
        ones[dig] = 1
    res = 0
    for row in threes:
        for col in row:
            res +=sum(col)
    print(res)
    # for i in range(10):
    #     for j in range(10):
    #         for k in range(10):
    #             if threes[i][j][k] == 1:
    #                 print(i,j,k)
main()

Measured memory_bytes: 3064