akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int a[50], b[50], c[50];
int n, tot = 0;

signed main()
{
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		cin >> b[i];
	for (int i = 1; i <= n-1; i++)
		cin >> c[i];
	tot = b[a[1]];
	for (int i = 2; i <= n; i++) {
		tot += b[a[i]];
		if (a[i] == a[i-1]+1) {
			tot +=c[a[i]-1];
		}
	}
	cout << tot << endl;
	return 0;
}


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

int main() {
    std::string S;
    std::cin >> S;

    char previous = 'a';
    for  (char& c : S) {
        if (c == previous) {
            std::cout << "Bad" << std::endl;
            return 0;
        }
        previous = c;
    }
    std::cout << "Good" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
    string S;
    cin>>S;
    
    while(1){
        if(S.size()>=6&&S.substr(S.size()-6,6) == "eraser"){
            S = S.erase(S.size()-6);
        }else if(S.size()>=5&&S.substr(S.size()-5,5) == "erase"){
            S = S.erase(S.size()-5);
        }else if(S.size()>=7&&S.substr(S.size()-7,7) == "dreamer"){
            S = S.erase(S.size()-7);
        }else if(S.size()>=5&&S.substr(S.size()-5,5) == "dream"){
            S = S.erase(S.size()-5);
        }else if(S.size()==0){
            cout<<"YES"<<endl;
            return 0;
        }else{
            cout<<"NO"<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/

ll Lucas(ll N){
  if (N == 0){
    return 2;
  }else if(N == 1){
    return 1;
  }
  ll ans;
  ans = Lucas(N-1) + Lucas(N-2);

  return ans;

}


int main() {
  ll H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  //vector<ll> a(N);
  //vector<ll> b(N);


  cout << ( H2 * 60 + M2 - H1 * 60 - M1 -K) << endl;

  return 0;
}

Measured memory_bytes: 3644
n=int(input())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
	dp[i]=min(dp[i-1]+abs(l[i-1]-l[i]),dp[i-2]+abs(l[i-2]-l[i]))
print(dp[-1])

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

using namespace std;

int n;
int x[202020];
int t[202020];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x[i]);
		t[i] = x[i];
	}
	sort(t, t + n);
	int m = (n - 1) >> 1;
	for (int i = 0; i < n; ++i) {
		int pos = lower_bound(t, t + n, x[i]) - t;
		if (pos <= m) {
			printf("%d\n", t[m + 1]);
		} else {
			printf("%d\n", t[m]);
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int A[2][100];
int sum[2][102];
int main(){
  int N;
  cin >> N ;
  for(int i=0;i<2;++i){
    for(int j=0;j<N;++j){
      cin >> A[i][j];
      sum[i][j+1] += sum[i][j] + A[i][j];
    }
  }
  int max_c = 0;
  for(int i=1;i<N+1;++i){
    int c = sum[0][i] + sum[1][N] - sum[1][i-1];
    if( max_c < c ) max_c = c;
  }
  cout << max_c << endl;
}

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

int main() {
    
    unsigned long long int X,S = 100;
    cin >> X;

    unsigned int count = 0;
    while(1){
        S += (S / 100);
        count++;
        if(S >= X) break;
    }
    cout << count <<endl;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define pi 3.14159265359
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (ll)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()
#define sp(a) setprecision(a)
#define rz resize
#define ld long double

using namespace std;

vector<vector<ll> > dp;

bool cmp(const pair<int,pair<int,int> > &a,const pair<int,pair<int,int> > &b)
{
	return a.ff+a.ss.ff<b.ff+b.ss.ff;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<pair<int,pair<int,int> > > p(n);
	int val[n],w=0;
	f(i,0,n)
	{
		cin>>p[i].ff>>p[i].ss.ff>>p[i].ss.ss;
		w+=p[i].ff;
	}
	dp.rz(n+1,vector<ll> (20202));
	sort(all(p),cmp);
	f(i,1,n+1)
		dp[i][0]=0;
	f(i,1,20202)
		dp[0][i]=0;
	dp[0][0]=0;
	// f(i,0,n)
	// 	cout<<p[i].ff<<' '<<p[i].ss.ff<<' '<<p[i].ss.ss<<"\n";
	f(i,1,n+1)
	{
		f(j,p[i-1].ff,20202)
		{
			if(p[i-1].ss.ff>=j-p[i-1].ff)
				dp[i][j]=max(dp[i-1][j],p[i-1].ss.ss+dp[i-1][j-p[i-1].ff]);
			dp[i][j-p[i-1].ff]=max(dp[i][j-p[i-1].ff],dp[i-1][j-p[i-1].ff]);
		}
	}
	// cout<<dp[n][w]<<"\n";
	ll mx=-1;
	// f(i,0,n+1)
	// {
	// 	f(j,0,w+1)
	// 		cout<<dp[i][j]<<' ';
	// 	cout<<"\n";
	// }
	f(i,1,20202)
		mx=max(mx,dp[n][i]);
	cout<<mx<<"\n";
}

Measured memory_bytes: 160640
#include<stdio.h>
int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(j=1;j<=H;j++){
            for(i=1;i<=W;i++){
                if(j>1&&j<H&&i<W&&i>1){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;

}



Measured memory_bytes: 2032
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int n = sc.nextInt();

        int ans = 0;

        for(int i = 0;i <= 3000;i++){
            for(int j = 0;j <= 3000;j++){
                int v = i * r + j * g;
                if(n >= v && (n - v) % b == 0){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> vec;
	int ans = -1e9;
	for(int i = 0; i < n; i++){
	 	int t; cin >> t; vec.pb(t);
	}
	for(int i = 0; i  < n; i++){
	 for(int j = i+1; j < n; j++){
	  	ans = max(ans, abs(vec[j]-vec[i]));
	 }
	}
	cout << ans << endl;
	return 0;
}                  


Measured memory_bytes: 3584
#include <stdio.h>
#include <math.h>


void kock(int n, double p1[], double p2[]){
	if(n == 0)return;
	
	double s[2]={}, t[2]={}, u[2]={};
	double th = M_PI*60/180;
	s[0] = (2*p1[0]+p2[0])/3;
	s[1] = (2*p1[1]+p2[1])/3;
	t[0] = (p1[0]+2*p2[0])/3;
	t[1] = (p1[1]+2*p2[1])/3;
	u[0] = (t[0]-s[0])*cos(th) - (t[1]-s[1])*sin(th) + s[0];
	u[1] = (t[0]-s[0])*sin(th) + (t[1]-s[1])*cos(th) + s[1];
	
	kock(n-1, p1, s);
	printf("%f %f\n", s[0], s[1]);
	kock(n-1, s, u);
	printf("%f %f\n", u[0], u[1]);
	kock(n-1, u, t);
	printf("%f %f\n", t[0], t[1]);
	kock(n-1, t, p2);
}

int main(void)
{
	int n;
	scanf("%d", &n);
	
	double p1[2] = {0.0, 0.0};
	double p2[2] = {100.0, 0.0};
	
	printf("%f %f\n", p1[0], p1[1]);
	kock(n, p1, p2);
	printf("%f %f\n", p2[0], p2[1]);
	
	return 0;
}


Measured memory_bytes: 2036
package main

import "fmt"

func main() {
	var (
		a, b, c int
	)
	fmt.Scanf("%d %d %d\n", &a, &b, &c)
	count := 0
	result := []int{}

	for i := 1; i <= 100; i++ {
		if a%i != 0 {
			continue
		}
		if b%i != 0 {
			continue
		}
		count ++
		result = append(result, i)
	}
	if len(result) == 1{
		fmt.Println(result[0])
	} else {
		fmt.Println(result[len(result)-c])
	}
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int X;

int main() {
	cin >> X;
	int low = 0, high = X+10;
	while (high-low > 1) {
		const int med = (low+high)/2;
		if ((ll)med*(med+1)/2 >= X) high = med;
		else low = med;
	}
	cout << high << endl;
	return 0;
}


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

int main() {
	vector<int>a(3);
	for (int i = 0; i < 3; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	if (a.at(0) == a.at(1))cout << a.at(2) << endl;
	else {
		if (a.at(0) == a.at(2))cout << a.at(1) << endl;
		else cout << a.at(0) << endl;
	}
}

Measured memory_bytes: 256
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
X = gets.chomp.to_i

sets = (0..A).to_a.product((0..B).to_a, (0..C).to_a)
result = sets.select{|set|
  500 * set[0] + 100 * set[1] + 50 * set[2] == X
}

print result.length

Measured memory_bytes: 8316
# -*- coding: utf-8 -*-
# E

import sys
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

H, W, M = map(int, input().split())
h = [] * M
w = [] * M
dic_combi = defaultdict(int)

for _ in range(M):
    h_, w_ = map(int, input().split())
    h.append(h_)
    w.append(w_)
    dic_combi[h_ * (10**6) +  w_]=1

dic_h = Counter(h)
dic_w = Counter(w)
# print(dic_h, dic_w)
max_h_key = max(dic_h.items(), key=lambda x:x[1])[0]
max_w_key = max(dic_w.items(), key=lambda x:x[1])[0]

max_h = dic_h[max_h_key]
max_w = dic_w[max_w_key]

keys_h = [k for k, v in dic_h.items() if v == max_h]
keys_w = [k for k, v in dic_w.items() if v == max_w]


ans = 0
for ind_h in keys_h:
    for ind_w in keys_w:
        ret = max_h + max_w
        if dic_combi[ind_h*(10**6) + ind_w] == 1:
            ret -= 1
        else:
            print(ret)
            sys.exit()
        ans = max(ans, ret)

print(ans)






Measured memory_bytes: 223120
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b; cin >>a >>b ;
	if(a>0)cout <<"Positive"<<endl;
	else if(a<=0 && b>=0) cout << "Zero"<< endl;
	else {
		if((b-a) %2==0)cout <<"Negative"<<endl;
		else cout <<"Positive"<<endl;
	}

}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

nums = sorted(list(map(int, input().split())))
if nums == [1, 4, 7, 9]:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 7976
#include <iostream>
//#include <vector>

using namespace std;

int search(int* arr, int len){
  int flag = 0;
  if(len > 0){
    for(int i = 0; i < len; i++){
      if(arr[len] == arr[i]){
	flag = 1;
	break;
      }
    }
  }
  return flag;
}
    
      
int main(){
  int N;
  int a[110000];

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

  //for(int i = 0; i < N; i++) cout << a[i];
  //cout << endl;
  
  int passed[110000] = {};
  
  int now = 1;
  int cnt = 0;

  passed[0] = now;
  while(now != 2){
    //if(cnt > 10) break;
    if(now == 2) break;
    
    cnt ++;
    now = a[now-1];
    passed[cnt] = now;

    //cout << "cnt: " << cnt << " now: " << now << endl;
    
    if(cnt > N){//if(search(passed, cnt)){
      cnt = -1;
      break;
    }
    
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number_a, number_b;
    number_a = Integer.parseInt(sc.next());
    number_b = Integer.parseInt(sc.next());
    if(number_a > number_b) System.out.println("a > b");
    else if(number_a < number_b) System.out.println("a < b");
    else System.out.println("a == b");
  }
}


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

int main(){
  int a,b,c,x,y;
  int ans=0;
  cin >> a >> b >> c >> x >> y;
  x *= 2;
  y *= 2;
  if( c <= (a+b)/2 ){
    while( ( x > 0 && y > 0 ) || 
           ( x > 0 && y <= 0 && a >= 2*c ) ||
           ( x <= 0 && y > 0 && b >= 2*c )   ){
      ans += c;
      x--;
      y--;
    }
  }else{
    while( x > 0 && y > 0 ){
      ans += a+b;
      x -= 2;
      y -= 2;
    }
  }
  while( x <= 0 && y > 0 ){
      ans += b;
      y -=2;
    }
  while( x > 0 && y <= 0 ){
    ans += a;
    x -= 2;
  }
  
  cout << ans << endl;
    
  return 0;
}


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

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.ArrayLong(5);
            var hm = (a[2] - a[0]);
            var m = a[3] - a[1];
            if(m < 0)
            {
                hm--;
                m = 60 + m;
            }
            hm = hm * 60;
            var ans = hm + m;
            
            Console.WriteLine(ans - a[4]);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException{
		InputReader in = new InputReader(System.in);
		
		while (true) {
			int height = in.readInt();
			int width = in.readInt();
			if (height == 0 && width == 0) break;
			
			StringBuffer sBuffer = new StringBuffer(width);
			StringBuffer sBufferWithDot = new StringBuffer(width);
			for (int j = 0; j < width; j++) {
				sBuffer.append("#");
				
				if (j == 0 || j == width - 1) {
					sBufferWithDot.append("#");
				}else {
					sBufferWithDot.append(".");
				}
			}
			
			
			for (int i = 0; i < height; i++) {
				if(i == 0 || i == height - 1) {
					System.out.println(sBuffer.toString());
				}else {
					System.out.println(sBufferWithDot.toString());
				}
				
			}
			System.out.println();
		}
	}
}

class InputReader{
	private BufferedReader br;
	private StringTokenizer buffer = null;	
	
	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));				
	}

	public String read() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return buffer.nextToken();
	}
	
	public int readInt() throws IOException {
		while(buffer == null || !buffer.hasMoreTokens()) {
			buffer = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(buffer.nextToken());
	}
}


Measured memory_bytes: 25176
#include <iostream>
#include <vector>

using namespace std;
 
int main() {
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; ++i) cin >> a[i];
	int now = 1, ans = 0;
	bool flag = false;
	while (n--) {
		now = a[now]; ans++;
		if (now == 2) {
			flag = true;
			break;
		}
	}
	cout << (flag ? ans : -1) << endl;

  return 0;
}

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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    h, n = input_to_int_map()
    a = input_to_int_tuple()

    ret = "Yes"
    if h - sum(a) > 0:
        ret = "No"

    return ret


if __name__ == "__main__":
    print(main())


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

using namespace std;

const int MAXN = 1010;

int n, answer = 1e9;

int sum(int v)
{
	int res = 0;
	while (v)
	{
		res += v % 10;
		v /= 10;
	}
	return res;
}

int main()
{
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		int j = n - i;
		answer = min(answer, sum(i) + sum(j));
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int Q, H, S, D;
  cin >> Q >> H >> S >> D;
  long long N;
  cin >> N;
  H = min(H, Q * 2);
  S = min(S, H * 2);
  D = min(D, S * 2);
  cout << (N / 2) * D + (N % 2) * S << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.HashMap;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        Map<Long, Long> cache = new HashMap<>();

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            long res = doit(a, 0, n - 1, 1, 1);
            out.println(res);
        }

        private long doit(long[] v, int left, int right, long a, long b) {
            if (left + 1 == right) {
                return v[left] * a + v[right] * b;
            }
            long key = left * 478156473535615131L + right * 4186574361539994L + a * 897748627637161L + b * 8548931758436781L;
            Long cached = cache.get(key);
            if (cached != null) return cached;
            long res = Long.MAX_VALUE;
            for (int mid = left + 1; mid < right; ++mid) {
                res = Math.min(res, doit(v, left, mid, a, a + b) + doit(v, mid, right, a + b, b) - v[mid] * (a + b));
            }
            cache.put(key, res);
            return res;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 68320
// luogu-judger-enable-o2
#include <iostream>
using namespace std;
long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
int main()
{
	cin>>a>>b>>c>>n;
	for(i=0;i<=a;i++)
	{
		for(k=0;k<=b;k++)
		{
			for(j=0;j<=c;j++)
			{
				if(i*500+k*100+j*50==n)
				{
					z++;
				}
			}
		}
	}
	cout<<z<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void sort(int in[]) {
	int i, j, temp;
	for (i = 0; i < 2; i++) {
		for (j = 2; j > i; j--) {
			if (in[j - 1] > in[j]) {
				temp = in[j - 1];
				in[j-1] = in[j];
				in[j] = temp;
			}
		}
	}
}

int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a[i]);
	}

	sort(a);

	for (int i = 0; i < 3; i++) {
		printf("%d", a[i]);
		if (i != 2) {
			printf(" ");
		}
		else printf("\n");
	}

	return 0;
}


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

int main(void)
{
        int n,m,i,c;
        char s[11],t[12];

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

        n=strlen(s);
        m=strlen(t);
        c=0;
        for(i=0;i<n;i++){
                if(s[i]==t[i]){
                        c++;
                }
        }

        if(c==n && m==n+1) printf("Yes\n");
        else printf("No\n");
        return 0;
}


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

int main(){
  ll N; cin >> N;
  ll A, B, C, D, E; cin >> A >> B >> C >> D >> E;
  ll x = min({A, B, C, D, E});
  if(N%x == 0) cout << N/x + 4 << endl;
  else cout << N/x + 5 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    map<int,int> ct;
    rep(i,n)
    {
        int a;
        cin >>a;
        ++ct[a];
    }

    int ans = 0;
    for(const auto &p:ct)
    {
        int val = p.fi;
        int num = p.se;
        if(val<=num) ans += num-val;
        else ans += num;
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		byte min, count = 0, arrayLength = Byte.parseByte(in.readLine());
		byte[] array = new byte[arrayLength];
		String[] strData = in.readLine().split(" ");
		for (int i = 0; i < arrayLength; i++) {
			array[i] = Byte.parseByte(strData[i]);
		}
		for (byte x = 0; x < arrayLength; x++) {
			min = x;
			for (byte y = (byte) (x + 1); y < arrayLength; y++) {
				if (array[min] > array[y]) {
					min = y;
				}
			}
			if (array[x] > array[min]) {
				byte temp = array[x];
				array[x] = array[min];
				array[min] = temp;
				count++;
			}
		}
		for (int j = 0; j < arrayLength; j++) {
			if (j == arrayLength - 1) {
				sb.append(array[j]);
			} else {
				sb.append(array[j] + " ");
			}
		}
		System.out.println(sb);
		System.out.println(count);
	}
}

Measured memory_bytes: 16968
#include <iostream>
#include <vector>

int main() {
    int H, N;
    std::cin >> H >> N;
    std::vector<int> A(N), B(N);

    for(int i = 0; i < N; i++) {
        std::cin >> A[i] >> B[i];
    }

    std::vector<long long> dp(H + 1);
    dp[0] = 0;

    for(int h = 1; h < H + 1; h++) {
        long long min = 10000000000;
        for(int i = 0; i < N; i++) {
            long long cost = B[i] + dp[h - A[i] > 0 ? h - A[i] : 0];
            if(cost < min)  min = cost;
        }
        dp[h] = min;
    }
    std::cout << dp[H] << std::endl;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long chu = n%k;
		long jian = Math.abs(chu-k);
		System.out.println(chu > jian ? jian : chu);
	}

}


Measured memory_bytes: 21844
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto xt = readints;
    int x = xt[0], t = xt[1];

    int ans = max(0, x - t);
    writeln(ans);
}


Measured memory_bytes: 256
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

N = int(input())
A = [0]*N
for i in range(N):
	A[i] = int(input())

ans = A[0] - 1
A[0] = 1

cnt = 1
# yobi = 1

for i in range(1, N):
	now = A[i]

	if now > cnt:
		if now == cnt + 1: ## 0 ni nattyau
			cnt += 1
		else: ## now >= cnt + 2
			ans += now // (cnt + 1)
			if now % (cnt + 1) == 0:
				ans -= 1

print(ans)


Measured memory_bytes: 7028
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int k, a, b;
	cin >> k >> a >> b;
	FOR(i,a,b+1){
		if (i%k == 0) {
			print("OK");
			break;
		}
		if (i == b)print("NG");
	}
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
int n,size[N];
vector<int>son[N];
inline int read()
{
	int x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();
	for(int i=2;i<=n;++i)
	{
		int x=read();
		son[x].push_back(i);
	}
	for(int i=1;i<=n;++i) cout<<son[i].size()<<endl;
	return 0;
}


Measured memory_bytes: 14404
n, x = map(int, input().split())
n -= 1
a = list(map(int, input().split()))
a.sort()
ans = 0
for i, ai in enumerate(a):
    if x < ai:
        break
    elif i == n and  x != ai:
        break
    x -= ai
    ans += 1

print(ans)


Measured memory_bytes: 3316
import numpy as np
N = int(input())
A = list(map(int, input().split()))

dp = np.zeros((N+1, 2), dtype=int)
dp[0, 1] = -10**9

for i in range(N):
    dp[i+1, 0] = max(dp[i, 0] + A[i], dp[i, 1] - A[i])
    dp[i+1, 1] = max(dp[i, 0] - A[i], dp[i, 1] + A[i])
print(dp[N, 0])

Measured memory_bytes: 23300
import java.util.Scanner;
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int loop;
        int target = 0;

        loop = sc.nextInt();
        target = sc.nextInt();

        int [] arr = new int [loop];

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

        int sum = 0;
        for(int i = 0; i < arr.length; i++) {

            if(arr[i] * 2 < (target - arr[i]) * 2) {
                sum += arr[i] * 2;
            } else {
                sum += (target - arr[i]) * 2;
            }
        }

        System.out.println(sum);

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll=long long ;
map<ll,ll>mp;
void calculate(ll n)
{
	while(n%2==0)
	{
		mp[2]++;
		n /= 2;
	}
	for(ll i=3;i<=sqrt(n);i+=2)
	{
		while(n%i==0)
		{
			mp[i]++;
			n /= i;
		}
	}
	if(n>2)
	{
		mp[n]++;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double a,b,c;
	cin>>a>>b;
	c=a*b;
	cout<<fixed<<setprecision(20);
	cout<<(ll)c;
	return 0;
}

Measured memory_bytes: 3808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		long con = 0;

		Y = Y/X;

		while (Y > 0) {
			Y = Y / 2;
			con++;
		}

		System.out.println(con);

	}
}


Measured memory_bytes: 35536
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=305;
int n,k,a[N];
ll dp[N][N][N];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    memset(dp,inf,sizeof(dp));
    dp[0][0][0]=0;
    ll ans=1e15;
    for(int i=1;i<=n;i++)
        for(int j=0;j<i;j++)
        for(int k=0;k<i;k++)
        {
            dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
            dp[i][i][k+1]=min(dp[i][i][k+1],dp[i-1][j][k]+max(0,a[i]-a[j]));
        }
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
        if(j>=n-k) ans=min(ans,dp[n][i][j]);
    printf("%lld\n",ans);
}


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

typedef pair<int, int> pi;
typedef vector<vector<int>> vv;
int reversDigits(int num) 
{ 
    int rev_num = 0; 
    while(num > 0) 
    { 
        rev_num = rev_num*10 + num%10; 
        num = num/10; 
    } 
    return rev_num; 
} 

int countDigit(long long n) 
{ 
    return floor(log10(n) + 1); 
} 

int firstDigit(int n) 
{ 
    // Remove last digit from number 
    // till only one digit is left 
    while (n >= 10)  
        n /= 10; 
      
    // return the first digit 
    return n; 
} 
  
// Find the last digit 
int lastDigit(int n) 
{ 
    // return the last digit 
    return (n % 10); 
}

int32_t main() 
{ 
	int n;
	cin >> n;
	int arr[7] = {0, 0, 1, 2, 12, 112, 1112};
	int ans = 0;
	map<pi, int> m;
	for (int i = 1; i <= n; ++i)
	{
		if(i%10 == 0)
			continue;
		int x = firstDigit(i);
		int y = lastDigit(i);
		// if(y < x)
		// 	swap(x, y);
		m[{x, y}]++;
	}

	for(auto i: m){
		int a = i.first.first;
		int b = i.first.second;
		ans += (i.second)*(m[{b, a}]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;

const double PI = 3.14159265358979323846;

const int mod = 1000000007;



int main(int argc, char *args[]) {
	int n, m; cin >> n >> m;
	vector<int> s(m);
	vector<int> c(m);
	rep(i, m) {
		cin >> s[i] >> c[i];
	}
	int tmp = 0;
	priority_queue<int,vector<int>,greater<int>> Q;
	
	if (n == 3) {
		for (int i = 1; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				for (int k = 0; k <= 9; k++) {
					tmp = 100 * i + 10 * j + k;
					bool flag = true;
					rep(l, m) {
						if (s[l] == 1 && i != c[l]) flag = false;
						if (s[l] == 2 && j != c[l]) flag = false;
						if (s[l] == 3 && k != c[l]) flag = false;
					}
					if (flag) Q.push(tmp);
				}
			}
		}
	}
	if (n == 2) {
		for (int i = 1; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				tmp = 10 * i + j;
				bool flag = true;
				rep(l, m) {
					if (s[l] == 1 && i != c[l]) flag = false;
					if (s[l] == 2 && j != c[l]) flag = false;
				}
				if (flag)Q.push(tmp);
			}
		}
	}
	if (n == 1) {
		for (int i = 0; i <= 9; i++) {
			tmp = i;
			bool flag = true;
			rep(l, m) {
				if (tmp != c[l]) flag = false;
			}
			if (flag) Q.push(tmp);
		}
	}
	if (Q.empty()) cout << -1 << endl;
	else cout << Q.top() << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
arr=list(map(int,input().split()))
print(' '.join(map(str,arr)))
for key in range(1,len(arr)):
    temp=arr[key]
    i=key-1
    while i>=0 and arr[i]>temp:
        arr[i+1]=arr[i]
        i-=1
    arr[i+1]=temp
    print(' '.join(map(str,arr)))

Measured memory_bytes: 5592
#include <iostream>
using namespace std;
int main() {
  int h,w,n,l,i=0;
  cin>>h>>w>>n;
  if(h<w){
    l=w;
  }else{
    l=h;
  }
  
  while(true){
    i++;
    if(n<=l*i){
      break;
    }
  }
  
  cout<<i<<endl;
}

Measured memory_bytes: 256
int main(int argc, const char * argv[]) {
    int m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1){
            break;
        }
        if(m==-1||f==-1){
            printf("F\n");
        }
        else if(m+f>=80){
            printf("A\n");
        }else if(m+f>=65&&m+f<80){
            printf("B\n");
        }else if(m+f>=50&&m+f<65){
            printf("C\n");
        }else if(m+f>=30&&m+f<50){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else if(m+f<30){
            printf("F\n");
            
        }
    }
    return 0;
}

Measured memory_bytes: 584
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()
a = [readint() for i in range(n)]

ans = a[0]-1
p = 2

for i in range(1,n):
    if a[i]%p==0:
        ans += a[i]//p-1
        if a[i] == p:
            p+=1
    else:
        ans += a[i]//p

print(ans)


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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (bit & (1LL << i))

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;
template<typename T> using VVVV = std::vector<std::vector<std::vector<std::vector<T>>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

	int N, K;
	cin >> N >> K;
	V<int> H(N);
	FOR(i, 0, N) {
	    cin >> H[i];
	}

	V<LL> dp(N, INF);
	dp[0] = 0;
	FOR(i, 0, N) {
	    FOR(k, 1, K + 1) {
            if (i + k < N) {
                chmin(dp[i + k], dp[i] + abs(H[i] - H[i + k]));
            }
        }
	}

	print(dp[N - 1]);

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  vector<vector<int>> vec(3,  vector<int>(3, 0));
  rep(i, 3){
    rep(j, 3){
      cin >> vec[i][j];
    }
  }
  for(int i=-100; i<=100; i++){
    int a1 = i;
    int b1 = vec[0][0]-i;
    int a2 = vec[1][0]-b1;
    int b2 = vec[1][1]-a2;
    int a3 = vec[2][0]-b1;
    int b3 = vec[2][2]-a3;
    bool isok;
    if(a1+b1 == vec[0][0] && a1+b2 == vec[0][1] && a1+b3 == vec[0][2]
      && a2+b1 == vec[1][0] && a2+b2 == vec[1][1] && a2+b3 == vec[1][2]
      && a3+b1 == vec[2][0] && a3+b2 == vec[2][1] && a3+b3 == vec[2][2])
      isok = true;
    else isok = false;
    if(isok){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 101
void enqueue(int q);
int dequeue();
int size();
void bfs(int i);

int G[MAX][MAX];
int d[MAX];
int n;
int Que[1000];
int head=0, tail=0;
 
void enqueue(int q){
  Que[head]=q;
  head++;
}
 
int dequeue(){
  tail++;
  return Que[tail-1];
}
 
int size(){
  return head-tail;
}
 
void bfs(int i){
  int j;
  for(j=0;j<n;j++){
    if(G[i][j]==1 && d[j]==-1){
      d[j]=d[i]+1;
      enqueue(j);
    }
  }
}
 
int main(){
  int i,j,v,k,u;
  scanf("%d",&n);
  for(i=0;i<MAX;i++) d[i]=-1;
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    } 
  }
  d[0]=0;
  bfs(0);
  while(size()!=0) bfs(dequeue());
  
  for(i=0;i<n;i++) printf("%d %d\n",i+1,d[i]);
  
return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, x, y, sum, cnt;
ll dp[1005][1005];
ll ans;
char s[1005][1005];
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  scanf("%d %d", &n, &m);
  dp[1][1] = 1;
  FOR(i, 1, n){
    scanf("%s", s[i]+1);
    FOR(j, 1, m) {
      if (!(i==1&&j==1)) {
        if (s[i][j] == '.') dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
        else dp[i][j] = 0;
      } 
    }
  }
  printf("%lld\n", dp[n][m]);
  return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n,m,key;
    cin>>n>>m>>key;
    vector<string> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<string> b = a;
    int ans=0;
    for(int j=0;j<1<<n;j++) {
        for(int k=0;k<1<<m;k++) {
            vi row,col;
            for(int i=0;i<n;i++) {
                if(j>>i&1) {
                    row.pb(i);
                }
            }
            for(int i=0;i<m;i++) {
                if(k>>i&1) {
                    col.pb(i);
                }
            }
            for(int i=0;i<sz(col);i++) {
                for(int l=0;l<n;l++) {
                    a[l][col[i]]='*';
                }
            }
            for (int i = 0; i < sz(row); i++)
            {
                for (int l = 0; l < m; l++)
                {
                    a[row[i]][l] = '*';
                }
            }
            int cnt=0;
            for(int i=0;i<n;i++) {
                for(int l=0;l<m;l++) {
                    if(a[i][l]=='#') {
                        cnt++;
                    }
                }
            }
            if(cnt==key) {
                ans++;
            }
            a=b;
        }
    }
    cout<<ans;

}


int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

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

long nump(long a){
  long count=0; long i=3;
  if(a%2==0){ //2で割る
      while(a%2==0) a=a/2;
      count++;
    }
  while(i*i<=a){ //奇数だけ試して時短
    if(a%i==0){
      while(a%i==0) a=a/i;
      count++;
    }
    i=i+2;
  }
  if(a!=1) count++;
  return count;
}

int main(){
  long a,b;
  cin>>a>>b;
  cout<<nump(gcd(a,b))+1<<endl;
}

Measured memory_bytes: 256
n = int(input())
red = sorted([tuple(map(int, input().split())) for _ in range(n)])
blue = sorted([tuple(map(int, input().split())) for _ in range(n)])

res = 0
for bx, by in blue:
    tmp_max = -1
    tmp_cnt = None
    for i, (rx, ry) in enumerate(red):
        if bx <= rx:
            break
        if tmp_max <= ry < by:
            tmp_max = ry
            tmp_cnt = i
    if tmp_cnt is not None:
        res += 1
        red.pop(tmp_cnt)

print(res)

Measured memory_bytes: 3064
K, N = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]

mi = 0

for n in range(N):
    j = n
    k = (n + 1) % N
    i = (A[k] - A[j] + K) % K
    if i > mi:
        mi = i

print(K-mi) 


Measured memory_bytes: 26436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = (A + B) / 2;

		if ((A+B)%2==0) {
			System.out.println(K);
		} else {
			System.out.println("IMPOSSIBLE");
		}
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
	float a,b;
	while(scanf("%f %f",&a,&b)!=EOF){
		if(a<35.5 && b<71.0){
				printf("AAA\n");
		}
		else if(a<37.5 && b<77.0){
				printf("AA\n");
		}
		else if(a<40.0 && b<83.0){
				printf("A\n");
		}
		else if(a<43.0 && b<89.0){
				printf("B\n");
		}
		else if(a<50.0 && b<105.0){
				printf("C\n");
		}
		else if(a<55.0 && b<116.0){
				printf("D\n");
		}
		else if(a<70.0 && b<148.0){
				printf("E\n");
		}
		else{
				printf("NA\n");
		}
	}
	return 0;
}

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

long long int N, fact[10010101], ifact[10010101], ans;
constexpr long long int M = 1000000007, m = 79133769, n = 536396504, mask = 1073741823;

static inline long long int MR(long long int A){
    long long int ret((A + M * (m * A & mask)) >> 30);
    return ret - (ret >= M) * M;
}

static inline long long int Prod(long long int lhs, long long int rhs){
    return MR(MR(lhs * rhs) * n);
}

int main(){
    scanf("%lld", &N);
    *fact = 1;
    for(int i = 1; i < N; ++i){
        fact[i] = Prod(fact[i - 1], i);
    }
    long long n = M - 2, r = fact[N - 1];
    ifact[N - 1] = 1;
    while(n){
        if(n & 1){
            ifact[N - 1] = ifact[N - 1] * r % M;
        }
        n /= 2;
        r = r * r % M;
    }
    for(int i = N - 1; i > 0; --i){
        ifact[i - 1] = Prod(ifact[i], i);
    }
    ans = fact[N - 1] * (N - 1);
    for(int i = N / 2; i < N - 1; ++i){
        ans += M - Prod(Prod(fact[i], fact[i - 1]), ifact[i * 2 - N]);
    }
    ans %= M;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 18688