akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define long long long // for codeforces

int node[1000][26];
int type[1000][26];
int nodes = 0;

string word[100];
int score[100];

char m[6][6];
bool visited[6][6];

inline int init_node(){
  rep(i,26) node[nodes][i] = -1;
  rep(i,26) type[nodes][i] = -1;
  return nodes++;
}

void build_trie(int idx, int l, int node_id){
  if(word[idx].size() == l+1){
    type[node_id][word[idx].back()-'A'] = idx;
    return;
  }
  int c = word[idx][l] - 'A';
  // dbg(idx,l,node_id,word[idx]);
  assert(0<=c && c<26);
  if(node[node_id][c] == -1) node[node_id][c] = init_node();
  build_trie(idx, l+1, node[node_id][c]);
}

int cnt[111];

void dfs(int x, int y, int node_id, int dep){
  int c = m[x][y] - 'A';
  if(type[node_id][c]>=0) cnt[type[node_id][c]]++;

  visited[x][y] = true;
  int nid = node[node_id][c];
  if(nid>=0){
    rep(dx,-1,2) rep(dy,-1,2){
      int nx = x + dx, ny = y + dy;
      if(visited[nx][ny] || m[nx][ny]=='\0') continue;
      if(nid>=0) dfs(nx, ny, nid, dep+1);
    }
  }
  visited[x][y] = false;
}

int main(){
  int n;
  cin>>n;
  rep(i,n) cin>>word[i]>>score[i];

  init_node();
  rep(i,n) build_trie(i,0,0);

  fill(m[0], m[6], '\0');
  fill(visited[0], visited[6], false);
  rep(i,4) scanf("%s", &m[i+1][1]);

  fill(cnt, cnt+n, 0);
  rep(i,1,5)rep(j,1,5) dfs(i,j,0,1);

  int t;
  cin>>t;
  vector<int> dp(t+1, 0);
  rep(i,n){
    vector<int> nxt(dp);
    int sz = word[i].size();
    for(int j=1; sz*j<=t && j<=cnt[i]; j++){
      int c = sz*j;
      int v = score[i]*j;
      for(int k = t-c; k>=0; k--){
        nxt[k+c] = max(nxt[k+c], dp[k]+v);
      }
    }
    swap(dp, nxt);
  }

  cout << *max_element(all(dp)) << endl;

  return 0;
}

Measured memory_bytes: 3380
#include <algorithm>
#include <climits>
#include <functional>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#ifdef _MSC_VER
using ll = __int64;
using ull = unsigned __int64;
#else
using ll = long long int;
using ull = unsigned long long int;
#endif

// 二乗を計算する。
ll sq(ll x) { return x * x; }

// 領域内にいるか。
bool within(ll x, ll min, ll max) {
	return min <= x && x <= max;
}

// container の中から key より小さい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator less_than(T& container, typename T::key_type& key) {
	typename T::iterator prev = container.lower_bound(key);
	if (prev == container.begin()) prev = container.end();
	else prev--;
	return prev;
}

// container の中から key より大きい値を見つける。
// 見つからない場合は container.end() を返す。
template<typename T>
typename T::iterator greater_than(T& container, typename T::key_type& key) {
	return container.upper_bound(key);
}

// b^e (mod m) を求める
ll modpow(ll b, ll e, ll m) {
	ll result = 1;
	while (e > 0) {
		if ((e & 1) == 1) result = (result * b) % m;
		e >>= 1;
		b = (b * b) % m;
	}
	return result;
}


// ここから解法

int main(void) {

	int n;
	cin >> n;
	vector<int> p; p.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int count = 0;
	for (int i = 1; i < n - 1; ++i) {
		vector<int> tmp;
		for (int j = i - 1; j <= i + 1; ++j) {
			tmp.push_back(p[j]);
		}
		sort(tmp.begin(), tmp.end());
		if (tmp[1] == p[i]) count++;
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	
	int answer = 0;
	int tmp = N;
	while(tmp > 0)
	{
		// 1桁の値を足す
		answer += tmp % 10;
		// 次の桁へ
		tmp = tmp / 10;
	}
	
	// 割り切れる
	if (N % answer == 0)
	{
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n,x;
    
    cin >> n>> x;vector<int>a(n);
    REP(i,n) cin >> a[i];
    int kid =0;//満足する子供の数
    sort(ALL(a));
    REP(i,n){
        if(x>=a.at(i)){
            kid++;
            x-=a.at(i);
        }

    }
    if(kid ==n and x>0){
        kid = n-1;
    }
    cout  << kid << endl;
    


}

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

int main() {

    int n;

    cin >> n;

    set<int> s;

    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        s.insert(a);
    }

    long long int ans = 0;

    ans = s.size();

    if(ans%2 == 0){
        ans--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c - a, y = d - b;
    cout << c - y << " " << d + x << " " << a - y << " " << b + x << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char c, x;
int main(){
  c=getchar();
  while(c!=32){
    x=c;
    c=getchar();
  }
  c=getchar();
  if(c!=x){printf("NO\n"); return 0;}
  while(c!=32){
    x=c;
    c=getchar();
  }
  c=getchar();
  if(c!=x){printf("NO\n"); return 0;}
  printf("YES\n");
}


Measured memory_bytes: 128
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let B: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let x = (0..N).filter(|&i| B[i] > A[i]).map(|i| B[i] - A[i]).sum::<i64>();
    let m = (0..N).filter(|&i| B[i] > A[i]).count() as i64;
    let I = {
        let mut I = (0..N).map(|i| i).collect::<Vec<_>>();
        I.sort_by_key(|&i| B[i] - A[i]);
        I
    };

    let (res, s) = I.iter().fold((0, 0), |(k, s), &i| if s >= x { (k, s) } else { (k + 1, s + A[i] - B[i]) });
    let ans = if s < x { -1 } else { m + res };

    println!("{}", ans);
}

Measured memory_bytes: 11512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		t = t.substring(0, t.length()-1);
		if(s.equals(t)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 35772
#include <iostream>
#include <map>
#include <cmath>
using namespace std;

int main() {
	long long N;
	cin >> N;
	long long i = 2;
	map<long long, int> Nums;
	while (i <= (long long)sqrt(N)) {
		while (N % i == 0) {
			Nums[i]++;
			N /= i;
		}
		i++;
	}
	if (N > 1) Nums[N]++;

	int ans = 0;
	for (auto p : Nums) {
		int now = 1;
		int num = p.second;
		while (num >= now) {
			num -= now;
			now++;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3728
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Thumbnail
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

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

  int sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", as + i);
    sum += as[i];
  }

  int mind = abs(as[0] * n - sum), mini = 0;
  for (int i = 1; i < n; i++) {
    int d = abs(as[i] * n - sum);
    if (mind > d) mind = d, mini = i;
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const int N = 100100;

int main()
{
	int i, n, a, b, m;
	scanf("%d %d", &n, &m);
	int ones[200500] = { 0 };
	vector<int> twos;
	for (i = 0; i < m ; i++)
	{
		scanf("%d %d", &a, &b); // read nodes
		if (a == 1)
			ones[b] = 1;
		else if (b == 1)
			ones[a] = 1;
		if (a == n)
			twos.push_back(b);
		else if (b == n)
			twos.push_back(a);
	}
	for (auto bb : twos)
	{
		if (ones[bb])
		{
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  int ans = 0;
  vector<int> v(n); cin >> v;
  int sum = 0;
  for(int e:v)sum += e;
  for(int e:v){
    if(4*e*m>=sum)ans++;
  }
  if(ans >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int X;
  cin>>X;
  if(X>=30){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

int main() {
  int a,b; cin >> a >> b;
  const int b_idx = b - a;

  const int LEN = 999;
  vector<int> vec(LEN);
  int sum = 0;
  for(int i = 1; i <= LEN; i++) {
    sum += i;
    vec[i - 1] = sum;
  }

  const int b_term = vec[b_idx - 1];
  const int x = b_term - b;
  cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	set<int> s;
	rep(_, n) {
		int a;
		cin >> a;
		s.insert(a);
	}
	if ((int)s.size() == n)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


Measured memory_bytes: 9600
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	fastio;

	ll a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 10000000
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, a[200010];
int used[200010];
map<int, int> mp;
set<int> visit;
vector<int> vis;
void func() {
	rep(i, n) {
		if (mp.find(a[i]) == mp.end())mp[a[i]] = i;
		else if (used[mp[a[i]]] == -1) {
			used[mp[a[i]]] = i;
			mp[a[i]] = i;
		}
	}
}
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	fill(used, used + n, -1);
	func();
	func();
	int now = 0;
	while (true) {
		vis.push_back(now);
		if (visit.find(now) != visit.end())break;
		visit.insert(now);
		now = (used[now] + 1) % n;
	}
	int cnt = 0;
	rep(i, vis.size() - 1) {
		if (vis[i] == n - 1 && vis[i + 1] == 0)cnt += 2;
		else if (vis[i] + 2 > vis[i + 1])cnt++;
	}
	//cntは何個消費するか
	k %= cnt;
	if (k == 0) {
		cout << endl;
		return 0;
	}
	int count = 0;
	vector<int> ans;
	rep(i, vis.size()) {
		if (i && vis[i - 1] + 2 > vis[i])count++;
		//今見ているのはcount+1個目
		if (count == k) {
			for (int j = vis[i - 1]; j < n; j++) {
				if (j < used[j]) {
					j = used[j];
					continue;
				}
				ans.push_back(a[j]);
			}
			break;
		}
	}
	if (!ans.empty()) {
		cout << ans[0];
		REP(i, ans.size() - 1)cout << " " << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 29936
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll N,X;
ll A[4009];

ll calc(int K){
    map<ll,int> dic;
    rep(i,K) dic[A[i]]++;
    ll res=0;
    rep(i,N){
        int idx=i+K;
        dic[A[idx]]++;
        auto itr=dic.begin();
        res+=itr->first;
        if(--dic[A[i]]<=0) dic.erase(A[i]);
    }
    res+=X*K;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>X;
    rep(i,N) cin>>A[i];
    rep(i,N) A[i+N]=A[i];
    
    ll ans=0;
    rep(i,N) ans+=A[i];
    
    rep1(i,N-1) chmin(ans,calc(i));
    cout1(ans)
}

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

int main() {
	while(1){
	int a[100000];int n,m;int b[100000];int p=0;
	cin >> n >> m;
	if(n ==0&&m == 0){break;}
	for(int i = 0;i<n;i++){
		cin >> a[i];
	}
	for(int i = 0;i<100000;i++){
		b[i]=0;
	}
	for(int i = 0;i<n-m;i++){
		if(a[i]>a[i+m]){
			for(int k = i;k<i+m;k++){
				b[p]+=a[k];
			}
			p++;
		}
	}
	for(int k = n-m;k<n;k++){
				b[p]+=a[k];
	}
	for(int i = 1;i<100000;i++){
		if(b[0]<b[i]){b[0]=b[i];}
	}
	cout << b[0]<<endl;
}
	return 0;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int T, D, L;
    while (cin >> T >> D >> L, T) {
        int ans = 0, rem = 0;
        REP (i, T) {
            int x;
            cin >> x;
            if (rem) {
                ans++;
                rem--;
            }
            if (x >= L) rem = D;
        }
        cout << ans << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3216
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include<time.h>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

int dfs(string &cur,string &goal,int cnt,int pos){
	if(pos==cur.size()){
		return cnt;
	}
	if(cur[pos]==goal[pos]){
		return dfs(cur,goal,cnt,pos+1);
	}
	int ret=INT_MAX;
	REP(i,cur.size()-pos){
		string ncur(cur);
		int plus=goal[pos]-cur[pos];
		if(plus<0)plus+=10;
		REP(j,i+1){
			ncur[pos+j]=(ncur[pos+j]-'0'+plus)%10+'0';
		}
		ret=min(ret,dfs(ncur,goal,cnt+1,pos+1));
	}
	return ret;
}

int main(){
	int k;
	while(cin>>k,k){
		string initial,goal;
		cin>>initial>>goal;
		cout<<dfs(initial,goal,0,0)<<endl;
	}
}

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

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

    int k;
    cin >> k;
    vector<int> a(k);
    rep(i, k) cin >> a[k - i - 1];
    int l = 2, r = 2;
    rep(i, k)
    {
        if ((r / a[i]) * a[i] < l)
        {
            cout << -1 << endl;
            return 0;
        }
        l = ((l + a[i] - 1) / a[i]) * a[i];
        r = (r / a[i]) * a[i] + a[i] - 1;
    }
    cout << l << " " << r << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int a, b;
	cin >> a >> b;

	int ans = 0;
	int cnt = 0;

	if (b == 1) cout << 0 << endl;
	else if (a >= b) cout << 1 << endl;
	else {
		int tmp = a, cnt = 1;

		while (tmp < b) {
			tmp += (a - 1);
			cnt++;
		}
		cout << cnt << endl;
	}
}

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

int main(){
    int l, r, m;
    cin >> l >> r;
    m = 2019;
    int ans = 1000000000;
    for (int len = 1; len <= r - l; len++){
        for (int i = l; i <= r - len; i++){
            int j = i + len;
            long long t = (long long)i * j;
            t %= m;
            ans = min(ans, (int)t);
            if (ans == 0){
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Homework

func main() {
    let nm = readLine()!.split(separator: " ").map{Int($0)!}
    let a = readLine()!.split(separator: " ").map{Int($0)!}

    let workingdays = a.reduce(0, +)
    let rest = nm[0] - workingdays
    if rest < 0 {
        print(-1)
    } else { 
        print(rest)
    }
}

main()

Measured memory_bytes: 8420
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <fstream>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory.h>
#include <limits.h>

using namespace std;

int main() {
	//ios_base::sync_with_stdio(false);
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");


	long long q, h, s, d;
	cin >> q >> h >> s >> d;
	h = min(h, q * 2);
	s = min(s, h * 2);
	d = min(d, s * 2);

	long long n;
	cin >> n;

	long long ans = n / 2 * d;
	n %= 2;
	ans += n * s;

	cout << ans;
	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

int h, w, k;
inline bool ins(int r, int c){
	return 1 <= r && r <= h && 1 <= c && c <= w;
}
char g[805][805];
int d[805][805];
int dr[] = {1,0,-1,0};
int dc[] = {0,1,0,-1};

queue<pii> q;
bool vis[805][805];
vector<pii> valid;
void bfs(pii st){
	memset(vis, 0, sizeof(vis));
	q.push(st); vis[st.fi][st.se] = 1;
	while (!q.empty()){
		pii u = q.front(); q.pop();
		if (d[u.fi][u.se] <= k) valid.pb(u);
		else continue;
		for (int i=0, r, c; i < 4; i++){
			r = u.fi + dr[i]; c = u.se + dc[i];
			if (!ins(r,c)) continue;
			if (vis[r][c] || g[r][c] == '#') continue;
			d[r][c] = d[u.fi][u.se] + 1;
			vis[r][c] = 1;
			q.emplace(r, c);
		}
	}
}

int main(){
	scanf("%d %d %d", &h, &w, &k);
	pii st = {-1,-1};
	for (int i = 1; i <= h; i++){
		scanf("%s", g[i] + 1);
		for (int j = 1; j <= w; j++)
			if (g[i][j] == 'S'){
				st = {i, j};
			}
	}
	bfs(st);
	int mn = 0x3f3f3f3f;
	for (pii x : valid){
		int dst = min(min(x.fi - 1, h - x.fi), min(x.se - 1, w - x.se));
		mn = min(mn, (dst + k - 1) / k + 1);
	}
	cout << mn << '\n';
	return 0;
}


Measured memory_bytes: 14060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int T = sc.nextInt();
    int ans = 2000;
    for(int i = 0; i < n; i++) {
      int c = sc.nextInt();
      int t = sc.nextInt();
      if(t <= T) {
        ans = Math.min(ans, c);
      }
    }
    if(ans == 2000) {
      System.out.println("TLE");
    } else {
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
ll inv(ll a,ll p){return qpow(a,p-2);}
int main()
{
    std::ios::sync_with_stdio(false);
    ll n,k;
    while(cin>>n>>k)
    {
        ll ans=1;
      /*  for(n;n&&k;n--,k--)
        {
            ans*=k;
        }*/
        cout<<k*qpow(k-1,n-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
 int n, m;
  cin >> n >> m;
  int a[60];
  int b[60];
  int c[60];
  int d[60];
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  rep(i,n) {
    int way = 1e20;
    int ans = 0;
    rep(j,m) {
      int manhattan = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (manhattan < way) {
        way = manhattan;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
import numpy as np
dp = np.zeros(N+1, dtype=int)
dp[2] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i+1] = min(
        dp[i] + abs(h[i-1]-h[i]),
        dp[i-1] + abs(h[i-2]-h[i])
    )
print(dp[N])


Measured memory_bytes: 17200
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    queue<pair<string,char> > que;
    set<string>answer;


    que.push(make_pair("a",'a'));
    if(n == 1){
        cout << "a" << endl;
        return 0;
    }

    while(!que.empty()){
        pair<string,char> temp = que.front();
        que.pop();
        for(int i = 0;i < temp.second-'a'+2;i++){
            string new_string;
            char new_char=temp.second;

            new_string = temp.first+(char)('a'+i);
            if('a'+i > temp.second)new_char = 'a'+i;
            if(new_string.length() == n){
                answer.insert(new_string);
                continue;
            }
            que.push(make_pair(new_string,new_char));
        }
    }
    for(auto itr = answer.begin(); itr != answer.end(); ++itr) {
        cout << *itr << endl;
    }
    return 0;
}

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

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j= 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans=-1;
    for (int s = 0; s < (1 << n); s++) {
        int cost = 0;
        vector<int> d(m);
        for (int i = 0; i < n; i++) {
            if (s >> i & 1) {
                cost += c[i];
                for (int j = 0; j < m; j++) {
                    d[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int i = 0; i < m; i++) {
            if (d[i] < x) {
                ok = false;
            }
        }
        if (ok) {
            if (ans == -1) {
                ans = cost;
            }
            else {
                ans = min(ans, cost);
            }
        }
    }
    cout << ans << endl;
    return 0; 
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int i,j,k,tmp;
ll ans = 0;

int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);
	ll x,y,D;
	int N;
	ans = 0;
	cin >> N >> D;
	for(i=0;i<N;i++){
		cin >> x >> y;
		if(x*x + y*y <= D*D){ans++;}
	}
	cout << ans << endl;

  return 0;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  
  int answer=0;
  
  for (int i=0; i<S.size(); i++){
    if (S.at(i)!=T.at(i))
      answer++;
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 3856
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1
used = set()
num = [0]*n
used.add(0)
now = 0
cnt = 0
while True:
    cnt += 1
    if not a[now] in used:
        used.add(a[now])
        num[a[now]] = cnt
        now = a[now]
    else:
        lps = a[now]
        mod = cnt - num[a[now]]
        # k %= mod
        break
now = 0
# print(mod, lps, k, num)
while k:
    if now == lps:
        k %= mod
    if k == 0:
        break
    now = a[now]
    k -= 1

print(now+1)

Measured memory_bytes: 36244
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter

N,M = map(int,readline().split())
A = list(map(int,readline().split()))
m = map(int,read().split())
BC = list(zip(m,m))

BC.sort(key = itemgetter(1),reverse=True)

BC.append((N,-1))

change = []
for b,c in BC:
    change += [c] * b
    if len(change) > N:
        break

A += change
A.sort()
answer = sum(A[-N:])
print(answer)


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
const ll ll_inf = ll(1e9) * ll(1e9);
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
    ll a,b,c,d;
    cin >> a>>b>>c>>d;
    ll m;
    ll tmp;

    tmp = a * c;
    m = tmp;
    tmp = a * d;
    m = max(tmp, m);

    tmp = b * c;
    m = max(tmp, m);
    tmp = b * d;
    m = max(tmp, m);


    cout << m;


    return 0;
}


Measured memory_bytes: 3608
s = input().split()
N = int(s[0])
L = int(s[1])
sum = N * (L + (N-1)/2)
if L + N -1 < 0:
  print(int(sum - (L+N-1)))
elif L > 0:
  print(int(sum - L))
else:
  print(int(sum))

Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
char s1[100005],s2[100005];
int q,cnt1[100005],cnt2[100005];
int main(){
    scanf("%s%s%d",s1+1,s2+1,&q);
    for(int i=1;s1[i];++i)
        cnt1[i]=cnt1[i-1]+s1[i]-'A'+1;
    for(int i=1;s2[i];++i)
        cnt2[i]=cnt2[i-1]+s2[i]-'A'+1;
    while(q--){
    	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
        if((cnt1[b]-cnt1[a-1])%3==(cnt2[d]-cnt2[c-1])%3) puts("YES");
        else puts("NO");
    }
}  

Measured memory_bytes: 1408
import sys

X,Y=map(int,input().split())
if X%Y!=0:
	i=1
	while X*i<10**18:
		if (X*i/Y)!=int(X*i/Y):
			print(X*i)
		sys.exit()
	else:
		print(-1)
else:
	print(-1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

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

Measured memory_bytes: 3624
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


n = int(readline())
table = []
for i in range(1, n + 1):
    table += prime_decomposition(i)
counter = list(Counter(table).values())
ans = [0, 0, 0, 0, 0]
for v in counter:
    if v >= 2:
        ans[0] += 1
        if v >= 4:
            ans[1] += 1
            if v >= 14:
                ans[2] += 1
                if v >= 24:
                    ans[3] += 1
                    if v >= 74:
                        ans[4] += 1
if n < 10:
    print(0)
    exit()
print(ans[4] + ans[3] * (ans[0] - 1) + ans[2] * (ans[1] - 1) + (ans[0] - 2) * cmb(ans[1], 2))


Measured memory_bytes: 3572
#include<stdio.h>
int A[251];
int main(){
  int H,Max,i;
  scanf("%d",&H);
  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  Max=i;
  for(i=1;i<=H;i++){
    printf("node %d: key = %d,",i,A[i]);
    if(i/2!=0) printf(" parent key = %d,",A[i/2]);
    if(i*2<Max)printf(" left key = %d,",A[i*2]);
    if(i*2+1<Max)printf(" right key = %d,",A[i*2+1]);
    printf(" \n");
  }
  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;

int main(){
  cin >> N;
  cout << 800 * N - 200 * (N / 15) << endl;
}


Measured memory_bytes: 256
object Main extends App {
    for (Array(a, b, n) <- io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))) {
        val x = (0 until n).foldLeft((a, 0))((p, _) => (p._1 % b * 10, p._2 + p._1 % b * 10 / b))
        println(x._2)
    }
}

Measured memory_bytes: 43920
#!ruby -pl
r=[*?A..?Z]
$_=($_.gsub!(/./,Hash[(" ',-.?".chars+r).zip"dggigggieedfigeiefiifdieffiigiii".bytes.map{|i|i-97}.zip("836$D4X-849<.C:+97,18:2;9:/05%&#".bytes.map{|c|c<51?c+109:c-51}).map{|a|"%0*b"%a}])+?0*((100-$_.size)%5)).gsub(/.{5}/,Hash[(0..31).map{|i|"%05b"%[i]}.zip r+" .,-'?".chars])

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

int main() {
  // ここにプログラムを追記
  int a, b;
  string c, result = "Yes";
  cin >> a >> b;
  cin >> c;
  if (c.size() != a + b + 1) {
		result = "No";
  }
  for (size_t i=0;i<c.size();i++) {
    if (i==a) {
      if (c[i] != '-') {
		    result = "No";
      }
    } else {
      if (c[i] <'0' || c[i] > '9') {
		    result = "No";
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d = dice(label)
n = int(input())
for i in range(n):
    top_front = [int(x) for x in input().split()]
    for op in 'EEENEEENEEESEEESEEENEEEN':
        if d.get_label()[:2] == top_front:
            d.print_right()
            break
        d.roll(op)


Measured memory_bytes: 5612
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		try{
          
          Scanner sc = new Scanner(System.in);

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

			int a2 = n-a;
			int b2 = n-b;
			
			int yes = 0;
			int no = 0;
			
			if(a>=b){
				yes = b;
			}else if(a<b){
				yes = a;
			}
			
			if(a2>=b2){
				no = b2;
			}else if(a2<b2){
				no = a2;
			}
			
			
			if(yes-no<0){
				no = 0;
			}else{
				no = yes-no;
			}
			
			System.out.println(yes +" "+ no);
			
		}catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}


Measured memory_bytes: 22740
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInts >>= print . uncurry (+) . ( id *** ( `div` 2 ) ) . mp

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;

    for(int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
}









Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;

int N, K;
vector<int> V;

int main()
{
  cin >> N >> K;
  for (int i=0;i<N;i++) {
    int v;
    cin >> v;
    V.push_back(v);
  }
  int act = min(N, K);
  int maxscore = 0;
  for (int i = 0; i < act+1; i++) {
    for (int j = 0; j < act-i+1; j++) {
      int score = 0;
      vector<int> minus;
      for (int k = 0; k < i; k++) {
        if (V[k]>=0) score += V[k];
        else {
          minus.push_back(V[k]);
        }
      }
      for (int k=0; k < j;k++) {
        if (V[N-k-1] >= 0) score+=V[N-k-1];
        else {
          minus.push_back(V[N-k-1]);
        }
      }
      sort(minus.begin(),minus.end());
      for (int k = K-i-j; k < minus.size();k++) {
        score += minus[k];
      }
      if (score > maxscore) maxscore = score;
    }
  }
  cout << maxscore << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j;
    char a[3][3];
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++){
            cin>>a[i][j];
        }
    }

    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++){

            if(i==j)
            cout<<a[i][j];
        }
    }
    return 0;
}


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

int main()
{
	long N, M;

	cin >> N >> M;

	long count = 0;

	vector<int> vec(M);

	for (int i = 0; i < M; i++) {
		cin >> vec.at(i);
		count = count + vec.at(i);
	}

	if (N - count > -1) {
		cout << N - count << endl;
	}
	else {
		cout << -1 << endl;
	}


}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
int n,u,v;
vector<int> edges[100100];
mint dp[100100][2];
void dfs(int x,int last=-1){
    dp[x][0]=dp[x][1]=1;
    for(auto to: edges[x]){
        if(to==last) continue;
        dfs(to,x);
        dp[x][0]=dp[x][0]*(dp[to][0]+dp[to][1]);
        dp[x][1]=dp[x][1]*dp[to][0];
    }
}
int main(){
    cin >> n;
    rep(i,n-1){
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    dfs(1);
    mint ans=dp[1][0]+dp[1][1];
    cout << ans.x << endl;
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&i:a)cin>>i;
	sort(a.begin(),a.end());
	double t=(double)a.back()/2;
	int r=a.front(); double abm=abs(t-r);
	for(auto&i:a){
		double tmp=abs(t-i);
		if(tmp>=abm)continue;
		r=i,abm=tmp;
	}
	cout<<a.back()<<" "s<<r<<"\n"s;
}

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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  // -1 => unknown, 1 => good, 0 => bad
  vector<vector<int>> p(N, vector<int>(N, -1));
  REP(i, N) {
    int a;
    cin >> a;
    REP(j, a) {
      int x, y;
      cin >> x >> y;
      x--;
      p[i][x] = y;
    }
  }
  vector<bool> good(N);
  auto ok = [&]() -> bool {
    REP(i, N) {
      if (good[i]) {
        REP(j, N) {
          if (p[i][j] != -1 && p[i][j] != good[j]) return false;
        }
      }
    }
    return true;
  };
  int max_good = 0;
  auto dfs = [&](auto rec, int i, int num) -> void {
    if (i == N) {
      if (ok()) {
        max_good = max(max_good, num);
      }
      return;
    }
    good[i] = false;
    rec(rec, i + 1, num);
    good[i] = true;
    rec(rec, i + 1, num + 1);
    good[i] = false;
  };
  dfs(dfs, 0, 0);
  cout << max_good << endl;
}

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

using namespace std;

#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;
vector<int>adj[mxn];

	
	
int main(){
    fast;

    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        int n,m;
        cin>>n>>m;
        for(int i = 0; i < m; i++) {
			int x,y;
			cin>>x>>y;
			//adj[x].pb(y);
			adj[y].pb(x);
		}
		for(int x : adj[n]) {
			sort(adj[x].begin(),adj[x].end());
			if(binary_search(adj[x].begin(),adj[x].end(),1)) return cout<<"POSSIBLE\n",0;
		}
        cout<<"IMPOSSIBLE\n";
        
    }



return 0;
}


Measured memory_bytes: 11728
def inputs(): return [int(x) for x in input().split()]
n,m = inputs()
sc = [inputs() for _ in range(m)]
a = 10**n
if m==0:
  if n!=1:
    a = 10**(n-1)
  elif n==1:
    a = 0
  print(a)
  exit()
for i in range(a):
  b = str(i)
  flag = 0
  for j in range(m):
    s1,c1 = sc[j]
    if len(b)!=n or b[s1-1]!=str(c1):
      break
    flag+=1
  if flag==m:
    print(b)
    exit()
print(-1)


Measured memory_bytes: 3064