akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int n;
int a[100005];
int cnt[100005][2];
vector<pair<int,int>> z[2];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		cnt[a[i]][i % 2]++;
	}
	for (int t = 0; t < 2; ++t) {
		z[t].push_back({0, 0});
		for (int i = 1; i < 100005; ++i) {
			if (cnt[i][t]) z[t].push_back({cnt[i][t], i});
		}
		sort(z[t].begin(), z[t].end());
	}
	if (z[0].back().second != z[1].back().second) {
		cout << n - z[0].back().first - z[1].back().first << '\n';
	}
	else {
		int mx = max(z[0].back().first + z[1][z[1].size() - 2].first, z[0][z[0].size() - 2].first + z[1].back().first);
		cout << n - mx << '\n';
	}
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string s; cin >> s;
    int N = s.size();
    bool f = true;
    if(s[0] == '0' || s[N - 1] == '1') f = false;



    FOR(i, 0, (N - 1) / 2 + 1) if(s[i] != s[N - 2 - i]) f = false;
    if(!f){
        cout << -1;
        return 0;
    }

    vector<Pii> ans(N - 1);
    int v1 = 2;
    ans[0] = Pii(1, 2);
    FOR(i, 1, N - 1){
        if(s[i] == '1'){
            ans[i] = Pii(v1, i + 2);
            v1 = i + 2;
        }else{
            ans[i] = Pii(v1, i + 2);
        }
    }
    REP(i, N - 1) cout << ans[i].first << " " << ans[i].second << endl;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_10_C
{
    class Program
    {
        static void Main(string[] args)
        {
            List<double> answer = new List<double>();
             while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                string[] str_score = Console.ReadLine().Split(' ');
                List<double> score = new List<double>();
                for (int i = 0; i < n; i++)
                {
                    score.Add(double.Parse(str_score[i]));
                }
                double m = score.Average();
                double α2 = 0;
                double α = 0;
                for (int i = 0; i < n; i++)
                {
                    α2 += (score[i] - m) * (score[i] - m);
                }
                α2 = α2 / n;
                α = Math.Sqrt(α2);
                answer.Add(α);
            }
            for (int i = 0; i < answer.Count; i++)
            {
                Console.WriteLine(answer[i]);
            }
        }
    }
}



Measured memory_bytes: 18300
import java.util.*;

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

		String S = sc.next();
		ArrayList<Integer> ansList = new ArrayList<>();
		ansList.add(0);

		for (int i=1; i<N; i++){
			if (S.charAt(i-1) == 'A' && S.charAt(i) == 'C'){
				ansList.add(ansList.get(i-1) + 1);
			} else{
				ansList.add(ansList.get(i-1));
			}
		}

		for (int q=0; q<Q; q++){
			int l = Integer.parseInt(sc.next());
			int r = Integer.parseInt(sc.next());

			System.out.println(ansList.get(r-1) - ansList.get(l-1));
		}
	}
}

Measured memory_bytes: 64740
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
bool check=false;

int main(void){
    long N;
    cin>>N;
    vector<vector<long>> A(N+1,vector<long>(N));//Nは自分と戦う系ダミー
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin>>A.at(i).at(j);
            A.at(i).at(j)--;
        }
        A.at(i).at(N-1)=N;
    }
    for(int j=0;j<N;j++) A.at(N).at(j)=N;
    
    
    queue<pair<pair<long,long>,long>> que;
    vector<long> waiting(N+1,0);
    for(int i=0;i<N;i++){
        long enemy=A.at(i).at(waiting.at(i));
        //cout<<enemy<<endl;
        long eofe=A.at(enemy).at(waiting.at(enemy));
        if(i<enemy && i==eofe) que.push(make_pair(make_pair(i,enemy),1));
    }
    //cout<<"!"<<A.at(1).at(0)<<endl;
    long ans=0;
    //cout<<que.size()<<endl;
    while(!que.empty()){
        long a=que.front().first.first,b=que.front().first.second,day=que.front().second;
        ans=max(ans,day);
        que.pop();
        waiting.at(a)++;
        waiting.at(b)++;
        
        long enemya=A.at(a).at(waiting.at(a));
        long eofea=A.at(enemya).at(waiting.at(enemya));
        if(a==eofea) que.push(make_pair(make_pair(a,enemya),day+1));
        
        long enemyb=A.at(b).at(waiting.at(b));
        long eofeb=A.at(enemyb).at(waiting.at(enemyb));
        if(b==eofeb) que.push(make_pair(make_pair(b,enemyb),day+1));
    }
    
    bool done=true;
    for(int i=0;i<N;i++) if(waiting.at(i)!=N-1) done=false;
    if(done) cout<<ans<<endl;
    else cout<<-1<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  int min_x = 100;
  int max_x = 1;
  for(int i = 0; i < n; ++i) {
      cin >> x[i];
      min_x = min(min_x, x[i]);
      max_x = max(max_x, x[i]);
  }
  int min_sum = 100 * 100 * 100;
  for(int p = min_x; p <= max_x; ++p) {
      int sum = 0;
      for(vector<int>::iterator it = x.begin(); it != x.end(); ++it) {
        sum += ((*it) - p) * ((*it) - p);
      }
      min_sum = min(min_sum, sum);
  }
  cout << min_sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
bool str[101000];
int a, b, pos;
int main(){
	int x;
	while( scanf("%1d", &x) != EOF )
		str[++pos] = x;
	for( int i = 1; i <= pos; ++i ){
		if( str[i] != i % 2 )
			++a;
		else
			++b;
	}
	printf("%d\n", min(a, b));
	return 0;
}

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

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


Measured memory_bytes: 2140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	vector<int>num_of_100coin;
	vector<int>num_of_500coin;
	vector<int>num_of_1000coin;
	long long a, b;
	while (cin >> a >> b) {
		if (a == 0 && b == 0)break;
		b -= a;
		b /= 100;
		int v = b % 5;
		num_of_100coin.push_back(v);
		b -= v;
		b /= 5;
		if (b % 2 == 1){
			num_of_500coin.push_back(1);
			b -= 1;
		}
		else num_of_500coin.push_back(0);
		num_of_1000coin.push_back(b / 2);
	}
	int g = num_of_100coin.size();
	for (int i = 0; i < g; i++){
		cout << num_of_100coin[i];
		cout << ' ';
		cout << num_of_500coin[i];
		cout << ' ';
		cout << num_of_1000coin[i];
		cout << endl;
	}
	char c;
	cin >> c;
	return 0;
}

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

using namespace std;
using Graph = vector<vector<int>>;
int main(){
int n,flag=1;
string s; cin >> s;

n = s.length();

for (int i = 0; i < n/2; ++i)
{
   if (s[i]!=s[n-1-i])
   {
       flag=0;
       break;

   }
}

if (flag)
{
    for (int i = 0; i < n/4; ++i)
    {
        if (s[i]!=s[n/2-1-i])
        {
           flag=0;
           break;
        }
    }
}


if (flag)
{
    for (int i = (n+3)/2-1; i < n; ++i)
    {
        if (s[i]!=s[n-1-i])
        {
           flag=0;
           break;
        }
    }
}

if (flag)
{
    cout << "Yes";
}
else{
    cout << "No";
}

return 0;
}




Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << ((C - 1) / B + 1 <= (A - 1) / D + 1 ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
const ll N = 2e5 + 5;
vector<ll> V[N];
ll A[N], dp[N];
multiset<ll> ms;
map<ll, ll> has;
void dfs(ll x, ll p) {
	for(auto u : V[x]) {
		if(u == p) continue;
		ms.insert(A[u]);
		auto it = ms.lower_bound(A[u]);
		++it;
		ll val = 0;
		if(it != ms.end()) ms.erase(it), val = *it;
		dp[u] = ms.size();
		dfs(u, x);
		if(val) ms.insert(val);
		if(ms.find(A[u]) != ms.end()) ms.erase(ms.find(A[u]));
	}
	return;
}
int main() {

    localTest();
    ll n;
    sll(n);
    REP(i, 1, n) sll(A[i]);
    REP(i, 1, n - 1) {
    	ll x, y;
    	sll2(x, y);
    	V[x].pb(y);
    	V[y].pb(x);
    }
    ms.insert(A[1]);
    dp[1] = 1;
    dfs(1, 0);
    REP(i, 1, n) printf("%lld\n", dp[i]);
    

    return 0;
}

Measured memory_bytes: 37896
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn is_sq(n: i64) -> bool {
    let mut left = 0;  // left * left <= n
    let mut right = n + 2;
    for _ in 0..100 {
        let mid = (left + right) / 2;
        if mid * mid <= n {
            left = mid;
        } else {
            right = mid;
        }
    }
    left * left == n
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let d: usize = sc.cin();
    let ps: Vec<Vec<i64>> = (0..n).map(|_| {
        (0..d).map(|_| sc.cin()).collect()
    }).collect();
    let mut ans = 0;
    for i in 0..n {
        for j in 0..i {
            let dist = (0..d).map(|k| (ps[i][k] - ps[j][k]) * (ps[i][k] - ps[j][k])).sum();
            if is_sq(dist) {
                ans += 1;
            }
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
# C - Sum of gcd of Tuples (Easy)

import math

K = int(input())
ans = 0

for a in range(1, K + 1):
	for b in range(1, K + 1):
		for c in range(1, K + 1):
			ans += math.gcd(a, math.gcd(b, c))

print(ans)

Measured memory_bytes: 68836
import java.util.*;
import java.math.BigDecimal;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();

        int h = ty - sy;    
        int w = tx - sx;    
 
        String ans = ""; 
 
        for(int i=0; i<h; i++){
            ans += "U";             
        }
        for(int i=0; i<w; i++){
            ans += "R";
        }
        for (int i=0; i<h; i++){
            ans += "D";
        }
        for(int i=0; i<w; i++){
            ans += "L";
        }
      
        ans += "L";
      
        for(int i=0; i<h+1; i++){
            ans += "U";
        }
        for (int i=0; i<w+1; i++){
            ans += "R";
        }
      
      	ans += "DR";	
      
        for (int i=0; i<h+1; i++){
            ans += "D";
        }
        for(int i=0; i<w+1; i++){
            ans += "L";
        }
 
      	ans +="U";	
      
        System.out.println(ans);
 
    }
}

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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

const int inf = 1 << 30;

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

    int n, m;
    cin >> n >> m;
    vt<int> dp(1 << n, inf);
    dp[0] = 0;
    while (m--) {
        int a, b;
        cin >> a >> b;
        int mask = 0;
        while (b--) {
            int x;
            cin >> x;
            mask |= 1 << x - 1;
        }

        for (int i = sz(dp) - 1; i >= 0; i--) {
            int &x = dp[i | mask];
            x = min(x, dp[i] + a);
        }
    }

    cout << (dp.back() == inf ? -1 : dp.back());
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

int n,A,B,pos;
int v[1 << 17];
int ans[1 << 17];
int tmp[1 << 17];

int popcount(int v)
{
	return v ? popcount(v - (v & -v)) + 1 : 0;
}

void solve(int l)
{
	if (l == 0)
		return;
	solve(l - 1);
	for (int i = 0;i < (1 << (l - 1));i++)
	{
		tmp[i << 1] = v[i] | ((i & 1) << (l - 1));
		tmp[i << 1 | 1] = v[i] | ((~i & 1) << (l - 1));
	}
	for (int i = 0;i < (1 << l);i++)
		v[i] = tmp[i];
}

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> A >> B;
	B ^= A;
	if (~popcount(B) & 1)
	{
		cout << "NO" << endl;
		return 0;
	}
	solve(n);
	for (int i = 0;i < (1 << n);i++)
		if (v[i] == B)
		{
			pos = i;
			break;
		}
	for (int i = 0;i < (1 << n);i++)
	{
		if (i < pos)
		{
			ans[i] = v[i];
			continue;
		}
		int t = (i - pos) / 2 + 1;
		if (t & 1)
			ans[(1 << n) - 1 - (t >> 1 << 1) - (~i & 1)] = v[i];
		else
			ans[i - t] = v[i];
	}
	cout << "YES" << endl;
	for (int i = 0;i < (1 << n);i++)
		cout << (ans[i] ^ A) << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
    int A,B,C,K;
    scanf("%d%d%d",&A,&B,&C);
    scanf("%d",&K);
    int i;
    int count = 0;
    for(i=0;A>=B;i++){
        B = B*2;
        count++;
    }
    for(i=0;B>=C;i++){
        C = C*2;
        count++;
    }
    if(count<=K){
        printf("Yes");
    }else{
        printf("No");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1684
use std::io::Read;
use std::cmp::min;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let h: Vec<i64> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut z = h.clone();
    z.push(0);
    z.sort();
    z.dedup();
    let inf = std::i64::MAX / 10;
    let mut dp = vec![vec![inf; z.len()]; m + 1];
    dp[0][0] = 0;
    for &a in h.iter() {
        let x = z.binary_search(&a).unwrap();
        let mut next = vec![vec![inf; z.len()]; m + 1];
        for i in 0..(m + 1) {
            let mut cost = vec![inf; z.len()];
            cost[0] = dp[i][0];
            for j in 1..z.len() {
                cost[j] = min(dp[i][j], cost[j - 1] + z[j] - z[j - 1]);
            }
            let mut local = inf;
            for j in (0..z.len()).rev() {
                local = min(local, dp[i][j]);
                if j == x {
                    next[i][j] = min(next[i][j], local);
                } else if i < m {
                    next[i + 1][j] = min(next[i + 1][j], local);
                }
                if j == x {
                    next[i][j] = min(next[i][j], cost[j]);
                } else if i < m {
                    next[i + 1][j] = min(next[i + 1][j], cost[j]);
                }
            }
        }
        dp = next;
    }
    let mut ans = inf;
    for i in 0..(m + 1) {
        for j in 0..z.len() {
            ans = min(ans, dp[i][j]);
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

int main(){
	char c, ch1, ch2;
	int i, j, n, m;
	string str;
	while(true){
		cin>>n;
		if(n==0) break;
		vector< pair<char, char> > change;
		for(i=0;i<n;i++){
			cin >> ch1 >> ch2;
			change.push_back(pair<char, char>(ch1, ch2));
		}
		cin>>m;
		for(i=0;i<m;i++){
			cin>> c;
			for(j=0;j<change.size();j++){
				if(change[j].first == c){
					c=change[j].second;
					break;
				}
			}
			cout << c;
		}
		cout<< endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,y;
    cin>>x>>y;
    int arr[13]={0,1,3,1,2,1,2,1,1,2,1,1,2};
    if(arr[x]==arr[y])
        cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#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 = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= 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;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

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 long long MOD = 1000000007;
const long long max_cache=1000000;
long long cache_fact[max_cache],cache_inv_fact[max_cache];
long long combination_cached(long long n,long long r){
  ll m=MOD;
  if(n<=0)return 0;
  if(r<0||r>n)return 0;
  if(r==0||r==n)return 1;
  static bool cached=false;
  if(cached==false){
    cached=true;
    cache_inv_fact[1]=1;
    for (long long i = 2; i < max_cache; i++) {
      cache_inv_fact[i]=(m-m/i)*cache_inv_fact[m%i]%m;
    }
    for (long long i = 2; i < max_cache; i++){
      cache_inv_fact[i]=cache_inv_fact[i]*cache_inv_fact[i-1]%m;
    }
    cache_fact[0]=1;
    for (long long i = 1; i < max_cache; i++) {
      cache_fact[i]=cache_fact[i-1]*i%m;
    }
  }
  r=min(r,n-r);
  return cache_fact[n]*cache_inv_fact[r]%m*cache_inv_fact[n-r]%m;
}
void solve(long long N, long long K, std::vector<long long> A){
  sort(A.begin(),A.end());
  ll ans=0;
  REP(N){
    ans=MOD+(ans-A[i]*combination_cached(N-i-1,K-1)%MOD)%MOD;
    ans%=MOD;
    ans=(ans+A[i]*combination_cached(i,K-1)%MOD)%MOD;
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 16640
#include <cstdio>
#include <algorithm>

int v[201];

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

    n*=2;

    for(int i=1; i<=n; i++)
        scanf("%d", &v[i]);

    std::sort(v+1, v+n+1);

    int ans=0;
    for(int i=1; i<=n; i+=2)
        ans+=v[i];

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll max(ll a,ll b){
	return a>b? a:b;
}
ll T;
ll a,b,c;
int main(){
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0){
    	cout<<"Possible\n";
	}
	else cout<<"Impossible\n";
    return 0;
}

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

int main()
{
  int n;
  for(;cin>>n;)
    {
      for(int i=0;i<n;i++)
	{
	  int x,y,b,p;
	  cin>>x>>y>>b>>p;
	  int ans;
	  if(b>4&&p>1)
	    ans=(int((x*b)+(y*p))*0.8);
	  else if(b>4)
	    ans=min((int)(((x*b)+(y*2))*0.8),(x*b)+(y*p));
	  else if(p>1)
	    ans=min((int)(((x*5)+(y*p))*0.8),(x*b)+(y*p));
	  else 
	    ans=min((int)(((x*5)+(y*2))*0.8),(x*b)+(y*p));
	  cout<<ans<<endl;
	}
    }
}

  

Measured memory_bytes: 1160
import java.util.Scanner;

class Main{
  static int partition(int[] a, int p, int r){
    int x = a[r];
    int i = p-1;
    for(int j = p; j < r; j++){
      if(a[j] <= x){
        i++;
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
    int tmp = a[i+1];
    a[i+1] = a[r];
    a[r] = tmp;
    return i+1;
  }

  static void output(int[] a, int q){
    int i;
    for(i = 0; i < q; i++)
      System.out.print(a[i] + " ");
    System.out.print("[" + a[i] + "] ");
    for(i = q + 1; i < a.length - 1; i++)
      System.out.print(a[i] + " ");
    System.out.println(a[i]);

  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int a[] = new int[n];
    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    output(a, partition(a, 0, n-1));
  }
}

Measured memory_bytes: 68100
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int N;
  	cin >> N;
  	int d[N];
  	for(int i=0;i<N;i++) cin >> d[i];

  	int ans = 0;
  	for(int i=0;i<N-1;i++){
  		for(int j=i+1;j<N;j++){
  			ans += d[i]*d[j];
  		}
  	}
  	cout << ans <<endl;
    
  	return 0;
}









Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)
	c := map[int]int{}
	d := 0
	for i := 0; i < n; i++ {
		if a[i] >= 3200 {
			d++
		} else {
			c[a[i]/400]++
		}
	}

	fmt.Fprintln(wr, max(len(c), 1), len(c)+d)

}


Measured memory_bytes: 1780
import java.util.*;
import java.lang.*;
import java.math.*;

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

	void run() {
		for (;;) {
			String buffer = sc.nextLine();
			int size = Integer.valueOf(buffer);
			if (size == 0)
				break;
			boolean[][] map = new boolean[size + 1][size + 1];
			for (int i = 0; i < size; i++) {
				buffer = sc.nextLine();
				for (int j = 0; j < size; j++) {
					map[i + 1][j + 1] = buffer.charAt(j) == '.';
				}
			}
			int[][] sq = new int[size+1][size+1];
			int max = 0;
			for (int i = 1; i < size + 1; i++) {
				for (int j = 1; j < size + 1; j++) {
					if (map[i][j]) {
						if (map[i - 1][j] && map[i - 1][j - 1] && map[i][j - 1]) {
							sq[i][j] = Math.min(Math.min(sq[i - 1][j],sq[i - 1][j - 1] ), sq[i][j - 1])+1;
						} else {
							sq[i][j] = 1;
						}
					}
					if(max < sq[i][j]) max = sq[i][j];
				}
			}
			System.out.println(max);
		}

	}

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

Measured memory_bytes: 15000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, 0, n) cin >> x[i];
    vector<ll> diff_r(n);
    ll ans = 0;
    rep(i, 1, n) {
        ll tmp = (x[i]-x[i-1])*a;
        if(tmp >= b) {
            ans += b;
        }
        else {
            ans += tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char arr[100000];

int main(){
	scanf("%s",&arr);
	
	int fase=1;
	for(int i=0;arr[i]!=0;i++){
		if((i+1)%2!=0){
			if(arr[i]=='R'||arr[i]=='U'||arr[i]=='D'){
			}else{
				fase=0;
				break;
			}
		}else{
			if(arr[i]=='L'||arr[i]=='U'||arr[i]=='D'){
			}else{
				fase=0;
				break;
			}
		}
	}
	if(fase){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, X, Y;
  cin >> N >> X >> Y;
  --X; --Y;
  
  vvi dp(N, vi(N, INF));
  vi counts(N);
  
  for(int i=0; i<N; i++) {
    for(int j=i+1; j<N; j++) {
      int dist;
      if(i+1==j) {
        dist = 1;
      } else {
        dist = min(j - i, abs(X-i) + abs(Y-j) + 1);
      }
      
      counts[dist]++;
    }
  }
  
  rep(i, N - 1) {
    fin(counts[i + 1]);
  }
  
  // for(int i=1; i<=N-1; i++) {
  //   ll sum = 0;
  //   //まず，X，Yを結んだものを考える
  //   int len = N - (Y - X - 1);
  //   sum += max(len - i, 0);
    
  //   //次に，XとYの間の頂点を考える
  //   for(int j=X+1; j<=Y-1; j++) {
  //     int l = j - i;
  //     int r = j + i;
  //     if(l>=1) sum ++;
  //     if(r<=N && r>=Y) sum++;
  //     // sum += max(0, j - i + 1);
  //     // sum += max(0, Y - j - i + 1);
  //   }
    
  //   fin(sum);
  // }
  // //1のぶん
  
}

Measured memory_bytes: 16000
/*B - 0 or 1 Swap*/

#include <bits/stdc++.h>

using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	bool orden = true;
	int tam;
	int pos;

	cin >> tam;

	vector <int> arr(tam);
	vector <int> copy(tam);

	for (int i = 0; i < tam; ++i)
	{
		cin >> arr[i];
	}
	copy = arr;
	sort(copy.begin(), copy.end());

	for (int i = 0; i < tam; ++i)
	{
		pos = arr[i];
		pos--;
		if(arr[i] != i + 1){
			swap(arr[i], arr[pos]);
			break;
		}
	}

	if(arr == copy)
		cout << "YES";
	else
		cout << "NO";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n, k;
	cin >> n >> k;
	int mn = INF;
	for(int i = 1; i <= n; i ++)
	{
		int x, y;
		cin >> x >> y;
		if(y <= k)
			umin(mn, x);
	}
	if(mn == INF)
		cout << "TLE";
	else
	cout << mn;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  while(true){
    bool odd = false;
    for(int i = 0; i < n; i++){
      if(a[i] % 2 == 1){
        odd = true;
      }
    }
    if(odd) break;
    ans++;
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<map>
#include<cstdio>
using namespace std;
typedef long long LL;;
const int MaxN = 1e5 + 5;

map <int, int> cnt;

struct point {
	int x, y, t;
} mapp[MaxN];

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		int x, y, t;
		scanf("%d%d%d", &t, &x, &y);
		mapp[i].x = x, mapp[i].y = y, mapp[i].t = t;
	}
	mapp[0].x = 0, mapp[0].y = 0, mapp[0].t = 0;
	for(int i = 1; i <= n; i++) {
		int s, t;
		s = fabs(mapp[i].x - mapp[i - 1].x) + fabs(mapp[i].y - mapp[i - 1].y);
		t = fabs(mapp[i].t - mapp[i - 1].t);
		if(s > t || s % 2  != t % 2 ) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll s, w;
	cin >> s >> w;

	cout << (w >= s ? "unsafe" : "safe") << endl;

}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    int nn = n;
    int cnt= 0;
    while(n > 0){
        cnt += n%10;
        n /= 10;
    }
    if(nn % cnt == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i, n) for(ll (i)=0;(i)<(n);(i)++)
#define prl(x) cout<<(x)<<endl

int main(void){
  string s,t;map<char,vl> c;
  cin>>s>>t;ll n=s.length(),cur=0;
  rep(i,n)c[s[i]].push_back(i);
  for(char a:t)if(!c[a].size()){prl(-1);return 0;}
  for(char a:t){
    vl& v=c[a];auto it=lower_bound(v.begin(),v.end(),cur%n);
    (cur=cur/n*n+1)+=it==v.end()?*(v.begin())+n:*it;
  }
  prl(cur);return 0;
}


Measured memory_bytes: 4632
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

#define sz(s) (int)(s.size())
#define eb emplace_back

const int N = 2e5 + 5;
const int sZ = (1 << 19);

#define ll long long

void solve() {
	int k, x;
	cin >> k >> x;
	cout << (k * 500 >= x ? "Yes" : "No");
}

int main () {
	cerr << "Ready\n";
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int H, W;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

int bfs(int x, int y, vector<vector<char>> &A){
    queue<Pint> Next;
    Next.push(Pint(x, y));
    vector<vector<int>> dist(H, vector<int> (W, 1000000007));
    dist.at(x).at(y) = 0;
    while(Next.size() != 0){
        Pint p = Next.front();
        Next.pop();
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx.at(i), ny = p.second + dy.at(i);
            if (nx < H && 0 <= nx && ny < W && 0 <= ny && dist.at(nx).at(ny) == 1000000007 && A.at(nx).at(ny) == '.'){
                Next.push(Pint(nx, ny));
                dist.at(nx).at(ny) = dist.at(p.first).at(p.second) + 1;
            }
        }
    }
    int value = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (dist.at(i).at(j) != 1000000007){
                value = max(value, dist.at(i).at(j));
            }
        }
    }
    return value;
}

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

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (A.at(i).at(j) == '.'){
                ans = max(ans, bfs(i, j, A));
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int x, a, b, v = 0;
	cin >> x >> a >> b;
	x -= a;
	v = x - (b * (x / b));
	cout << v;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
	
	string s;
	cin >> s;
	for (int i = 0; i < 4; ++i)
		cout << s[i];
	cout << " ";
	for (int i = 4; i < 12; ++i)
		cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

int L[110000];
int R[110000];

int main() {
    int N, M;
    cin >> N >> M;
    rep(i, M) cin >> L[i] >> R[i];

    int lmax = 0;
    int rmin = 110000;
    rep(i, M) {
        if (L[i] > lmax) lmax = L[i];
        if (R[i] < rmin) rmin = R[i];
    }

    if (rmin-lmax<0) {
        cout << 0 << endl;
    } else {
        cout << (rmin-lmax+1) << endl;
    }

    return 0;

    
}

Measured memory_bytes: 1024
array = readlines.map(&:chomp)

item = array[0].chomp.split(" ").map(&:to_i)
prices_re = array[1].chomp.split(" ").map(&:to_i).to_a
prices_de = array[2].chomp.split(" ").map(&:to_i).to_a
ans = []
ans.push(prices_re.min + prices_de.min)

item[2].times do |i|
  dis = array[i + 3].chomp.split(" ").map(&:to_i)
  af_dis = prices_re[dis[0] - 1] + prices_de[dis[1] - 1] - dis[2]
  ans.push(af_dis)
end

print ans.min

Measured memory_bytes: 32516
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,m,n,a,b;
    int arr[101];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int sum=0,sum1=0;
    for(i=n-1;i>=0;i=i-2)
    {
        sum=sum+arr[i];
    }

     for(j=n-2;j>=0;j=i=j-2)
    {
        sum1=sum1+arr[j];
    }

    cout<<sum-sum1;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int N;
    cin >> N;
    
    if (N == 1)cout << "Hello World" << endl;
    else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n;cin>>n;
    VEC(int,v,n);
    if(n==2){
        set<int>set;
        set.insert(v[0]);
        set.insert(v[1]);
        if(set.size()==1)cout<<1;
        else cout<<0;
        return 0;
    }
    vector<P>p;
    map<int,int>mp;
    for(int i=0;i<n;i++){
        mp[v[i]]++;
        i++;
    }
    for(auto m:mp){
        p.emplace_back(m.second,m.first);
    }
    
    map<int,int>mpp;
    vector<P>pp;
    for(int i=1;i<n;i+=2){
        mpp[v[i]]++;
    }
    for(auto mm:mpp){
        pp.emplace_back(mm.second,mm.first);
    }
    sort(ALL(p),greater<P>());
    sort(ALL(pp),greater<P>());
    int mxp = 0,mxpp = 0;
    if(p[0].second != pp[0].second)mxp = p[0].first,mxpp = pp[0].first;
    else if(p[0].second == pp[0].second && p[0].first>pp[0].first)mxp = p[0].first,mxpp = pp[1].first;
    else if(p[0].second == pp[0].second && p[0].first<pp[0].first)mxp = p[1].first,mxpp = pp[0].first;
    else if(p[0].second == pp[0].second && p[0].first==pp[0].first){
        if(p[1].first>pp[1].first)mxp = p[1].first,mxpp = pp[0].first;
        else mxp = p[0].first,mxpp = pp[1].first;
    }
    cout<<n-mxp-mxpp;
}



Measured memory_bytes: 6520
import sys
import itertools
input = sys.stdin.readline

n=int(input())
a= list(map(int, input().split()))
a+=a
b=itertools.accumulate(a)
b=[0]+list(b)
INF=10**15
dp=[[INF] *(2*n+1) for i in range(2*n+1)]
# dp[i][j][0]: コスト
# dp[i][j][1]:合成したスライムの合計

for i in range(n):
    for l in range(2*n-i):
        r=l+i
        if r==l:
            dp[l][r]=0
        else:
            # 合成の仕方を確定
            for k in range(l,r):
                dp[l][r]=min(dp[l][k]+dp[k+1][r]+b[r+1]-b[l],dp[l][r])

print(dp[0][n-1])

Measured memory_bytes: 49628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool N = false;
  
  for(int i = A;i <= B;i++){
    if(i % K == 0){
    N = true;
    }
  }
  if(N) cout << "OK" << endl;
  else cout << "NG" << endl;
}

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

int main(){
    int A = 0, B = 0;
    for(long i = 0; i < 1000000000000000; i++)
      if(1 < 2) A *= 100000;;
  cin >> A >> B;
  cout << A * B << endl;
  return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    int min = 1, max = N;
    bool flag = true;
    
    for(int i = 0; i < M; i++){
        int L, R;
        cin >> L >> R;
        if(L > min){min = L;}
        if(R < max){max = R;}
        if(L > max || R < min){flag = false;}
    }
    if(flag == true){
        cout << (max - min + 1) << endl;
    }else{
        cout << 0 << endl;
    }

}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
 
fn main() {
    
    let a = read::<u64>();
    let s = read::<String>();

    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define N 10000
#define INT(X) \
  ( *( (const int *)(X) ) )

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

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int lv[ N ], ar[ N ];
    int res = 0;
    int n;

    scanf ( " %d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      int h, m, s;

      scanf ( " %d:%d:%d", &h, &m, &s );
      lv[ i ] = h * 3600 + m * 60 + s;
      scanf ( " %d:%d:%d", &h, &m, &s );
      ar[ i ] = h * 3600 + m * 60 + s;
    }

    qsort ( lv, n, sizeof ( int ), comparator );
    qsort ( ar, n, sizeof ( int ), comparator );

    res = n;
    for ( j = 0; j < n; ++j )
    for ( i = 0; i < j; ++i )
    {
      if ( ar[ i ] <= lv[ j ] )
      {
        --res;
        ar[ i ] = INT_MAX;
        break ;
      }
    }

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

  return ( 0 );
}

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

int main() {
    string S;
    cin >> S;

    int yyyy = stoi(S.substr(0, 4));
    int mm = stoi(S.substr(5, 2));
    int dd = stoi(S.substr(8, 2));

    if (yyyy <= 2019 && mm <= 04 && dd <=30) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256