akhauriyash/Code-Regression huggingface dataset:
use std::collections::BinaryHeap;
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

pub fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

const INF: usize = 1_000_000_000_000_000;

fn main() {
    let nmst = readn::<usize>(" ");
    let n = nmst[0];
    let m = nmst[1];
    let s = nmst[2] - 1;
    let t = nmst[3] - 1;

    let mut yen = vec![Vec::new(); n];
    let mut snuke = vec![Vec::new(); n];

    for _ in 0..m {
        let uvab = readn::<usize>(" ");
        let u = uvab[0] - 1;
        let v = uvab[1] - 1;
        let a = uvab[2];
        let b = uvab[3];

        yen[u].push((v, a));
        yen[v].push((u, a));
        snuke[u].push((v, b));
        snuke[v].push((u, b));
    }

    let mut ds = vec![INF; n];
    let mut dt = vec![INF; n];
    ds[s] = 0;
    dt[t] = 0;

    let mut que = BinaryHeap::new();
    que.push(Rev((0, s)));
    while let Some(Rev((d, i))) = que.pop() {
        if ds[i] != d { continue; }
        for &tup in yen[i].iter() {
            let j = tup.0;
            let dd = tup.1;
            if ds[j] > d + dd {
                ds[j] = d + dd;
                que.push(Rev((d + dd, j)));
            }
        }
    }

    let mut que = BinaryHeap::new();
    que.push(Rev((0, t)));
    while let Some(Rev((d, i))) = que.pop() {
        if dt[i] != d { continue; }
        for &tup in snuke[i].iter() {
            let j = tup.0;
            let dd = tup.1;
            if dt[j] > d + dd {
                dt[j] = d + dd;
                que.push(Rev((d + dd, j)));
            }
        }
    }

    let mut que = BinaryHeap::new();
    for i in 0..n {
        let cost = ds[i] + dt[i];
        if cost > INF {
            que.push((0, i));
        } else {
            que.push((INF - cost, i));
        }
    }

    let mut di = que.pop().unwrap();
    let mut ans = String::new();
    for i in 0..n {
        while di.1 < i {
            di = que.pop().unwrap();
        }
        ans += &((di.0).to_string());
        ans += "\n";
    }
    println!("{}", ans);
}

Measured memory_bytes: 40700
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int c;
    if(b/10==0){
        c=a*10+b;
    }
    else if(b/10!=0 && b!=100){
        c=a*100+b;
    }
   else if(b==100){
        c=a*1000+b;
    }
    for(int i=1;i<318;i++){
        if(c==i*i){
            cout << "Yes" << endl;
            break;
        }
        else if(i==317){
            cout << "No" << endl;
        }
        else{
            continue;
        }
    }
}

Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int,input().split()))

flag = False
b = []
cnt = 1
for i in range(n):
    if a[i] == cnt:
        flag = True
        b += [i]
        cnt += 1

if not flag:
    print(-1)
    sys.exit()

print(n - len(b))

Measured memory_bytes: 32372
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int p[N], cnt = 0;
    bool flag = false;
    for (int i = 1; i <= N; i++)
    {
        cin >> p[i];
        if (p[i] != i)
        {
            cnt++;
        }
    }
    if (cnt == 0)
    {
        cout << "YES" << endl;
        return 0;
    }
    if (cnt == 2)
    {
        flag = true;
    }
    if (!flag)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        for (int l = 1; l <= N; l++)
        {
            if (l != p[l])
            {
                if (p[p[l]] == l)
                {
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N,K,ans=0;
    cin >> N >> K;
    while(N>0){
        ans++;
        N/=K;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n,d,a; cin >> n >> d >> a;
    vector<Pll> mon(n);
    rep(i,n){
        ll x,h; cin >> x >> h;
        mon[i] = Pll(x,h);
    }
    sort(all(mon));
    vector<ll> imos(n+1,0);
    vector<ll> X(n), H(n);
    rep(i,n){
        X[i] = mon[i].first;
        H[i] = mon[i].second;
    }
    ll ans = 0;
    ll damage = 0;
    rep(i,n){
        damage += imos[i];
        if(H[i] - damage <= 0)continue;
        ll num = (H[i] - damage + a - 1) / a;
        ans += num;
        ll ed = upper_bound(all(X), X[i] + 2 * d) - X.begin();
        damage += num * a;
        imos[ed] -= num * a;
    }

    cout << ans << endl;

}

Measured memory_bytes: 8064
#[allow(unused_macros)]
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 , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }

fn main() {
    input! {
        x: i64,
        y: i64,
    }
    let mut ret = 1;
    let mut tmp = x;
    loop {
        tmp  *= 2;
        if tmp <= y {
            ret += 1;
        } else {
            break;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#include<algorithm>

int main()
{
	int N;

	std::cin >> N;

	std::vector<int> m(3);

	for(int i=0;i<N;++i)
	{
		for(int j=0;j<3;++j)
		{
			std::cin >> m[j];
		}
		std::sort(m.begin(),m.end());

		if(m[2]*m[2]==m[0]*m[0]+m[1]*m[1])
		{
			std::cout << "YES" << '\n';
		}
		else
		{
			std::cout << "NO" << '\n';
		}
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i=0; i<H; i++){
    vector<char> vec(W);
    for (int j=0; j<W; j++){
      cin >> vec.at(j);
    }
    for (int j=0; j<2; j++){
      for (int k=0; k<W; k++){
        cout << vec.at(k);
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Mysterious Operator
public class Main{
	Scanner sc=new Scanner(System.in);

	String s;

	void run(){
		s=sc.nextLine();
		solve();
	}

	void solve(){
		HashSet<Long> set=new HashSet<Long>();
		for(int i=0; i<s.length(); i++){
			int sub=i==0?0:Integer.parseInt(s.substring(0, i));
			int add=Integer.parseInt(s.substring(i, s.length()));
			int a=(sub+add)/2, b=(-sub+add)/2;
			if(a>=0&&b>=0
					&&Integer.parseInt((a-b)+""+(a+b))==Integer.parseInt(s)){
				set.add(a*(1L<<64)+b);
			}
		}
		println(set.size()+"");
	}

	void println(String s){
		System.out.println(s);
	}

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

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

using namespace std;

int N , A , B , C , D;

int Solve(){
	if( A > B )
		swap( A , B );
	if( C == 0 ){
		if( D == 0 )
			return A == B;
		else
			return 1LL * ( N - 2 ) * D + A >= B;
	}
	for(int i = 0 ; i <= N - 1 ; ++ i){
		long long x = i , y = N - 1 - i;
		long long l = 1LL * x * C - 1LL * y * D;
		long long r = 1LL * x * D - 1LL * y * C;
		if( l <= B - A && B - A <= r )
			return true;
	}
	return false;
}

int main( int argc , char * argv[] ){
	cin >> N >> A >> B >> C >> D;
	if( Solve() )
		puts( "YES" );
	else
		puts( "NO" );
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	int ans = 0;
	rep(i, n) {
		if (a[i] != -1) {
			if (a[a[i]] == i) {
				ans++;
				a[a[i]] = -1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
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);
    APoor solver = new APoor();
    solver.solve(1, in, out);
    out.close();
  }

  static class APoor {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int[] a = new int[3];
      a[0] = in.nextInt();
      a[1] = in.nextInt();
      a[2] = in.nextInt();
      Arrays.sort(a);
      if ((a[1] == a[0] || a[1] == a[2]) && a[0] != a[2]) {
        out.println("Yes");
      } else {
        out.println("No");
      }
    }

  }
}



Measured memory_bytes: 21972
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		int[] a = new int[M+1];
		int[] b = new int[M+1];
		int[,] graph = new int[N+1, N+1];
		for(int i = 1; i <= M; i++)
		{
			a[i] = GetInt();
			b[i] = GetInt();
			int c = GetInt();
			graph[a[i], b[i]] = c;
			graph[b[i], a[i]] = c;
		}

		int[,] d = new int[N+1, N+1];
		for(int i = 1; i <= N; i++)
			for(int j = 1; j <= N; j++)
				d[i,j] = (graph[i,j] != 0) ? graph[i,j] : (i == j) ? 0 : int.MaxValue/100;

		for(int k = 1; k <= N; k++)
			for(int i = 1; i <= N; i++)
				for(int j = 1; j <= N; j++)
					d[i,j] = Math.Min(d[i,j], d[i,k] + d[k,j]);

		bool[] used = new bool[M+1];
		for(int i = 1; i <= M; i++)
		{
			for(int s = 1; s <= N; s++)
			{
				for(int t = 1; t <= N; t++)
				{
					if(d[s,t] == d[s, a[i]] + graph[a[i], b[i]] + d[b[i], t])
						used[i] = true;
				}
			}
		}

		int numNotUsed = 0;
		for(int i = 1; i <= M; i++)
			if(!used[i])
				numNotUsed++;
		Console.WriteLine(numNotUsed);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 13180
#include<stdio.h>
int main()
{
        int i,j,n;

        scanf("%d",&n);

        for(i=1;i<10;i++){
                for(j=1;j<10;j++){
                        if(n==i*j){
                                printf("Yes\n");
                                return 0;
                        }
                }
        }

        printf("No\n");

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;



int main(){
	ll n,k; cin>>n>>k;
	cout<<min(n%k, k-(n%k));
			
	return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> p(N);
  
  for (int i=0;i<N;i++) {
    cin >> p.at(i);
  }
  
  int MAX = 0, sum = 0;
  for (int i=0;i<N;i++) {
    MAX = max(MAX,p.at(i));
    sum += p.at(i);
  }
  
  cout << sum - MAX/2 << endl;
  
  
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	var s string
	fmt.Scan(&s)
	q := make([]bool, n)
	qt, qa, qb := 0, 0, 0
	for i, v := range s {
		switch v {
		case 'a':
			if qt < a+b {
				qa++
				qt++
				q[i] = true
			}
		case 'b':
			if qt < a+b && qb < b {
				qb++
				qt++
				q[i] = true
			}
		}
	}
	for i := range q {
		if q[i] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


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

int answer(vector<vector<int>>& adj_list, int curr, map<int,int>& dp) {
  if (dp[curr] != -1) {
    return dp[curr];
  } else {
    int m = 0;
    for (int val : adj_list[curr]) {
      m = max(1+answer(adj_list, val, dp), m);
      dp[curr] = m;
    } 
    return m;
  }
}

int main() { 
  int n, m; cin >> n >> m;
  vector<vector<int>> adj_list(n+1);
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    adj_list[a].push_back(b);
  }
  map<int,int> dp;
  for (int i = 1; i <= n; i++) {
    dp[i] = -1;
  }

  int res = -1;
  for (int i = 1; i <= n; i++) {
    res = max(res, answer(adj_list, i, dp));
  }
  cout << res << endl;

  return 0;
}

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

int main(){
  char s[100001];
  scanf("%s",s);
 int ls;
  ls = strlen(s);
  if (s[0] == s[ls-1])
  {if (ls%2 == 0) printf("First\n");
   else printf("Second\n");}
  else
    {if (ls%2 == 0) printf("Second\n");
   else printf("First\n");}
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {

    string s;
    cin >> s;

    int cnt1 = 0, cnt2 = 0;

    for (int i=0; i<s.size(); ++i) {
        if (i % 2 == 0) {
            if (s[i] == '0') cnt1++;
            if (s[i] == '1') cnt2++;
        } else {
            if (s[i] == '1') cnt1++;
            if (s[i] == '0') cnt2++;
        }
    }

    cout << min(cnt1, cnt2) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int x, y;

void solve()
{
    cin >> x >> y;
    for (int i=0; i<=x; i++) {
        if (((i*2)+(x-i)*4)==y) {
            nout("Yes"); return;
        }
    }nout("No");

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
import static java.lang.Integer.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
		st = new StringTokenizer(br.readLine());
		int N = parseInt(st.nextToken());
		int M = parseInt(st.nextToken());
		boolean[] foods = new boolean[M];

		for(int i=0;i<N;i++) {
			st = new StringTokenizer(br.readLine());
			int K = parseInt(st.nextToken());

			List<Integer> indexList= new ArrayList<>();

			for(int j=0;j<K;j++) {
				int n = parseInt(st.nextToken());
				if(i==0) {
					foods[n-1] = true;
				}
				indexList.add(n);
			}

			for(int x=0;x<foods.length;x++) {
				if(foods[x] == true) {
					if(indexList.indexOf(x+1) == -1) {
						foods[x] = false;
					}
				}
			}

		}

		int sum = 0;
		for(int x=0;x<foods.length;x++) {
			if(foods[x] == true) {
				sum ++;
			}
		}

		System.out.println(sum);

	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
  vector<vector<ll>> graph(N);
  REP(M){
    --A[i];--B[i];
    graph[A[i]].push_back(B[i]);
    graph[B[i]].push_back(A[i]);
  }
  priority_queue<pair<ll,pll>,vector<pair<ll,pll>>,greater<pair<ll,pll>>> q;
  vector<ll> dist(N,INF),prev(N,-1);
  q.push(make_pair(0LL,pll(0,-1)));
  while(!q.empty()){
    auto cur=q.top();q.pop();
    ll idx=cur.second.first;
    ll p=cur.second.second;
    ll d=cur.first;
    if(chmin(dist[idx],d)){
      prev[idx]=p;
      for (auto &&j : graph[idx])
      {
        if(dist[j]>d+1){
          q.push(make_pair(d+1,pll(j,idx)));
        }
      }
    }
  }
  cout<<YES<<endl;
  REP(N-1){
    cout<<prev[i+1]+1<<endl;
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 19680
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	unsigned long long h;
	cin >> h;
	unsigned long long s = 0;
	unsigned long long c = 1;
	for (unsigned long long i = h; i > 0; i /= 2) {
		s += c;
		c *= 2;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>

int n, k, h[100055], dp[100055];

int main() {
	
	scanf("%d%d", &n, &k);
	
	for (int i = 0; i < n; i++) {
		scanf("%d", h + i);
	}
	
	for (int i = 1; i < n; i++) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for (int j = 2; j <= k; j++) {
			if (i - j < 0) {
				break;
			}
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	
	printf("%d\n", dp[n - 1]);
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  char s[N];
  int r = 0, b = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    if (s[i] == 'R') {
      r += 1;
    } else {
      b += 1;
    }
  }
  if (r > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
};


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

int	main() {
	string S;
	cin >>S;
	int g, p;
	g=p=0;
	for (int i=0; i<S.size(); i++) {
		char c=S.at(i);
		if ('g'==c)
			g++;
		else
			p++;
	}
	cout <<(g-p)/2 <<endl;
	return 0;
};


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  rep(i,N+1){
    if((int)((double)i*1.08) == N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    ll c = 1;
    for ( int i = 0; i < N; i++ ) {
        if ( A[i] == c ) c++;
    }
    if ( c == 1 ) return -1;
    ll ans = N - (c-1);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n,m;
  cin >> n >> m;
  VI s(m);
  VI c(m);
  rep(i,m){
    cin >> s.at(i) >> c.at(i);
  }
  bool a=true;
  rep(i,m){
    if(s.at(i)==1 && c.at(i)==0 && n!=1){
      a=false;
    }
	rep(j,m){
      if(s.at(i)==s.at(j) && c.at(i)!=c.at(j)){
        a=false;
      }
    }
  }      
  VI ans(n);
	rep(j,m){
      ans.at(s.at(j)-1)=c.at(j);
    }
  if(ans.at(0)==0 && n!=1){
    ans.at(0)=1;
  }
  if(a){
    rep(i,n){
      cout << ans.at(i);
      if(i==n-1) cout << endl;
    }
  }
  else if(!a) cout << -1 << endl;
  
  
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=0,j;cin>>N;vector<ll>A(N),X;
  REP(i,N)cin>>A.at(i);sort(ALL(A));
  X.push_back(0);
  REP(i,N){
    if(i!=0&&A.at(0)==1)continue;
    if(upper_bound(ALL(A),A.at(i))-lower_bound(ALL(A),A.at(i))>1)continue;
    for(j=2;j*j<=A.at(i);j++)if(A.at(i)%j==0){
      if(binary_search(ALL(A),j))break;
      if(binary_search(ALL(A),A.at(i)/j))break;
    }
    if(j*j>A.at(i))ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4844
S = input()
count = 0
max_long = 0
for i in range(len(S)):
    if S[i] == "A" or S[i] == "T" or S[i] == "C" or S[i] == "G":
        count += 1
        if max_long < count:
            max_long = count
    else:
        count = 0

print(max_long)


Measured memory_bytes: 2940
a, b, m = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

cost = float('inf')
for i in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    cost = min(cost, a[x] + b[y] - c)

a.sort()
b.sort()
cost = min(cost, a[0] + b[0])
print(cost)

Measured memory_bytes: 18736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>

using namespace std;

long long N, A[100];
long long X[100][100], Y[100][100];

int main()
{
    cin >> N;
    for(int i = 0;i < N;i++)
    {
        cin >> A[i];
        for(int j = 0;j < A[i];j++)
        {
            cin >> X[i][j] >> Y[i][j];
            X[i][j]--;
        }
    }
    int ans = 0;
    for(int i = (1 << N) - 1;i >= 1;i--)
    {
        int cnt = 0;
        int cand[100] = {0};
        for(int j = 0; j < N; j++)
        {
            if((i & (1 << j)))
            {
                cnt++;
                cand[j] = 1;
            }
        }
        bool f = true;
        for(int j = 0;j < N; j++)
        {
            for(int k = 0;k < A[j]; k++)
            {
                int x = X[j][k];
                int y = Y[j][k];
                if(cand[j] == 1 && cand[x] != y)
                {
                    f = false;
                    break;
                }
            }
        }
        if(f)
        {
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
s="abcdefghijklmnopqrstuvwxyz"
l=1
n=int(input())-1
while n>=26**l:
  n-=26**l
  l+=1
li=[]
while n:
  li=[n%26]+li
  n=n//26
r=""
for i in li:
  r+=s[i]
while len(r)!=l:
  r="a"+r
print(r)

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

class Main {
    private static InputReader in;
    private static PrintWriter out;

    static String convert(String input){
        int lgt = input.length();
        char last = input.charAt(lgt-1);
        if(last == 's'){
            return input + "es";
        }else{
            return input + "s";
        }
            
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        in = new InputReader(inputStream);
        OutputStream outputStream = System.out;
        out = new PrintWriter(outputStream);

        String s = in.next();
        System.out.println(convert(s));
            
        }

    // taken from https://codeforces.com/submissions/Petr
    // together with PrintWriter, these input-output (IO) is much faster than the usual Scanner(System.in) and System.out
    // please use these classes to avoid your fast algorithm gets Time Limit Exceeded caused by slow input-output (IO)
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
 
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
 
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
 
        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 36640
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int r,c,i,j,x=0,y=0,z=0;
    int a[100][100];
    scanf("%d %d",&r,&c);
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            x=x+a[i][j];
            printf("%d ",a[i][j]);
            if(j==c-1){
                printf("%d\n",x);
                z=z+x;
                x=0;
            }
        }
    }
    for(j=0;j<c;j++){
        for(i=0;i<r;i++){
            y=y+a[i][j];
                        }
        printf("%d ",y);
        y=0;
    }
    printf("%d\n",z);
    return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  cin >> n;
  vpll an;
  MAP mp[111];
  FOR(i, 1, n + 1) FOR(j, i + 1, n + 1) mp[i][j]++;
  n % 2 ? tmp = n : tmp = n + 1;
  FOR(i, 1, n + 1) {
    if (i >= tmp - i) break;
    mp[tmp - i][i]--;
    mp[i][tmp - i]--;
  }
  FOR(i, 1, n + 1) {
    FOR(j, i + 1, n + 1) {
      if (mp[i][j]) an.pb(make_pair(i, j));
    }
  }
  cout << an.size() << endl;
  rep(i, an.size()) cout << an[i].first << " " << an[i].second << endl;


  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pair<int, int>, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, A[3];
    cin >> N >> A[0] >> A[1] >> A[2];
    vector<int> d(N + 1);
    char c[4] = "ABC";
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < 3; ++j) {
            if (s[0] == c[j] || s[1] == c[j])
                d[i] |= 1 << j;
        }
    }
    d[N] = 7;

    vector<int> ans(N);
    for (int i = 0; i < N; ++i) {
        bool isok = false;
        int tmp = d[i] & d[i + 1];
        for (int j = 0; j < 3; ++j) {
            if ((tmp & (1 << j))) {
                for (int k = 0; k < 3; ++k) {
                    if ((d[i] ^ (1 << j)) & (1 << k)) {
                        if (A[k] > 0) {
                            isok = true;
                            A[k]--;
                            ans[i] = (1 << j);
                            A[j]++;
                            break;
                        } else if (A[j] > 0) {
                            isok = true;
                            A[j]--;
                            ans[i] = (1 << k);
                            A[k]++;
                            break;
                        }
                    }
                }
                if (isok)
                    break;
            }
        }

        if (!isok) {
            cout << "No" << '\n';
            return 0;
        }
    }

    cout << "Yes" << '\n';
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (ans[i] & (1 << j)) {
                cout << c[j] << '\n';
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int x,n;cin>>x>>n;
    v p(n);in(p,n);
    v vst(102,0);
    f(i,n)vst[p[i]]=1;
    int j=-1;
    f(i,102)
    {
        if(!vst[i])
        {
            if(j==-1 || abs(j-x) > abs(i-x))
                j=i;
        }
    }
    cout<<j<<endl;
    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, T):
    return B * (T//A)


def main():
    A, B, T = read_int_n()
    print(slv(A, B, T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6340
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
typedef long long ll;
int main()
{
    ll a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a*b<c)
    {
        printf("%lld\n",a*b);
    }
    else
    {
        printf("%lld\n",c);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s="ACL";
  int k;
  cin>>k;
  string s1;
 if(k==1){
     cout<<"ACL";
 }
 else if(k==2){
     cout<<"ACLACL";
 }
 else if(k==3){
     cout<<"ACLACLACL";
 }
 else if(k==4){
     cout<<"ACLACLACLACL";
 }
 else if(k==5){
     cout<<"ACLACLACLACLACL";
 }
  return 0;
}

Measured memory_bytes: 3592
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = list(map(int, input()))
    res = 0
    for i in n:
        res += i
        res %= 9
    if res == 0:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 78292
// D - Coloring Edges on Tree

// 再帰を用いる

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

#define LEN 100001

typedef struct _Node {
    vector<int> connected_node_indeces;
    int parent_node_index = 0;
    unordered_set<int> used_colors;
} Node;

typedef struct _Edge {
    int color;
} Edge;

int a[LEN];
int b[LEN];
Node nodes[LEN];
map<pair<int, int>, Edge> edges;
int num_colors = 0;

// ノードの接続をセット
void set_connection (int idx_a, int idx_b) {
    nodes[idx_a].connected_node_indeces.emplace_back(idx_b);
    nodes[idx_b].connected_node_indeces.emplace_back(idx_a);
}

// 辺の色を取得
int get_edge_color(int idx_a, int idx_b) {
    if (idx_a > idx_b) swap(idx_a, idx_b);
    return edges[make_pair(idx_a, idx_b)].color;
}

// 辺の色をセット
void set_edge_color(int idx_a, int idx_b, int color) {
    if (idx_a > idx_b) swap(idx_a, idx_b);
    edges[make_pair(idx_a, idx_b)].color = color;
}

// 再帰的に親をセット
void set_parent (int target_node_idx, int parent_node_idx) {
    //cout << target_node_idx << " " << parent_node_idx << endl; // **** debug ****
    nodes[target_node_idx].parent_node_index = parent_node_idx;
    for (int connected_node_idx : nodes[target_node_idx].connected_node_indeces) {
        if (connected_node_idx == parent_node_idx) continue;
        set_parent(connected_node_idx, target_node_idx);
    }
}

void paint_edge (int target_node_idx, int parent_node_idx) {
    auto& used_colors = nodes[target_node_idx].used_colors;

    // まず親と接続する辺の色をused_colorsに追加
    if (parent_node_idx > 0) {
        used_colors.insert(get_edge_color(parent_node_idx, target_node_idx));
    }

    // 親以外と接続する辺の色を決定
    int color = 1;
    for (int connected_node_idx : nodes[target_node_idx].connected_node_indeces) {
        if (connected_node_idx == parent_node_idx) continue; // 親nodeは除外

        while (used_colors.find(color) != used_colors.end()) {
            color++; // 既に使われている色の場合は次の色へ
        }

        used_colors.insert(color);
        set_edge_color(target_node_idx, connected_node_idx, color);
        paint_edge(connected_node_idx, target_node_idx);

        if (color > num_colors) num_colors = color;

        color++;
    }
}

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

    for (int i=1; i<=N-1; i++) {
        cin >> a[i] >> b[i];
    }

    // まず接続だけを定義する
    for (int i=1; i<=N-1; i++) {
        set_connection(a[i], b[i]);
    }

    // rootを1として親を決定
    set_parent(1, 0);

    // rootから順に色を塗る
    paint_edge(1, 0);

    cout << num_colors << endl;

    for (int i=1; i<=N-1; i++) {
        cout << get_edge_color(a[i], b[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 29696
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int n, m;
map<string, int> mp;
int ans = 0;
/**********************************************/

signed main(){
    cin >> n;
    REP(i, n){
        string s;
        cin >> s;
        mp[s]++;
    } 
    cin >> m;
    REP(i, m){
        string t;
        cin >> t;
        mp[t]--;
    }

    for(auto x: mp){
        ans = max(x.second, ans);
    }

    cout << ans << endl;

    

}


Measured memory_bytes: 256
from numpy import*
h,*s=open(0)
h,w=int64(h.split())
r=range
s=int32([[u>'#'for u in t[:w]]for t in s])
a,b,c,d=eval('s.copy(),'*4)
for i in r(1,w):a[:,i],b[:,~i]=-~a[:,i-1]*s[:,i],-~b[:,-i]*s[:,~i]
for i in r(1,h):c[i,:],d[~i,:]=-~c[i-1,:]*s[i,:],-~d[-i,:]*s[~i,:]
print(int((a+b+c+d).max())-3)

Measured memory_bytes: 121952
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline

s=input().rstrip()
n=len(s)
t="keyence"
for i in range(n):
    for j in range(i,n):
        if s[:i]+s[j:]==t:
            print("YES")
            exit()
print("NO")

Measured memory_bytes: 9020
#include <iostream>
#include <string>
using namespace std;
string s,t;
int main(){
    cin>>s>>t;
    
    for (int x=0;x<s.size();x++){
        s=s[s.size()-1]+s;
        s.pop_back();
        
        if (s==t){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}

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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(n);
	get(k);

	get(x);
	get(y);

	if(n <= k){
		cout << n*x << endl;
	}
	else
	{
		cout << k*x + (n-k)*y << endl;
	}


	return 0;
}

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll > 
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;
 
const double EPS = 1e-12;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
 
 
 
 
int main()
{
    fast;
    ll n;
    cin >> n ;
    ld p[n+1];
    for(int i = 1 ; i <= n ; i++ ){
        cin >> p[i];
    }
    ld dp[n+1][n+1] = {};
    dp[0][0] = 1;
    for(int i = 1 ; i <= n ;i++ ){
        for(int heads = 0 ; heads <= i ; heads++ ){
            dp[i][heads] += dp[i-1][heads]*(1-p[i]);
            if(heads){
                //cout <<  dp[i][heads] << " ";
                //cout << dp[i-1][heads-1] << " ";
                /*cout <<  dp[i][heads] << " ";*/
                dp[i][heads] += (dp[i-1][heads-1])*p[i];
            }
           //cout << dp[i][heads] << " ";
        }
        //cout << "\n";
    }

    ld ans = 0 ;
    for(int i = n/2 + n%2 ; i <= n ; i++ ){
        ans += dp[n][i];
    }    
    cout << fixed << setprecision(9) << ans;





















    
    return 0;
    
}

Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x,y;
  cin >> N;
  x = 800;
  x *= N;
  y = 0;
  if (N >= 15) {
    y = N / 15;
    y *= 200;
  }
  cout << x - y << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c=0,d=0,i,j;
    int s=0,t=0;
    scanf("%d%d",&a,&b);
    for(i=0;i<a;i++)
    {
        c=c+s;
        s++;

    }
    for(j=0;j<b;j++)
    {
        d=d+t;
        t++;

    }
    printf("%d\n",c+d);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;
constexpr int64_t mod = 998244353;
int64_t fact[300010];
int64_t mod_fact[300010];

int64_t mod_pow(int64_t x, int64_t n)
{
    int64_t ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

int64_t nCr(int64_t n, int64_t r){
    int64_t res = fact[n];
    res *= mod_fact[r];
    res %= mod;
    res *= mod_fact[n - r];
    res %= mod;
    return res;
}

int64_t Fact(int64_t n){
    if(n <= 1){
        return 1;
    }
    if(fact[n] > 0){
        return fact[n];
    }
    return fact[n] = (Fact(n - 1) * n) % mod;
}

int main(){
    int64_t N, A, B, K;
    cin >> N >> A >> B >> K;

    for(int i = 0; i <= N; ++i){
        fact[i] = Fact(i);
        mod_fact[i] = mod_pow(fact[i], mod - 2);
    }

    int64_t ans = 0;
    for(int64_t i = 0; i <= min(N, K / A); ++i){
        int64_t po = K - i * A;
        if(po % B == 0 && po / B <= N){
            ans += (nCr(N, i) * nCr(N, po / B)) % mod;
            ans %= mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(void){
	int n,m,l,i,j,k;
	int a[100][100],b[100][100];
	long int c[100][100];
	
	scanf("%d %d %d",&n,&m,&l);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j) printf(" ");
			printf("%ld",c[i][j]);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 760