akhauriyash/Code-Regression huggingface dataset:
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout << endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define o(x)		  cout << x << endl;
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

ll bS(ll l, ll r, ll x, vll arr) {
	while (l <= r) {
		ll m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;
}

void primeFactors(ll n) {
	while (n % 2 == 0) {
		//cout << 2 << " ";
		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			//cout << i << " ";
			n = n / i;
		}
	}

	if (n > 2)
		cout << n << " ";
}

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

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

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		ll n, k;
		cin >> n >> k;
		vll fsum(n + 2, 0);
		vll esum(n + 2, 0);
		fsum[0] = 0;
		esum[n + 1] = n + 1;

		forn(i, 1, n + 2) {
			fsum[i] = (i % mod + fsum[i - 1] % mod) % mod;
		}
		revn(i, n, 1) {
			esum[i] = (i % mod + esum[i + 1] % mod) % mod;
		}
		//out(fsum);
		//out(esum);
		ll count = 0;

		forn(i, k, n + 2) {
			count += ((esum[n + 2 - i] - fsum[i] + mod) % mod + 1) % mod;
			count %= mod;
		}

		o(count)

	}
	CLOCK
	return 0;
}



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] ABK = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray();
            long A = ABK[0];
            long B = ABK[1];
            long K = ABK[2];
            if(A >= K)
            {
                Console.WriteLine(A - K + " " + B);
            }
            else if(A < K && A + B > K)
            {
                Console.WriteLine(0 + " " + (B - (K - A)));
            }
            else
            {
                Console.WriteLine(0 + " " + 0);
            }

        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28136
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int line[n];
  for(int i=0;i<n;i++){
    cin>>line[i];
  }
  int a=n-1;
  for(int i=0;i<n;i++){
    cout<<line[a];
    if(a)cout<<" ";
    --a;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1160
program water_bottle
    implicit none
    integer(8):: a, b, x
    read*, a,b,x
    if (x*2 < a*a*b) then
        print*, 180d0/acos(-1d0)*atan((dble(a*b*b))/dble(2*x))
    else
        print*, 180d0/acos(-1d0)*atan(dble(2*(a*a*b-x))/dble(a*a*a))
    end if
end program water_bottle

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        String T = sc.next();

        for (int i = 0; i < N; i++) {
            System.out.print(S.toCharArray()[i]);
            System.out.print(T.toCharArray()[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 21460
n=int(input())
s={}
for _ in range(n):
	_s=input()
	if _s in s:
		s[_s]=s[_s]+1
	else:
		s[_s]=1

s=sorted(s.items(),key=lambda x:(x[1],x[0]))
max=s[-1][1]
for i in s:
	if i[1]==max:
		print(i[0])



Measured memory_bytes: 57436
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#include "string"

vector<int>preffix(string &s) {
    int n=s.size();
    vector<int>pi(n,0);
    for(int i=1;i<n;i++) {
        int j=pi[i-1];
        while(j>0 and s[i]!=s[j])
            j=pi[j-1];
        if(s[i]==s[j])
            pi[i]=j+1;
    }
    return pi;
}

int kmp(string &t,string &p) {
    vector<int>ans;
    int n=t.size();
    int m=p.size();
    vector<int>pi=preffix(p);
    int j=0;
    for(int i=0;i<n;i++) {
        while(j>0 and t[i]!=p[j])
            j=pi[j-1];
        if(t[i]==p[j]) {
            j++;
            if(j==m){
                ans.push_back(i-j+1);
                j = pi[j-1];
            }
        }
    }
    return ans.size();
}

int solve(string &s,string &t){
	int l=1,r = s.size()/t.size() + 1,ans = 0;

	while(l<=r){
		int m = (l + r)/2;
		string tt = "";
		for(int i=0;i<m;i++)
			tt += t;
		if(kmp(s,tt) > 0){
			ans = m;
			l = m + 1;
		}
		else
			r = m - 1;
	}
	return ans;
}

int32_t main(){
	boost;
	string S,T;
	cin>>S>>T;
	string s = S;
	while(s.size() <= S.size()  + T.size())
		s += S;
	s += S;
	int ans1 = solve(s,T);
	s += s;
	int ans2 = solve(s,T);

	if(ans1 != ans2)
		cout<<-1<<endl;
	else
		cout<<ans2<<endl;
}




Measured memory_bytes: 60684
def ketanowa(p):
    ans = 0
    p = str(p)
    for i in p:
        ans += int(i)
    return ans


def main():
    temp = input()
    a,b=temp.split(" ")
    a=int(a)
    b=int(b)
    if a*b==15:
        print("*")
    elif a+b==15:
        print("+")
    
    else:
        print("x")

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#define N 30

/*
How to test
% diff <(./a.out < b1in.txt) <(cat b1out.txt) 
$ ./a.out < ain.txt 2>erra.txt

  for( i=0 ; i < n ; i++){
    fprintf(stderr, "%d: C2[%d] = %c%c \n" ,__LINE__ ,i ,C2[i].suit ,C2[i].value );
  }
    fprintf(stderr, "%d:\n" ,__LINE__ );
*/
typedef enum{
  ROOT, INT, LEAF,
} t_e;

typedef struct{
  int left;
  int right;
  int pa;
} tree_t;

void prew(tree_t *t_p ,int id );
void inow(tree_t *t_p ,int id );
void posw(tree_t *t_p ,int id );

int main(){
  int    n, i, j, k;
  int    id;
  int    pid; // parent ID
  tree_t a[N]; // a[id]

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%d", &id );
    scanf("%d%d" ,&(a[id].left) ,&(a[id].right) );
  }

  // initilize parent,
  for( i=0 ; i<n ; i++){
    a[i].pa = -1;
  }

  // set parent
  for( i=0 ; i<n ; i++ ){
    if( a[i].left != -1 ){
      a[(a[i].left)].pa  = i;
    }
    if( a[i].right != -1 ){
      a[(a[i].right)].pa = i;
    }
  }

  // set  parent ID
  for( i=0 ; i<n ; i++ ){
    if( a[i].pa == -1 ){
      pid = i;
      break;
    }
  }
  for( i=0 ; i<n ; i++ ){
    if( a[i].left != -1 ){
      a[(a[i].left)].pa  = i;
    }
    if( a[i].right != -1 ){
      a[(a[i].right)].pa = i;
    }
  }


  printf("Preorder\n");
  prew(a, pid);
  printf("\n");

  printf("Inorder\n");
  inow(a, pid);
  printf("\n");

  printf("Postorder\n");
  posw(a, pid);
  printf("\n");

  
  return 0; // Don't forget return 0
}

void prew(tree_t *t_p ,int id){ // preorder tree walk
  if(id == -1){
    return;
  }

  printf(" %d" ,id);
  prew(t_p, t_p[id].left);
  prew(t_p, t_p[id].right);
}

void inow(tree_t *t_p ,int id){ // preorder tree walk
  if(id == -1){
    return;
  }

  inow(t_p, t_p[id].left);
  printf(" %d" ,id);
  inow(t_p, t_p[id].right);
}

void posw(tree_t *t_p ,int id){ // preorder tree walk
  if(id == -1){
    return;
  }

  posw(t_p, t_p[id].left);
  posw(t_p, t_p[id].right);
  printf(" %d" ,id);
}

Measured memory_bytes: 616
a=[list(map(int,input().split()))for _ in range(3)]
n=int(input())
b=[int(input())for _ in range(n)]
ans='No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
         a[i][j]=0
      
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int S, C;
	cin >> S >> C;
	int ans = 0;
	
	ans = min(S, C / 2);
	S -= ans;
	C -= ans * 2;
	if (S == 0) {
		ans += C / 4;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
def solve(n, m, v, p, a)
  a = a.sort.reverse
  a.unshift nil

  xmin = 0
  xmax = n + 1
  loop do
    break if xmin + 1 == xmax
    x = ((xmin + xmax) / 2).floor
    r = if x <= p
          true
        elsif a[x] + m < a[p]
          false
        else
          b = [0]
          1.upto(n) do |i|
            if p <= i && i < x
              b[i] = a[x] + m - a[i]
            else
              b[i] = m
            end
          end
          b.inject(:+) >= m * v
        end

    if r
      xmin = x
    else
      xmax = x
    end
  end
  return xmin
end

n, m, v, p = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
puts solve(n, m, v, p, a)


Measured memory_bytes: 25080
#include <stdio.h>

int main()
{
    int board[100][100];
    int skipH[100] = {0};
    int skipW[100] = {0};
    int H, W;
    scanf("%d", &H);
    scanf("%d", &W);

    for (int i = 0; i < H; i++) {
        int skipflag = 1;
        char temp2;
        scanf("%c", &temp2);
        for (int j = 0; j < W; j++) {
            char temp;
            scanf("%c", &temp);
            if (temp == '.') {
                //printf(".");
                board[i][j] = 0;
            }
            else if (temp == '#') {
                //printf("#");
                board[i][j] = 1;
                skipflag = 0;
            }
            else if (temp == '\n') {
                printf("invalid\n");
                return 1;
            }
        }
        //scanf("%c", &temp2);
        if (skipflag == 1) {
            skipH[i] = 1;
        }
    }   
    for (int j = 0; j < W; j++) {
        int skipflag = 1;
        for (int i = 0; i < H; i++) {
            if (board[i][j] == 0) {
                continue;
            }   
            else {
                skipflag = 0;
            }   
        }
        if (skipflag == 1) {
            skipW[j] = 1;
        }
    }
    for (int i = 0; i < H; i++) {
        if (skipH[i] == 0) {
            for (int j = 0; j < W; j++) {
                if (skipW[j] == 0) {
                    if (board[i][j] == 0){ 
                        printf(".");
                    }   
                    else {
                        printf("#");
                    }
                }
                else {
                    continue;
                }
            }
            printf("\n");
        }
        else {
            continue;
        }
    }
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  for(int i=0;i<n-1;i++)
    sum += a[i];
  if(sum > a[n-1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
}

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

a = [0] * (10 ** 5 + 1)
ans = sum(A)

for i in range(N):
    a[A[i]] += 1

for i in range(Q):
    B, C = map(int, input().split())
    ans += a[B] * (C - B)
    a[C] += a[B]
    a[B] = 0
    print(ans)


Measured memory_bytes: 21128
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> a(h*w+1);
    for( int i = 1; i <= h; i++ ) {
        for( int j = 1; j <= w; j++ ) {
            int tmp;
            cin >> tmp;
            a[tmp] = make_pair(i, j);
        }
    }
    vector<int> b(h*w+1, 0);
    for( int k = 0; k < d; k++ ) {
        for( int i = 1+k; i <= h*w-d; i+=d ) {
            b[i+d] += b[i] + abs(a[i].first-a[i+d].first) + abs(a[i].second-a[i+d].second);    
        }
    }
    int q;
    cin >> q;
    vector<int> l(q), r(q);
    for( int i = 0; i < q; i++ ) cin >> l[i] >> r[i];
    for( int i = 0; i < q; i++ ) dump(b[r[i]] - b[l[i]]);
    return 0;  
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

int N;
int p[100003];



int main(){
	cin>>N;
	rep(i,N) cin>>p[i];
	p[N+1]=0;
	int cnt=0;
	rep(i,N){
		if(p[i]==i && p[i+1]==i+1){
			p[i+1]=i;
			p[i]=i+1;
			cnt++;
		}
		else if(p[i]==i){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	

	

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> G(2 * K, vector<int>(2 * K, 0));
  rep(i, N) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    if (c == 'W') x += K;
    y %= 2 * K;
    x %= 2 * K;
    G[y][x]++;
  }

  vector<vector<int>> csum(2 * K + 1, vector<int>(2 * K + 1, 0));
  for (int y = 0; y < 2 * K; ++y) {
    for (int x = 0; x < 2 * K; ++x) {
      csum[y + 1][x + 1] =
          csum[y + 1][x] + csum[y][x + 1] - csum[y][x] + G[y][x];
    }
  }

  int answer = 0;
  for (int y = 0; y <= K; ++y) {
    for (int x = 0; x <= K; ++x) {
      int sum = csum[y][x];
      sum += csum[2 * K][x] - csum[K + y][x];
      sum += csum[y][2 * K] - csum[y][K + x];
      sum += csum[K + y][K + x] + csum[y][x] - csum[K + y][x] - csum[y][K + x];
      sum += csum[2 * K][2 * K] + csum[K + y][K + x] - csum[2 * K][K + x] -
             csum[K + y][2 * K];
      answer = max(answer, sum);
      answer = max(answer, N - sum);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 31616
N, W = map(int, input().split())

dp = [[0] * (W + 1) for i in range(N + 1)]

for i in range(1, N + 1):
    w, v = map(int, input().split())
    for j in range(1,  W + 1):
        if j >= w:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[N][W])

Measured memory_bytes: 149104
n, x, y = map(int, input().split())

ans = [0] * (n - 1)
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        ans[min(abs(j - i), abs(x - i) + 1 + abs(y - j), abs(x - j) + 1 + abs(y - i)) - 1] += 1

for x in ans:
    print(x)

Measured memory_bytes: 9340
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);    
    return a / g * b;
}


int main(){
    int n;
    cin >> n;
    ll ans = 1;

    rep(i, n) {
        ll t;
        cin >> t;
        ans = LCM(ans, t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M = reads()
print((M * 1900 + (N-M) * 100) << M)


Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	vi a(5);
	rep(i,5){cin>>a[i];}
	int k; cin>>k;
	sort(a);
	if(a[4]-a[0]>k){
		cout<<":(";
		return 0;
	}
	cout<<"Yay!";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 100000000
using namespace std;
int main(){
  int n,m[150];
  int a[150][150];
  while(1){
    cin >> n;
    if(n==0) break;
    rep(i,n){
      cin >> m[i];
      rep(j,m[i]){
	cin >> a[i][j];
      }
    }
    int K,tmp;
    cin >> K;
    int l[150];
    vector<int> ans;
    int count[150]={};
    rep(i,K) cin >> l[i];
    rep(i,n){
      rep(j,m[i]){
	rep(k,K){
	  if(l[k] == a[i][j]){
	    count[i]++;
	  }
	}
      }
    }
    rep(i,n) if(count[i]==K) ans.push_back(i+1);
    if(ans.size()==1) cout << ans.front() << endl;
    else cout << -1 << endl;
    ans.clear();
  }
  
  return 0;
}




Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

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

	vector<int> x(N);
	vector<int> y(N);

	vector<int> index(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> x[i] >> y[i];
		index[i] = i;
	}

	double sum = 0;
	int count = 0;
	do
	{
		int prev_x = x[index[0]];
		int prev_y = y[index[0]];
		int cur_x = 0;
		int cur_y = 0;
		for (int i = 1; i < N; ++i)
		{
			cur_x = x[index[i]];
			cur_y = y[index[i]];
			sum += sqrt(pow(cur_x - prev_x, 2.0) + pow(cur_y - prev_y, 2.0));
			
			prev_x = cur_x;
			prev_y = cur_y;
		}

		++count;
	} while (next_permutation(index.begin(), index.end()));

	cout << fixed << setprecision(15) << sum / count << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)


class SegmentTree():
    def __init__(self, array, f, ti):
        """
        Parameters
        ----------
        array : list
            to construct segment tree from
        f : func
            binary operation of the monoid
        ti : 
            identity element of the monoid
        """
        self.f = f
        self.ti = ti
        self.n = n = 2**(len(array).bit_length())
        self.dat = dat = [ti] * n + array + [ti] * (n - len(array))
        for i in range(n - 1, 0, -1):  # build
            dat[i] = f(dat[i << 1], dat[i << 1 | 1])

    def update(self, p, v):  # set value at position p (0-indexed)
        f, n, dat = self.f, self.n, self.dat
        p += n
        dat[p] = v
        while p > 1:
            p >>= 1
            dat[p] = f(dat[p << 1], dat[p << 1 | 1])

    def query(self, l, r):  # result on interval [l, r) (0-indexed)
        f, ti, n, dat = self.f, self.ti, self.n, self.dat
        res = ti
        l += n
        r += n
        while l < r:
            if l & 1:
                res = f(res, dat[l])
                l += 1
            if r & 1:
                r -= 1
                res = f(dat[r], res)
            l >>= 1
            r >>= 1
        return res


class UnionFind:
    def __init__(self, size):
        self.dat = list(range(size))
        self.SIZE = [1] * size  # 0-indexed

    def find(self, x):
        dat = self.dat
        stack = [x]
        while True:
            y = stack[-1]
            if dat[y] != y:
                stack += [dat[y]]
            else:
                break
        for s in stack:
            dat[s] = y
        return y

    def unite(self, x, y):
        is_same = self.is_same
        find = self.find
        SIZE = self.SIZE
        dat = self.dat
        if not is_same(x, y):
            X, Y = find(x), find(y)
            SX, SY = SIZE[X], SIZE[Y]
            if SX > SY:
                m = dat[X] = Y
            else:
                m = dat[Y] = X
            SIZE[m] = SX + SY
            SIZE[X + Y - m] = 0

    def is_same(self, x, y):
        find = self.find
        return find(x) == find(y)

    def scan_uf(self):
        find = self.find
        length = len(self.dat)
        for i in range(length):
            find(i)

    def size(self, x):
        return self.SIZE[self.find(x)]


N, K = [int(_) for _ in input().split()]
P = [int(_) for _ in input().split()]
STmax = SegmentTree(array=P, f=max, ti=-float('inf'))
STmin = SegmentTree(array=P, f=min, ti=float('inf'))
UF = UnionFind(N - K + 1)
for i in range(N - K):
    if P[i] == STmin.query(i, i + K) and P[i + K] == STmax.query(
            i + 1, i + K + 1):
        UF.unite(i, i + 1)
inc = 0
incK = []
for i in range(N - 2, -1, -1):
    if P[i] <= P[i + 1]:
        inc += 1
        if inc >= K - 1:
            incK += [i]
    else:
        inc = 0
for i in incK:
    UF.unite(incK[0], i)
UF.scan_uf()
print(len(set(UF.dat)))


Measured memory_bytes: 126720
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  string s;
  cin >> n >>s;


  for(ll i=0;i<s.size();i++){
    ll b=(s[i]-0+n-65)%26+65;
    char c=b;
    s[i]=c;
  }

  for(ll i=0;i<s.size();i++)cout << s[i];

}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	cout << GET<int>() * GET<int>() / 2 << endl;
}

void solve()
{
}


Measured memory_bytes: 256
N,M=map(int,input().split())

# 箱iの中のボールの個数 箱の番号は問題文に合わせ1-initial
num=[1 for i in range(N+1)];num[0]=0
# 箱iの中に赤いボールが入っている可能性があるか
red=[False for i in range(N+1)];red[1]=True

for i in range(M):
    x,y=map(int,input().split())
    num[x]-=1;num[y]+=1
    if red[x]:
        if not red[y]:
            red[y]=True
        if num[x]==0:
            red[x]=False

print(len([1 for i in range(N+1) if red[i]]))

Measured memory_bytes: 53852
while True:
  m,f,r = map(int,input().split())
  if m==-1 and f==-1 and r==-1:
    break
  if m==-1 or f==-1:
    print('F')
  elif m+f >= 80:
    print('A')
  elif 65 <= m+f < 80:
    print('B')
  elif 50 <= m+f < 65:
    print('C')
  elif 30 <= m+f < 50:
    if r >= 50:
      print('C')
    else:
      print('D')
  else:
    print('F')
    
      


Measured memory_bytes: 5596
n, m = map(int, raw_input().split())
prefecs = [[] for i in range(n+1)]
queries = []
for _ in range(m):
    p, y = map(int, raw_input().split())
    queries.append((p, y))
    prefecs[p].append(y)
for i in range(1, n+1):
    prefecs[i].sort()
dic_list = [{} for i in range(n+1)]
for i in range(1, n+1):
    for j in range(len(prefecs[i])):
        dic_list[i][prefecs[i][j]] = j+1
for p, y in queries:
    print "%06d%06d" % (p, dic_list[p][y])

Measured memory_bytes: 71036
X=input()
max_num=10**6
A=[ 0 for _ in range(max_num+1) ]
A[1]=1

t_sqrt=int(max_num**0.5)

for n in range(2,t_sqrt+2):
    for i in range(n*2,max_num+1,+n):
        A[i]=1

for i in range(X,max_num+1):
    if A[i]==0:
        print i
        quit()

Measured memory_bytes: 38636
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	vi P(N);
	vi minn(N);
	rep(i,0,N){
		cin>>P[i];
	}
	int ans=1;
	minn[0]=P[0];
	rep(i,1,N){
		minn[i]=min(P[i],minn[i-1]);
		if(minn[i-1]>P[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
	
	string s,f;
	cin>>s;
	
    size_t i;
	for(i=0;i<s.size();i++)
	{
		
		if(s[i]!='B')
		{
			
			f=f+s[i];
			
			
		}
		
		
		else if(s[i]=='B')
		{
			
			if(f.size()>=1)
			{
				

				f.erase(f.size()-1,i);
				
				
			}
			
			
		}
		
		
		
	}
	
     
	
	cout<<f<<endl;
	
	
	
	return 0;
	
}

Measured memory_bytes: 3540
#include <stdio.h>
#include <iostream>

using namespace std;

#define ICPC_2010_A
//#define ICPC_2010_B

#ifdef ICPC_2010_A

int ary[410][410]={0};

int main(void){

	while(1){

		for(int i=0;i<410;i++)
			for(int j=0;j<410;j++)
				ary[i][j]=-1;

		int n;
		int nn,dd;
		ary[200][200]=0;
		int left=0,right=0,up=0,down=0;


		cin >> n;
		if(!n)break;

		for(int k=1;k<n;k++){
			cin >> nn >>dd;
			for(int i=0;i<410;i++)
				for(int j=0;j<410;j++)
					if(ary[i][j]==nn){
						if(dd==0){
							ary[i][j-1]=k;
							if(j-1-200<left)left--;
						}
						else if(dd==1){
							ary[i+1][j]=k;
							if(i+1-200>down)down++;
						}
						else if(dd==2){
							ary[i][j+1]=k;
							if(j+1-200>right)right++;
						}
						else{
							ary[i-1][j]=k;
							if(i-1-200<up)up--;
						}
						break;
					}
		}

		cout << right-left+1<<" "<<down-up+1<<endl;

	}

	return 0;
}

#endif

#ifdef ICPC_2010_B

bool Wall[32][32];

int main(){
	
	while(true){
		//	init
		memset(Wall,true, sizeof(bool)*32*32);

		int w,h;
		cin >> w >> h;

		for(int i = 0 ; i < (2*h-1) ; ++i){
			//	|の壁
			for(int j = 0 ; j < (w-1) ; ++j){
				int tmp;
				cin >> tmp;

				if(tmp == 0)
					Wall[j][i] = false;
				else
					Wall[j][i] = true;

				
			}
			i++;
			//	--の壁
			for(int j = 0 ; j < w ; ++j){
				int tmp;
				cin >> tmp;

				if(tmp == 0)
					Wall[j][i] = false;
				else
					Wall[j][i] = true;

				
			}
				
		}

	}
}

#endif

Measured memory_bytes: 1816
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int K; cin >> K;
    string S = "";
    REP(_, K) S += "ACL";
    cout << S << '\n';

    return 0;
}


Measured memory_bytes: 3676
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    vector<vector<char> > C((2), vector<char>(3));

    cin >> C[0][0] >> C[0][1] >> C[0][2];
    cin >> C[1][0] >> C[1][1] >> C[1][2];

    if (C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0]) { cout << "YES" << endl; }
    else { cout << "NO" << endl; }

}

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

long double dis[1005][1005]={};
struct circ
{
    long long x,y,r;
};
circ arr[1005]={};
int n;

vector < long double > s(1006,1e18);
vector < bool > vist;

void dij(int i)
{
    long double kk;
    int j,jj,k;
    priority_queue <pair<long double,int > >ll;
    ll.push({1e17,i});
    s[i]=0;

    while(!ll.empty()){

        jj=ll.top().second;
      //  cout<<jj<<' ';
        ll.pop();
       // cout<<jj<<endl;
        for(j=0;j<n+1;j++)
        {
            k=j;
            kk=dis[jj][j];
            if(s[k]>s[jj]+kk)
            {
                s[k]=s[jj]+kk;
                ll.push({1e17-s[k],k});
            }
        }

    }
}

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);

    long long x1,x2,y1,y2,i,j;

    cin>>x1>>y1>>x2>>y2;
    cin>>n;

    for(i=0;i<n;i++)
        cin>>arr[i].x>>arr[i].y>>arr[i].r;
    long double a,b,c,d,e,f;

    a=(x1-x2);
    a=a*a;
    b=(y1-y2);
    b=b*b;
    c=sqrt(a+b);
    d=c;
    d=max(d,(long double)0);
    dis[1001][n]=d;

    for(i=0;i<n;i++)
    {
        dis[i][i]=1e18;
        for(j=i+1;j<n;j++)
        {
            a=(arr[i].x-arr[j].x);
            a=a*a;
            b=(arr[i].y-arr[j].y);
            b=b*b;
            c=sqrt(a+b);
            d=c-(arr[i].r+arr[j].r);
            d=max(d,(long double)0);
            dis[i][j]=d;
            dis[j][i]=d;
        }
        a=(arr[i].x-x2);
        a=a*a;
        b=(arr[i].y-y2);
        b=b*b;
        c=sqrt(a+b);
        d=c-(arr[i].r);
        d=max(d,(long double)0);
        dis[i][n]=d;

        a=(arr[i].x-x1);
        a=a*a;
        b=(arr[i].y-y1);
        b=b*b;
        c=sqrt(a+b);
        d=c-(arr[i].r);
        d=max(d,(long double)0);
        dis[1001][i]=d;
        dis[i][1001]=d;
    }
    dij(1001);
  //  for(i=0;i<1004;i++)for(j=0;j<1005;j++)dp[i][j]=-1;
    cout<<fixed<<setprecision(10)<<s[n]<<' ';




    return 0;
}


Measured memory_bytes: 26348
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

int n;

// char X[100][100];
// int dp[1000000001];

int main(void){
    cin >> n;
    
    int ans = n;
    REP(i,0,n + 1) {
        int cost = 0;
        int t = i;
        while(t > 0) cost += t % 6, t /=6;
        t = n - i;
        while(t > 0) cost += t % 9, t /= 9;
        ans = min(ans,cost);
    }
    
    cout << ans << endl;
    

    

}

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


using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();it++)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');

int main(){

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vi arr(n);
    vi flag(100001,0);
    ll sum=0;
    rep(i,0,n){
        cin>>arr[i];
        flag[arr[i]]++;
        sum+=arr[i];
    }
    int q;
    cin>>q;
    int b,c;
    rep(i,0,q){
        cin>>b>>c;
        sum-=1LL*flag[b]*b;
        sum+=1LL*flag[b]*c;
        flag[c]+=flag[b];
        flag[b]=0;
    cout<<sum<<endl;
    }
    
}
    

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

struct store{
	int a,b;
};
bool cmp(store p,store q){
	return p.a<q.a;
}

int main(){
	int m,n;
	long long cnt=0;
	store s[100010];
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>s[i].a>>s[i].b;
	sort(s,s+n,cmp);
	
	int i=0;
	while(m>0){
		if(s[i].b>0){
			m--;
			s[i].b--;
			cnt+=s[i].a;
		}else i++;
	}
	cout<<cnt;
	
	return 0;
}

Measured memory_bytes: 1024
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

vector<int> _prime;
vector<int> build_prime_table(int max) {
	vector<int> table = vector<int>(max + 1, -1);
	table[0] = 0;
	table[1] = 0;
	table[2] = 1;
	for (size_t i = 3; i <= max; i++) {
		if (i % 2 == 0) { table[i] = 0; continue; }
		if (table[i] != -1)continue;
		table[i] = 1;
		for (size_t j = i + i; j <= max; j += i) {
			table[j] = 0;
		}
	}
	return table;
}

inline int ceileing(int a, int b) {
	return a % b == 0 ? a / b : a / b + 1;
}

int main() {
	int N, H; cin >> N >> H;
	auto as = vector<int>(N);
	auto bs = vector<int>(N);
	int max_a = 0;
	for (size_t i = 0; i < N; i++) {
		cin >> as[i] >> bs[i];
		max_a = max(as[i], max_a);
	}
	sort(as.begin(), as.end(), greater<int>());
	sort(bs.begin(), bs.end(), greater<int>());
	int count = 0;
	for (size_t i = 0; i < N; i++) {
		if (bs[i] < as[0])break;
		H -= bs[i];
		++count;
		if (H <= 0) {
			cout << count << endl;
			return 0;
		}
	}
	cout << count + ceileing(H, as[0]) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	string s;

	cin >> s;
	s.erase(s.end() - 2, s.end());

	for (int i = 0; s.size() != 0; i++)
	{
		for (int k = 0; k <= s.size()/2; k++)
		{
			if (k == s.size() / 2) {
				cout << s.size() << endl;
				exit(0);
			}

			if (s[k] != s[k + s.size() / 2]) break;
		}
		s.erase(s.end() - 2, s.end());
	}

	
}

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

using namespace std;

struct DATA{
  int x;
  int y;
};

int SearchConstellation(vector<DATA>, vector<DATA>, int, int);

int main(){
  int i, n, m, x, y;
  DATA _data;
  vector<DATA> data1, data2;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> x >> y;
      _data.x = x;
      _data.y = y;
      data1.push_back(_data);
    }

    cin >> m;

    for(i=0; i<m; ++i){
      cin >> x >> y;
      _data.x = x;
      _data.y = y;
      data2.push_back(_data);
    }

    for(i=0; i<data2.size(); ++i){
      x = data2[i].x - data1[0].x;
      y = data2[i].y - data1[0].y;
      if(SearchConstellation(data1, data2, x, y) == 1) break;
    }

    cout << x << " " << y << endl;
    data1.clear();
    data2.clear();
  }
  return 0;
}

int SearchConstellation(vector<DATA> data1, vector<DATA> data2, int x, int y){
  int i, j, k;

  for(i=1; i<data1.size(); ++i){
    for(j=0, k=0; j<data2.size(); ++j){
      if(data1[i].x == data2[j].x-x && data1[i].y == data2[j].y-y){
	k = 1;
	break;
      }
    }
    if(k == 0) return 0;
  }
  return 1;
}

Measured memory_bytes: 932
#include <stdio.h>

int main(void)
{
	char cup='A';
	char a;
	char b;
	while(scanf("%c,%c",&a,&b)!=EOF){
		if(a==cup){
			cup=b;
		}else if(b==cup){
			cup=a;
		}
	}
	printf("%c\n",cup);
	return 0;
}

Measured memory_bytes: 544
#include <iostream>
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    char c[h][w];
    int cnt[h+2][w+2] = {};
    string s;
    for (int i=0; i<h; i++) {
        cin >> s;
        for (int j=0; j<w; j++) {
            c[i][j] = s[j];
            if (c[i][j] == '#') {
                cnt[i][j]++;
                cnt[i][j+1]++;
                cnt[i][j+2]++;
                cnt[i+1][j]++;
                cnt[i+1][j+2]++;
                cnt[i+2][j]++;
                cnt[i+2][j+1]++;
                cnt[i+2][j+2]++;
            }
        }
    }
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (c[i][j] == '.') {
                cout << cnt[i+1][j+1];
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
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;
}

const long long INF = 1LL << 60;



int main() {
	int N;
	long long dp[100010];
	long long h[100010];

	cin >> N;
	rep(i, N) cin >> h[i];

	for (int i = 0; i < 100010; i++) dp[i] = INF;
	dp[0] = 0;

	for (int i = 1; i < N; i++) {
		chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
		if (i > 1) {
			chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
		}
	}
	
	cout << dp[N-1] << endl;

	return 0;
}


Measured memory_bytes: 1792
import sys,math
import itertools

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	pos = LLI(N)
	dist = [[0 for _ in range(N)] for _ in range(N)]
	total = 0
	for i in range(N):
		for j in range(i+1,N):
			dist[i][j] = math.sqrt((pos[i][0]-pos[j][0])**2 + (pos[i][1]-pos[j][1])**2)
			dist[j][i] = dist[i][j]
		total += sum(dist[i])
	print(total/N)

main()

Measured memory_bytes: 3064
/**
 * Author : RDP
 * There are no two words in the English language more harmful than "good job".
 * 1729 ;)
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */

void test_case()
{
    int n;
    cin >> n;
    vector <ll> p, q, r, s;
    for(int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        p.push_back(x + y);
        q.push_back(x - y);
        r.push_back(-x -y);
        s.push_back(-x + y);
    }
    sort(all(p));
    sort(all(q));
    sort(all(r));
    sort(all(s));
    ll ans = max({abs(p[0] - p[n - 1]), abs(q[0] - q[n - 1]), abs(r[0] - r[n - 1]), abs(s[0] - s[n - 1])});
    cout << ans << endl;
	return ;
}
int main()
{
	FAST_IO
    test_case();
	return 0;
}



Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    pair<ll,ll> tmp={0,0};
    ll prev=0;
    bool ifpossible=true;
    rep(i,n){
        ll t,x,y; cin>>t>>x>>y;
        ll move=abs(tmp.first-x)+abs(tmp.second-y);
        if(move>t-prev) ifpossible=false;
        else if((t-prev-move)%2==1) ifpossible=false;
        tmp={x,y};
        prev=t;
    }
    if(ifpossible) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

template<class T>
struct BIT {
	vector<T> bit;
	int sz;
	BIT(int sz, T x = 0) :
		bit(vector<T>(sz, x)),
		sz(sz)
		{}
	void add(int i, T x) {
		while(i < sz) {
			bit[i] += x;
			i |= i + 1;
		}
	}
	// [0, r)
	T sum(int r) {
		T ret = 0;
		--r;
		while(r >= 0) {
			ret += bit[r];
			r = (r & (r + 1)) - 1;
		}
		return ret;
	}
	// [l, r)
	T sum(int l, int r) {
		return sum(r) - sum(l);
	}
};

int main() {
	const int MAX = 1e5 + 10;
	int n; cin >> n;
	int a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	BIT<int64_t> ascend(MAX);
	int64_t l[n] = {};
	for(int i = 0; i < n; ++i) {
		l[i] = ascend.sum(a[i] + 1, MAX);
		ascend.add(a[i], 1);
	}
	BIT<int64_t> descend(MAX);
	int64_t r[n] = {};
	for(int i = n - 1; i >= 0; --i) {
		r[i] = descend.sum(a[i] + 1, MAX);
		descend.add(a[i], 1);
	}
	int64_t ans = 0;
	for(int i = 0; i < n; ++i) {
		// cerr << l[i] << " " << r[i] << endl;
		ans += min(l[i], r[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6260
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
}

Measured memory_bytes: 3612
import math
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min(a,b,c,d,e)
#切り上げでなくてはいけなかった
n2 = int(math.ceil(n / m))
time = 5 + (n2-1)
print(time)

Measured memory_bytes: 38384
#include <iostream>
int main() {
    int case_index = 1;
    int answer;
    while (true) {
        std::cin >> answer;
        if (answer == 0) {
            break;
        } else {
            std::cout << "Case " << case_index << ": " << answer << "\n";
        }
        case_index += 1;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,x;
    cin>>n;
    rep(i,n){
        cin>>x;
        if(x%2==0){
            if(x%3!=0&&x%5!=0){
                cout<<"DENIED";
              return 0;
            }
        }
    }
    cout<<"APPROVED";
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;
#define int long long int

const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 2e15;


signed main(){
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	double a,b,c;
	cin>>a>>b>>c;
	if(c<0.5*b*a*a)
	{
		double ans=atan(1.0*b*a*b/(2.0*c))*180.0/3.14159265;
		cout<<setprecision(8)<<fixed<<ans;
		return 0;
	}
	double x=1.0*c/(a*a);
	double h=2.0*(b-x)/a;
	double ans=atan(h)*180.0/3.14159265;
	cout<<setprecision(8)<<fixed<<ans;
	return 0;
}

Measured memory_bytes: 256