akhauriyash/Code-Regression huggingface dataset:
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    double a,b,c;
	cin>>a>>b>>c;
	if(a/c<=b)
	cout<<"Yes";
	else
	cout<<"No";
    return 0;
}

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

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
char s[110];
int l,p1=-1,p2=-1;
int main(){
	cin>>s;
	l=strlen(s);
	for(int i=0;i<l;i++){
		if(s[i]=='C'&&p1==-1) p1=i;
		if(s[i]=='F') p2=i;
	}
	if(p1==-1||p2==-1){
		printf("No");
		return 0;
	}
	if(p1<p2) printf("Yes");
	else printf("No");
}

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

int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            string s;
            cin >> s;
            if (s == "snuke") cout << (char)('A' + j) << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  static int count;
  static int N;
  static int A;
  static int B;
  static int C;
  static int Array[];
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
     N = sc.nextInt();
     A = sc.nextInt();
     B = sc.nextInt();
     C = sc.nextInt();
     Array = new int[N];
     for(int i=0;i<N;i++){
       Array[i]=sc.nextInt();
     }
     count = dfs(0,0,0,0,0);
     System.out.println(count);



  }

  static int dfs(int i, int Aco, int Bco, int Cco,int co){
    if(i==N){
      if(Aco==0 || Bco==0 || Cco==0){
        return 100000000;
      }
      else
      return Math.abs(Aco-A)+Math.abs(Bco-B)+Math.abs(Cco-C)+co-30;
    }
    else{
      return minimum(dfs(i+1,Aco+Array[i],Bco,Cco,co+10),
                               dfs(i+1,Aco,Bco+Array[i],Cco,co+10),
                               dfs(i+1,Aco,Bco,Cco+Array[i],co+10),
                               dfs(i+1,Aco,Bco,Cco,co));
    }
  }

  static int minimum(int a,int b,int c,int d){
    int ans = 1999999;
    int[] Arra= new int[4];
    Arra[0] = a;
    Arra[1] = b;
    Arra[2] = c;
    Arra[3] = d;
    for(int i=0;i<4;i++){
      if(ans>=Arra[i]){
        ans = Arra[i];
      }
    }
      return ans;
    }






}

Measured memory_bytes: 22676
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int[] point = new int[n];
			int sum = 0, max = 0, min = 1000;
			for(int i = 0; i < n; i++){
				point[i] = sc.nextInt();
				sum += point[i];
				if(point[i] > max) max = point[i];
				if(point[i] < min) min = point[i];
			}
			sum =  sum - max - min;
			System.out.println(sum / (n-2));
		}
	}
}

Measured memory_bytes: 20952
from collections import deque

N,M = map(int,input().split())
rol = [[] for _ in range(N)]
for _ in range(M):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  rol[a].append(b)
  rol[b].append(a)
  
q = deque()
q.append([0,0,0])
minr = [[10**10,0] for _ in range(N)]

while len(q)>0:
  el = q.popleft()
  room = el[0]
  step = el[1]
  oya = el[2]
  if minr[room][0] <= step:
    continue
  minr[room] = [step,oya]
  for el in rol[room]:
    q.append([el,step+1,room])
  
for i in range(1,N):
  if minr[i] == [10**10,0]:
    print("No")
    exit()
    
print("Yes")
for i in range(1,N):
  print(minr[i][1]+1)

Measured memory_bytes: 70120
/*
 * Talk is cheap, show me the code.
 * Author:  JiangDingyuan
 * Created Time:  2017/9/2 20:22:10
 * File Name: 12345.cpp
 */
#include <time.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#define PI acos(-1.0)
#define LL long long
#define bug printf("bug!\n");
#define RD freopen("in.txt", "r", stdin);
#define LD freopen("out.txt", "w", stdout);

using namespace std;
string ssr;
int main() {
    cin >> ssr;
    for (int i = 0; i < ssr.size(); i+=2)
        cout << ssr[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 512
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let k: u64 = read();
    let a: Vec<u64> = (0..n).map(|_| read()).collect();

    let imax = a.iter().max().unwrap();
    let gcd_a = a.iter().fold(0, gcd);

    println!(
        "{}",
        if k % gcd_a == 0 && *imax >= k {
            "POSSIBLE"
        } else {
            "IMPOSSIBLE"
        }
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn gcd(n: u64, m: &u64) -> u64 {
    if n % m == 0 {
        *m
    } else {
        gcd(*m, &(n % m))
    }
}


Measured memory_bytes: 4476
N, M = list(map(int, input().split()))
a = [int(input()) for i in range(M)]
a.append(0)
dp = [0, 1]
a_flag = 0

for i in range(1, N + 1):
    if i == a[a_flag]:
        dp.append(0)
        a_flag += 1
        continue
    dp.append(dp[i - 1] + dp[i])

print(dp[N + 1] % 1000000007)


Measured memory_bytes: 460020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int main(){
	int h, w;
	scanf("%d%d", &h, &w);
	ll an = 1e18;
	f(i, 1, w){
		ll s1 = (ll)i * h, s2 = (ll)(w - i) * (h >> 1), s3 = (ll)(w - i) * (h + 1 >> 1);
		ll mx = max(s1, max(s2, s3));
		ll mn = min(s1, min(s2, s3));
		an = min(an, mx - mn);
		s2 = (ll)(w - i >> 1) * h, s3 = (ll)(w - i + 1 >> 1) * h;
		mx = max(s1, max(s2, s3));
		mn = min(s1, min(s2, s3));
		if (mn)an = min(an, mx - mn);
	}
	f(i, 1, h){
		ll s1 = (ll)i * w, s2 = (ll)(h - i) * (w >> 1), s3 = (ll)(h - i) * (w + 1 >> 1);
		ll mx = max(s1, max(s2, s3));
		ll mn = min(s1, min(s2, s3));
		an = min(an, mx - mn);
		s2 = (ll)(h - i >> 1) * w, s3 = (ll)(h - i + 1 >> 1) * w;
		mx = max(s1, max(s2, s3));
		mn = min(s1, min(s2, s3));
		if (mn)an = min(an, mx - mn);
	}
	printf("%lld\n", an);
}

Measured memory_bytes: 256
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <cmath>  
#include <algorithm>  
#include <vector>  
#include <map>  
using namespace std;  
typedef long long LL;  
const int N = 1100000;  
int vis[2010][2010];  
  
  
int main()  
{  
    int s1, e1, s2, e2;  
    scanf("%d %d %d %d", &s1, &e1, &s2, &e2);  
    for(int i=1;i<=(e2-e1);i++) printf("U");  
    for(int i=1;i<=(s2-s1);i++) printf("R");  
    for(int i=1;i<=(e2-e1);i++) printf("D");  
    for(int i=1;i<=(s2-s1);i++) printf("L");  
  
    printf("L");  
    for(int i=1;i<=(e2-e1)+1;i++) printf("U");  
    for(int i=1;i<=(s2-s1)+1;i++) printf("R");  
    printf("D");  
  
    printf("R");  
    for(int i=1;i<=(e2-e1)+1;i++) printf("D");  
    for(int i=1;i<=(s2-s1)+1;i++) printf("L");  
    printf("U\n");  
    return 0;  
}  



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

using namespace std;

long long n;
set<long long> se;

int main() {
	scanf("%lld", &n);
	se.insert(1), se.insert(n);
	for(int i = 2; 1LL * i * i <= n; ++i) {
		if(n % i) continue;
		long long d = i, temp = n / d;
		while(temp % d == 0) temp /= d;
		if(temp % d == 1) se.insert(d);
		d = n / i, temp = i;
		while(temp % d == 0) temp /= d;
		if(temp % d == 1) se.insert(d);
	}
	--n;
	for(int i = 1; 1LL * i * i <= n; ++i) {
		if(n % i) continue;
		se.insert(i), se.insert(n / i);
	} se.erase(1);
	printf("%d\n", int(se.size()));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
        cout<<"Yes"<<endl;
    }
    else if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
        cout<<"Yes"<<endl;
    }
    else if(s[0]==s[3] && s[2]==s[1] && s[0]!=s[2]){
        cout<<"Yes"<<endl;
    }
    
    else cout<<"No"<<endl;
    
}


Measured memory_bytes: 256
n=int(input())
s={}
for i in range(n):
  wd=input()
  if wd in s:
    s[wd]+=1
  else:
    s[wd]=1
mx=max(s.values())

ans=[]
for i in s.keys():
  if s[i]==mx:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)


Measured memory_bytes: 92040
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewReader(os.Stdin)

	result := make(map[string]int, 50)

	// アルファベットでmapを初期化する
	for i:=0; i<26; i++{
		result[string('a'+i)] = 0
	}

	for{
		str, err := scanner.ReadString('\n')
		if err == io.EOF{
			break
		}
		for _, s := range str{
			result[strings.ToLower(string(s))]++
		}
	}

	for i:=0; i<26; i++{
		fmt.Printf("%s : %d\n", string('a'+i), result[string('a'+i)])
	}
}


Measured memory_bytes: 1112
import numpy as np
import itertools

N, M = map(int, input().split())
a = np.zeros((M,N), dtype='int8')
for n in range(M):
    for c in input().split()[1:]:
        a[n, int(c) - 1] = 1
p = np.array(list(map(int, input().split())))
count = 0
for case in itertools.product(range(2), repeat=N):
    np_case = np.array(case)
    b = np.sum(a * np_case, axis=1) % 2
    if all(p == b):
        count += 1
print(count)

Measured memory_bytes: 18604
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int k,s,ans=0;
	cin >> k >> s;
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++)
			if(s-i-j<=k&&i+j<=s)
				++ans;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#####segfunc######                                                              
def segfunc(x,y):
    return x+y

def init(init_val):
    #set_val                                                                    
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built                                                                      
    for i in range(num-2,-1,-1):
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2])
    
def update(k,x):
    k+=num-1
    seg[k]=x
    while k+1:
        k=(k-1)//2
        seg[k]=segfunc(seg[k*2+1],seg[k*2+2])

def query(p,q):
    if q<=p:
        return ide_ele
    p+=num-1
    q+=num-2
    res=ide_ele
    while q-p>1:
        if p&1==0:
            res=segfunc(res,seg[p])
        if q&1==1:
            res=segfunc(res,seg[q])
            q-=1
        p=p//2
        q=(q-1)//2
    if p==q:
        res=segfunc(res,seg[p])
    else:
        res=segfunc(segfunc(res,seg[p]),seg[q])
    return res

ide_ele=0
n,q=map(int,input().split())
num=2**(n-1).bit_length()
seg=[ide_ele]*2*num
a=list(map(int,input().split()))
init(a)
ans=0
for i in range(q):
    x,l,r=map(int,input().split())
    if x==0:
        update(l,query(l,l+1)+r)
    else:
        print(query(l,r))


Measured memory_bytes: 178104
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define PB push_back
#define MOD 100000000007
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld l,x,y,n,m,i,z,p,s,e,j,k,c,d,t,h,q;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin>>n;
  lld a[n],b[n],c[n],d[n];
  rep(i,0,n)
  {
    cin>>a[i];
  }  
  rep(i,0,n)
  {
    cin>>b[i];
  }
  k=0;
  for(i=0;i<n;i++)
  {
    k+=a[i];
    c[i]=k;
  }k=0;
  for(i=n-1;i>=0;i--)
  {
    k+=b[i];
    d[i]=k;
  }
  p=0;
  rep(i,0,n)
  {
    p=max(p,c[i]+d[i]);
  }
  cout<<p;
}

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt,factorial
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()

    p = n - k + 1
    b = k - 1

    def comb(n, r):
      if n-r>=0:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      else:
        return 0

    for i in range(1,k+1):
        pci = comb(p,i)
        bci1 = comb(b,i-1)
        print((pci*bci1)%MOD)

if __name__=="__main__":
    main()


Measured memory_bytes: 76428
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL n, k; cin >> n >> k;
    n -= n / k * k;
    cout << min(k - n, n) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

#define p(a, b) make_pair(a, b)
struct neighbor { int d1, d2; };
vector<int> G[100001];
bool visited[100001];

int main()
{
	int N, K;
	ll ans = 1;
	neighbor ng;
	queue<pair<int, neighbor> > q;

	cin >> N >> K;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	repc(i, 1, N) visited[i] = false;

	ng.d1 = 0;
	ng.d2 = 0;
	q.push(p(1, ng));
	visited[1] = true;

	while (!q.empty()) {
		pair<int, neighbor> item = q.front(); q.pop();
		neighbor nbr = item.second;
		bool first = true;
		int current = item.first;
		int size = G[current].size();

		if (K - nbr.d1 - nbr.d2 <= 0) {
			ans = 0;
			break;
		}
		ans = (ans * ((ll)K - nbr.d1 - nbr.d2)) % MOD;

		nbr.d2 = nbr.d1;
		nbr.d1 = 1;

		rep(i, size) {
			int next = G[current][i];

			if (visited[next]) continue;

			if (!first) nbr.d2++;
			first = false;
			q.push(p(next, nbr));
			visited[next] = true;
		}
	}

	cout << ans << endl;

	return 0;
}


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


int main(){
  int n,k;
  cin>>n>>k;
  int *arr=new int[n];
  long *dp=new long[n];
  for(int i=0;i<n;i++) cin>>arr[i];
  dp[0]=0;
  for(int i=1;i<n;i++){
    dp[i]=LONG_MAX;
    for(int j=1;j<=k && i-j>=0;j++){
      dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
    }
  }
  long ans=dp[n-1];
    cout<<ans<<endl;
    delete [] dp;
    delete [] arr;
  }
    

Measured memory_bytes: 1408
N, K = list(map(int,input().split()))
d = []
A = []
Nlist = []
for i in range(N):
  Nlist.append(0)
for i in range(K):
  temp = int(input())
  d.append(temp)
  temp = list(map(int,input().split()))
  A.append(temp)
  for j in range(len(temp)):
    Nlist[temp[j]-1] += 1
ans = 0
for i in range(N):
  if(Nlist[i]==0):
    ans += 1
print(ans)

Measured memory_bytes: 9220
n=int(input())
ans=10**100
for t in range(n+1):
    p=t
    q=n-p
    c=0
    while p>0:
        c+=p%6
        p=p//6
    while q>0:
        c+=q%9
        q=q//9
    ans=min(ans,c)
print(ans)








Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
using namespace std;

void b_a_to_z_string(void) {
	string s;
	int a_index, z_index;
	bool a_detect = false;
	bool z_detect = false;

	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (!a_detect) {
			if (s[i] == 'A') {
				a_index = i;
				a_detect = true;
			}
		}
		if(!z_detect){
			if (s[s.size() - 1 - i] == 'Z') {
				z_index = s.size() - 1 - i;
				z_detect = true;
			}
		}
		if (a_detect & z_detect) break;
	}

	cout << z_index - a_index + 1 << endl;
}

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

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n, r, p, c;
  int card[51], tmp1[51], tmp2[51];
  
  while(cin >> n >> r){
    if(n == 0 && r == 0) break;
    for(int i = 0 ; i < n ; i++){
      card[i] = n-i;
    }
    
    for(int i = 0 ; i < r ; i++){
      cin >> p >> c;
      p--;
      for(int j = 0 ; j < c ; j++) tmp1[j] = card[j+p];
      
      for(int j = p-1 ; j >= 0 ; j--) card[j+c] = card[j];
     
      for(int j = 0 ; j < c ; j++) card[j] = tmp1[j];
    
      /*cout << endl;
      for(int k = 0 ; k < n ; k++){
	cout << card[k] << endl;
	}*/
      
    }
    
    
    cout << card[0] << endl;
  }
  return 0;  
}
    

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

using namespace std;
typedef long long ll;

ll n, k, l;
ll allCases;

bool possible(vector<int> &v, int wanted) {
    vector<int> c_sum(n + 1);
    for (int i = 0; i < n; i++) {
        c_sum[i + 1] = v[i] < wanted;
        c_sum[i + 1] += c_sum[i];
    }

    ll count = 0;
    for (int i = 0; i <= n; i++) {
        int x = lower_bound(c_sum.begin(), c_sum.end(), c_sum[i] + k) - c_sum.begin();
        count += max(0LL, x - (i + k));
    }

    return count + l > allCases;
}

int main() {
    cin >> n >> k >> l;
    allCases = (n - k + 1) * (n - k + 2) / 2;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];

    int ok = 0;
    int ng = 200001;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if (possible(a, mid))ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;
int h[101010];
int Total[101010];
int main() {
	int N = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		Total[i] = INF;
	}
	Total[0] = 0;
	for (int i = 0; i < N; i++) {
		Total[i + 1] = min(Total[i + 1], Total[i] + abs(h[i + 1] - h[i]));
		if (i != N - 1) {
			Total[i + 2] = min(Total[i + 2], Total[i] + abs(h[i + 2] - h[i]));
		}
		
			
		
	}
	
	cout << Total[N-1] << endl;
	return 0;
}


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

signed main() {
  int H, W, K;
  cin >> H >> W >> K;
  
  vector<string> A(H);
  for( int i = 0; i < H; i++ ) cin >> A.at(i);
  
  vector<vector<int>> ans(H, vector<int>(W));
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ){
      ans.at(i).at(j) = -1;
    }
  }
  
  int count = 0; //何個目の苺のケーキを切り分けてるか
  int fullcount = 0; //通算何個目の苺か
  
  //横一列苺がないやつ
  vector<int> nasi;
  bool fg;
  for( int i = 0; i < H; i++ ){
    count = 0;
    fg = false;
    for( int j = 0; j < W; j++ ){
      if( A.at(i).at(j) == '#' ){
        count = fullcount + 1;
        fullcount++;
        ans.at(i).at(j) = count;
        fg = true;
      }else if( count > 0 && A.at(i).at(j) == '.' ) ans.at(i).at(j) = count;
    }
    if( fg == false ) nasi.push_back(i);
  }
  
  //逆から見て-1を埋める
  for( int i = 0; i < H; i++ ){
    for( int j = W-1; j > 0; j-- ){
      if( ans.at(i).at(j) != -1 && ans.at(i).at(j-1) == -1 ){
        ans.at(i).at(j-1) = ans.at(i).at(j);
      }
    }
  }
  
  if( nasi.size() > 0 ){
    for( int i = 0; i < W; i++ ){
      for( int j = 1; j < H; j++ ){
        if( ans.at(j).at(i) == -1 && ans.at(j-1).at(i) != -1 ){
          ans.at(j).at(i) = ans.at(j-1).at(i);
        }
      }
    }
    for( int i = 0; i < W; i++ ){
      for( int j = H-1; j > 0; j-- ){
        if( ans.at(j).at(i) != -1 && ans.at(j-1).at(i) == -1 ){
          ans.at(j-1).at(i) = ans.at(j).at(i);
        }
      }
    }
  }
  
  
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ){
      cout << ans.at(i).at(j) << " ";
    }
    cout << endl;
  }
      
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

lli mod = 1e9 + 7;

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a, h, w;
    vector<lli> v;
    cin >> h >> w;
    vector<string> arr(h + 2);
    fr(i, 0, h) {
        cin >> arr[i];
    }

    vector<lli> p(w + 2, 0);
    vector<vector<lli>> dp(h + 2, p);
    dp[0][0] = 1;
    for (lli i = 0; i < h; i++) {
        for (lli j = 0; j < w; j++) {
            if (arr[i][j] == '.') {
                if (i != 0) {
                    dp[i][j] += dp[i - 1][j];
                    dp[i][j] %= mod;
                }
                if (j != 0) {
                    dp[i][j] += dp[i][j - 1];
                    dp[i][j] %= mod;
                }
            }
        }
    }

    cout << dp[h - 1][w - 1] << endl;
    rt;
}


Measured memory_bytes: 9216
//In The Name Of God
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<ll, ll> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<vii> vvii;

#define forn(i, n) for (int i = 0; i < n; i++)
#define forr(i, n) for (int i = n; i >= 0; i--)
#define forne(i, x, n) for (int i = x; i < n; i++)
#define forre(i, x, n) for (int i = n; i >= x; i--)
#define all(a) (a).begin(), (a).end()
#define eps 1e-9

ll inf = 1LL << 50;
const int maxn = 410;
ll dp[maxn][maxn];
vi al;

ll get(int i, int j) {
    return al[j + 1] - al[i];
}

int main() {
    ios::sync_with_stdio(false);
    forn(i, maxn) forn(j, maxn) dp[i][j] = inf;
    int n; cin >> n;
    al.assign(n + 1, 0);
    forn(i, n) cin >> al[i + 1];
    forn(i, n) dp[i][i] = 0;
    forne(i, 2, n + 1) al[i] += al[i - 1];
    forne(i, 2, n + 1) forn(j, n) if(j + i <= n) {
        int l = j, r = j + i - 1;
        forne(k, l, r) {
            dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + get(l, r));
        }

    }
    cout << dp[0][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1536
import java.io.FileNotFoundException;
import java.util.Scanner;

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

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	String a = sc.next();

    	if(Character.isUpperCase(a.charAt(0))) {
    		System.out.println("A");
    	} else {
    		System.out.println("a");
    	}


    }
}


Measured memory_bytes: 26976
MOD =  pow(10,9)+7
def MODINV(n:int, MOD=MOD):
    return pow(n, MOD-2, MOD)

def perm(n, k, MOD):
    numer = 1
    for i in range(n, n-k, -1):
        numer *= i
        numer %= MOD
    return numer

def main():
    N, M = map(int, input().split())
    if N == M+1 or N+1 == M:
        ans = (perm(N, N, MOD)*perm(M, M, MOD))%MOD
    elif N == M:
        ans = (2*(perm(N, N, MOD)*perm(M, M, MOD)))%MOD
    else:
        ans = 0
    print(ans)

if __name__ == "__main__":
    main()


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

int main(){
    int N, M;
    char s[110][20], t[110][20];
    int checks[110], checkt[110];
    int sum=0, ans=0;

    scanf("%d", &N);
    for(int i=0; i<N; i++){
        scanf("%s", &s[i]);
        checks[i] = 0;
    }
    scanf("%d", &M);
    for(int i=0; i<M; i++){
        scanf("%s", &t[i]);
        checkt[i] = 0;
    }
    for(int i=0; i<N; i++){
        sum=0;
        if(checks[i]==0){
            //printf("%s\n", s[i]);
            for(int j=i; j<N; j++){
                if(strcmp(s[i],s[j])==0){
                    sum++;
                    checks[j]=1;
                }
            }
            for(int j=0; j<M; j++){
                if(strcmp(s[i],t[j])==0){
                    sum--;
                }
            }
            if(sum>ans){
                ans=sum;
            }
        }
        //printf("%d\n", ans);
    }
    printf("%d", ans);

    return 0;
}

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

char s[3000000];

int main(){
	
	string str;
	int q, t, f;
	char c;
	bool rev = false;
	
	cin >> str >> q;
	for(int i=0;i<str.length();i++){
		s[i+1500000] = str[i];
	}
	int l = 1500000-1, r = 1500000+str.length();
	for(int i=0;i<q;i++){
		cin >> t;
		if(t==1){
			if(rev)
				rev = false;
			else
				rev = true;
		}	
		else{
			cin >> f >> c;
			if((f==1 && !rev) || (f==2 && rev)){
				s[l--] = c;
			}
			else{
				s[r++] = c;
			}
		}
	}
	
	if(!rev){
		for(int i=l+1;i<r;i++){
			cout << s[i];
		}
		cout << endl;
	}
	else{
		for(int i=r-1;i>l;i--){
			cout << s[i];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1024
package main

// Solution for https://atcoder.jp/contests/abc070/tasks/abc070_d

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

type edge struct{ to, cost int }

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	e := make([][]edge, n)
	for i := 1; i < n; i++ {
		var a, b, c int
		con.Scan(&a, &b, &c)
		a--
		b--
		e[a] = append(e[a], edge{b, c})
		e[b] = append(e[b], edge{a, c})
	}
	var q, k int
	con.Scan(&q, &k)
	c := make([]int, n)
	var dfs func(p, q, r int)
	dfs = func(p, q, r int) {
		c[p] = r
		for _, x := range e[p] {
			if x.to == q {
				continue
			}
			dfs(x.to, p, r+x.cost)
		}
	}
	dfs(k-1, -1, 0)
	for i := 0; i < q; i++ {
		var x, y int
		con.Scan(&x, &y)
		con.Println(c[x-1] + c[y-1])
	}
	return nil
}


Measured memory_bytes: 27860
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  static vector<int> H[100001];
  static int D[100001];
  while (M--) {
    int a, b;
    cin >> a >> b;
    H[a].emplace_back(b);
    ++D[b];
  }
  queue<int> Q;
  for (auto u = 1; u <= N; ++u)
    if (!D[u])
      Q.emplace(u);
  static int F[100001];
  while (!Q.empty()) {
    auto u = Q.front();
    Q.pop();
    for (auto v : H[u]) {
      F[v] = max(F[v], F[u] + 1);
      if (!--D[v])
        Q.emplace(v);
    }
  }
  cout << *max_element(F + 1, F + N + 1) << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  string s,a="abcdefghijklmnopqrstuvwxyz";
 
  cin>>s;
  int sz=s.size();
  for(int i=0;i<26;i++){
    bool flag=false;
    for(int j=0;j<sz;j++){
      if(a[i]==s[j]) flag=true;
    }
    if(!flag){
        cout<<a[i]<<endl; 
        return 0; 
    }
  }
  cout<<"None"<<endl;
 
} 

Measured memory_bytes: 512
N=int(input())
A=list(map(int,input().split()))

from collections import Counter
counter=Counter(A)

ANS=0

for i in counter:
    if counter[i]==i:
        continue
    elif counter[i]>i:
        ANS+=counter[i]-i
    else:
        ANS+=counter[i]

print(ANS)


Measured memory_bytes: 18168
#include <stdio.h>


int main(void)
{
	//変数の宣言
	int x,a,b,c;
	int ans=0;
	int remain;
	int i,j,k;
	
	//データの読み込み
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&x);
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			remain=x-500*i-100*j;
			if(remain/50>=0&&remain/50<=c) ans++;
		}
	}
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string w;
    cin >> w;
    vector<int> v(26, 0);
    for (const char c : w) {
        v[c - 'a']++;
    }
    for (const int n : v) {
        if (n % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
const ll mx=1e18;
int main()
{
    ll a,b=0,c=0;
    string s;
    cin>>a>>s;
    rep(i,s.size())
    {
        if(s[i]=='.') break;
        b=b*10+s[i]-'0';
    }
    c=10*(s[s.size()-2]-'0')+s[s.size()-1]-'0';
    cout<<a*b+a*c/100;
}


Measured memory_bytes: 3624
from collections import deque

input_list = input()
area = 0
depth_arr = deque()
area_arr = deque()

for i, input_str in enumerate(input_list):
    if "\\" == input_str:
        depth_arr.append(i)
    elif "/" == input_str:
        if len(depth_arr):
            position = depth_arr.pop()
            pool = i - position
            area += pool

            while len(area_arr):
                pre_position, pre_pool = area_arr.pop()
                if position <= pre_position:
                    pool += pre_pool
                else:
                    area_arr.append((pre_position, pre_pool))
                    break
            area_arr.append((position, pool))

areas = 0
for pos, pool in area_arr:
    areas += pool
print(areas)
print(len(area_arr), *[list[1] for list in area_arr])

Measured memory_bytes: 8528
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      string s;
      cin >> s;
      for(int i=0; i<s.size(); i++){
        if(s.at(i)=='C'){
          for(int j=i+1; j<s.size(); j++){
            if(s.at(j)=='F'){
              cout << "Yes" << endl;
              return 0;
            }
          }
        }
      }
      cout << "No" << endl;
      return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,x;
	scanf("%d",&x);
	int a[x];
	for(i=0;i<x;i++)
	{
		scanf("%d",&a[i]);
		
	}
	for(i=x-1;i>=0;i--)
	{
		if(i>0)
		printf("%d ",a[i]);
		else
		printf("%d",a[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2028
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int a,b;
cin>>a>>b;
for(int i=0;i<=2000;i++){
    int c=int(double(i)*0.08),d=int(double(i)*0.10);
    if(c==a&&d==b){
        cout<<i<<endl;
        return 0;
    }
}
cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define H_MAX 50
#define W_MAX 50


int main()
{
    int h, w;
    char s[H_MAX][W_MAX + 1];
    
    scanf("%d %d", &h, &w);
    for (int i = 0; i < h; i++)
    {
	scanf("%s", &s[i]);
    }
    
    for (int i = 0; i < h; i++)
    {
	for (int j = 0; j < w; j++)
	{
	    if (s[i][j] == '#')
	    {
		if (i > 0) // 上
		{
		    if (s[i - 1][j] == '#')
		    {
			continue;
		    }
		}
		if (j > 0) // 左
		{
		    if (s[i][j - 1] == '#')
		    {
			continue;
		    }
		}
		if ((j - 1) < w) // 右
		{
		    if (s[i][j + 1] == '#')
		    {
			continue;
		    }
		}
		if ((i - 1) < h) // 下
		{
		    if (s[i + 1][j] == '#')
		    {
			continue;
		    }
		}
		printf("No\n");
		return 0;
	    }
	}
    }

    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (i=a;i<n;i++)
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){

	int i,j,k,n;
	ll ans=0;
	cin>>n;
	rep(i,1,n+1)
		rep(j,1,n+1)
			rep(k,1,n+1)
				ans+=gcd(gcd(i,j),k);
	cout<<ans;

	return 0;
}


Measured memory_bytes: 3632
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 10000000009

int main() {
    FAST_IO
    ll n,y,i,j,k,x=0,yy=0,z=0,ans=0,sum=0,rest=0,c=0;
    cin>>n>>y;
    y /= 1000;
	x = 10;
	yy = 5;
	z = 1;
	for ( i = 0; i <= n; i++) {
		for (j = 0; j <= n; j++) {
            sum = i + j;
            rest = n - sum;
			if (rest >= 0) {
                ans = i*x + yy*j + z*rest;
				if (ans == y) {
					cout << i << " " << j << " " << rest << endl;
					return 0;
				}
			}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;
return 0;
}


Measured memory_bytes: 256
def main():
    from collections import Counter
    n,k=[int(i) for i in input().split()]
    c=Counter([int(i) for i in input().split()])
    key=sorted(c,key=lambda x:c[x])
    ans=0
    if len(c)-k <=0:
        print("0")
    else:
        for i in key[:len(c)-k]:
            ans+=c[i]
        print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 32512
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=2005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int dp[N][N];
int cache[N];
int32_t main()
{
    IOS;
    int s;
    cin>>s;
    dp[0][0]=1;
    int ans=0;
    for(int i=1;(3*i)<=s;i++)
    {
        cache[0]=dp[i-1][0];
        for(int j=1;j<=s;j++)
        cache[j]=(cache[j-1]+dp[i-1][j])%mod;
        for(int j=3*i;j<=s;j++)
        dp[i][j]=cache[j-3];
        fill(cache, 0);
        ans=(ans+dp[i][s])%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 11132
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  
  // read data
  int n, m;
  cin >> n >> m;
  int pena[105000];
  bool ac[105000];
  
  for(int i = 1; i <= n; i++){
  	pena[i] = 0;
    ac[i] = false;
  }
  
  int real_pena = 0;
  int num_ac = 0;
  for(int i = 0; i < m; i++){
    int id;
    string sac;
  	cin >> id >> sac;
    if(ac[id]){
      continue;
    }
    if(sac == "AC"){
      num_ac++;
      ac[id] = true;
      real_pena += pena[id];
    }else{
      pena[id] += 1;
    }
  }
  cout << num_ac << " " << real_pena << endl;
}

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

void main_()
{
    ll N;
    cin >> N;

    ll A1;
    cin >> A1;

    auto ans = A1;
    for (ll i = 1; i < N; ++i) {
        ll A;
        cin >> A;
        ans = __gcd(ans, A);
    }
    cout << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(ll i=a;i<=(ll)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
vector<int> v(101);int n;
void pre() {
    repp(i,1,n) {
        int q=sqrt(i),k=i;
        repp(j,2,q) {
            if(k%j==0) {
                while(k%j==0) {k/=j;v[j]++;}
            }
        }
        if(k>1) v[k]++;
    }
}
int cal(int x) {
    int t=0;
    repp(i,2,n) {
        if(v[i]>=x-1) t++;
    }
    return t;
}
int main() {
    cs
    cin>>n;
    pre();
    cout<<cal(75)+cal(25)*(cal(3)-1)+cal(15)*(cal(5)-1)+(cal(5)*(cal(5)-1)*(cal(3)-2))/2;
}

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

struct Card
{
    char suit, value;
};

void bubble(struct Card card[], int N)
{
    for (int i = 0; i < N; i++)
    {
        for (int j = N - 1; j >= i + 1; j--)
        {
            if (card[j].value < card[j - 1].value)
            {
                Card t = card[j];
                card[j] = card[j - 1];
                card[j - 1] = t;
            }
        }
    }
}

void selection(Card card[], int N)
{
    for (int i = 0; i < N; i++)
    {
        int minj = i;
        for (int j = i; j < N; j++)
        {
            if (card[j].value < card[minj].value)
            {
                minj = j;
            }
        }
        Card t = card[i];
        card[i] = card[minj];
        card[minj] = t;
    }
}
void print(Card c[], int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i)
            cout << " ";
        cout << c[i].suit << c[i].value;
    }
    cout << endl;
}

bool isStable(Card c1[], Card c2[], int N)
{
    for (int i = 0; i < N; i++)
    {
        if (c1[i].suit != c2[i].suit)
            return false;
    }
    return true;
}

int main()
{
    Card C1[100], C2[100];
    int N;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> C1[i].suit >> C1[i].value;
        C2[i] = C1[i];
    }

    bubble(C1, N);
    selection(C2, N);
    print(C1, N);
    cout << "Stable" << endl;

    print(C2, N);
    if (isStable(C1, C2, N))
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int gcd(int x,int y){
if(x==0 || y==0)
  return max(x,y);
  else{
  if(x<y)
    return gcd(x,y%x);
    else if(y<x)
      return gcd(y,x%y);
    else
      return x;
  }

}
int main(){
int N;
  cin>>N;
  int Min;
  cin>>Min;
  for(int i=0;i<N-1;i++){
  int a;
    cin>>a;
    Min=gcd(a,Min);
  }cout<<Min<<endl;
         return 0;
  }

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

using namespace std;

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

  for (int x = 0; x <= n; x++) {
    for (int y = 0; y <= n; y++) {
      int need = sum_y - (10000 * x + 5000 * y);
      int z = n - (x + y);
      if (z < 0 || need < 0) {
        continue;
      }
      if (need == z * 1000) {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <limits.h>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >>A>>B;
    if (A > 8 || B > 8) {
        cout << ":(\n";
    }
    else {
        cout << "Yay!\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int p,q,a,n;
inline bool ge(int a,int b,int c,int d){
  return a*d <= b*c;
}
inline bool eq(int a,int b,int c,int d){
  return a*d == b*c;
}
int func(int np,int nq,int nn,int nu){
  if(nn == n){
    return eq(p,q,np,nq);
  }
  if(ge(p,q,np,nq)){
    return eq(p,q,np,nq);
  }
  if(nq*nu>a)return 0;
  int res = func(np,nq,nn,nu+1);
  np *= nu;
  np += nq;
  nq *= nu;
  res += func(np,nq,nn+1,nu);
  return res;
}
int main(){
  while(cin>>p>>q>>a>>n&&p){
    cout << func(0,1,0,1) << endl;
  }
  return 0;
}



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

int main() {
  int n; cin >> n;
  long long ans[n];
  ans [0] = 2; ans[1] = 1;
  for(int i = 0; i < n; i++) ans[i+2] = ans[i] + ans[i+1];
  cout << ans[n] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int A[100][100];
    int k=50;
    // 1 white 2 black
    REP(i,100) {
        REP(j,k) {
            A[i][j]=1;
        }
        REP1(j,k,99) {
            A[i][j]=2;
        }
    }
    int a,b;
    cin >> a >> b;
    --a; --b;
    // draw black
    for ( int j=1; j<k-1; j+=2 ) {
        for ( int i=1; i<100 && b>0; i+=2 ) {
            A[i][j]=2;
            b--;
        }
    }
    // draw black
    for ( int j=k+1; j<100; j+=2 ) {
        for ( int i=1; i<100 && a>0; i+=2 ) {
            A[i][j]=1;
            a--;
        }
    }
    cout << 100 << ' ' << 100 << '\n';
    for ( int i=0; i<100; i++ ) {
        for ( int j=0; j<100; j++ ) {
            if ( A[i][j]==1 ) {
                cout << '.';
            }
            else {
                cout << '#';
            }
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256