akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
//		String t = sc.next();
//		String buff="";
		//long b = Long.parseLong(sc.next());
		//int c = Integer.parseInt(sc.next());
		//int n = Integer.parseInt(sc.next());
		//long res=n;
		//int l = Integer.parseInt(sc.next());
		//int sum=0;
		//String s = sc.next();
		//String t = sc.next();
		//String b = sc.next();
		//int a = Integer.parseInt(sc.next());
		//String t = sc.next();

		/*if(a==b) {//a、e、i、o、u
			System.out.println("Draw");
		}else if(a==1){
			System.out.println("Alice");
		}*/
		/*for(int i=0;i<t.length();i++) {
			if(t.substring(i,i+1).equals(",")) {
				buff+=" ";
			}else {
				buff+=t.substring(i, i+1);
			}
		}*/
		System.out.println(a*800-(a/15)*200);
	}
}




Measured memory_bytes: 23636
def main():
  n = int(input())
  c = [0,0,0,0]
  for i in range(n):
    s = input()
    if s == 'AC':
      c[0] += 1
    elif s == 'WA':
      c[1] += 1
    elif s == 'TLE':
      c[2] += 1
    else:
      c[3] += 1
  print(f'AC x {c[0]}')
  print(f'WA x {c[1]}')
  print(f'TLE x {c[2]}')
  print(f'RE x {c[3]}')
main()

Measured memory_bytes: 9200
n = int(input())
v = [int(i) for i in input().split()]

v.sort()

for i in range(1,n):
    x = v.pop(0)
    y = v.pop(0)
    xy = (x + y) / 2
    v.append(xy)
    v.sort()

print(v.pop(0))



Measured memory_bytes: 3064
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions
fn enum_prime(n: u64) -> Vec<u64>{
    let mut prime = vec![];
    let mut is_prime = vec![true; n as usize + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..n as usize{
        if is_prime[i] == true{
            prime.push(i as u64);
            let mut j = 2;
            while (i*j) as u64 <= n{
                is_prime[i*j] = false;
                j += 1;
            }
        }
    }
    return prime;
}

// Main
fn main(){
    input!{
        N: usize,
    }
    let mut ans = 1;
    let modulo = 1_000_000_007;
    let prime = enum_prime(N as u64 +1);
    let mut map:HashMap<u64,u64> = HashMap::new();
    for i in 2..N+1{
        let mut x = i as u64;
        for p in prime.iter(){
            while x as u64 %p==0{
                *map.entry(*p).or_insert(0) += 1;
                x /= *p;
            }
            if x==1{
                break;
            }
        }
    }
    for m in &map{
        let (_,v) = m;
        ans *= v+1;
        ans %= modulo;
    }
    println!("{}", ans);
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> res(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        res[a]++;
        res[b]++;
    }
    for(int i=0;i<n;i++) cout<<res[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
# E - Coprime

import math
from functools import reduce

n = int(input())
a = list(map(int, input().split()))
assert len(a) == n

if reduce(math.gcd, a) > 1:
    print("not coprime")
    exit()

def factors(n):
    """Return the list of prime factors of n."""
    fac = set()
    sqrtn = math.sqrt(n)
    d = 2
    while d <= sqrtn:
        if n % d == 0:
            fac.add(d)
            n //= d
        else:
            d += 1
    if n > 1:
        fac.add(n)
    return fac

count = [0] * (10 ** 6 + 1)
for x in a:
    for f in factors(x):
        count[f] += 1
        if count[f] > 1:
            print("setwise coprime")
            exit()
print("pairwise coprime")


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

using namespace std;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  if (a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[60][2];
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    ll K;
    cin >> n >> K;
    ll A[100100];
    rep(i,0,n) cin >> A[i];
    rep(i,0,60){
      dp[i][0] = -1;
      dp[i][1] = -1;
    }
    dp[59][0] = 0;
    for(int i=58;i>=0;i--){
        ll add = 1LL << i;
        ll cnt = 0;
        rep(i,0,n) if(A[i] & add) cnt++;
        if(dp[i+1][1] >= 0){
                chmax(dp[i][1], dp[i+1][1] + add * max(n-cnt, cnt));
        }
        if(dp[i+1][0] >= 0){
            if(K & (1LL << i)){
              chmax(dp[i][1], dp[i+1][0] + add * cnt);
              chmax(dp[i][0], dp[i+1][0] + add * (n-cnt));
            }else{
              chmax(dp[i][0], dp[i+1][0] + add * cnt);
            }   
        }
    }

    ll ans = max(dp[0][0], dp[0][1]);
    cout << ans << endl;
    return 0;
}

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

void bubbleSort(vector<int> A, int N)
{
  int sw = 0;
  REP(i, N)
  {
    for (int j = N - 1; j >= 1; j--)
    {
      if (A[j] < A[j - 1])
      {
        swap(A[j], A[j - 1]);
        sw++;
      }
    }
  }
  REP(i, N)
  {
    cout << A[i];
    if (i < N - 1)
    {
      cout << " ";
    }
  }
  cout << endl << sw << endl;
}

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

  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N)
      cin >> A[i];
  bubbleSort(A, N);
  return 0;
}


Measured memory_bytes: 3136
s = list(input())

n = len(s)

if s[0] == '0' or s[n-1] == '1':
    print(-1)
    exit()

for i in range(1, n // 2):
    if s[i] != s[n-i-2]:
        print(-1)
        exit()

s[n-1] = '1'

i = 0
while i < n-1:
    p = -1
    for j in range(i+1, n):
        if s[j] == '1':
            p = j
            break
    for k in range(i, p):
        print(k+1, p+1)
    i = p




Measured memory_bytes: 5288
/*
  AOJ 0136
  Title:Frequency Distribution of Height
  @kankichi573
*/
#include <stdio.h>
#include <float.h>
int n;
int dist[7];
double height[40];
int min_;
display_graph()
{
  int i,j;
  for(i=1;i<=6;i++)
    {
      printf("%d:",i);
      for(j=0;j<dist[i];j++)
	printf("*");
      printf("\n");
    }

}
main()
{
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%lf",&height[i]);
    }
  for(i=0;i<n;i++)
    {
      if(height[i]<165.0)
	dist[1]++;
      else if(height[i]<170.0)
	dist[2]++;
      else if(height[i]<175.0)
	dist[3]++;
      else if(height[i]<180.0)
	dist[4]++;
      else if(height[i]<185.0)
	dist[5]++;
      else if(height[i]>=185.0)
	dist[6]++;
    }
  display_graph();
  return(0);
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int a = sc.nextInt();
		int b = sc.nextInt();


		for (int i = 0; i <= 20; i++) {
			int now = 1 + (a-1)*i;
			if(now >= b){
				System.out.println(i);
				break;
			}
		}

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,A,B;
  cin >> N;
 vector<int> H(N);
  for (int k=0;k<N;k++){
    cin >> H.at(k);
  }
   A = B = 0;
 for (int i=0;i<N-1;i++){
   if ( H.at(i) >= H.at(i+1)){
     A++;
   }
   else {
   B =  max(A,B);
   A = 0;
   }
 } 
  B = max(A,B);
   cout << B << endl;
 }
     
   
  

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

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i = (a); i != (b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int) (v).size())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string S;
	cin >> S;
	int idx = -1;

	vi ws;

	for (char ch : S) {
		++idx;
		if (ch == 'W') ws.pb(idx);
	}

	ll ret = 0;
	int j = -1;
	for (int i : ws) {
		++j;
		ret += i - j;
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1680
using System;
using System.Linq;

namespace ConsoleApp3
{
    internal class Class2
    {
        private static void Main(string[] args)
        {
            var abx = Console.ReadLine().Split(" ").Select(long.Parse).ToArray();

            var a = abx[0];
            var b = abx[1];
            var x = abx[2];

            var result = b / x - a / x;
            if (a % x == 0)
            {
                ++result;
            }
            Console.WriteLine(Math.Max(a == 0 ? 1 : 0, result));
        }
    }
}

Measured memory_bytes: 28220
#include<stdio.h>

int main(void){
	const int limitA = 1, limitB = 9;
	int i, j;
	i = j = 0;
	for(i = limitA;i <= limitB;i++)
		for(j = limitA;j <= limitB;j++)
			printf("%dx%d=%d\n", i, j, (i*j));
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	int i, j;
	while(scanf("%d%d%d", &a, &b, &c)!=EOF) {
		if(a+b<=10) printf("YES\n");
		else {
			d=20-a-b;
			j=0;
			for(i=1; i<=d; i++)
				if(i==a || i==b || i==c) j++;
			if((d-j)/7.0>=0.50) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;
}


Measured memory_bytes: 580
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

dp = Array.new(k+1) {[nil, nil]}

(k+1).times do |i|
    2.times do |player|
        a.each do |e|
            if i < e
                dp[i][player] = player ^ 1
                break
            end

            if dp[i-e][player ^ 1] == player
                dp[i][player] = player
                break
            end
        end or next
        dp[i][player] = player ^ 1
    end
end

puts dp[k][0] == 0 ? "First" : "Second"

Measured memory_bytes: 22476
from collections import deque
N, K = map(int, input().rstrip().split())
route = [0] + list(map(int, input().rstrip().split()))

# 町1から町nまでの距離
dis = [0] * (N+1)

# 訪問済み
checked = [0] * (N+1)

queue = deque([1])
hop_count = 0
offset = 0

ans = 1
while queue:
    i = queue.popleft()

    if hop_count == K:
        ans = i
        break

    A_i = route[i]

    if checked[A_i] == 1:
        roop_node_count = abs(hop_count+1 - dis[A_i])
        offset = (K - hop_count) % roop_node_count

        for _ in range(offset):
            i = route[i]
        ans = i
        break

    queue.append(A_i)
    hop_count += 1
    dis[A_i] = dis[i] + 1
    checked[i] = 1

print(ans)


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

public class Main {
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String strA = insBR.readLine();
			int intA = Integer.parseInt(strA);
			int intDiv = 0;
			int intDiv10 = 0;
			String strIndex = "";
			int intIndex = 0;
			for(int i = 1; i <= intA; i++){
				intDiv = i % 3;
				intDiv10 = i % 10;
				strIndex = Integer.toString(i);
				intIndex = strIndex.indexOf("3");
				if(intDiv == 0 || intDiv10 == 3 || intIndex != -1){
					System.out.print(" " + i);
				}
			}
			System.out.println();
		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}
	}

}



Measured memory_bytes: 27864
# D - Road to Millionaire
def sell(asset, price):
  return price * asset[1] + asset[0]


def buy(money, price):
  stock = money // price
  remainder = money % price
  
  return (remainder, stock)


from collections import deque
import copy

N = int(input())
A = list(map(int, input().split()))

# タプルのキュー
assets = deque()
assets.append((1000, 0))

for i in range(N - 1):
  new_assets = deque()
  max_money = 0
  
  for a in assets:
    max_money = max(max_money, sell(a, A[i]))  
  
  assets.append((max_money, 0))
  assets.append(buy(max_money, A[i]))

ans = 0

for a in assets:
  ans = max(ans, sell(a, A[N - 1]))

print(ans)

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

ll num[100001];

int main(){
  int n;
  ll k;
  cin >> n >> k;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    num[a] += b;
  }
  rep(i,100000) num[i+1] += num[i];

  int l = 0, r = 100000;
  while (r - l > 1) {
    int m  = (l + r) / 2;
    if (num[m] >= k) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 1024
import collections
N, M = input().split()
N = int(N)
M = int(M)
H = list(map(int, input().split()))
adjacent = [set() for i in range(N)]
for i in range(M):
  A, B = input().split()
  A = int(A)
  B = int(B)
  adjacent[A-1].add(B-1)
  adjacent[B-1].add(A-1)
Num = 0
for i in range(N):
  num = 1
  for j in adjacent[i]:
    if H[i] <= H[j]:
      num = 0
  if num == 1:
    Num += 1
print(Num)

Measured memory_bytes: 45640
#include<iostream>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

int main() {
  int a;
  cin >> a;
  char b[a];
  char c[a];
  char d[a];
  int answer = 0;
  for(int i = 0;i < a;i++){
    cin >> b[i];
  }
  for(int i = 0;i < a;i++){
    cin >> c[i];
  }  
  for(int i = 0;i < a;i++){
    cin >> d[i];    
  }
  for(int i = 0;i < a;i++){
    if(b[i] == c[i] && c[i] == d[i]){
      answer += 0;
    }else if(b[i] != c[i] && c[i] == d[i] || b[i] == c[i] && c[i] != d[i] || b[i] == d[i] && c[i] != d[i]){
      answer += 1;
    }else{
      answer += 2;
    }
  }
  cout << answer << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        if(n % 2 == 0){
            System.out.println(n / 2);
        }else{
            System.out.println((n/2) + 1);
        }
    }
}

Measured memory_bytes: 21844
input_str = input()
input_list = list(map(lambda x: int(x), input_str.split(' ')))

input_list[0], input_list[1] = input_list[1], input_list[0]
input_list[0], input_list[2] = input_list[2], input_list[0]

print(' '.join(list(map(lambda x: str(x), input_list))))


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

using namespace std;

const int max_n = 6022;
int mod;

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int power(int a, int b) {
    if (b == 0) {
        return 1 % mod;
    }
    if (b % 2 == 0) {
        return power(mul(a, a), b / 2);
    }
    return mul(a, power(a, b - 1));
}

int inv(int x) {
    return power(x, mod - 2);
}

int n, rev[max_n], dp[max_n][max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> mod;
    n *= 3;
    for (int i = 1; i <= n; ++i) {
        rev[i] = inv(i);
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int cnt = 0; cnt <= n / 3; ++cnt) {
            for (int len = 1; len <= 3 && i + len <= n; ++len) {
                dp[i + len][cnt + (len > 1)] += mul(dp[i][cnt], rev[i + len]);
                dp[i + len][cnt + (len > 1)] %= mod;
            }
        }
    }
    int ans = accumulate(dp[n], dp[n] + n / 3 + 1, 0LL) % mod;
    for (int i = 1; i <= n; ++i) {
        ans = mul(ans, i);
    }
    printf("%d", ans);
    return 0;
}


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

using namespace std;

#define intt long long

const int N = 105;

int a[N];

int main() {

    intt n, k;
    cin >> n >> k;
    if (n == k) cout << 0 << '\n';
    else if (n > k) {
        cout << min(n % k, k - n % k) << '\n';
    }
    else {
        cout << min(n, abs(n - k)) << '\n';
    }
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,m;

signed main() {
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(vi) (vi.begin(),vi.end())
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() {
	int a[3];
	
	for(int i=0;i<3;i++) si(a[i]);
	
	sort(a,a+3);
	
	cout<<a[0]+a[1]<<endl;
	return 0;
}

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

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	
	string a[h];
	for(int i = 0; i < h; i++)
	{
		cin >> a[i];
	}
	
	int cnt = 0;
	while(cnt < h + 2)
	{
		if(cnt == 0 || cnt == h + 1)
		{
			for(int i = 0; i < w + 2; i++)
			{
				cout << '#';
			}
			cout << endl;
		}
		else
		{
			cout << '#' << a[cnt - 1] << '#' << endl;
		}
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
  int a , b;
  scanf("%d %d\n",&a , &b);
  if(a < b)
  printf("a < b\n");

  if(a > b)
  printf("a > b\n");

  if(a == b)
  printf("a == b\n");

  return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

//ll d[200200], t[200200];
//ll cnt[100100100];

vector<ll> d, t;
unordered_map<ll, ll> cnt;

int main(void)
{
  ll n, m;
  
  cin >> n;
  REP(i, n) {
    int d1;
    cin >> d1;
    d.push_back(d1);
  }
 
  cin >> m;
  REP(i, m) {
    int t1;
    cin >> t1;
    t.push_back(t1);
  }
  
 REP(i, n) {
     cnt[d[i]] ++;
 }
  bool ok = true;
  REP(i, m) {
    cnt[t[i]] --;
    if(cnt[t[i]] < 0) {
      ok = false;
    }
  }
  cout << (ok?"YES":"NO") << endl;
  

}


Measured memory_bytes: 11632
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)

using LL = long long;
const int maxn = 100100;
LL mod = 1e9 + 7;
char s[maxn];
LL f[maxn][3];
int n;

LL mul(LL x, LL n) {
	LL ret = 1;
	while(n) {
		if(n & 1) {
			ret *= x; ret %= mod;
		}
		n >>= 1;
		x *= x; x %= mod;
	}
	return ret;
}

signed main() {
	// freopen("in", "r", stdin);
	while(~scanf("%s", s+1)) {
		memset(f, 0, sizeof(f));
		n = strlen(s+1);
		for(int i = 1; i <= n; i++) {
			f[i][0] = f[i-1][0] + (s[i] == 'A');
			f[i][1] = f[i-1][1] + (s[i] == 'C');
			f[i][2] = f[i-1][2] + (s[i] == '?');
		}
		LL ret = 0;
		for(int i = 1; i <= n; i++) {
			if(s[i] == 'B' || s[i] == '?') {
				LL q = f[n][2] - (s[i] == '?');
				ret += mul(3LL, q) * (f[i-1][0] * (f[n][1] - f[i][1]) % mod);
				ret %= mod;
				if(q >= 1) {
					ret += mul(3LL, q-1) * (f[i-1][0] * (f[n][2] - f[i][2]) % mod);
					ret %= mod;
					ret += mul(3LL, q-1) * (f[i-1][2] * (f[n][1] - f[i][1]) % mod);
					ret %= mod;
				}
				if(q >= 2) {
					ret += mul(3LL, q-2) * (f[i-1][2] * (f[n][2] - f[i][2]) % mod);
					ret %= mod;
				}
			}
		}
		printf("%lld\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2688
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for (int i=0;i<10;i++){
            for (int j=0;j<10;j++){
                int cij = 0;
                int cji = 0;
                for (int k=1;k<=n;k++){
                    String s = Integer.toString(k);
                    if (s.charAt(0)-'0'==i&&k%10==j)cij++;
                    if (s.charAt(0)-'0'==j&&k%10==i)cji++;
                }
                ans+=cij*(long)cji;
            }
        }
        System.out.println(ans);
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l; cin>>n>>l;
    vector<string> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    rep(i,n) cout<<v[i];
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int dis(int a,int b) {
    return (a-b)*(a-b);
}
int main(){
    int a, b;
    while (scanf("%d %d",&a,&b)!=EOF) {
        int ans = -1;
        for (int i=1;i<=1000;i++) {
            if (int(i*0.08)==a && int(i*0.1)==b)
            {
                ans = i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define N 100010
int a[N];
typedef struct
{
    int u,v;
}Node;
Node e[N];
int cmp(Node a,Node b)
{
    return a.v<b.v;
}
int main()
{
    int i,j,k,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for(i=0;i<n-1;i++)
    {
        e[i].u=a[i];
        j=a[i];
        if(a[i]>=(a[n-1]+1)/2)
            j=a[n-1]-a[i];
        e[i].v=j;
    }
    sort(e,e+n-1,cmp);
    printf("%d %d\n",a[n-1],e[n-2].u);
    return 0;
}


Measured memory_bytes: 1280
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int dp[333][333];
int c[333][333];

int solve(string &s,string &t){
  fill(dp[0],dp[333],MOD);
  fill(c[0],c[333],0);
  int n=s.size();
  rrep(i,n)rrep(j,n) c[i][j]=c[i+1][j+1]+(s[n-1-i]==t[n-1-j]);
  //cout<<s<<","<<t<<endl;
  //rep(i,n){rep(j,n)cout<<c[i][j]<<",";cout<<endl;}
  dp[0][0]=0;
  rep(i,n+1)rep(j,n+1){
    dp[i][j]+=c[i][j];
    MN(dp[i+1][j],dp[i][j]);
    MN(dp[i][j+1],dp[i][j]);
  }
  return dp[n][n];
}

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int h,w;
  cin>>h>>w;
  vector<string> s(w);
  rep(i,h){
    string str;
    cin>>str;
    rep(j,w) s[j]+=str[j];
  }
  int re=0;
  reps(i,1,w) re+=solve(s[i-1],s[i]);
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 1280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            boolean ok = false;
            if (S.compareTo("2019/04/30") <= 0) ok = true;
            out.println(ok ? "Heisei" : "TBD");

        }

    }
}



Measured memory_bytes: 21716
#include<stdio.h>
int main(void){
    int n, x, y, key, i, j;
    scanf("%d", &n);
    while ( n ) {
        int a[100][100] = { 0 };
        y = n / 2 + 2;
        x = n / 2 + 1;
        for ( i = 1; i <= n * n; i++ ) {
            key = 1;
            while ( key ){
                key = 0;
                if ( y > n ) { y = 1; key++;}
                else if ( y < 1 ) { y = n; key++;}
                if ( x > n ) { x = 1; key++;}
                else if ( x < 1 ) { x = n; key++;}
                if ( a[y][x] != 0 ) { y++; x--; key++;}
            }
            a[y][x] = i;
            /*printf("%d, x%d y%d\n", a[y][x], x, y);*/
            y++;
            x++;
        }
        for ( i = 1; i <= n; i++ ) {
            for ( j = 1; j <= n; j++ ) {
                printf("%4d", a[i][j]);
            }
            printf("\n");
        }
        scanf("%d", &n);
    }
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

bool dp[2][20000];

bool check(int pos, vector<int> vec){
    memset(dp, 0, sizeof(dp));
    dp[0][10000] = true;//原点
    for(int i = 0; i < vec.size(); ++i){
        for(int j = 0; j < 20000; ++j){
            if(dp[i%2][j] == 0) continue;
            if(j - vec[i] >= 0)     dp[(i+1)%2][j - vec[i]] |= dp[i%2][j];
            if(j + vec[i] < 20000)  dp[(i+1)%2][j + vec[i]] |= dp[i%2][j];
        }
        for(int j = 0; j < 20000; j++){
            dp[i%2][j] = false;
        }
    }
    return dp[vec.size() % 2][pos + 10000];
}

int main(){
    string s; cin >> s;
    int x, y; cin >> x >> y;
    
    {
        //一回もTがないとき->のみ
        int cntT = 0;
        int cntF = 0;
        for(auto c : s) {
            if(c == 'T') cntT++;
            else cntF++;
        }
        if(cntT == 0){
            if(x == cntF && y == 0) cout << "Yes" << endl;
            else cout << "No" << endl;
            return 0;
        }
    }
    
    vector<int> vecx, vecy;
    int id = 0;
    int cnt = 0;
    s += 'T';
    bool goright = true;
    int offset = 0;
    for(auto c : s){
        if(c == 'F') cnt++;
        else {
            if(id%2==0){
                if(goright){
                    goright = false;
                    offset = cnt;
                    id++;
                    cnt = 0;
                }else{
                    vecx.push_back(cnt);
                    id++;
                    cnt = 0;
                }
            }else{
                vecy.push_back(cnt);
                id++;
                cnt = 0;
            }
        }
    }
    /*
    for(auto elem : vecx) cout << elem;
    cout << endl;
    for(auto elem : vecy) cout << elem;
    cout << endl;
    */
    if(check(x-offset,vecx) && check(y, vecy)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll h,w,n;
	cin>>h>>w>>n;
	ll a,b;
	ll ans[10];
	rep(i,10){
		ans[i] = 0;
	}
	ans[0] = (h-2) * (w-2);
	set<pair<ll,ll>> s;
	rep(i,n){
		cin>>a>>b;a--;b--;
		s.insert(pair<ll,ll>{a,b});
		rep(nx,3){
			rep(ny,3){
				if(a-nx < 0 || b-ny < 0 || a-nx+2 >= h || b-ny+2 >= w) continue;
				int count = 0;
				rep(x,3){
					rep(y,3){
						if(s.count(pair<ll,ll>{a-nx+x, b-ny+y}) > 0){
							count++;
						}
					}
				}
				if(count > 0){
					ans[count-1]--;
					ans[count]++;
				}
			}
		}
	}
	rep(i,10){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

	int n;
	cin >> n;
	vector<pair<int, int>> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i].first;
		x[i].second = i;
	}

	sort(x.begin(), x.end());
	int m2 = n / 2;
	int m1 = m2 - 1;
	vector<int> ans(n);
	for (int i = 0; i <= m1; i++) {
		ans[x[i].second] = x[m2].first;
	}
	for (int i = m2; i < n; i++) {
		ans[x[i].second] = x[m1].first;
	}

	for (int k : ans) cout << k << "\n";
}


Measured memory_bytes: 4608
import java.util.Scanner;
public class Main{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int w = sc.nextInt();
int n = sc.nextInt();
int[] values = new int[w];
for(int i = 0;i<values.length;i++){
  values[i] = i+1;
}
for(int i = 0;i<n;i++){
  String str = sc.next();
  String[] ab = str.split(",");
  int a = Integer.parseInt(ab[0])-1;
  int b = Integer.parseInt(ab[1])-1;
  int x=values[a];
  values[a]=values[b];
  values[b]=x;
}
for(int i=0;i<w;i++){
  System.out.println(values[i]);
}
}
}



Measured memory_bytes: 26172
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    scanf("%d",&N);
    int h[N+1];
    for(int i=1;i<=N;i++)
        scanf("%d",&h[i]);
    int f[N+1];
    f[1]=0;
    f[2]=abs(h[2]-h[1]);
    for(int i=3;i<=N;i++)
        f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
    printf("%d\n",f[N]);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    ll n; cin >> n;
    bool ok = false; ll cnt =0;
    while(n--){
        ll x, y; cin >>x>>y;
        if(x == y) cnt++;
        else cnt =0; 
        if(cnt == 3) ok = true;
    }
    if(ok ) cout << "Yes\n";
    else cout << "No\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,k,i,tmp,ans=0;
  scanf("%d %d",&n,&k);
  int a[200000]={};
  for(i=0;i<n;i++) {
    scanf("%d",&tmp);
    a[tmp-1]++;
  }
  qsort(a,n,sizeof(int),cmp);
  for(i=0;i<n-k;i++) ans+=a[i];
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
 int main()
 {
   int n;
   cin>>n;
   int ac=0;
   int wa=0;
   int tle=0;
   int re=0;
   for(int i=0;i<n;i++)
   {
     string temp;
     cin>>temp;
     if( temp=="AC")
       ac++;
     if( temp=="TLE")
       tle++;
     if( temp=="WA")
       wa++;
     if( temp=="RE")
       re++;
   }
   cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
   cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
   cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
   cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
 }

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

int N, K;
vector<ll> line(100001, 0);

int main(void){
	
	scanf("%d %d", &N, &K);
	for(int i = 0; i < N; ++i) scanf("%lld", &line[i]);
    
    ll ans = LLONG_MAX;
    for(int i = 0; i < N; ++i){
        if(i + K - 1 >= N) break;
        ans = min(ans, abs(line[i]) + abs(line[i] - line[i + K - 1]));
    }
    for(int i = N - 1; i >= 0; --i){
        if(i - K + 1 < 0) break;
        ans = min(ans, abs(line[i]) + abs(line[i] - line[i - K + 1]));
    }
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	rep(i, n) ans += h[i];
	int M = 0;
	rep(i, n) M = max(M, h[i]);
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= M; j++) {
			if (h[i - 1] >= j&&h[i] >= j) ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, v = nm()
    b, w = nm()
    t = ni()
    df_x = abs(b-a)
    df_v = v - w
    if df_v * t >= df_x:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9732
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0;
    for (int i = 100; i >= 1; i--)
        if (a % i == 0 && b % i == 0)
        {
            cnt++;
            if (cnt == k)
            {
                cout << i << endl;
                return 0;
            }
        }
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
    int a,b,i; char c[15]={0};
    scanf("%d %d",&a,&b);
    scanf("%s",c);
    for(i=0;i<a;i++)
        if(c[i]<'0'||c[i]>'9')
        {
            printf("No");
            return 0;
        }
    if(c[i]!='-')
    {
        printf("No");
        return 0;
    }
    for(i++;i<a+b+1;i++)
        if(c[i]<'0'||c[i]>'9')
        {
            printf("No");
            return 0;
        }
    if(c[i]!='\0')
        printf("No");
    else
        printf("Yes");
    return 0;
}


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

int main() {

  int H,W,K;
  cin >> H >> W >> K;

  vector<vector<char>> s(H,vector<char>(W));
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      cin >> s.at(i).at(j);
    }
  }

  vector<vector<int>> b(H,vector<int>(W,0));
  int k = 0;
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      if(s.at(i).at(j) == '#') {
        k++;
        b.at(i).at(j) = k;
      }
    }
  }

  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W-1;j++) {
      if(b.at(i).at(j+1) == 0) b.at(i).at(j+1) = b.at(i).at(j);
    }
    for(int j = W-1;j > 0;j--) {
      if(b.at(i).at(j-1) == 0) b.at(i).at(j-1) = b.at(i).at(j);
    }
  }

  for(int i = 0;i < W;i++) {
    for(int j = 0;j < H-1;j++) {
      if(b.at(j+1).at(i) == 0)b.at(j+1).at(i) = b.at(j).at(i);
    }

    for(int j = H-1;j > 0;j--) {
      if(b.at(j-1).at(i) == 0) b.at(j-1).at(i) = b.at(j).at(i);
    }
  }

  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      cout << b.at(i).at(j) << " ";
    }
    cout << endl;
  }
  

}









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

const int MOD = 1000000007;

int main()
{
    while(1){
        int n, x,count=0;
        cin >> n >> x;
        if(n==0 && x == 0)
            return 0;
        for (int i = 1; i <= n - 2;i++)
        {
            for (int j = 2; j <= n - 1;j++){
                if(x-i-j <= n && i !=j && i != x-i-j && j != x-i-j && i<j && j<x-i-j)  
                {
                    count++;
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D = 0;
	int N = 0;
  map<string,int> gacha{};
  cin >> N;
  for (int i = 0; i < N; i ++){
  	string s = "";
    cin >> s;
    gacha[s] = 0;
  }
  cout << gacha.size() << endl;
  return 0;
}

Measured memory_bytes: 19152
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a,b;
    cin>>a>>b;
    cout<<(((a%3*b%3*(a+b)%3)==0)?"Possible":"Impossible")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int a[1010], b[1010];
int c[1010][15];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, m){
        cin >> a[i] >> b[i];
        rep(j, b[i]) cin >> c[i][j];
    }

    int dp[5000];
    rep(i, 5000) dp[i] = INF;
    dp[0] = 0;

    rep(i, m){
        int now = 0;
        rep(j, b[i]) now |= (1<<(c[i][j]-1));
        for(int bits = 0; bits < (1<<n); bits++){
            dp[bits|now] = min(dp[bits|now], dp[bits] + a[i]);
        }
    }
    if (dp[(1<<n)-1]  == INF) cout << -1 << endl;
    else cout << dp[(1<<n)-1] << endl;

    return 0;
}


Measured memory_bytes: 3556
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
const int MAX_N =1000;
int r,c;
int S[MAX_N][MAX_N] = {0};

int main()
{
  scanf("%d %d",&r,&c);
  for (int i = 0; i < r; i++){
    for (int j = 0;j < c; j++){
      cin >>S[i][j];
      S[i][c] +=S[i][j];
    }
          S[r][c] +=S[i][c];
    }
  for (int i = 0; i < c; ++i){
    for(int j = 0;j < r;j++){
      S[r][i] +=S[j][i];
    }
  }
    for(int i = 0;i <=r ;i++){
      for(int j = 0;j <=c;j++){
	cout <<S[i][j];
	if(j !=c)
	  cout <<" ";
	else
	  cout <<endl;
      }
    }
  return 0;
}

Measured memory_bytes: 1636
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return map(int, input_tuple)


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    s = input()
    acgt = ['A', 'C', 'G', 'T']

    count = 0
    max_count = 0
    for i in s:
        if i in acgt:
            count += 1
            max_count = max(count, max_count)
        else:
            count = 0

    print(max_count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;

    vector<int> a(n);
    int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    rep(i, n){
        // a[i] >= sum/4m
        // 4m*a[i]>=sum
        if(4 * m * a[i] >= sum){
            ++cnt;
        }
    }

    if(cnt >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    cout << flush;

    return 0;
}

Measured memory_bytes: 384