akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	string O, E;
	int a, b, i;
	cin >> O >> E;
	a = O.length();
	b = E.length();
	if (a > b) {
		for (i = 0; i < a - 1; i++)
			cout << O[i] << E[i];
		cout << O[i] << endl;
	}
	else {
		for (int i = 0; i < a; i++)
			cout << O[i] << E[i];
		cout << endl;
}
	return 0;
}

Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Set  as S
import qualified Data.IntMap.Strict as IM
import Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las


large = 100000

solve :: [Int] -> [Int] -> [(Int, Int, Int)] -> Int
solve as bs waribikiList = 
    let
        minA = minimum as
        minB = minimum bs
        currentMin = minA + minB
        aMap = IM.fromList $ zip [1..] as
        bMap = IM.fromList $ zip [1..] bs
        getA x = IM.findWithDefault large x aMap
        getB y = IM.findWithDefault large y bMap
        go minim (x, y, c) = min minim $ (getA x + getB y - c)
    in
    foldl' go currentMin waribikiList

main = do
    (a, b, m) <- readTuple3
    as <- readInts
    bs <- readInts
    waribikiList <- replicateM m (readTuple3)
    print $ solve as bs waribikiList




Measured memory_bytes: 90492
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

string ws;
int bd[3][3], wk;

	while(!cin.eof()){
		getline(cin,ws);
		if(cin.eof()) break;
		rep(i,9){
			int zi = i/3; int zz = i%3 ;int sp;
			if(ws[i] == 's') sp=0;
			if(ws[i] == 'o') sp=100;
			if(ws[i] == 'x') sp=1;
			
			bd[zi][zz] = sp;
		}
//		rep(i,3) rep(j,3) { cout << bd[i][j] << "-";if(j>1) cout <<endl; }
		int ans = 0;
		rep(i,3) {
			wk = bd[i][0] + bd[i][1] + bd[i][2];
				if(wk >= 300 || wk % 100 >= 3) ans = bd[i][0];
		}
		if(ans==0){ 
			rep(i,3){
				wk = bd[0][i] + bd[1][i] + bd[2][i];
				if(wk >= 300 || wk % 100 >= 3) ans = bd[0][i];
			}
		}
		if(ans==0){ 
			if(bd[0][0]==bd[1][1] && bd[1][1]==bd[2][2] ||
			   bd[0][2]==bd[1][1] && bd[1][1]==bd[2][0]){
					ans = bd[1][1]; 
			}
		}
		string z = ( ans==100? "o": ans==1? "x" : "d"); 
		cout << z << endl;
	}		
	return 0;
	
}

Measured memory_bytes: 1176
using System;

// AtCoder Educational DP -B Frog


public class Program{

	public static void Main(){
	
		var inp = Console.ReadLine().Split(' ');
		var len = long.Parse(inp[0]);
		var cap = long.Parse(inp[1]);
		

		var dp = new long[len];
		for(long i = 1; i < len; i++) dp[i] = 9223372036854775807;
		dp[0] = 0;
		
		var stage = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
		
		for(long i = 0; i < len; i++){
			
			for(long k = 1; k <= cap && i+k < len; k++){
			
				dp[i+k] = Math.Min(dp[i+k], dp[i] + Math.Abs(stage[i] - stage[i+k]));
			
			}
			
		}
		
		Console.WriteLine(dp[len-1]);
		
	
	
	}
	




}

Measured memory_bytes: 19424
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long int k,n,answ=1000000000000000;
 cin>>k>>n;
 int a[n];
 int i;
 for(i=0;i<n;i++)
 cin>>a[i];
 int x,y,z;
 for(i=0;i<n;i++)
 {
 x=a[i];
 y=a[(i+1)%n];
 z=a[(i-1+n)%n];
 long long int ans=0;
 if(y<x)
 {
 	y=y+k;
 	if(x<z)
 	{
 	 x=x+k;

	}
		 ans=min(k-(y-x),k-(x-z));	
 }
 else
 {
 	
 	if(x<z)
 	{
 	 x=x+k;
	 //ans=min(k-(y-x),k-(x-z));	
	}
		 ans=min(k-(y-x),k-(x-z));	
 }
 
 answ=min(ans,answ);
}
cout<<answ<<endl; 
 return 0;
}


Measured memory_bytes: 1024
function Main(input) {

    tmp = input.split(" ");
    d = parseInt(tmp[0], 10);
    t = parseInt(tmp[1], 10);
    s = parseInt(tmp[2], 10);
    m = 0;

    m = d / s;

    if (m <= t) {
        result = 'Yes';
    } else{
        result = 'No';
    }

    console.log(result);


}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29684
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <utility>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000007;
//ll mod = 998244353;

ll ord(ll n) {
	ll ans = 0;
	while (n % 2 == 0) {
		n /= 2;
		ans++;
	}
	return ans;
}

vector<ll> solve(ll n, ll a, ll b) {
	ll k = (1 << n);
	vector<ll> ans(k);
	if (n == 0) {
		ans[0] = 0;
		return ans;
	}
	if (n == 1) {
		ans[0] = a;
		ans[1] = b;
		return ans;
	}
	b ^= a;
	if ((k / 2) & b) {
		vector<ll> x = solve(n - 1, 0, 1);
		vector<ll> y = solve(n - 1, 1, b - k / 2);
		for (int i = 0; i < k / 2; i++) {
			ans[i] = x[i];
			ans[i + k / 2] = y[i] + k / 2;
		}
	}
	else {
		vector<ll> x = solve(n - 1, 0, b);
		vector<ll> y = solve(n - 1, x[k / 2 - 2], b);
		for (int i = 0; i < k / 2 - 1; i++) {
			ans[i] = x[i];
		}
		for (int i = 0; i < k / 2; i++) {
			ans[i + k / 2 - 1] = y[i] + k / 2;
		}
		ans[k - 1] = x[k / 2 - 1];
	}
	for (int i = 0; i < k; i++) {
		ans[i] = (ans[i] ^ a);
	}
	return ans;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		if (((1 << i)&a) != ((1 << i)&b)) {
			cnt++;
		}
	}
	if (cnt % 2 == 0) {
		cout << "NO" << endl;
		return 0;
	}
	vector<ll> ans = solve(n, a, b);
	cout << "YES" << endl;
	for (int i = 0; i < (1 << n); i++) {
		cout << ans[i] << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 3320
#include "bits/stdc++.h"
using namespace std;

const int N = 55;
vector< pair<int, int> > conn[N];
bool seen[N];


void dfs(int u, int e) {
    seen[u] = true;
    for (auto it : conn[u]) {
        if (it.second == e) continue;
        if (seen[it.first]) continue;
        dfs(it.first, e);
    }
}


int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        conn[a].emplace_back(b, i);
        conn[b].emplace_back(a, i);
    }

    int res = 0;
    for (int i = 0; i < m; ++i) {
        memset(seen, 0, sizeof seen);

        int comp = 0;
        for (int u = 1; u <= n; ++u) {
            if (seen[u] == false) {
                comp++;
                dfs(u, i);
            }
        }
        if (comp > 1) res++;
    }

    printf("%d\n", res);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int main(void)
{
  // char year[5], month[3], date[3];
  int yeari, monthi, datei;
  scanf("%d/%d/%d", &yeari, &monthi, &datei);
  // 2019年以降で平成になるのは 4 / 30 まで
  if (yeari == 2019 && monthi <= 4) {
    cout << "Heisei" << endl;
    return 0;
  }
  cout << "TBD" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

ll n,k;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	cout<<min(n%k,k-(n%k))<<'\n';
	return 0;
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<char>>;

int main(){
  int H,W,K;cin >> H >> W >> K;
  Graph c(100,vector<char>(100));

  rep(i,H){
    rep(j,W){
      cin >> c[i][j];
    }
  }
  int last=0;

  for(int bit1=0;bit1<(1<<H);bit1++){
    for(int bit2=0;bit2<(1<<W);bit2++){

      vector<int> I;
      vector<int> J;
      for(int i=0;i<H;i++){
        if(!(bit1 & (1<<i))){
          I.PB(i);
        }
      }

      for(int i=0;i<W;i++){
        if(!(bit2 & (1<<i))){
          J.PB(i);
        }
      }

      int count=0;
      for(int i=0;i<I.size();i++){
        for(int j=0;j<J.size();j++){
          if(c[I[i]][J[j]]=='#'){
            count++;
          }
        }
      }

      if(count==K) last++;
    }
  }

  cout << last;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ARRAY_LEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
using namespace std;
int main(void){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = n + 1;
  int p;
  std::vector<int> w {0};
  std::vector<int> e {0};
  REP(i,n){
    if(s[i] == 'W'){
      w.push_back(w[i] + 1);
      e.push_back(e[i]);
    }else{
      w.push_back(w[i]);
      e.push_back(e[i] + 1);
    }

  }
  w.push_back(w[n]);
  e.push_back(e[n]);

  FOR(i,1,n+1){
    p = w[i-1] + e[n+1] - e[i];
    ans = min(ans,p);
  }

  cout << ans << endl;

}

Measured memory_bytes: 3960
// AOJ DLS_1_A: Disjoint Set: Union Find Tree
// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/1/DSL_1_A

#include <iostream>
#include <algorithm>
#include <vector>
bool debug = false;

class DisjointSet {
    std::vector<int> rank, parent;
  public:
    
    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size);
        parent.resize(size);
        for (int i=0; i<size; i++) makeSet(i);
    }

    void makeSet(int node) {
        parent[node] = node;
        rank[node] = 0;
    }

    bool isSame(int first_node, int second_node) {
        return findSet(first_node) == findSet(second_node);
    }

    void unite(int first_node, int second_node) {
        link(findSet(first_node), findSet(second_node));
    }

    void link(int first_node, int second_node) {
        if (rank[first_node] < rank[second_node]) {
            parent[second_node] = first_node;
        } else /* if (rank[first_node] >= rank[second_node]) */ {
            parent[first_node] = second_node;
            if (rank[first_node] == rank[second_node]) {
                rank[first_node]++;
            }
        }
    }

    int findSet(int node) {
        if (parent[node] != node) {
            parent[node] = findSet(parent[node]);
        }
        return parent[node];
    }
};

int main() {
    int total_node_num; std::cin >> total_node_num;
    int total_query_num; std::cin >> total_query_num;

    DisjointSet ds = DisjointSet(total_node_num);
    for (int i=0; i<total_query_num; i++) {
        int query, first_target, second_target;
        std::cin >> query >> first_target >> second_target;
        if (query == 0) {
            ds.unite(first_target, second_target);
        } else if (query == 1) {
            bool flag = ds.isSame(first_target, second_target);
            std::cout << (flag ? 1 : 0) << "\n";
        }
    }
    return 0;
}


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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int a[n], b[m];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=0; i<m; i++) cin >> b[i];
  sort(a, a+n);
  sort(b, b+m);
  if(min(b[0], y)>max(a[n-1], x)) cout << "No War" << endl;
  else cout << "War" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<time.h>
#include<string.h>
#include<cstring>
#include<string>
#define ll long long
using namespace std;
const int maxn=1e5+10;
int n,m;
ll a[maxn],b[maxn];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%lld",&b[i]);
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]>=b[i]){
			ans+=b[i];
		}
		else if((a[i]+a[i+1])>=b[i]&&a[i]<b[i]){
			ans+=b[i];
			a[i+1]=a[i+1]-(b[i]-a[i]);
			a[i]=0;
		}
		else if((a[i]+a[i+1])<b[i]){
			ans+=a[i]+a[i+1];
			a[i]=0;
			a[i+1]=0;
		}
	}
//	for(int j=1;j<=n+1;j++){
//		cout<<a[j]<<" ";
//	}
//	cout<<endl;
//	for(int j=1;j<=n;j++){
//		cout<<b[j]<<" ";
//	}
	printf("%lld\n",ans);
	return 0;
}



/*

5
1 2 3 4 5 6
7 7 7 7 7
27

*/

Measured memory_bytes: 1792
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut scan = Scanner::new(cin);
    let mut g = vec![vec![];4];
    for _ in 0..3 {
        let a = scan.read::<i32>()-1;
        let b = scan.read::<i32>()-1;
        g[uz(a)].push(b);
        g[uz(b)].push(a);
    }
    let mut odd = 0;
    for i in 0..4 {
        if g[i].len() % 2 != 0 {odd+=1}
    }
    println!("{}", if odd == 2 || odd == 0 { "YES" } else {"NO"});
}

// region template
fn uz(i: i32) -> usize {i as usize}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read_opt<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_opt().unwrap()
    }
}
// endregion


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

string multiply(string num1, string num2) 
{ 
    int len1 = num1.size(); 
    int len2 = num2.size(); 
    if (len1 == 0 || len2 == 0) 
    return "0"; 
  
    // will keep the result number in vector 
    // in reverse order 
    vector<int> result(len1 + len2, 0); 
  
    // Below two indexes are used to find positions 
    // in result.  
    int i_n1 = 0;  
    int i_n2 = 0;  
      
    // Go from right to left in num1 
    for (int i=len1-1; i>=0; i--) 
    { 
        int carry = 0; 
        int n1 = num1[i] - '0'; 
  
        // To shift position to left after every 
        // multiplication of a digit in num2 
        i_n2 = 0;  
          
        // Go from right to left in num2              
        for (int j=len2-1; j>=0; j--) 
        { 
            // Take current digit of second number 
            int n2 = num2[j] - '0'; 
  
            // Multiply with current digit of first number 
            // and add result to previously stored result 
            // at current position.  
            int sum = n1*n2 + result[i_n1 + i_n2] + carry; 
  
            // Carry for next iteration 
            carry = sum/10; 
  
            // Store result 
            result[i_n1 + i_n2] = sum % 10; 
  
            i_n2++; 
        } 
  
        // store carry in next cell 
        if (carry > 0) 
            result[i_n1 + i_n2] += carry; 
  
        // To shift position to left after every 
        // multiplication of a digit in num1. 
        i_n1++; 
    } 
  
    // ignore '0's from the right 
    int i = result.size() - 1; 
    while (i>=0 && result[i] == 0) 
    i--; 
  
    // If all were '0's - means either both or 
    // one of num1 or num2 were '0' 
    if (i == -1) 
    return "0"; 
  
    // generate the result string 
    string s = ""; 
      
    while (i >= 0) 
        s += std::to_string(result[i--]); 
  
    return s; 
} 


void solve(){
    string a;
    cin>>a;
    string s;
    cin>>s;
    string neww = "abc";
    neww[0] =s[0],neww[1] =s[2],neww[2] =s[3];
    
    
    string soln = multiply(a,neww);
    if(soln.size()<3){
        cout<<"0";
    }
    else{
        for (int i = 0; i < soln.size()-2; i++)
        {
            cout<<soln[i];
        }
        
    }
    

    return;

}

int main(){
   int t;
   t=1;
    while(t--){
        solve();
    }

}

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

int main(){
	int turn, scrt, scrh;
	string st, sh;
	scrt = scrh = 0;
	cin >> turn;
	for(int i = 0; i < turn; i++){
		cin >> st >> sh;
		if(st > sh){
			scrt += 3;
		}
		else if(st < sh){
			scrh += 3;
		}
		else if(st == sh){
			scrt++;
			scrh++;
		}
	}
	cout << scrt << " " << scrh << endl;
	return 0;
}


Measured memory_bytes: 3140
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int N;
vector<ll> A(3010);
ll memo[3010][3010];
ll solve(int left, int right){
  if(memo[left][right] != INFL) return memo[left][right];
  bool turn = (N + left + right) % 2;
  if(turn){
    if(right == left) return A[left];
    return memo[left][right] = max(solve(left+1, right) + A[left], solve(left, right-1) + A[right]);
  }else{
    if(right == left) return -A[left];
    return memo[left][right] = min(solve(left+1, right) - A[left], solve(left, right-1) - A[right]);
  }
}

int main(void){
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < 3010; i++){
    for(int j = 0; j < 3010; j++){
      memo[i][j] = INFL;
    }
  }
  cout << solve(0, N-1) << endl;
}


Measured memory_bytes: 71168
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	map<string, vector<int>> m;
	string s; int p;
	while (cin >> s >> p) {
		m[s].pb(p);
	}

	for (auto a : m) {
		string str = a.first;
		VI vec = a.second;
		sort(all(vec));

		Cout(str);
		rep(i, sz(vec))cout << vec[i] << (i == sz(vec) - 1 ? "\n" : " ");
	}
}


Measured memory_bytes: 3048
#include<cstdio>
using namespace std;
int main()
{
	int n;scanf("%d",&n);
	if(n<=111) printf("111\n");
	else if(n<=222) printf("222\n");
	else if(n<=333) printf("333\n");
	else if(n<=444) printf("444\n");
	else if(n<=555) printf("555\n");
	else if(n<=666) printf("666\n");
	else if(n<=777) printf("777\n");
	else if(n<=888) printf("888\n");
	else printf("999\n");
	return 0;
}

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

int main(){
	string N;
  cin>>N;
  int X=0;
  int Y=0;
  for(int i=0;i<N.size();i++){
    X+=N.at(i)-48;
    Y+=(N.at(N.size()-i-1)-48)*pow(10,i);
  }
  
  if(Y%X==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

typedef long long ll;
#define MAX_N (101)
const ll MOD = (ll)1e9+7;

int main() {
	int a[5], k;
    int ma=0, mn=1000;
    for(int i=0; i<5; i++) {
        cin >> a[i];
        ma = max(ma, a[i]);
        mn = min(mn, a[i]);
    }
    cin >> k;

    if(ma-mn > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = (int)1e9 + 7;
const int N = 2005;
int dp[N][N];
int a[N];
int b[N];

void add(int &a, int b){  
  a += b;
  if(a >= MOD) a -= MOD;
  else if(a < 0) a += MOD;
}

int main(){
  fastIO;
  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; i ++ )
    cin >> a[i];
  for(int i = 1; i <= m ; i ++ )
    cin >> b[i];
  for(int i = 0 ; i < N ; i ++ ){
    dp[0][i] = 1;
    dp[i][0] = 1;
  }
  for(int i = 1; i <= n; i ++ ){
    for(int j = 1; j <= m ; j ++ ){
      add(dp[i][j],dp[i-1][j]);
      add(dp[i][j],dp[i][j-1]);
      add(dp[i][j],-dp[i-1][j-1]);
      if(a[i]==b[j]){
        add(dp[i][j],dp[i-1][j-1]);
      }
    }
  }
  cout << dp[n][m];
  return 0; 
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  switch(n%10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9: 
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8: 
      cout << "pon" << endl;
      break;
    case 3: cout << "bon" << endl;
  }
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> ma;
    ll MOD = pow(10, 9) + 7;
    rep(i, N) {
        cin >> A[i];
        ma[A[i]] += 1;
    }

    if (N % 2 == 0) {
        ll cnt = 0;
        bool judge = true;
        for (auto p : ma) {
            cnt++;
            if (p.second != 2)
                judge = false;
        }

        if (judge) {
            cout << modpow(2, cnt, MOD) << endl;
        } else
            cout << 0 << endl;
    } else {
        ll cnt1 = 0;
        bool judge = true;
        for (auto p : ma) {
            cnt1++;
            if (p.first == 0 && p.second != 1)
                judge = false;
            else if (p.first != 0 && p.second != 2)
                judge = false;
        }

        if (judge)
            cout << modpow(2, cnt1 - 1, MOD) << endl;
        else
            cout << 0 << endl;
    }
}

Measured memory_bytes: 3584
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    long long int a,b,x;
    int flag=0;
    cin >> x;

    for(int i=-120;i<121;i++){
        if(flag) break;
        for(int j=-120;j<121;j++){
            if(x == pow(i,5.0) - pow(j,5.0)){
                cout << i << " " << j << endl;
                flag = 1;
                break;
            }    
        }
    }
    return 0;

}

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

int main() {
  int h, w; cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) cin >> s[i];

  auto f = [&](int i, int j) {
    int res = 0;
    for (int dx = -1; dx <= 1; dx++) {
      for (int dy = -1; dy <= 1; dy++) {
        if (dx == 0 && dy == 0) continue;
        int y = i + dy;
        int x = j + dx;
        if (y < 0 || y >= h || x < 0 || x >= w) continue;
        if (s[y][x] == '#') res++;
      }
    }
    return res;
  };

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') cout << f(i, j);
      else cout << '#';
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#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 ld long double
#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);
    string a,b,c; cin>>a>>b>>c;
    cout<<a[0]<<b[0]<<c[0]<<endl;
    return 0;
}


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

int main() {
	int N, D;
	int X[11][11] = {};
	cin >> N >> D;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}
	int sum = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			double x = 0;
			for (int k = 0; k < D; k++) {
				x += pow(X[i][k]-X[j][k], 2);
			}
			x = sqrt(x);
			if (floor(x) == ceil(x)) {
				sum++;
			}
		}
	}
	cout << sum << endl;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private long fac[];
    private long finv[];
    private long inv[];
    private static int MAX_LEN = 510000;
    private static int MOD = 1000000007;
    void COMinit() {
        this.fac = new long[MAX_LEN];
        this.finv = new long[MAX_LEN];
        this.inv = new long[MAX_LEN];
        this.fac[0] = this.fac[1] = 1;
        this.finv[0] = this.finv[1] = 1;
        this.inv[1] = 1;
        for (int i = 2; i < MAX_LEN; i++) {
            fac[i] = fac[i-1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i-1] * inv[i] % MOD;
        }
    }
    long COM(int n, int k) {
        if (n < k) {
            return 0;
        };
        if (n <0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k]%MOD)%MOD;
    }
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        this.COMinit();
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int A = scan.nextInt();
        int B = scan.nextInt();
        long answer = 0;
        for (int i = B + 1; i <= W; i++) {
            long temp = this.COM(H-A-1+i-1, i-1);
            temp *= this.COM(A-1+W-i,A-1);
            answer += temp;
            answer %= MOD;
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 36308
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define display(v) for (auto x : v) cout << x << ", "
#define dbg(x) cout << (#x) << " = " << (x) << "\n"
#define dbgp(x) cout << (#x) << " = {" << (x.first) << ", " << (x.second) << "}\n";
#define print(x) cout << (#x) << " = [ ";display(x); cout << "]\n"
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int len = 1e5 + 10;
const ll mod = 1e9 + 7;
ll ans = 1;
vector <int> adj[len];
ll deg[len];

void dfs (bool visited[], int v, bool flag, int k)
{
	visited[v] = 1;
	int temp = k;
	if (flag)
	{
		for (auto x : adj[v])
		{
			deg[x] = --temp;
			dfs(visited, x, false, k);
		}
	}
	else
	{
		int temp = k - 2;
		for (auto x : adj[v])
		{
			if (!visited[x])
			{
				deg[x] = temp--;
				dfs(visited, x, flag, k);
			}
		}
	}
}
int main()
{
	fastio;

	fill(deg, deg + len, 0);
	ll n, k;
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	bool visited[n + 1];
	fill(visited, visited + n + 1, 0);
	dfs(visited, 1, true, k);
	deg[1] = k;
	for (int i = 1; i <= n; i++)
	{
		//cout << deg[i] << " ";
		if (deg[i] <= 0)
		{
			cout << 0;
			return 0;
		}
		ans = (ans * deg[i]) % mod;
	}
	//cout << endl;
	cout << ans;
	return 0;
}


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

int main(){
	string sa,sb,sc;
	cin>>sa>>sb>>sc;
	
	char v=sa[0];
	sa.erase(sa.begin());
	
	int l=sa.length()+sb.length()+sc.length();
	//cout<<l<<" "<<sa<<endl;
	
	for(int i=0;i<l;i++){
		if(v=='a'){
			if(sa.length()==0){
				cout<<"A";
				return 0;
			}
			else{
				v=sa[0];
				sa.erase(sa.begin());
			}
			continue;
		}
		else if(v=='b'){
			if(sb.length()==0){
				cout<<"B";
				return 0;
			}
			else{
				v=sb[0];
				sb.erase(sb.begin());
			}
			continue;
		}
		else if(v=='c'){
			if(sc.length()==0){
				cout<<"C";
				return 0;
			}
			else{
				v=sc[0];
				sc.erase(sc.begin());
			}
			continue;
		}
	}
	
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l+r)/2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6

#define T double
typedef complex<T> pt;
#define x real()
#define y imag()
T dot(pt v, pt w) {return (conj(v)*w).x;}
T cross(pt v, pt w) {return (conj(v)*w).y;}
T orient(pt a, pt b, pt c) {return cross(b-a,c-a);}
T dist(pt a, pt b) {return abs(a-b);}

int main(){
	int n, k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int b[n] = {};
	for(int i=1;i<n;i++) b[i] = MOD;
	for(int i=1;i<n;i++){
		for(int j=max(0, i-k);j<i;j++){
			b[i] = min(b[i], b[j] + abs(a[j]-a[i]));
		}
	}
	cout<<b[n-1]<<endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,m; cin >> n >> m;
        int grid[n+1][m+1];
        memset(grid,0,sizeof(grid));
        FOR(i,0,n){
            FOR(j,0,m){
                char blockornot; cin >> blockornot;
                if(blockornot == '#') grid[i+1][j+1] = -1;
            }
        }
        if(grid[1][1] == -1 or grid[n][m] == -1){
            cout << 0; return 0;
        }
        FOR(i,1,m+1){
            if(grid[i][1] == -1) break;
            grid[i][1] = 1LL;
        }
        FOR(j,2,n+1){
            if(grid[1][j] == -1) break;
            grid[1][j] = 1LL;
        }
        FOR(i,2,n+1){
            FOR(j,2,m+1){
                if(grid[i][j] == -1) continue;
                if(grid[i-1][j] != -1) grid[i][j] = (grid[i][j] + grid[i-1][j] + mod)%mod;
                if(grid[i][j-1] != -1) grid[i][j] = (grid[i][j] + grid[i][j-1] + mod)%mod;
            }
        }
        if(grid[n][m] == -1)
            cout << 0;
        else cout << grid[n][m];
    }   
}

Measured memory_bytes: 11376
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
ans = [1]*N
for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] == H[B-1]:
        ans[B-1] = 0
        ans[A-1] = 0
    elif H[A-1] > H[B-1]:
        ans[B-1] = 0
    else:
        ans[A-1] = 0
print(sum(ans))

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

const int num=3;

int main() {
	std::vector<int> v;
	v.resize(num);

	for (auto&& x : v) {
		std::cin >> x;
	}

	for (int i = 0; i < v.size(); i++) {
		if (1 == std::count(v.begin(), v.end(), v[i])) {
			std::cout << v[i] << std::endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 764
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    S = readline().strip()

    # 各色について累積和を取る
    R = [0]
    G = [0]
    B = [0]
    for i, s in enumerate(S):
        if s == "R":
            R.append(R[-1] + 1)
            G.append(G[-1])
            B.append(B[-1])
        elif s == "G":
            R.append(R[-1])
            G.append(G[-1] + 1)
            B.append(B[-1])
        else:
            R.append(R[-1])
            G.append(G[-1])
            B.append(B[-1] + 1)

    ans = 0
    for i, s in enumerate(S, start=1):
        if s == "R":
            ans += G[i-1] * (B[-1] - B[i])
            ans += B[i-1] * (G[-1] - G[i])
            for j in range(i):
                if S[j] == "G":
                    if 2*i-j-2 < N and S[2*i-j-2] == "B":
                        ans -= 1
                if 2*i-j-2 < N and S[j] == "B":
                    if S[2*i-j-2] == "G":
                        ans -= 1
        
        elif s == "G":
            ans += R[i-1] * (B[-1] - B[i])
            ans += B[i-1] * (R[-1] - R[i])
            for j in range(i):
                if S[j] == "R":
                    if 2*i-j-2 < N and S[2*i-j-2] == "B":
                        ans -= 1
                if 2*i-j-2 < N and S[j] == "B":
                    if S[2*i-j-2] == "R":
                        ans -= 1

        else:
            ans += G[i-1] * (R[-1] - R[i])
            ans += R[i-1] * (G[-1] - G[i])
            for j in range(i):
                if S[j] == "R":
                    if 2*i-j-2 < N and S[2*i-j-2] == "G":
                        ans -= 1
                if S[j] == "G":
                    if 2*i-j-2 < N and S[2*i-j-2] == "R":
                        ans -= 1
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9400
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;


ll N;
string S;


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

	cin >> S;
	if (S == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;


	return 0;
}


Measured memory_bytes: 3132
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.HashMap
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val n = readInt
  val map = new HashMap[String,Int]
  val b = new ArrayBuffer[String]
  for(i<-1 to n) {
    val s = readLine.split(" ")
    if(s(0)(0)=='i') map(s(1)) = 1
    else if(map.contains(s(1))) b+="yes" else b+= "no"
  }
  println(b.mkString("\n"))
}

Measured memory_bytes: 418228
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int book[maxn];
typedef long long ll;
struct A {
	ll t;
	ll d;
}a[maxn];
ll n, k;
ll ans[maxn];

bool cmp1(A a, A b) {	//大到小排序
	return a.d > b.d;
}
struct cmp2 {	//小顶堆
	bool operator()(A a, A b) {
		return a.d > b.d;
	}
};

priority_queue < A, vector<A>, cmp2> Q;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i].t >> a[i].d;
	}
	sort(a, a + n, cmp1);
	ll x = 0, y = 0;
	for (int i = 0; i < k; i++) {
		Q.push(a[i]);
		x += a[i].d;
		if (book[a[i].t] == 0)y++;
		book[a[i].t]++;
	}
	int pc = 0;
	ans[pc++] = x + y * y;	//记录解
	ll j = k;
	while (!Q.empty()&&j<n) {
		A tot = Q.top();
		//cout << tot.t << " " << tot.d << endl;
		Q.pop();
		if (book[tot.t] <= 1) {
			continue;
		}
		else {
			book[tot.t]--;
			for (j; j < n; j++) {
				if (book[a[j].t] == 0) {	//	加进S
					Q.push(a[j]);
					ans[pc] = ans[pc - 1] - tot.d + a[j].d + 2 * y + 1;
					pc++;
					y++;
					book[a[j].t]++;
					j++;
					break;
				}
			}
		}
	}
	ll sum = -1;
	for (int i = 0; i < pc; i++) {
		sum = max(sum, ans[i]);
	}
	cout << sum << endl;
}

Measured memory_bytes: 4340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k,sum=0,gsum=0,t; cin>>n;
    k=n*(n+1)/2;
    vector<ll> a(n,0),g(n,0);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    t=sum/k;
    rep(i,n){
        g[i]=a[(i+1)%n]-a[i];
        gsum+=g[i];
    }
    if(sum%k!=0 || gsum!=0) cout<<"NO"<<endl;
    else{
        ll cnt=0;
        rep(i,n){
            ll l=(-g[i]+t)/n,r=(-g[i]+t)%n;
            if(l>=0 && l<=t && r==0) cnt++;
        }
        if(cnt==n) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	private static final Integer BLOCK = Integer.valueOf(31);
	static Map<Hex, Integer> move = new HashMap<Hex, Integer>();

	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			int t = in.nextInt();
			int n = in.nextInt();
			if (t == 0 && n == 0) {
				break;
			}
			move.clear();
			for (int i = 0; i < n; i++) {
				move.put(new Hex(in.nextInt(), in.nextInt()), BLOCK);
			}
			setMoved(new Hex(in.nextInt(), in.nextInt()), t);
			System.out.println(move.size() - n);
		}
		in.close();
	}

	static void setMoved(Hex hex, int t) {
		Integer thisT = Integer.valueOf(t);
		if (!move.containsKey(hex)) {
			move.put(hex, t);
		} else {
			if (move.get(hex).compareTo(thisT) < 0) {
				move.put(hex, thisT);
			}
		}
		if (t-- > 0) {
			// System.out.println(hex.x + ":" + hex.y + "=>" + t);
			int x = hex.x;
			int y = hex.y;
			Hex[] hexs = new Hex[] { new Hex(x + 1, y + 1), new Hex(x + 1, y),
					new Hex(x, y - 1), new Hex(x - 1, y - 1),
					new Hex(x - 1, y), new Hex(x, y + 1), };
			for (Hex tonari : hexs) {
				if (!move.containsKey(tonari)
						|| move.get(tonari).intValue() < t) {
					setMoved(tonari, t);
				}
			}
		}
	}
}

class Hex {
	public final int x, y;

	public Hex(int x, int y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Hex other = (Hex) obj;
		if (x != other.x) {
			return false;
		}
		if (y != other.y) {
			return false;
		}
		return true;
	}
}

Measured memory_bytes: 117940
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
cnt_dict = {}
for si in s:
    cnt_dict[si] = 0
for ti in t:
    cnt_dict[ti] = 0
for si in s:
  	cnt_dict[si] += 1
for ti in t:
    cnt_dict[ti] -= 1
print(max(max(cnt_dict.values()), 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
ll N, M;
int t[110000];
int d[110000];
int main(){
   cin >> N;
   REP(i,N) cin >> t[i];

   // 方針：合計値を前から見てって条件を満たさなくなったら操作
   // 奇数・偶数番目を正にした時の捜査回数
   ll odd = 0, even = 0;
   // 奇数番目が正
   ll sum = 0; ll sign = 1;
   REP(i,N){
       sum += t[i];
       if(sum * sign  <= 0){ // 条件を満たしていない。
           odd += abs(sum) + 1; // 符号を変えるための捜査回数
           sum = sign;
       }
       sign *= -1;
   }

   // 偶数番目
   sum = 0; sign = -1;
   REP(i,N){
       sum += t[i];
       if(sum * sign <= 0){ 
           even += abs(sum) + 1;
           sum = sign;
       }
       sign *= -1;
   }



   cout << min(odd,even) << endl;
}

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

int main() {
  int n;
  long long k;
  scanf("%d %lld", &n, &k);
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  
  vector<int> f(n, -1);
  f[0] = 0;
  int now = 0, x = 0, y = 0, z = 0;
  while (true) {
    int nxt = a[now];
    if (f[nxt] != -1) {
      x = f[now] - f[nxt] + 1;
      y = f[nxt];
      z = nxt;
      break;
    }
    else {
      f[nxt] = f[now] + 1;
      now = nxt;
    }
  }

  if (k >= y)
    k = (k - y) % x;
  else
    z = 0;
  for (int i = 0; i < k; i++)
    z = a[z];
  
  printf("%d\n", z + 1);

  return 0;
}

Measured memory_bytes: 4860
class SegTree:
    def __init__(self, N):
        self.N = N
        self._N = 1<<((N-1).bit_length())
        self.node = [10**15]*(2*self._N-1)
        self.node[self._N-1] = 0

    def eval(self,p):
        i = p + self._N-1
        cur = self.node[i]
        while i:
            i = (i-1) // 2
            if cur > self.node[i]:
                cur = self.node[i]
        self.node[p+self._N-1] = cur
        return cur

    def update(self,x,p,q,idx=0,a=0,b=None):
        if not idx:
            x += self.eval(p)
        if x >= 10**15:
            return
        if b is None:
            b = self._N
        if q <= p or b <= p or q <= a:
            return
        elif p <= a and b <= q:
            if x < self.node[idx]:
                self.node[idx] = x
            return
        else:
            self.update(x,p,q,idx*2+1,a,(a+b)//2)
            self.update(x,p,q,idx*2+2,(a+b)//2,b)
            return


n,m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]
edge.sort()
tr = SegTree(n)
for s,t,c in edge:
    tr.update(c,s-1,t)
ans = tr.eval(n-1)
if ans >= 10**15:
    ans = -1
print(ans)


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

int main()
{
	int N,M;
	cin >> N >> M;
	vector<int> a(M);
	vector<int> b(M);
	vector<int> r(N);
	for(int i = 0; i < M; i++) {
		cin >> a[i] >> b [i];
		r[a[i] - 1]++; 
		r[b[i] - 1]++; 
	}
	for(int i = 0; i < N; i++) {
		cout << r[i] << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
#define maxn 200010
LL k,t;
int n,a[maxn],vis[maxn];
int main(){
	int i,nx,s,b,c;
	scanf("%d%lld",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	nx=1;
	while(1){
		vis[nx]=1,nx=a[nx];
		if(vis[nx]){s=nx;break;}
	}
	//printf("s=%d\n",s);
	nx=s;
	for(i=1;i<=n;i++)vis[i]=0;
	while(1){
		vis[nx]=1,nx=a[nx],t++;
		if(vis[nx])break;
	}
	b=0,nx=1;
	while(1){
		if(nx==s)break;
		nx=a[nx],b++;
	}
	c=0;
	if(k<=b){
		nx=1;
		while(1){
			if(k==c)break;
			nx=a[nx],c++;
		}
		printf("%d\n",nx);
		return 0;
	}
	k-=b;k%=t;
	{
		nx=s;
		c=0;
		while(1){
			if(k==c)break;
			nx=a[nx],c++;
		}
		printf("%d\n",nx);
	}
	//printf("b=%d\n",b);
	//printf("t=%lld\n",t);
}

Measured memory_bytes: 4804
A, B, C, D = map(int, input().split())
att_cnt = 0

while(A > 0 and C > 0):
    if att_cnt % 2 == 0:
        C -= B
        att_cnt += 1
    else:
        A -= D
        att_cnt += 1
        
if A <= 0:
    print("No")
if C <= 0:
    print("Yes")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll t1, t2, a1, a2, b1, b2;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	a1 *= t1;
	a2 *= t2;
	b1 *= t1;
	b2 *= t2;
	if(a1+a2 == b1+b2){print("infinity") return 0;}
	if((a1-b1 > 0 && a2-b2 > 0) || (a1-b1 < 0 && a2-b2 < 0)){print(0) return 0;}
	if(a1 > b1){
		a1 -= b1;
		a2 = b2-a2;
	}
	else{
		a1 = b1-a1;
		a2 = a2-b2;
	}
	if(a1 > a2){print(0) return 0;}
	
	ll ans = 1;
	if(a1-a2 < 0){
		ans += 2*(a2/(a2-a1)-1);
		if(a2%(a2-a1) == 0){
			ans--;
		}
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	var cnt [26]uint16
	var str string
	sc := bufio.NewReader(os.Stdin)
	for {
		line, err := sc.ReadString('\n')
		str += line
		if err == io.EOF {
			break
		}
	}
	s := 'a'
	b := 'A'
	for i := 0; i < 26; i++ {
		cnt[i] = uint16(strings.Count(str, string(s)))
		cnt[i] += uint16(strings.Count(str, string(b)))
		fmt.Printf("%s : %d\n", string(s), cnt[i])
		s++
		b++
	}
	return
}



Measured memory_bytes: 1092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<long> q;
    long res = 0;
    for(long i=0; i<N; i++){
        long temp;
        cin >> temp;
        q.push(temp);
    }

    

    for(long i=0; i<M; i++){
        long temp = q.top();
        q.pop();
        q.push(temp/2);
    }

    for(long i=0; i<N; i++){
        long temp = q.top();
        res += temp;
        q.pop();
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1400
import bisect

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ct = 0
for j in B:
    a_max = bisect.bisect_left(A, j)
    c_min = bisect.bisect_right(C, j)
    ct += a_max * (n - c_min)
print(ct)

Measured memory_bytes: 23232