akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 1000000
void insertionSort(int [],int,int);
void shellSort(int [],int);
int cnt = 0;

int main(){
  int b,i,a[N];
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&a[i]);
  }
  shellSort(a,b);
  printf("%d\n",cnt);
  for(i=0;i<b;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}

void insertionSort(int A[],int n,int g){
  int i,j,v;
  for(i=g;i<n;i++){
    v = A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g] = A[j];
      j = j - g;
    cnt++;
    }
    A[j+g] = v;
  }
}


void shellSort(int A[],int n){
  int i,m=0;
  int G[n];

  G[0]=0;
  for(i=0;i<n;i++){
    G[i+1] = 3*G[i]+1;
    m++;
    if(G[i+1]>N) break;
  }
  while(G[m]>n){
    m--;
  }
  printf("%d\n",m);
  for(i=m;i>1;i--){
    printf("%d ",G[i]);
  }
  printf(" %d\n",G[1]);
  for(i=m;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}

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

void lcs(string a,string b,ll m,ll n){
    string s="";
    ll l[m+1][n+1];
    ll i,j;
    for(i=0;i<=m;i++){
        for(j=0;j<=n;j++){
            if(i==0||j==0)
                l[i][j]=0;
            else if(a[i-1]==b[j-1]){
                l[i][j]=l[i-1][j-1]+1;
               // s=s+a[i-1];
            }
            else
                l[i][j]=max(l[i-1][j],l[i][j-1]);
        }
    }
    while(m>=0 && n>=0){
        if(l[m][n]==l[m-1][n]){
            m=m-1;
            continue;
        }
        else if(l[m][n]==l[m][n-1]){
            n=n-1;
            continue;
        }
        else{
            m=m-1;
            n=n-1;
            if(m>=0 && n>=0)
            s=s+a[m];
        }
    }
    reverse(s.begin(),s.end());

    cout<<s;
}

int main(){
    string a,b;
    cin>>a>>b;
    ll m=a.size();
    ll n=b.size();
    lcs(a,b,m,n);
}


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

#define MAX_N 500000
struct Node {
	int key;
	Node *parent;
	Node *left;
	Node *right;
	Node() :key(0), parent(NULL), left(NULL), right(NULL) {}
	~Node(){}
};

Node *root, *NIL;

void insert(int key) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = new Node;
	z->key = key;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
	return;
}

void inorder(Node *u) {
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
	return;
}

void preorder(Node *u) {
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
	return;
}

int main() {
	int n = 0;
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		string order;
		cin >> order;
		if (order == "insert") {
			int key;
			scanf("%d", &key);
			insert(key);
		}
		else {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 26704
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int k, n, a[200009], ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	ans = k;
	for (int i = 0; i < n - 1; i++) {
		ans = min(ans, k - (a[i + 1] - a[i]));
	}
	ans = min(ans, k - (a[0] + k - a[n - 1]));
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int n, a[5005], dp[5005][4];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i <= a[0]; ++i) {
		dp[0][i] = i;
	}
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= a[i]; ++j) {
			dp[i][j] = inf;
			for (int k = 0; k <= a[i - 1]; ++k) {
				if (a[i - 1] - k - j <= 0) {
					dp[i][j] = min(dp[i][j], dp[i - 1][k] + 2 * j);
				}
			}
		}
	}
	int ret = inf;
	for (int i = 0; i <= a[n - 1]; ++i) {
		ret = min(ret, dp[n - 1][i] + (a[n - 1] - i));
	}
	cout << ret << '\n';
	return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
bool is_ok(ll x, ll y){
    if(x == y) return true;
    else return false;
}
int main(){

    deque<char> s;
    string u;
    cin >> u;
    for(int i = 0; i < u.size(); i++){
        s.push_back(u[i]);
    }
    int q;
    cin >> q;

    bool flg_rev = false;

    for(int i = 0; i < q; i++){
        int t;
        cin >> t;
        if(t == 1){
            if(flg_rev) flg_rev = false;
            else flg_rev = true;
        }
        else if(t == 2){
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(!flg_rev){
                if(f == 1) s.push_front(c);
                else if(f == 2) s.push_back(c);
            }
            else{
                if(f == 1) s.push_back(c);
                else if(f == 2) s.push_front(c);
            }
        }
    }
    
    if(flg_rev){
        reverse(s.begin(), s.end());
    }
    for(int i = 0; i < s.size(); i++){
        cout << s[i];
    }
    cout << endl;
}


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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> c(n - 1), s(n - 1), f(n - 1);
    for(int i = 0; i < n - 1; i++){
        std::cin >> c[i] >> s[i] >> f[i];
    }

    for(int i = 0; i < n - 1; i++){
        int time = s[i];
        time += c[i];

        // 今i + 1地点に来た
        for(int now = i + 1; now < n - 1; now++){
            // 待ち時間の考慮
            if(time < s[now]){
                time = s[now];
            }else{
                if(time % f[now] != 0){
                    time += f[now] - time % f[now];
                }
            }

            // 乗る
            time += c[now];
        }

        std::cout << time << std::endl;
    }
    std::cout << 0 << std::endl;
    return 0;
}


Measured memory_bytes: 256
n = int(raw_input())
edges = [map(int , raw_input().split()) for _ in range(n-1)] 


q = 0
for i in range(1, n + 1): q += i * (n - i + 1)
for u,v in edges:
	u,v = min(u,v), max(u,v)
	q += (u ) * (n -v +1) * -1
print q

Measured memory_bytes: 97612
#include<bits/stdc++.h>
using namespace std;
int main(int args, char** argv){
  int n,m;
  cin>>n>>m;
  int count=0;
 
  vector<int>arr(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>arr[i];
    sum+=arr[i];
  }
  for(int i=0;i<n;i++){
    if(arr[i]*4*m>=sum){
      count++;
    }
  }
  if(count>=m){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  
  return 0;
}


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

void compare(vector<ll>& v,vector<ll>::iterator itr,bool fr){ //fr : true 1引く

	vector<ll>::iterator nitr = itr;
	nitr++;

	if(nitr == v.end()){
		cout << "Yes" << endl;
		return;
	}

	if(fr){ // 1引ける状態
		if(*itr - 1 == *nitr) compare(v,nitr,0);
		if(*nitr - (*itr -1) >= 1) compare(v,nitr,1);
		if(*nitr - (*itr -1) < 0){ cout << "No" << endl; return;}
	}else{
		if(*itr == *nitr) compare(v,nitr,0);
		if(*nitr - *itr >= 1) compare(v,nitr,1);
		if(*nitr - *itr < 0){ cout << "No" << endl; return;}
	}
}


int main(){
	int n;
	cin >> n;
	vector<ll> h;

	int th;
	rep(i,n){

		cin >> th;
		h.push_back(th);
	}
	vector<ll>::iterator itr = h.begin();
	compare(h,itr,0);

	return 0;
}

Measured memory_bytes: 4340
#include <iostream>

int main()
{
    int a,b;
    int max;
    std::cin >> a >> b;
    max = a + b;
    if(max < a - b) max = a - b;
    if(max < a * b) max = a * b;
    std::cout << max << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1].value=R[n2].value=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
  }
}

void mergesort(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(A,n,left,mid);
    mergesort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n,int p,int r){
  int i,j;
  struct Card temp,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}

void quicksort(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quicksort(A,n,p,q-1);
    quicksort(A,n,q+1,r);
  }
}
int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char str[10];
  int stable=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",str,&v);
    A[i].suit=B[i].suit=str[0];
    A[i].value=B[i].value=v;
  }
  mergesort(A,n,0,n);
  quicksort(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}

Measured memory_bytes: 2952
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
#define mod  1000000007
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define pi  3.141592653589793238
#define ms(x,v) ((x), v, sizeof((x)))
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
ll i, j, k;
ll dp[15][15];
ll get_first(ll x){
   ll b;
   while(x){
     b = x % 10;
     x/=10;
   }
   return b;
}
void solve(){
     ll n;  cin >> n; 
     for(i = 1; i <= n; i++){
        dp[get_first(i)][i%10]++;
     }
     ll ans = 0;
     for(i = 0; i <= 9; i++){
       for(j = 0; j <=9; j++){
            ans = ans + dp[i][j]*dp[j][i];
       }
     }

       cout << ans << endl;
           

     return ; 
} 
    signed main(){
    //CASET
    solve();
    
   
    return 0;
  }

Measured memory_bytes: 256
import math


a, b, h, m = map(int, input().split())


h_t = (h + m / 60) * (360 / 12)
m_t = m * (360 / 60)

t = abs(h_t - m_t)
print(
    math.sqrt((float(a**2 + b**2)) - (float(2*a*b*math.cos(math.radians(t)))))
)


Measured memory_bytes: 9508
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++)
        cin>>d[i];
    set<int>a;
    for(int i=0;i<n;i++)
        a.insert(d[i]);
    cout<<a.size()<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
import java.lang.Math.*


fun main(args: Array<String>) {
    val (n, d) = readIntList()
    val x = mutableListOf<MutableList<Int>>()
    n.rep {
        x.add(readIntList().toMutableList())
    }
    var ans = 0
    n.rep { i0 ->
        n.rep { i1 ->
            if (i0 == i1) {
            } else {
                val doubleVal = sqrt(x[i0].mapIndexed { index: Int, i: Int ->
                    abs(i - x[i1][index]) * abs(i - x[i1][index])
                }.sum().toDouble())
                val intVal = doubleVal.toInt()
                if (doubleVal - intVal < 0.0000001) {
                    ans++
                }
            }
        }
    }
    println(ans / 2)
}


fun readList() = readLine()!!.split(' ')
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

Measured memory_bytes: 36520
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
	int h,w;
	cin>>h>>w;
	string s;
	vector<string> A;
	rep(i,h){
		cin>>s;
		A.push_back(s);
	}
	queue<pair<int,int>> q;
	rep(i,h){
		rep(j,w){
			if(A[i][j] == '#'){
				q.push(pair<int,int>{i,j});
			}
		}
	}
	int ans = 0;
	while(q.size() > 0){
		queue<pair<int, int>> q2;
		while(q.size() > 0){
			pair<int, int> p = q.front();
			q.pop();
			int tate = p.first;
			int yoko = p.second;
			for(int i=-1; i<=1; i++){
				for(int j=-1; j<=1; j++){
					if(abs(i) + abs(j) != 1) continue;
					if(tate+i < 0 || tate+i >= h || yoko+j < 0|| yoko+j >= w) continue;
					if(A[tate+i][yoko+j] == '.'){
						A[tate+i][yoko+j] = '#';
						q2.push(pair<int,int>{tate+i,yoko+j});
					}
				}
			}
		}
		if(q2.size() == 0){
			break;
		}
		ans++;
		q = q2;

	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 9600
import sys
import math
import bisect
import atexit
import io
import heapq
from collections import defaultdict, Counter
MOD = int(1e9+7)



# n = map(int, raw_input().split())
# input = map(int, raw_input().split())
def main():
    n = map(int, raw_input().split())[0]
    d = defaultdict(int)
    for i in range(n):
        s = raw_input()
        s = ''.join(sorted(s))
        d[s] += 1
    ans = 0
    for v in d.itervalues():
        if v > 1:
            ans += v * (v-1)/2
    print ans
main()


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

int N,K;
int main(){
	while(cin >> N >> K && N>0){
		int a[2][N+1];
		for(int i=0;i<N;i++){
			if(i==0){
				a[0][i] = 2;
				a[1][i] = 1+K;
			}
			else{
				a[0][i] = 2*min(a[0][i-1],a[1][i-1]);
				a[1][i] = K+min(a[0][i-1],a[1][i-1]);
			}
		}
		cout << min(a[0][N-1],a[1][N-1]) << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define f(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
int main(){

  ll h,w;
  cin>>h>>w;

char cc[h][w];

f(i,0,h){
    f(j,0,w){
        cin>>cc[i][j];
    }
}

ll dp[h][w];
f(i,0,h){
    f(j,0,w){
        dp[i][j]=0;
        if(cc[i][j]=='#'){
            dp[i][j]=-1;
        }
    }
}

f(i,0,w){
if(cc[0][i]=='#'){
break;
}
dp[0][i]=1;
}


f(i,0,h){
if(cc[i][0]=='#'){
break;
}
dp[i][0]=1;
}




f(i,1,h){
    f(j,1,w){
        if(cc[i][j]=='#'){
            continue;
        }
        if(cc[i-1][j]!='#'){
            dp[i][j]+=dp[i-1][j];
        }
dp[i][j]=dp[i][j]%mod;
        if(cc[i][j-1]!='#'){
            dp[i][j]+=dp[i][j-1];
        }
dp[i][j]=dp[i][j]%mod;


    }
}
if(cc[h-1][w-1]=='#'){
    cout<<"0"<<endl;
}
else{
    cout<<dp[h-1][w-1]%mod<<endl;
}



// f(i,0,h){
//     f(j,0,w){
// cout<<dp[i][j]<<" ";
// }cout<<endl;}


    }




Measured memory_bytes: 9088
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
char a[100+5],b[100+5],c[100+5],x;
int f1=0,f2=-1,f3=-1,alen,blen,clen;
char ans;
int main()
{
	scanf("%s%s%s",a,b,c);
	alen=strlen(a);
	blen=strlen(b);
	clen=strlen(c);
	x=a[0];
	while(1)
	{
		if(x=='a')
		{
			f1++;
			if(f1>=alen)
			{
				ans='A';
				break;
			}
			x=a[f1];
		}
		if(x=='b')
		{
			f2++;
			if(f2>=blen)
			{
				ans='B';
				break;
			}
			x=b[f2];
		}
		if(x=='c')
		{
			f3++;
			if(f3>=clen)
			{
				ans='C';
				break;
			}
			x=c[f3];
		}
	}
	printf("%c\n",ans);
	return 0;
}


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

int main() {
	// your code goes here
	long int N, trans[5];
	cin >> N;
	for(int i=0; i<5; i++){
	    cin >> trans[i];
	}
	long int min = trans[0];
	for(int i=1; i<5; i++){
	    if(min > trans[i])
	        min = trans[i];
	}
	
	cout << 5 + (N-1) / min << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
using namespace std;

int main(){
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    
    for (int i = 0; i < H-B; i++)
    {
        for (int j = 0; j < A; j++)
        {
            cout << "0";
        }
        for (int j = 0; j < W-A; j++)
        {
            cout << "1";
        }
        cout << endl;
    }
    for (int i = 0; i < B; i++)
    {
        for (int j = 0; j < A; j++)
        {
            cout << "1";
        }
        for (int j = 0; j < W-A; j++)
        {
            cout << "0";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main(void){
   int h,w,k;
   long long p=1000000007;
   scanf("%d%d%d",&h,&w,&k);
   int a[w][w];
   for(int i=0;i<w;i++){
       for(int j=0;j<w;j++)a[i][j]=0;
   }
   int b[10];
   b[0]=1;
   for(int i=1;i<10;i++)b[i]=b[i-1]*2;
   int c[w-1];
   int e;
   int g;
   int f[w];
   for(int i=0;i<b[w-1];i++){
       e=0;
       for(int j=0;j<w;j++){
           f[j]=j;
       }
       for(int j=0;j<w-1;j++){
           c[j]=i/b[j]%2;
       }
       for(int j=0;j<w-2;j++){
           if(c[j]&&c[j+1])e++;
       }
       if(e==0){
           for(int j=0;j<w-1;j++){
               if(c[j]){
                   g=f[j];
                   f[j]=f[j+1];
                   f[j+1]=g;
               }
           }
           for(int j=0;j<w;j++){
               a[j][f[j]]++;
           }
       }
   }
   long long dp[h][w];
   for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           dp[i][j]=0;
       }
   }
   for(int i=0;i<w;i++){
       dp[0][i]=a[0][i];
   }
   for(int i=1;i<h;i++){
       for(int j=0;j<w;j++){
           for(int k=0;k<w;k++){
               dp[i][j]+=dp[i-1][k]*a[k][j];
               dp[i][j]=dp[i][j]%p;
           }
       }
   }
   printf("%lld\n",dp[h-1][k-1]);
}

Measured memory_bytes: 128
from collections import deque
n, m = map(int, input().split())
graph = [[] for _ in range(n)]

cand = []
for _ in range(m):
  a, b = map(int, input().split())
  cand.append((a-1, b-1))
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)

def bfs(i):
  dist = [-1] * n
  dist[i] = 0
  d = deque()
  d.append(i)
  while d:
    v = d.popleft()
    for j in graph[v]:
      if dist[j] != -1:
        continue
      dist[j] = dist[v] + 1
      d.append(j)
  return dist

def judge(c):
  graph[c[0]].remove(c[1])
  graph[c[1]].remove(c[0])
  dist = bfs(0)
  graph[c[0]].append(c[1])
  graph[c[1]].append(c[0])
  for d in dist:
    if d == -1:
      return True
  return False

ans = 0
for c in cand:
  if judge(c):
    ans += 1
print(ans)



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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	int h1, m1, h2, m2, x;
	cin >>h1>>m1>>h2>>m2>>x;
	int A = h1*60+m1;
	int B = h2*60+m2;
	int R = B-A;
	if (R<0) R+=24*60;
	cout <<max(0,R-x)<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ');
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

int main () {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  rep(i,n) cin >> a[i];
  vector<string> b(m);
  rep(i,m) cin >> b[i];

  // n = 5, m = 2

  // 0 1 2 3 4
  // 1 2 3 4 5
  // 2 3 4 5 6
  // 3 4 5 6 7
  // 4 5 6 7 8

  // 0 1
  // 1 2

  for (int i = 0; i+m <= n; ++i) {
    for (int j = 0; j+m <= n; ++j) {
      bool ok = true;
      for (int k = 0; k < m; ++k) {
        if (a[i+k].substr(j,m) != b[k]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;
typedef pair<int, int> P;

int wa(ll n) {
    ll ans = 0;
    while (n > 0) {
        ans += (n % 10);
        n /= 10;
    }
    return ans;
}

int main() {

    int n;
    cin >> n;

    cout << (n % wa(n) == 0 ? "Yes" : "No") << endl;


}

Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    System.out.println(2*(nextInt())*(Math.PI));

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35764
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += B[A[i]-1]
    if i < N-1 :
        if A[i]+1 == A[i+1]:
            ans += C[A[i]-1]
print(ans)


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

const int N = 5e5+100, MOD = 998244353;

int add(ll a, int b){
	return (a + b + 2LL*MOD) % MOD;
}

int mul(ll a, int b){
	return (a * b) % MOD;
}

void sadd(int &a, int b){
	a = add(a, b);
}

void smul(int &a, int b){
	a = mul(a, b);
}

vector<int> divs[N];

int cnt[N];

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n;
	string x;
	cin >> n >> x;
	n *= 2;
	string t = x;
	for(auto &c : t)
		c = (c == '0' ? '1' : '0');
	x.insert(x.end(), t.begin(), t.end());
	for(int i=1 ; i<=n ; i++)
		for(int j=i ; j<=n ; j+=i)
			divs[j].push_back(i);
	vector<int> ds;
	for(int i=1 ; i<=n ; i++)
		if(n%i == 0 && n%(2*i) != 0)
			ds.push_back(i);

	int ans=0;
	for(auto g : ds){
		int cur=0;
		string cx;
		for(int i=0 ; i<g/2 ; i++){
			smul(cur, 2);
			if(x[i] == '1')
				sadd(cur, 1);
			cx.push_back(x[i]);
		}
		sadd(cnt[g], cur);
		for(int i=0 ; i<g/2 ; i++)
			cx.push_back((cx[i] == '0' ? '1' : '0'));
		for(int i=g ; i<n ; i++)
			cx.push_back(cx[i%g]);
		if(cx <= x)
			sadd(cnt[g], 1);
		for(auto d : divs[g])
			if(d != g)
				sadd(cnt[g], -cnt[d]);
		sadd(ans, mul(g, cnt[g]));
	}
	cout << ans << "\n";
}
















Measured memory_bytes: 48208
package main

import "fmt"

func main() {
	for {
		var n, x, cnt int
		fmt.Scan(&n, &x)
		if n == 0 && x == 0 {
			break
		}
		for i := 1; i <= n; i ++ {
			for j := i+1; j <= n; j++ {
				for k := j+1; k <= n; k++ {
					if i + j + k == x {
						// fmt.Println(i, j, k)
						cnt++
					}
				}
			}
		}
		fmt.Println(cnt)
	}
}


Measured memory_bytes: 1088
#include <iostream>
#include <string>
using namespace std;
int main () {
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.length() <= k) {
		cout << s << endl;
		return 0;
	}
	string o = "";
	for (int i=0; i<k; i++) {
		o += s[i];
	}
	o += "...";
	cout << o << endl;
	return 0;
}

Measured memory_bytes: 3576
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("POSSIBLE")
    elif q == 0:print("IMPOSSIBLE")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,m= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
#これを消すとなぜかWAになる呪い
right = set()
left = set()
for i in range(m):
    a = [int(i) for i in input().split()]
    if a[0] == 1:
        right.add(a[1])
    elif a[1] == n:
        left.add(a[0])
right = right & left
if len(right):j(1)
j(0)


Measured memory_bytes: 21148
open Scanf
open Printf

let rec f i x s =
	if 0 <> x then 
		let ss = s^"Case "^(string_of_int i)^": "^(string_of_int x)^"\n" in
		let c = read_int() in
		f (i+1) c ss
	else
		printf "%s" s;;

let ptc =
	let c = read_int() in
	let s = "" in
	f 1 c s;;

ptc;;

Measured memory_bytes: 9128
# https://atcoder.jp/contests/abc144/tasks/abc144_d

import math
a, b, x = map(int, input().split())

# 高さ
y = x / (a ** 2)

if y >= ((1 / 2) * b):
    d = math.atan2(2 * (y * a - a * b), a ** 2)

    # dを度数法単位に変換
    d_deg = math.degrees(d)

    print(abs(d_deg))

else:
    d = math.atan2((1 / 2) * (b ** 2), y * a)

    # dを度数法単位に変換
    d_deg = math.degrees(d)

    print(abs(d_deg))


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int n,x,count,i;
    scanf("%d",&n);

    count=0;
    for(i=1;i<=n;i++)
    {
        x=log10(i);

        if(x%2==0)
            ++count;
    }

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


return 0;


}

Measured memory_bytes: 512
import numpy as np
n,m,x = map(int,input().split())
CA = []
money = 10**7

for i in range(n):
  ca = list(map(int,input().split()))
  CA.append(ca)
  
CA = np.array(CA)
for i in range(2**n):
  tmp = 0
  X = np.array([0]*m)
  for j in range(n):
    if (i>>j)&1:
      X += CA[j][1:]
      tmp += CA[j][0]
  N = len([1 for z in X if z>=x])
  if N == m:
    money = min(money,tmp)

if money != 10**7:
  print(money)
else:
  print(-1)

Measured memory_bytes: 27080
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int r,d,x;
  cin>>r>>d>>x;
  for(int i=0;i<10;i++){
    x=r*x-d;
    cout<<x<<endl;
  }
  return 0;
}

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;
void solve(){
     string s;
     long long k;
     cin>>s>>k;
     
       for(int i=0;i<s.size();i++){
            if(i+1==k){
                     cout<<s[i];break;}
            else if(s[i]!='1'){
                     cout<<s[i];break;
             }
       }
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int N,M;
    cin >> N >> M;
    
    
    auto L=vector<int>(M);
    auto R=vector<int>(M);
    for(int i=0;i<M;i++)
        cin >> L[i] >> R[i];
    
    int minimum=*max_element(L.begin(),L.end());
    int maxium=*min_element(R.begin(),R.end());
    
    cout << max(0,maxium-minimum+1) <<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char c[103];
int main()
{
	long long ans=0;
	scanf("%s",c);
	int len=strlen(c);
	for(int i=0;i<(1<<len-1);i++)
	{
		long long num=c[0]-'0';
		for(int j=0;j<len-1;j++)
		{
			if(i&(1<<j))
			{
				ans+=num;
				num=0;
			}
			num=num*10+c[j+1]-'0';
		}
		ans+=num;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	double w, h, x, y;
	cin >> w >> h >> x >> y;

	if (w/2==x and h/2==y) cout << w*h/2 << " " << 1 << endl;
	else cout << w*h/2 << " " << 0 << endl;
}

Measured memory_bytes: 256
n, m = gets.to_s.split
n, m = n.to_i, m.to_i 

card_min = 1
card_max = n
 
m.times do
  l, r = gets.to_s.split
  l, r = l.to_i, r.to_i
  card_min = l if card_min < l
  card_max = r if card_max > r
end
 
ans = card_max - card_min + 1

puts ans > 0 ? ans : 0

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

int main(){
    int N;
    cin >> N;
    if(N<2)
    cout << 1 << endl;
    else if(N<4)
    cout << 2 << endl;
    else if(N<8)
    cout << 4 << endl;
    else if(N<16)
    cout << 8 << endl;
    else if(N<32)
    cout << 16 << endl;
    else if(N<64)
    cout << 32 << endl;
    else
    cout << 64 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define DINF (double)1e9
#define MOD 1000000007
#define MAX 210000
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;


struct nCrmod {
	ll _MAX, _mod;
	vector<ll> ruiseki, inv, ruisekiinv; //累積の積、逆元、累積の積の逆元
	nCrmod(ll MAXvalue, ll mod) {
		_MAX = MAXvalue;
		_mod = mod;
	}
	void init() {
		ruiseki = vector<ll>(_MAX + 2);
		inv = vector<ll>(_MAX + 2);
		ruisekiinv = vector<ll>(_MAX + 2);
		ruiseki[0] = 0;
		ll tmp = 1;
		for (int i = 1; i < _MAX; i++) {
			tmp = tmp * i%_mod;
			ruiseki[i] = tmp;
		}
		inv[1] = 1;
		inv[0] = 1;
		for (int i = 2; i < _MAX; i++) {
			inv[i] = _mod - (inv[_mod%i] * (_mod / i)) % _mod;
		}
		ruisekiinv[1] = 1;
		ruisekiinv[0] = 1;
		tmp = 1;
		for (int i = 1; i < _MAX; i++) {
			tmp = (tmp * inv[i]) % _mod;
			ruisekiinv[i] = tmp;
		}
	}
	ll nCr(int n, int r) {
		if (n < r || n < 0 || r < 0) {
			cout << "error" << endl;
			exit(1);
		}
		ll ans = (ruiseki[n] * (ruisekiinv[r] * ruisekiinv[n - r] % _mod)) % _mod;
		return ans;
	}
};



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, l;
	cin >> n >> l;
	m = l;
	vector<int> x;
	for (int i = 2; i*i <= m; i++) {
		if (m%i == 0) {
			int a = 0;
			while (m%i == 0) {
				a++;
				m /= i;
			}
			x.push_back(a);
		}
	}
	if (m != 1) {
		x.push_back(1);
	}
	nCrmod a = nCrmod(MAX, MOD);
	a.init();
	ll ans = 1;
	for (auto itr : x) {
		ans *= a.nCr(itr + n - 1, n - 1);
		ans %= MOD;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 5248
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = 0;


    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){

                bool fi = false;
                bool se = false;
                bool th = false;

                for(int l = 0; l < n; l++){
                    if(!fi){
                        if(s[l] - '0' == i){
                            fi = true;
                            continue;
                        }
                    }

                    if(fi){
                        if(!se){
                            if(s[l] - '0' == j){
                                se = true;
                                continue;
                            }
                        }
                    }

                    if(fi && se){
                        if(s[l] - '0' == k){
                            th = true;
                            continue;
                        }
                    }
                }

                if(fi && se && th){
                    //cout << i << j << k << endl;
                    ans++;
                }

            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
N=int(input())
S=[input() for _ in range(N)]
ansdic={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in S:
  ansdic[i]+=1
print(f"AC x {ansdic['AC']}")
print(f"WA x {ansdic['WA']}")
print(f"TLE x {ansdic['TLE']}")
print(f"RE x {ansdic['RE']}")

Measured memory_bytes: 16332
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;


int main(void)
{
    int n,k;
    cin >> n >> k;

    vector<int> a(n,1);
    
    for (int i = 0;i < k;i++)
    {
        int d;
        cin >> d;
        for (int j = 0;j < d;j++)
        {
            int bu;
            cin >> bu;
            a[bu-1] = 0;
        }
    }

    cout << accumulate(a.begin(),a.end(),0) << endl;
    
    return 0;
}


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

int main(){
	int ant[5];
	cin >> ant[0];
	cin >> ant[1];
	cin >> ant[2];
	cin >> ant[3];
	cin >> ant[4];
	int k;
	cin >> k;
	int i, j;
	for (i = 4; i > 0; i--) {
		for (j = 0; j < i; j++) {
			if (ant[i] - ant[j] > k) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll mul(ll a, ll b){
    return ((a%mod) * (b%mod))%mod;
}
ll power(ll a, ll b){
    ll z = 1; ll x = a;
    while(b>0){
        if (b&1)z = mul(z, x);
        x = mul(x, x);
        b >>= 1;
    }
    return z;
}
map<ll, ll> m;
void fac(ll n)
{
    ll temp = n;
    for (ll i=2; i<=sqrt(n); i++){
        if (temp%i == 0){
            ll cnt = 0;
            while(temp%i == 0){
                cnt++;
                temp/=i;
            }
            m[i] += cnt;
        }
    }
    if (temp > 1)m[temp]++;
}
int main()
{
    ll n;
    cin>>n;
    for (ll i=2; i<=n; i++){
        fac(i);
    }
    ll ans = 1;
    for (auto it = m.begin(); it!=m.end(); it++){
        ans = mul(ans, it->second+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
ll max(ll a,ll b)
{
  if (a>b) {

    return a;
  }
  return b;
}

ll min(ll a,ll b)
{
  if (a<b) {

    return a;
  }
  return b;
}

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

ll lcm(ll a,ll b)
{
  return a/gcd(a,b)*b;
}
int main()
{
  long long int n;
  cin>>n;
  long long int sum=0;
  for(ll i=1;i<=n;i++)
  {
      if(i%3!=0 && i%5!=0)
      {
          sum+=i;
      }
  }
  cout<<sum<<endl;
  return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h,w;cin >> h >>w;
    vector<vector<char>> f(h,vector<char>(w));
    rep(i,h)rep(j,w)cin >> f[i][j];
    vvl seen(h,vl(w,0));
    vvl lr(h,vl(w,0));
    rep(i,h){
        rep(j,w){
            if(f[i][j]=='#')continue;
            if(seen[i][j])continue;
            seen[i][j]=1;
            ll tmp=1;
            ll s=j;
            while(true){
                s++;
                if(s>=w)break;
                if(f[i][s]=='#')break;
                tmp++;
            }
            s=j;
            while(true){
                seen[i][s]=1;
                lr[i][s]=tmp;
                s++;
                if(s>=w)break;
                if(f[i][s]=='#')break;
            }
        }
    }
    rep(i,h)rep(j,w)seen[i][j]=0;
    rep(i,h){
        rep(j,w){
            if(f[i][j]=='#')continue;
            if(seen[i][j])continue;
            seen[i][j]=1;
            ll tmp=1;
            ll r=i;
            while(true){
                r++;
                if(r>=h)break;
                if(f[r][j]=='#')break;
                tmp++;
            }
            r=i;
            while(true){
                seen[r][j]=1;
                lr[r][j]+=tmp;
                r++;
                if(r>=h)break;
                if(f[r][j]=='#')break;
            }
        }
    }
    ll ans=0;
    rep(i,h){
        rep(j,w)chmax(ans,lr[i][j]);
    }
    cout << ans-1 <<endl;
}

Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    int n, ctr = 0;
    string s, str = "";
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        str = s.substr(i, 3);
        //cout << "str: " << str << endl;
        if (str == "ABC")
            ctr++;
        str = "";
    }
    cout << ctr << endl;
    return 0;
}


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

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

#define roop(i, n) for(int i = 0;i < n;i++)
#define INF 1000000000

int main(void){

    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    vector<vector<int>> cost(h, vector<int>(w, INF));
    roop(i, h) cin >> field[i];

    int ans = h*w;

    roop(i, h){
        roop(j, w){
            if(field[i][j] == '#') ans--;
        }
    }

    queue<P> que;

    que.push(P(0, 0));

    cost[0][0] = 0;

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

    while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();

        roop(i, 4){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
            if(field[ny][nx] == '#') continue;
            if(cost[ny][nx] != INF) continue;

            que.push(P(ny, nx));
            cost[ny][nx] = cost[y][x] + 1;
        }
    }

    if(cost[h-1][w-1] == INF){
        cout << -1 << endl;
        return 0;
    }

    cout << ans-cost[h-1][w-1]-1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int w = sc.nextInt();
			int h = sc.nextInt();
			int [][] data = new int[h+1][w+1];
			
			for(int i = 0; i < n;i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				data[y][x] = 1;
			}
			int s = sc.nextInt();
			int t = sc.nextInt();
			
			for(int i = 1; i <= h; i++){
				for(int j = 1; j <= w; j++){
					data[i][j] = data[i][j-1] + data[i][j];
				}
			}
			
			int max = 0;
			for(int i = 1; i <= h; i++){
				for(int j = 1; j <= w; j++){
					if(j + s - 1 > w) continue;
					int sum = 0;
					for(int k = 0; k < t; k++){
						if(i + k > h) break;
						sum += data[i + k][j + s-1] - data[i + k][j-1];
					}
					max = Math.max(max, sum);
				}
			}
			System.out.println(max);
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 34216
import java.util.Scanner;

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

		prime = new int[1300000];
		for (int i = 2; i * i <= 1300000; i++) {
			for (int j = 2; 0 <= i * j && i * j < 1300000; j++) {
				prime[i * j] = 1;
			}
		}
		n = sc.nextInt();
		while (n != 0) {
			sum = 0;
			count = 0;
			for (int i = 2; count < n; i++) {
				if (prime[i] == 0) {
					sum += i;
					count++;
				}
			}
			System.out.println(sum);
			n = sc.nextInt();
		}
	}
}

Measured memory_bytes: 17000
x = int(input().strip())

for i in range(120):
    for j in range(120):
        y = i**5 + j**5
        z = i**5 - j**5
        if z == x:
            a = i
            b = j
            print("{} {}".format(a, b))
            exit()
        if y == x:
            a = i
            b = -j
            print("{} {}".format(a, b))
            exit()



Measured memory_bytes: 9020