akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


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

	cin >> N >> M;
	vector<int>v(N);
	vector<int>w(M);
	for (auto &i : v)cin >> i;
	for (auto &i : w)cin >> i;
	map<int, int>m;
	for (auto i : v)m[i]++;
	for (auto i : w)m[i]++;
	vector<int>a;
	vector<int>b;
	for (auto i : m) {
		if (i.second >= 1)b.push_back(i.first);
		if (i.second == 2)a.push_back(i.first);
	}
	cout << a.size() << " " << b.size() << endl;
	for (auto i : a)cout << i << endl;
	for (auto i : b)cout << i << endl;
} 


Measured memory_bytes: 14996
#include <iostream>
using namespace std;
 
int main(){
  double n ,flag=0 ,num[4001] ,price[4001] ,earnings[4001] ,total[4001] ,overlap;
  while( true ){
    cin >> n;
    if( n == 0 ){
      break;
    }
    for( int i=0 ; i<n ; i++ ){ // ??\?????¨????¨?????¨????
      cin >> num[i] >> price[i] >> earnings[i];
      total[i] = price[i] * earnings[i];
    }
 
    for( int i=0 ; i<n ; i++ ){ // ??????????????????
      overlap = num[i]; // ????????????????????????
      for( int j=0 ; j<n ; j++ ){
    if( num[j] == overlap && i != j ){ // ???????????????
      total[i] += total[j];
      num[j] = -1;
      total[j] = 0;
    }
      }
    }
 
    for( int i=0 ; i<n ; i++ ){ // ??????
      if( total[i] >= 1000000 ){
    cout << num[i] << endl;
    flag = 1;
      }
    }
 
    if( flag == 0 ){ // ???????????£??????
      cout << "NA" << endl;
    }
    flag = 0;
  }
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

int n;
void solve(int p, int m, string atual){
	if(p == n){
		cout << atual << '\n';
	}else{
		for(int i = 0; i <= m; i++){
			string novo = atual + (char)('a'+i);
			solve(p+1, (i==m ? m+1 : m), novo);
		}
	}
}
 
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	cin >> n;
 
	solve(0, 0, "");

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a - b == b - c){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
x = int(input())
while x != 0:
    y = 1000 - x
    a = y // 500
    A = y % 500
    b = A // 100
    B = A % 100
    c = B // 50
    C = B % 50
    d = C // 10
    D = C % 10
    e = D // 5
    E = D % 5
    print(a + b + c + d + e + E)
    x = int(input())


Measured memory_bytes: 5588
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;

vector<long long> dijkstra(const Graph &g, int s) {
    int n = g.size();
    vector<long long> dist(n, INF);
    vector<bool> fixed(n);
    dist[s] = 0;
    while (true) {
        int u = -1;
        for (int i = 0; i < n; i++) if (!fixed[i]) {
            if (u == -1 || dist[i] < dist[u]) u = i;
        }
        if (u == -1) break;
        fixed[u] = true;
        for (auto &e: g[u]) chmin(dist[e.first], dist[u] + e.second);
    }
    return dist;
}

int main() {
    int V; cin >> V;
    Graph g(V);
    for (int i = 0; i < V; i++) {
        int u, k; cin >> u >> k;
        while (k--) {
            int v, c; cin >> v >> c;
            g[u].emplace_back(v, c);
        }
    }
    auto dist = dijkstra(g, 0);
    for (int u = 0; u < V; u++) cout << u << " " << dist[u] << endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a[100010];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	ll h = n - 1, w;
	while (h&&a[h] != a[h - 1])h--;
	if (h < 1) {
		cout << 0 << endl;
		return 0;
	}
	w = h - 2;
	while (w&&a[w] != a[w - 1])w--;
	if (w < 1) {
		cout << 0 << endl;
		return 0;
	}
	cout << a[h] * a[w] << endl;
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<int,int> P;
typedef pair<int,P> T;

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

int main(){
   int h,w,k; cin>>h>>w>>k;
   int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; x1--; y1--; x2--; y2--;
   vector<vector<char>> g(h,vector<char>(w));
   rep(i,0,h)rep(j,0,w)cin>>g[i][j];
   vector<vector<int>> dist(h,vector<int>(w,inf));
   dist[x1][y1]=0; queue<P> que; que.push(P(x1,y1));
   while(!que.empty()){
      auto [nx,ny]=que.front(); que.pop();
      rep(i,0,4)rep(add,1,k+1){
         int tx=nx+dx[i]*add,ty=ny+dy[i]*add;
         if(tx<0 or tx>=h or ty<0 or ty>=w or g[tx][ty]=='@')break;
         if(dist[tx][ty]<=dist[nx][ny])break;
         if(dist[tx][ty]==inf){
            dist[tx][ty]=dist[nx][ny]+1; que.push(P(tx,ty));
         }
      }
   }
   if(dist[x2][y2]==inf)puts("-1");
   else cout<<dist[x2][y2]<<endl;
   return 0;
}

Measured memory_bytes: 11984
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
string s, t; ll n, m, p, q, ans = 0, sum = 0, num = 0;
int main() {
    cin >> n; vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        sum += a[i];      // 1項目＋
        if (i % 2 == 0 && sum <= 0) {
            num += 1 - sum;
            sum = 1;
        }
        else if (i % 2 == 1 && sum >= 0) {
            num += sum + 1;
            sum = -1;
        }
    }sum = 0;
    rep(i, n) {  // first -
        sum += a[i]; 
        if (i % 2 == 0 && sum >= 0) {
             ans += sum + 1;
             sum = -1;
        }
        else if (i % 2 == 1 && sum <= 0) {
             ans += 1 - sum;
             sum = 1;
        }
    }
    cout << min(ans, num) << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		String str ="";
		//??°?????????
		while(true){
			//???????????????????????????
			str = sc.next(); 
			//"-"????????????????????????
			if(str.equals("-")){
				break;
			}
			//??°????????????
			int num = sc.nextInt();
			
			//??????????????°???????????£?????????
			for(int i = 0;i< num;i++){
				int h = sc.nextInt();
				//
				str = str.substring(h)+str.substring(0,h);
			}
			//??¨???
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 26252
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char a,b,c;
	cin>>a>>b>>c;
	int s=700;
	if(a=='o')
	  s=s+100;
	if(b=='o')
	  s=s+100;
	if(c=='o')
	  s=s+100;
	cout<<s<<endl;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  priority_queue<long long> q;
  int n,m;
  cin>>n>>m;
  long long a;
  REP(i,n){
    cin>>a;
    q.push(a);
  }
  long long temp;
  REP(i,m){
    temp = q.top();
    q.pop();
    temp = temp/2;
    q.push(temp);
  }
  
  long long ans = 0;
  while(!q.empty()){
    ans += q.top();
    q.pop();
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int h, w; cin >> h >> w;
	map<char, int> a;
	REP(i, h * w) {
		char c; cin >> c;
		a[c - 'a']++;
	}
	int cnt1, cnt2;
	cnt1 = cnt2 = 0;
	for (auto x : a) {
		if (x.second % 4 == 1) cnt1++;
		if (x.second % 4 == 2) cnt2++;
		if (x.second % 4 == 3) cnt1++;
	}
	bool ok = false;
	if (h % 2 && w % 2) {
		if (cnt1 == 1 && cnt2 <= (h / 2) + (w / 2))
			ok = true;
	}
	else if (h % 2 == 0 && w % 2 == 0) {
		if (cnt1 == 0 && cnt2 == 0)
			ok = true;
	}
	else if (h % 2 == 0 && w % 2) {
		if (cnt1 == 0 && cnt2 <= h / 2)
			ok = true;
	}
	else if (h % 2 && w % 2 == 0) {
		if (cnt1 == 0 && cnt2 <= w / 2)
			ok = true;
	}
	cout << (ok ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 3552
n = int(input())
a = list(map(int, input().split()))

n1 = 0
n2 = 0
n4 = 0

for ai in a:
    if ai % 2 == 0:
        if ai % 4 == 0:
            n4 += 1
        else:
            n2 += 1
    else:
        n1 += 1

if n1 > n4:
    if (n4 >= 1) and (n1 == (n4 + 1)) and n2 == 0:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Measured memory_bytes: 19992
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
char s[51][51]={};
int h,w;
int bfs(int y,int x){
    int size=0;
    queue<pair<int,int>>que;
    que.push(make_pair(y,x));
    while(!que.empty()){
        pair<int,int>now=que.front();
        que.pop();
        int nowx,nowy;
        nowy=now.first;
        nowx=now.second;
        s[nowy][nowx]='.';
        size++;
        for(int i=0;i<4;i++){
           int nexty=nowy+dy[i];
           int nextx=nowx+dx[i];
            if(nextx<0 or nexty<0 or nexty>=h or nextx>=w or s[nexty][nextx]=='.'){
                continue;
            }else{
                s[nexty][nextx]='.';
                que.push(make_pair(nexty,nextx));
            }
        }
    }
    return size;
}
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    bool ok=true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                if(bfs(i,j)<=1){
                    ok=false;
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
   return 0;
}

Measured memory_bytes: 256
n = int(input())
aList = list(map(int,input().split()))
bList = list(map(int,input().split()))
cList = list(map(int,input().split()))

manzoku = bList[aList[0]-1] 
for i in range(1,n):
  if aList[i]-1 == aList[i-1]:
    manzoku += bList[aList[i]-1]+cList[aList[i]-1-1]
  else:
    manzoku += bList[aList[i]-1]
print(manzoku)


Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		if (k * 2 - 1 <= n) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
typedef long long int ll;
using namespace std;
const int MOD = 1000000007;


int main() {
	ll X, K, D; cin >> X >> K >> D;
	ll num = abs(X) / D;
	if (num > K) {
		cout << abs(X) - K * D << endl;
	}
	else {
		if ((K-num) % 2 == 0) {
			cout << abs(abs(X) - num * D) << endl;
		}
		else {

			cout << abs(abs(X) - (num + 1) * D) << endl;
		}
	}
}

Measured memory_bytes: 3136
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string S;

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

  cin >> N; cin >> S;
  if (N%2!=0) {
    cout << "No" << "\n";
    return 0;
  }
  string T = S.substr(N/2, N);
  rep(i, N/2) {
    if (T[i]==S[i]) continue;
    cout << "No" << "\n";
    return 0;
  }
  cout << "Yes" << "\n";
  return 0;
}

Measured memory_bytes: 256
using System;

namespace at
{
    class Program
    {
        static void Main(string[] args)
        {
            int day = int.Parse(Console.ReadLine());
            switch (day)
            {
                case 25:
                    Console.WriteLine("Christmas");
                    break;
                case 24:
                    Console.WriteLine("Christmas Eve");
                    break;
                case 23:
                    Console.WriteLine("Christmas Eve Eve");
                    break;
                case 22:
                    Console.WriteLine("Christmas Eve Eve Eve");
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 13140
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

import java.io.BufferedReader;



public class Main{

    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        HashMap<String,Integer> a = new HashMap<>();

        int n = sc.nextInt();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            String[] s = sc.next().split("");
            Arrays.sort(s);
            String ss = "";
            for (int j = 0; j < s.length; j++) {
                ss += s[j];
            }
            if(a.containsKey(ss)){
                ans += a.get(ss);
                a.put(ss,a.get(ss)+1);
            }
            else {
                a.put(ss,1);
            }

        }
        out.print(ans);
        out.flush();

    }

}



class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream system) {
        br = new BufferedReader(new InputStreamReader(system));
    }

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

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

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

    public char nextChar() throws IOException {
        return next().charAt(0);
    }

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

    public boolean ready() throws IOException {
        return br.ready();
    }

    public void waitForInput() throws InterruptedException {
        Thread.sleep(3000);
    }


}



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

using namespace std;

#define UN unsigned
#define ll long long int
#define pb push_back
#define MOD 1000000007

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b;
	cin >> a >> b;
	
	if(a <= 2*b)
		cout << 0;
	else
		cout << a-2*b;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] ar = new int[N];
        for (int i = 0; i < N; i++) {
            ar[i] = sc.nextInt();
        }
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        int now = 0;
        int count = 0;
        int ans = 0;
        for (int i : ar) {
            if (map.containsKey(i)) {
                map.put(i, map.get(i)+1);
            } else {
                map.put(i, 1);
            }
        }
        for (Entry<Integer, Integer> e : map.entrySet()) {
            int key = e.getKey();
            int val = e.getValue();
            if (key < val) {
                ans += (val-key);
            } else if (val < key) {
                ans += val;
            }
        }
        System.out.println(ans);
    }   
}


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

namespace Aojx
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s;
            while ((s = Console.ReadLine()) != null)
            {
                List<int> intList = new List<int>();
                foreach (char c in s)
                {
                    intList.Add(int.Parse(c.ToString()));
                }

                Console.WriteLine(Solve(intList));
            }
        }

        public static int Solve(List<int> list)
        {
            if (list.Count == 1)
            {
                return list[0];
            }
            else
            {
                List<int> newList = new List<int>();
                for (int i = 0; i < list.Count - 1; i++)
                {
                    newList.Add((list[i] + list[i + 1]) % 10);
                }

                return Solve(newList);
            }
        }
    }
}

Measured memory_bytes: 5600
#include<cstdio>
long long g(long long a, long long b){
return b?g(b,a % b):a;
}
#define l(a,b) a*b/g(a,b)
main(){
int a[3],m[3],p[3]={1,1,1};
while(scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2),*a){
int c[3]={0};
for(int i=0;i<3;i++){
do{
p[i]=a[i]*p[i]%m[i];c[i]++;
}while(p[i]!=1);
}
printf("%lld\n",l(l(c[0],c[1]),c[2]));
}
}

Measured memory_bytes: 0
s = input()
#AKIHABARAからAを抜いた文字列ならOK
#全抜き、1個抜き、2個抜き、3個抜き、そのまま
if s == "KIHBR" or s == "KIHABARA" or s == "AKIHBARA" or s == "AKIHABRA" or s == "AKIHABAR" or \
    s == "AKIHABARA" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or \
        s == "AKIHABR" or s == "AKIHBAR" or s == "AKIHBRA" or s == "KIHABAR" or s == "KIHABRA" or s == "KIHBARA":
        print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
program main
 implicit none
 integer*8 N,D,i,j,k,cnt
 real*8 dist
 real*8, allocatable::X(:,:)
 read(*,*) N,D
 allocate( X(1:N,1:D) )
 do i=1,N
   read(*,*) X(i,:)
 end do
 cnt = 0
 do i=1,N-1
  do j=i+1,N
   dist = 0.0D0
   do k=1,D
    dist = dist + (X(i,k) - X(j,k))**2
   end do
   dist = sqrt(dist)
   !write(*,*) i,j,dist
   if(dist - floor(dist) == 0) then
    cnt = cnt+1
   end if
  end do
 end do
 write(*,*) cnt
end program main

Measured memory_bytes: 256
h, w = map(int, input().split())
ans = [[0 for _ in range(w+2)] for _ in range(h+2)]

for i in range(h):
    S = input()
    for j, s in enumerate(S):
        if s == "#":
            ans[i+1][j+1] = "#"
            if ans[i][j+1] != "#":
                ans[i][j+1] += 1
            if ans[i+1][j] != "#":
                ans[i+1][j] += 1
            if ans[i][j] != "#":
                ans[i][j] += 1
            if ans[i+1][j + 2] != "#":
                ans[i+1][j + 2] += 1
            if ans[i][j + 2] != "#":
                ans[i][j + 2] += 1
            if ans[i + 2][j+1] != "#":
                ans[i + 2][j+1] += 1
            if ans[i + 2][j + 2] != "#":
                ans[i + 2][j + 2] += 1
            if ans[i + 2][j] != "#":
                ans[i + 2][j] += 1

for a in ans[1:-1]:
    print("".join(map(str, a))[1:-1])


Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	map<ll,ll> mp;
	rep(i,0,n){
		int a; cin>>a;
		mp[a]++;
	}
	ll m; cin>>m;
	vl t(m);
	rep(i,0,m)cin>>t[i];
	rep(i,0,m){
		if(mp[t[i]]==0){
			cout<<"NO"<<endl;
			return 0;
		}
		else mp[t[i]]--;
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  sort(A.begin(), A.end(), greater<int>());
  if (4*M*A.at(M-1) < sum) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <chrono>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <map>
#include <deque>
#include <string.h>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define ABS(a) (a < 0 ? -a : a)
#define YesNo(flag) (flag ? "Yes\n" : "No\n")
#define YESNO(flag) (flag ? "YES\n" : "NO\n")

constexpr auto NMAX = (int)1e2 + 20;
constexpr auto INF_ULL = 18446744073709551615;
constexpr auto INF_INT = 2147483647;
constexpr auto PI = 3.14159265359;
using namespace std;

typedef unsigned long long ull;

int main()
{
	ull a, b = 0;
	string s;
	cin >> a;
	cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '.') {
			continue;
		}
		b = b * 10 + (char)s[i] - '0';
	}
	cout << (a * b) / 100;
	return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 4000005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}


int main()
{	boost
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif

ll a,n,temp=1;
ll max=1e18;
ll ans=-1; 
ll prev;
cin>>n;
ll b[n];
REP(a,n)
{
	cin>>b[a];
	if(b[a]==0)
	{
		cout<<"0";
		return 0;
	}
}
REP(a,n)
{
	prev=temp;
	temp*=b[a];
	//cout<<temp<<"\n";
	if(temp>max||temp<0||prev>temp)
	{
cout<<ans;
return 0;
}
}
cout<<temp;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll x, y;
  cin >> x >> y;

  ll ans = 1e18;
  ll diff = abs(abs(y) - abs(x));

  if (x+diff == y) {
    ans = min(ans, diff);
  }
  if (-(-x+diff) == y) {
    ans = min(ans, diff+2);
  }
  if (-(x+diff) == y) {
    ans = min(ans, diff+1);
  }
  if (-x+diff == y) {
    ans = min(ans, diff+1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
while 1:
    t,(n,m)=[0],map(int,input().split())
    if n==m==0:break
    if n:t+=map(int,input().split())
    if m:t+=map(int,input().split())
    t.sort()
    print(max(t[i+1]-t[i] for i in range(n+m)))

Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};


long double x[105], y[105], z[105], r[105];

long double dist(int i, int j) {
    double sum = 0.0;
    sum += pow(x[i]-x[j], 2);
    sum += pow(y[i]-y[j], 2);
    sum += pow(z[i]-z[j], 2);
    return pow(sum, 0.5);
}

typedef pair<long double, i_i> d_i_i;

int main() {
    cout << fixed << setprecision(3);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        UnionFind uni(n + 1);
        for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i] >> r[i];
        priority_queue<d_i_i, vector<d_i_i>, greater<d_i_i> > que;
        for(int i = 1; i <= n; i++) {
            for(int j = i + 1; j <= n; j++) {
                long double now = dist(i, j) - r[i] - r[j];
                if(now < 0) now = 0.0;
                que.push({now, {i, j}});
            }
        }
        long double sum = 0.0;
        while(uni.size(1) != n) {
            d_i_i now = que.top();
            que.pop();
            //cerr << now.first << endl;
            int i = now.second.first;
            int j = now.second.second;
            if(!uni.issame(i, j)) {
                sum += now.first;
                uni.merge(i, j);
            }
        }
        cout << sum << endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i%k == 0) {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int A[1010][1010];
struct za{
  int x;
  int y;
  int num;
};

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

int main(){
  int H,W; cin>>H>>W;

  queue<za> que;
  rep(i,H) rep(j,W){
    char c; cin>>c;
    if(c=='#'){
      A[i][j]=1;
      que.push({i,j,0});
    }
  }

  int ans=0;
  while(que.size()){
    struct za z=que.front();
    que.pop();
    rep(k,4){
      int i=z.x+dx[k],j=z.y+dy[k];
      if(i<0||i>=H||j<0||j>=W) continue;
      if(A[i][j]==0){
        A[i][j]=1;
        que.push({i,j,z.num+1});
        ans=max(ans,z.num+1);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

void solve(){
    ll n; cin >> n;
    vector<ll> A(n), B(n);
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }
    ll sum = 0;
    for(int i=n-1; i>=0; i--){
        ll rem = A[i]%B[i];
        if(rem != 0) sum += B[i] - rem;
        if(i != 0) A[i-1] += sum;
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int MX = 2e5+5;
vector<int> to[MX];
int t[MX];
int c[MX];
ll ans[MX];
ll f(ll n){ return n*(n+1)/2;}

int tfs(int v , int p = -1){
	t[v] = 1;
	for(auto u : to[v]){
		if(u == p)
			continue;
		t[v] += tfs(u,v);
	}
	return t[v];
}

stack<int> st[MX];
ll d[MX],remsz[MX];
void dfs(int v,int p = -1){
	st[c[v]].push(v);
	for(int u : to[v]){
		if(u==p)
			continue;
		d[v] = t[u];
		dfs(u,v);
		ans[c[v]] -= f(d[v]);
	}
	st[c[v]].pop();
	if((int)st[c[v]].size()){
		d[st[c[v]].top()] -= t[v];
	}
	else{
		remsz[c[v]] -= t[v];
	}
}

int main()
{
	int n; cin >> n;
	for(int i = 0 ; i < n ; i++){
		cin >> c[i];
		c[i]--;
	}
	for(int i = 1 ; i < n ; i++){
		int a , b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	tfs(0);
	for(int i = 0 ; i < n ; i++){
		ans[i] = f(n);
	}
	for(int i = 0 ; i < n ; i++){
		remsz[i] = n;
	}
	dfs(0);
	for(int i = 0 ; i < n ; i++){
		ans[i] -= f(remsz[i]);
	}
	for(int i = 0 ; i < n ; i++){
		cout<<ans[i]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 171528
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  char c;
  cin >> c;
  c++;
  cout << c << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	bool ok = ((n + 1) / 2) >= k;
	cout << (ok ? "YES": "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
p = [1,n]
for i in range(0,m):
    lr = list(map(int,input().split()))
    p = [max(p[0],lr[0]),min(p[1],lr[1])]
if p[0]>p[1]:
    print(0)
else:
    print(p[1]-p[0]+1)

Measured memory_bytes: 3060
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(defconstant +mod+ 1000000007)


(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~a" b)) () '(signed-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~a" b)) () '(unsigned-byte ,b))) bits)))

(define-int-types 2 4 8 16 32 64)

;;; Utils

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1
        (write obj :stream stream)
      (fresh-line stream))))

(declaim (inline fast-sort))
(defmethod fast-sort ((sequence list) &key (test #'<))
  (declare (inline sort)
           (inline sb-impl::stable-sort-list))
  (sort sequence (lambda (x y)
                   (funcall test x y))))

(declaim (inline quick-sort))
(defmethod quick-sort ((sequence array))
  (labels ((swap (arr x y)
             (rotatef (aref arr x)
                      (aref arr y)))
           (qsort-sub (arr left right)
             (let ((l left)
                   (r right)
                   (pivot (aref arr (+ left
                                       (random (- right left))))))
               (loop while (<= l r) do
                    (loop while (< (aref arr l) pivot) do
                         (incf l))
                    (loop while (> (aref arr r) pivot) do
                         (decf r))
                    (when (<= l r)
                      (swap arr l r)
                      (incf l)
                      (decf r)))
               (when (< left r)
                 (qsort-sub arr left r))
               (when (< l right)
                 (qsort-sub arr l right)))))
    (qsort-sub sequence 0 (1- (length sequence)))
    sequence))


(defmacro read-numbers-to-list (size)
  `(loop repeat ,size collect (read)))



(defmacro read-numbers-to-array (size)
  `(make-array ,size :initial-contents (loop repeat ,size collect (read))))

(defmacro read-numbers-to-board (row-size column-size)
  (let ((board (gensym))
        (r (gensym))
        (c (gensym)))
    `(let ((,board (make-array '(,row-size ,column-size))))
       (dotimes (,r ,row-size)
         (dotimes (,c ,column-size)
           (setf (aref ,board ,r ,c) (read))))
       ,board)))


(defun princ-for-each-line (list)
  (format t "~{~a~&~}" list))

(defun unwrap (list)
  (format nil "~{~a~^ ~}" list))



(defmacro with-buffered-stdout (&body body)
  (let ((out (gensym)))
    `(let ((,out (make-string-output-stream :element-type 'base-char)))
       (let ((*standard-output* ,out))
         ,@body)
       (write-string (get-output-stream-string ,out)))))




;;; Body


(defun main ()
  (declare #.OPT)
  (let ((c (read-char)))
    (declare (character c))
    (format t "~a~&" (code-char (1+ (char-code c))))))

#-swank (main)


Measured memory_bytes: 25196
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    power = lcm(power, b)

mn = min(B)
p2 = power // mn

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn // p2
ans2 = M // mn // (p2 * 2)
print(ans1-ans2)


Measured memory_bytes: 89708
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        mut k: usize,
    }

    let mut ans = vec![];
    for &ns in &s {
        if ns != 'a' {
            let bet_a = ('z' as u8 + 1 - ns as u8) as usize;
            if bet_a <= k {
                k -= bet_a;
                ans.push('a');
            } else {
                ans.push(ns);
            }
        } else {
            ans.push('a');
        }
    }

    if ans.iter().filter(|c| **c == 'a').count() == ans.len() {
        ans.pop();
        let add = k % 26;
        let c = ('a' as u8 + add as u8) as char;
        ans.push(c)
    } else {
        let mut c = ans.pop().unwrap();
        c = (c as u8 + k as u8) as char;
        ans.push(c);
    }

    for &a in &ans {
        print!("{}", a);
    }
    println!();
}


Measured memory_bytes: 2960
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>

bool is_sosuu(uint32_t v)
{
    if ( v <= 2 ) return true;
    for ( uint32_t _v = 2; _v < v; _v++ ) {
        if ( v % _v == 0 ) return false;
    }
    return true;
}

void calc_sosuu(std::vector<uint64_t> &s, uint64_t max)
{
    for ( uint64_t v = 2; v <= max; v++ ) {
        if ( is_sosuu(v) ) s.emplace_back(v);
    }
}

void get_soinsuu(uint64_t val, const std::vector<uint64_t> &sosuu, std::vector<std::pair<uint64_t, uint64_t>> &insuu)
{
    for ( auto ss : sosuu ) {
        uint64_t cnt = 0;
        uint64_t sss = ss;
        while ( val % sss == 0 ) {
            cnt++;
            sss *= ss;
        }
        if ( cnt == 0 ) continue;
        insuu.emplace_back(std::make_pair(ss, cnt));        
    }
    return;
}


void mondai_c()
{
    uint64_t a,b;
    std::cin >> a >> b;

    std::vector<uint64_t> sosuu;
    calc_sosuu(sosuu, std::max(a,b));

    std::vector<std::pair<uint64_t, uint64_t>> insuu_a;
    std::vector<std::pair<uint64_t, uint64_t>> insuu_b;

    get_soinsuu(a, sosuu, insuu_a);
    get_soinsuu(b, sosuu, insuu_b);

    // 乗数が0より大きい場合、大きい方の値のペアを全部掛ける
    uint64_t min_a = a, min_b = b;
    uint64_t r = 1;
    for ( auto ia = insuu_a.cbegin(); ia != insuu_a.cend(); ia++ ) {
        uint64_t ib_a = std::get<0>(*ia);
        bool isok = false;
        for ( auto ib = insuu_b.cbegin(); ib != insuu_b.cend(); ib++ ) {
            uint64_t ib_b = std::get<0>(*ib);
            if ( ib_a == ib_b ) {
                uint64_t e = std::max(std::get<1>(*ia), std::get<1>(*ib));
                uint64_t rr = ib_a;
                while ( e > 1 ) {
                    rr *= ib_a;
                    e--;
                }
                r *= rr;
                isok = true;
                insuu_b.erase(ib);
                break;
            }
        }
        if ( isok ) continue;
        // 見つからない
        uint64_t e = std::get<1>(*ia);
        uint64_t rr = ib_a;
        while ( e > 1 ) {
            rr *= ib_a;
            e--;
        }
        r *= rr;
    }
    for ( auto ib = insuu_b.cbegin(); ib != insuu_b.cend(); ib++ ) {
        uint64_t e = std::get<1>(*ib);
        uint64_t ib_b = std::get<0>(*ib);
        uint64_t rr = ib_b;
        while ( e > 1 ) {
            rr *= ib_b;
            e--;
        }
        r *= rr;
    }

    std::cout << r;
}

int main()
{
    mondai_c();

    return 0;
}



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

using namespace std;

const int mxn = 2e5 + 10;
const int Mod = 1e9 + 7;

int eps = -1000000000;

int Ans = 1e7;
int arr[mxn];

int main()
{
    double n, k, t;
    cin>>n>>k>>t;
    if((k-(n/t)) >= 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

int main(){
  int c = 0, n; cin>>n;
  // for(int i=1;i<=n;i++) if((int)log10(i)%2==0) c++;
  for(int i=1;i<=n;i++) if(to_string(i).size()%2) c++;
  cout<< c <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

    if(data[i] >= ans[0]){
      ans[2] = ans[1];
      ans[1] = ans[0];
      ans[0] = data[i];
    }else if(data[i] >= ans[1]){
      ans[2] = ans[1];
      ans[1] = data[i];
    }else if(data[i] >= ans[2]){
      ans[2] = data[i];
    }
  }
  for(i = 0; i < 3; i++){
    printf("%d\n", ans[i]);
  }
  
  return 0;
}

Measured memory_bytes: 600
n,k=map(int,input().split())
z=[0 for i in range(n+1)]

for i in range(k-1,n+1):#i+1こ選んだ場合
  #zにi+1個選んだ場合の和の組み合わせを格納。
  z[i]=(2*n-i)*(i+1)/2-i*(i+1)/2+1

#z[i]にはkとしてi+1個選んだ場合の和の数が格納(1=<k<=n+1) 
ans=0
for i in range(n+1):
  ans+=z[i]
print(int(ans%(10**9+7)))


Measured memory_bytes: 16980
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int 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; }
int n,k; 
vector <int> a, f;
bool check(int limit, int k){
    for(int i=0;i<n;i++){
        int c = a[i]*f[i];
        if(c > limit){
            int x = (c - limit + f[i] - 1)/ f[i];
            k -= x;
            if(k < 0) return false;
        }
    }
    return true;
}
signed main(void){
    cin>>n>>k;
    // k回まで
    //最大~まででにぶたん
    a.resize(n), f.resize(n);
    rep(i,n) cin>>a[i]; 
    rep(i,n) cin>>f[i];
    sort(f.begin(),f.end());
    sort(a.begin(),a.end(),greater<int>());
    int l =-1, r = 1e13; //rがok
    while(abs(l-r) > 1){
        int mid = (l+r)/2;
        if(check(mid, k)) r = mid;
        else l = mid;
    }
    cout<<r<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;


int main()
{
	fastio
  int n;
  cin >> n;
  n %= 10;
  if(n==2 || n==4 || n==5 || n==7 || n==9) cout << "hon";
  else if (n==0 || n==1 || n==6 || n==8) cout << "pon";
  else cout << "bon";

	return 0;
}






Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main()
{
	char a[3], b[3];
	int i, count=0;
	for(i=0; i<3; i++)
	{
		cin>>a[i];
	}
	for (i=0; i<3; i++)
	{
		cin>>b[i];
	}
	for (i=0; i<3; i++)
	{
		if (a[i] == b[i])
		count++;
	}
	cout<<count;
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
for i in range(N):
  t = list(map(int, input().split())) 
  A.append(t[1:])

count = [0 for i in range(M)]
for i in range(N):
  for j in range(M):
    count[j] += A[i].count(j+1)

print(sum([1 for i in count if i == N]))

Measured memory_bytes: 3060
local h, w, k = io.read("*n", "*n", "*n", "*l")
local map = {}
for i = 1, h do
  local s = io.read()
  for j = 1, w do
    map[(i - 1) * w + j] = s:sub(j, j) == "#"
  end
end
local hfound = false
local id = {}
local curid = 0
for i = 1, h * w do id[i] = 0 end
for i = 1, h do
  local wfound = false
  for j = 1, w do
    if map[(i - 1) * w + j] then
      curid = curid + 1
      if wfound then
        id[(i - 1) * w + j] = curid
      else
        for k = 1, j do
          id[(i - 1) * w + k] = curid
        end
        wfound = true
      end
    else
      id[(i - 1) * w + j] = curid
    end
  end
  if not wfound then
    if hfound then
      for j = 1, w do
        id[(i - 1) * w + j] = id[(i - 2) * w + j]
      end
    end
  else
    if not hfound then
      for k = 1, i - 1 do
        for j = 1, w do
          id[(k - 1) * w + j] = id[(i - 1) * w + j]
        end
      end
    end
    hfound = true
  end
end
for i = 1, h do
  for j = 1, w do
    io.write(id[(i - 1) * w + j])
    io.write(j == w and "\n" or " ")
  end
end


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

int main(){
    int a,b,c,d,l,r;
    cin >> a >> b >> c >> d;
    l = a + b;
    r = c + d;
    if(l!=r){
        if(l>r){
            cout << "Left" << endl;
        }else{
            cout << "Right" << endl;
        }
    }else{
        cout << "Balanced" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int N, A, B;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B;

  int diff = B - A;
  if (diff % 2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <vector>
using namespace std;

int n, k;
int par[5050], dep[5050];
vector <int> sons[5050];
int  dp[2020][2020];

int point[5050], te = 1;
struct e {int to, next;} edge[5050];
void add (int a, int b) {
	te ++;
	edge[te].next = point[a];
	edge[te].to = b;
	point[a] = te;
}

int ans = 1e9;

void dfs (int x) {
	dep[x] = 1;
	for (int e = point[x]; e; e = edge[e].next) {
		int to = edge[e].to;
		if (to == par[x])
			continue;
		par[to] = x;
		sons[x].push_back(to);
		dfs (to);
		dep[x] = max (dep[x], dep[to] + 1);
	}
	dp[x][0] = 1;
	for (int j = 0; j < sons[x].size(); j ++)
		dp[x][0] += dp[sons[x][j]][0];
	for (int i = 1; i <= dep[x]; i ++) {
		int tg = i - 1;
		int rem = min (tg, k - tg);
		int max_loss = 0;
		for (int j = 0; j < sons[x].size(); j ++) {
			int s = sons[x][j];
			dp[x][i] += dp[s][rem];
			// cerr << "dp " << x << " " << i << " += " << "dp " << s << " " << rem << " : " << dp[x][i] << " " << dp[s][rem] << endl;
			max_loss = max (max_loss, dp[s][rem] - dp[s][tg]);
		}
		dp[x][i] -= max_loss;
	}
	// cerr << x << " ::: ";
	// for (int i = 1; i <= dep[x]; i ++)
		// cerr << dp[x][i] << " ";
	// cerr << endl;
	for (int i = 1; i <= dep[x]; i ++)
		dp[x][i] = min (dp[x][i], dp[x][i - 1]);
	int pans = min (dep[x], k + 1);
	// cerr << x << " : " << n - dp[x][0] + dp[x][pans] << endl;
	ans = min (ans, n - dp[x][0] + dp[x][pans]);
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 1; i < n; i ++) {
		int a, b;
		cin >> a >> b;
		add (a, b);
		add (b, a);
	}
	dfs (1);
	cout << ans << endl;
	return 0;
}
/*
10 4
1 2
2 3
3 4
1 5
5 6
6 7
1 8
8 9
9 10
*/

Measured memory_bytes: 15744
#include <stdio.h>
#include <string.h>
char a[82];
char b[82];
char s[82];
int main()
{
  int n,i,j,c,d;
  scanf("%d",&n);
  while(n>0){
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(s,0,sizeof(s));
    scanf("%s\n%s",&a,&b);
    i=strlen(a)-1;
    j=strlen(b)-1;
    c=0;
    d=0;
    while(i>=0 || j>=0) {
      if(i>=0 && j>=0){
	s[d++] = (((a[i]-'0')+(b[j]-'0')+c) % 10)+'0';
	c = ((a[i]-'0')+(b[j]-'0')+c) / 10;
	i--;j--;
      }else if(i>=0){
	s[d++] = (((a[i]-'0')+c) % 10)+'0';
	c = ((a[i]-'0')+c) / 10;
	i--;
      }else if(j>=0){
	s[d++] = (((b[j]-'0')+c) % 10)+'0';
	c = ((b[j]-'0')+c) / 10;
	j--;
      }
    }
    if(c!=0) s[d++] = c+'0';
    if(d>80) printf("overflow");
    else {
      for(d--;d>=0;d--){
	printf("%c",s[d]);
      }
    }
    printf("\n");
    n--;
  }
  return 0;
}

Measured memory_bytes: 0