akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int n, pos;
vector<int> pre, post, in;

void recon(int l, int r){
    if(l >= r){
        return;
    }
    int c = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), c));
    recon(l, m);
    recon(m+1, r);
    post.push_back(c);
}

int main() {
    cin >> n;
    rep(i,n){
        int k; cin >> k;
        pre.push_back(k);
    }
    rep(i, n){
        int k; cin >> k;
        in.push_back(k);
    }

    pos = 0;
    recon(0, n);

    rep(i, n){
        cout << post[i];
        if(i != n-1){
            cout << " ";
        } else {
            cout << endl;
        }
    }

}


Measured memory_bytes: 3152
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class ARemainingBalls {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (S == U) {
      A--;
    } else {
      B--;
    }
    cout << A << " " << B << endl;
  }
};


signed main() {
  ARemainingBalls solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
 int i, j, n, a, ans=0;

	scanf("%d", &n);

	for(i = 0 ; i<n ; i++){
		scanf("%d", &a);

		if(a == 2)ans++;

		else if(a == 3)ans++;

		else if( (a % 2) == 0)continue;

		else {
			for(j = 3 ; j<(int)sqrt(a)+1 ; j++){
				if( (a % j) == 0)break;
				}
				if(j ==  (int)sqrt(a)+1)ans++;	
			}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 2088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int K = reader.nextInt();
		String S = reader.next();
		int ans = 0;
		for (int i = 1; i < K; i++) {
			int tmp = 0;
			String bf = S.substring(0, i);
			String af = S.substring(i, S.length());
			while (bf.length() > 0) {
				if (af.indexOf(bf.charAt(0)) != -1) {
					tmp++;
				}
				bf = bf.replaceAll(Character.toString(bf.charAt(0)), "");
			}
			if (tmp > ans) {
				ans = tmp;
			}
		}

		reader.close();
		System.out.print(ans);
	}
}



Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {sws;

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for ( int i = l; i <= r; i++ ) if ( i % d == 0 ) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> tree;
unordered_map<int,int> mp;
void dfs(int s){
    mp[s]=1;
    for(int j=0;j<(int)tree.at(s).size();j++){
        int g=tree.at(s).at(j);
        if(mp[g]==0){
            mp[g]=1;
            dfs(g);
        }
    }
}
int main(){
    int N,M;
    cin>>N>>M;
    tree.resize(N,vector<int>(0));
    for(int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        tree.at(a-1).push_back(b-1);
        tree.at(b-1).push_back(a-1);
    }
    int sum=0;
    for(int i=0;i<N;i++){
        if(mp[i]==0){
            dfs(i);
            sum++;
        }
    }
    cout<<sum<<endl;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;

	vector <string> s(H, "");
	for (int ii = 0; ii < H; ++ii){
		cin >> s[ii];
	}

	queue<pair<int,int>> q;
	q.push(make_pair(0,0));

	vector<vector<int>> dist(H, vector <int>(W, -1));
	dist[0][0] = 0;

	int nx[4] = {1, -1, 0, 0};
	int ny[4] = {0, 0, 1, -1};
	while (!q.empty()) {
		int ty = q.front().first;
		int tx = q.front().second;
		q.pop();

		for (int ii = 0; ii < 4; ++ii){
			int x = tx + nx[ii];
			int y = ty + ny[ii];
			if (x<0 || x>= W || y<0 || y>= H ){continue;}
			if (s[y][x] == '#'){continue;}
			int tmp = dist[ty][tx] + 1;
			if ( (dist[y][x] < 0) || (tmp < dist[y][x])){
				dist[y][x] = tmp;
				q.push(make_pair(y, x));
			}
		}
	}

	int orgBlack = 0;
	for (int ii = 0; ii < H; ++ii){
		for (int jj = 0; jj < W; ++jj){
			if (s[ii][jj] == '#'){
				orgBlack++;
			}
		}
	}

	if (dist[H-1][W-1] < 0){
		cout << -1 << "\n";		
	} else {
		cout << H*W - orgBlack - (dist[H-1][W-1] + 1) << "\n";
	}

	return 0;
}


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

int main() {
  int A, B, M; cin >> A >> B >> M;
  vector<int> a(A), b(B);
  int min_a = 1e9, min_b = 1e9;
  for (int &v:a) cin >> v, min_a = min(min_a, v);
  for (int &v:b) cin >> v, min_b = min(min_b, v);
  
  int mi = min_a + min_b;
  while (M--) {
    int x, y, c; cin >> x >> y >> c; --x; --y;
    mi = min(mi, a[x] + b[y] - c);
  }
  
  cout << mi << endl;
}

Measured memory_bytes: 1024
use std::collections::*;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

struct OrderedString {
    used_chars: usize,
    length: usize,
    string: BTreeMap<usize, usize>,
}

impl OrderedString {
    fn increment(&mut self, length: usize) -> bool {
        if let Some(&v) = self.string.get(&length) {
            if v == self.used_chars - 1 {
                self.string.remove(&length);
                if length == 1 {
                    false
                } else {
                    self.increment(length - 1)
                }
            } else {
                *self.string.get_mut(&length).unwrap() += 1;
                true
            }
        } else if self.used_chars == 1 {
            false
        } else {
            self.string.insert(length, 1);
            true
        }
    }
}

fn is_ok(a: &Vec<usize>, used_chars: usize) -> bool {
    let mut last_string = OrderedString {
        used_chars: used_chars,
        length: a[0],
        string: BTreeMap::new(),
    };
    for i in 1..a.len() {
        if a[i] > a[i - 1] {
            continue;
        }
        if a[i] < a[i - 1] {
            while let Some(&key) = last_string.string.keys().next_back() {
                if key > a[i] {
                    last_string.string.remove(&key);
                } else {
                    break;
                }
            }
            last_string.length = a[i];
        }
        if !last_string.increment(a[i]) {
            return false;
        }
    }
    true
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();

    let mut ng = 0;
    let mut ok = n;
    while ok - ng > 1 {
        let mid = (ok + ng) / 2;
        if is_ok(&a, mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok);
}


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

#define ull unsigned long long
#define ll long long

bool isprime(int n){
    for(int i=2; i*i <= n; ++i){
        if(n%i==0)
            return false;
    }

    return true;
}

int main(){
    int n;
    cin >> n;
    for(int i=n; 1; ++i){
        if(isprime(i)){
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	vector<int> v(3);
	FDS(i,3){
		cin>>v[i];
	}
	VSORT(v);
	int sum=0;
	int t=0;
	int k=0;
	FDS(i,100){
		if(v[0]!=v[1]&&v[1]!=v[2]&&v[2]!=v[0]){
			v[0]++;
			v[1]++;
			sum++;
			continue;
		}
		if(v[0]!=v[1]&&v[1]==v[2]&&k==0){
			k++;
			t=v[1]-v[0];
		}
		if(v[0]==v[1]&&v[1]!=v[2]){
			sum+=v[2]-v[0];
			break;
		}
		if(t%2==0){
			sum+=t/2;
			break;
		}
		if(t%2==1){
			sum++;
			sum+=(t+1)/2;
			break;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9+7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> S(N, 0);
    rep(i, Q)
    {
        ll a;
        cin >> a;
        --a;
        ++S[a];
    }
    rep(i, N)
    {
        yes(K - Q + S[i] > 0);
    }
    //
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 103;
const int mod = 1e9 + 7;
int n,m,a[maxn],b[maxn],f[maxn][maxn],tp;
int i,j;
ll mypow(ll a,ll b)
{
	if(b <= 0)
	{
		return 1;
	}
	ll res = 1;
	for(;b;b >>= 1,a = a * a % mod)
	{
		if(b & 1)
		{
			res = res * a % mod;
		}
	}
	return res;
}
void trans(int d)
{
	d = min(d,a[i + 1]);
	f[i + 1][d] = (f[i + 1][d] + mypow(2,b[a[i]] - b[max(j,a[i + 1])]) * tp) % mod;
}
int main(int argc, char const *argv[])
{
	scanf("%d",&n);
	for(int i = 0;i < n; ++i)
	{
		scanf("%d",&a[i]);
		b[i] = --a[i];
	}
	sort(b,b + n + 1);
	m = unique(b,b + n + 1) - b;
	for(int i = 0;i < n; ++i)
	{
		a[i] = lower_bound(b,b + m,a[i]) - b;
	}	
	f[0][0] = 1;
	for(i = 0;i < n; ++i)
	{
		for(j = 0;j <= a[i]; ++j)
		{
			if((tp = f[i][j]))
			{
				trans(j),trans(a[i]);
			}
		}
	}
	printf("%d\n",f[n][0]);
	return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll M = 0;
ll ret = 0;

vector<pair<ll, ll>> AB;

bool compareA(pair<ll, ll> ab1, pair<ll, ll> ab2) {
  return ab1.first < ab2.first;
}

// bool compareB(pair<ll, ll> ab1, pair<ll, ll> ab2) {
//   return ab1.second > ab2.second;
// }

auto compareB = [](pair<ll, ll> p1, pair<ll, ll> p2) {
  return p1.second > p2.second;
};

priority_queue<int> q;

void input() {
  IN(N);
  IN(M);
  ll tmp1, tmp2;
  REP(i,N) {
    IN(tmp1);
    IN(tmp2);
    AB.push_back(make_pair(tmp1, tmp2));
  }
}

void solve() {
  sort(AB.begin(), AB.end(), compareA);

  ll j = 0;
  FOR(i, 1, M+1) { //日付を逆から見ていく
    while(j < AB.size() && AB[j].first <= i) {
      q.push((int)AB[j].second);
      j++;
    }
    if (!q.empty()) {
      ret += q.top();
      q.pop();
    }
  }

  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 2672
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout << a[k-1]<<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>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vvi a(n, vi(m));
    vi c(n);
    for (int i = 0; i < n; i++)
        cin >> c[i] >> a[i];
    int res = LLONG_MAX;
    for (int msk = 0; msk < (1 << n); msk++)
    {
        int cur = 0;
        vi v(m);
        for (int i = 0; i < n; i++)
            if (msk & (1 << i))
            {
                cur += c[i];
                for (int j = 0; j < m; j++)
                     v[j] += a[i][j];
            }
        bool ok = true;
        for (int i = 0; i < m; i++)
            ok &= v[i] >= x;
        if (ok)
            res = min(res, cur);
    }
    if (res == LLONG_MAX)
        res = -1;
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        string[] strer = new string[3];
        strer = str.Split(' ');

        int n = int.Parse(strer[0]);
        int m = int.Parse(strer[1]);
        int l = int.Parse(strer[2]);

        long[,] array1 = new long[n,m];
        string[] array1_str = new string[m];

       
        for (int i = 0; i < n; i++)
        {
            str = Console.ReadLine();
            array1_str = str.Split(' ');

            for (int j = 0; j < m; j++)
            {
                array1[i, j] = int.Parse(array1_str[j]);
            }
        }

        long[,] array2 = new long[m, l];
        string[] array2_str = new string[l];

       
        for (int i = 0; i < m; i++)
        {
            str = Console.ReadLine();
            array2_str = str.Split(' ');

            for (int j = 0; j < l; j++)
            {
                array2[i, j] = int.Parse(array2_str[j]);
            }
        }

        long[,] result = new long[n, l];
        
       
        for (int i = 0; i < n; i++)
        {          
            for (int j = 0; j < l; j++)
            {
                for (int k = 0; k < m; k++)
                {
                    result[i, j] += array1[i, k] * array2[k, j];
                }
              
            }
        }

        
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < l; j++)
            {
                if (j == l - 1)
                {
                    Console.Write(result[i, j]);
                }
                else
                {
                    Console.Write(result[i, j] + " ");
                }
            }
            Console.WriteLine();
        }



    }
}


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

int main(){
    long long n;
    cin >> n;
    char a[26] = {
        'a', 'b', 'c', 'd', 'e', 'f', 'g',
        'h', 'i', 'j', 'k', 'l', 'm', 'n',
        'o', 'p', 'q', 'r', 's', 't',
        'u', 'v', 'w', 'x', 'y', 'z'
    };
    string ans = "";
    long long mod = 0;
    while(n != 0){
        --n;
        mod = n%26;
        ans += a[mod];
        n /= 26;
    }
    for(int i = ans.length()-1; i >= 0; --i){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 3e3 + 5;
const ll MOD = 998244353;

int n, k;
ll dp[maxN][maxN], pref[maxN], pref2[maxN];
int arr[maxN];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	RI(i, n) {
		cin >> arr[i];
	}
	dp[0][0] = 0;
	// dp[i][s] - suma lewych koncow o sumie s konczy sie na i
	RI(i, n) {
		dp[i][arr[i]] = i;
		FOR(j, arr[i] + 1, k) {
			dp[i][j] = pref[j - arr[i]];
			pref2[j] = (pref[j] + dp[i][j]) % MOD;
			//cout << i << " " << j << " " << dp[i][j] << endl;
		}
		pref[arr[i]] = (pref[arr[i]] + i) % MOD;
		FOR(j, arr[i] + 1, k) pref[j] = pref2[j];
	}
	ll ans = 0;
	RI(i, n) {
		ans = (ans + (ll)(n - i + 1) * dp[i][k]) % MOD;
	}	
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 70656
def main():
  N, M = map(int, input().split())
  num = [-1] * N

  for _ in range(M):
    s, c = map(int, input().split())
    s -= 1
    if s == 0 and c == 0:
      if N != 1:
        print(-1)
        return
    if num[s] == -1:
      num[s] = c
    elif num[s] != c:
      print(-1)
      return

  ans = ""
  for i in range(len(num)):
    c = num[i]
    if c == -1:
      if i != 0 or N == 1:
        ans += "0"
      else:
        ans += "1"
    else:
      ans += str(c)

  print(ans)

main()


Measured memory_bytes: 61988
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 105;
const int Mod = 2019;
#define pi acos(-1)
#define INF 1e8
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
/*
类似前缀区间和的一个变形.
但是不同的是,这里可以以任意一段区间组成一个数.
思路：
对于区间[L,r].满足sum[L,r]%Mod == 0的条件是
sum[1,L] == sum[1,r].
*/
int main()
{
	string s;cin >> s;
	int re = 0,t = 1;
	LL ans = 0;
	map<int,int> mp;
	mp[0] = 1;
	for(int i=s.size()-1;i>=0;--i)
	{
		re = (re+(s[i]-'0')*t)%Mod;
		t = (t*10)%Mod;
		ans += mp[re];
		mp[re]++;
	}
	plr(ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(3*N);
  for (int i=0;i<3*N;i++){
    cin >> a[i];
  }
  priority_queue<int,vector<int>,greater<int>> pq1;
  priority_queue<int> pq2;
  vector<long long> front(N+1),back(N+1);
  for (int i=0;i<N;i++){
    front[0]+=a[i];
    pq1.push(a[i]);
    back[N]+=a[3*N-1-i];
    pq2.push(a[3*N-1-i]);
  }
  for (int i=1;i<N+1;i++){
    pq1.push(a[N-1+i]);
    front[i]=front[i-1]+a[N-1+i]-pq1.top();
    pq1.pop();
    pq2.push(a[2*N-i]);
    back[N-i]=back[N+1-i]+a[2*N-i]-pq2.top();
    pq2.pop();
  }
  long long ans=front[0]-back[0];
  for (int i=1;i<N+1;i++){
    ans=max(ans,front[i]-back[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;


int main(){
   
   ll n,x,k;
   cin>>n;
   ll cost[n][n], siz[n][n];

   for(int i=0; i<n; i++)
     cin>>siz[i][i];

   for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        cost[i][j] = 1e16;
      }
      cost[i][i] = 0;
   }

   for(int l=1; l<=n; l++){
      for(int i=0, j=l-1; i<n && j<n; i++,j++){
          for(int k=i; k<j; k++){
            ll c =  cost[i][k]+cost[k+1][j]+siz[i][k]+siz[k+1][j];
            if( c < cost[i][j] )
                cost[i][j] = c, siz[i][j] = siz[i][k]+siz[k+1][j];
            else if( c == cost[i][j] && siz[i][j] > siz[i][k]+siz[k+1][j]  )
                cost[i][j] = c, siz[i][j] = siz[i][k]+siz[k+1][j];
          }
      }
   }

   cout<<cost[0][n-1];

} 

Measured memory_bytes: 6072
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,C,a[8],p[8];
LL ans;
LL dp[310][1<<7][310];
inline LL Solve()
{
	mem(dp,0);
	dp[0][0][a[n]*n]=1;
	For(i,1,C*n)
	{
		For(j,0,(1<<(n-1))-1)
		{
			For(k,i,C*n)
			{
				dp[i][j][k]+=dp[i-1][j][k];
				int t=i%n;
				if(t&&(!((j>>(t-1))&1)))
					dp[i][j|(1<<(t-1))][min(C*n,max(k,i+a[p[t]]*n))]+=dp[i-1][j][k];
			}
		}
	}
	return dp[C*n][(1<<(n-1))-1][C*n];
}
inline void dfs(int now)
{
	if(now==n){ans+=Solve();return;}
	For(i,1,n-1)
	if(!p[i])
	{
		p[i]=now;
		dfs(now+1);
		p[i]=0;
	}
}
int main()
{
	file();
	read(n),read(C);
	For(i,1,n)read(a[i]);
	sort(a+1,a+n+1);
	dfs(1);
	LL cnt=1;
	For(i,1,n-1)cnt=cnt*i;
	For(i,1,n-1)cnt=cnt*C;
	printf("%.20lf\n",(double)ans/(double)cnt);
	return 0;
}


Measured memory_bytes: 96384
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


x,y = input().split()

if x > y:
    print(">")
elif x < y:
    print("<")
else:
    print("=")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int a, b; cin >> a >> b;
	cout << max(0, a - 2 * b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define fast_io ios_base::sync_with_stdio(false)
#define pb push_back
#define fir first
#define sec second
#define tr(it,x) for(it = x.begin();it != x.end();it++)
#define mp make_pair
#define sz(x) (ll)x.size()
#define rep(i,n) for(ll i=0;i<n;i++)
#define double long double
#define accuracy ll precision = numeric_limits<double>::digits10
#define pll pair<ll,ll>
#define N 105
#define M 100005

ll n,k,a[N],dp[M];

int main() {
	// freopen("input.txt", "r", stdin); 
	// freopen("output.txt", "w", stdout);
	fast_io;	 
	accuracy;
	cin >> n >> k;
	fr(i,1,n) cin >> a[i];
	fr(i,1,M-1) {
		fr(j,1,n) {
			ll temp = i - a[j];
			if(temp >= 0) {
				if(dp[temp] == 0) {
					dp[i] = 1;	
				}
			}
		}
	}
	if(dp[k] == 0) cout << "Second" << endl;
	else cout << "First" << endl;
}

Measured memory_bytes: 1024
n,k=map(int,input().split())
mod=10**9+7
a,b,c,d=1,n-k-1,2,0
print(((b+c)*a)%mod)
for i in range(2,k+1):
    a=(a*(k-i+1)//(i-1))
    d=max(0,c//2)
    c=max(0,2*b)
    b=max(0,(b*(n-k-i)//i))
    if n-k>=i+1:
        print((a*(b+c+d))%mod)
    elif n-k>=i:
        print((a*(c+d))%mod)
    elif n-k>=i-1:
        print((a*d)%mod)
    else:
        print(0)

Measured memory_bytes: 3316
/**
 *		author:  zvm
 *		created: 25.09.2020 13:51:29
**/

#include <bits/stdc++.h>

using namespace std ;

typedef long long int ll ;
const ll INF = 1e18 ;

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

	int n ;
	cin >> n ;

	vector<int> a(n), b(n), c(n);

	for( int i = 0 ; i < n ; ++i ) {
		cin >> a[i] ;
	}
	for( int i = 0 ; i < n ; ++i ) {
		cin >> b[i] ;
	}
	for( int i = 0 ; i < n ; ++i ) {
		cin >> c[i] ;
	}

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());

	vector<pair<int,ll>> good(n);
	for( int i = 0 ; i < n ; ++i ) {
		good[i].first = b[i] ;
		good[i].second = c.end() - upper_bound(c.begin(),c.end(),b[i]) ;
	}

	for( int i = n-2 ; i >= 0 ; --i ) {
		good[i].second += good[i+1].second ;
	}

	ll ans = 0 ;
	for( int i = 0 ; i < n ; ++i ) {
		pair<int,ll> to_find{a[i],INF};
		auto total = upper_bound(good.begin(),good.end(),to_find) ;
		if( total != good.end() ) {
			ans += (*total).second ;
		}
	}
	
	cout << ans << endl ;
}	


Measured memory_bytes: 6100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll prime = 10000000000 + 7;

/*
vector<int> z_algorithm(const string& s) {
	vector<int> prefix(s.size());
	for (int i = 1, j = 0; i < s.size(); i++)
	{
		if (i + prefix[i - j] < j + prefix[j]) {
			prefix[i] = prefix[i - j];
		}
	}
}
*/

struct UnionFind {
	vector<ll> par;
	vector<ll> rank;

	UnionFind(ll n) {
		par = vector<ll>(n);
		rank = vector<ll>(n);
		for (ll i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 0;
		}
	}

	ll root(ll x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return root(par[x]);
		}
	}

	bool is_same(ll x, ll y) {
		return (root(x) == root(y));
	}

	void connect(ll x, ll y) {
		if (!is_same(x, y)) {
			ll x1, y1;
			x1 = root(x);
			y1 = root(y);
			if (rank[x1] < rank[y1]) {
				par[x1] = y1;
			}
			else if (rank[x1] > rank[y1]) {
				par[y1] = x1;
			}
			else {
				par[x1] = y1;
				rank[y1]++;
			}
		}
	}
};

int main() {
  
  	cout << fixed << setprecision(10);

	ll a, b;
	cin >> a >> b;
	if (1 <= min(a, b) and max(a, b) <= 9) {
		cout << (a * b) << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        if (S.length() <= K) {
            System.out.println(S);
        } else {
            System.out.println(S.substring(0,K)+"...");
        }
    }
}


Measured memory_bytes: 38564
#include <queue>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

priority_queue <double, vector <double>, greater <double> > q;
int n, a[110];
double ans; 

int main(){

	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]), q.push((double)a[i]);
	
	while(q.size() != 1){
		double x = q.top();
		q.pop();
		double y = q.top();
		q.pop();
		q.push((x + y) / 2.0);
	}
	
	printf("%.6lf\n", q.top());

	return 0;
}


Measured memory_bytes: 256
# include <cstdio>
# include <iostream>
# include <vector>
# include <map>
# include <set> 
# include <algorithm> 
# include <string>
# include <cstring>
# include <queue> 
# include <stack> 
# include <cstdlib> 
# include <cassert> 

using namespace std ;

int N ; 
long long int INF = 1000000000LL + 10LL ; 
long long int dp[100009] ; 
long long int H[100009]  ; 

long long int iabs(long long int a){
	if(a<0LL)return (a*-1LL) ; 
	return a ;  
}
long long minVal(long long a, long long b){
	if(a>b) return b ; 
	return a ; 
}

long long go(int cur)
{
	//if(cur < 0 ) return INF ; 
	long long int& ret = dp[cur]; 
	if(ret != -1LL) return ret ;
	if(cur==0) return ret = 0LL ; 
	ret = INF ; 
	if(cur>0)ret = minVal(ret, go(cur-1)+iabs(H[cur]-H[cur-1])); 
	if(cur>1) ret = minVal(ret, go(cur-2)+iabs(H[cur]-H[cur-2])) ; 
	return ret ;
}

int main()
{
	scanf("%d",&N);
	//vector< int > H(N) ; 
	for(int i = 0 ; i < N ; ++i){
		scanf("%lld",&H[i]);
		dp[i]=-1LL; 
	}
	dp[N] = -1LL ; 
	//vector< int > dp(N+3, -1); 

	long long tmp = go(N-1) ; 

	assert(tmp != INF) ; 

	cout << tmp << "\n" ; 
	

	//cout << "Hello World\n" ; 
	return 0 ; 
}

Measured memory_bytes: 4992
import math

N=int(input())
a = [int(i) for i in input().split()]

flag=""
for i,ia in enumerate(a):
    if (i+1)==ia:
       flag += "1"
    else:
        flag += " "

flags=flag.split()

count =0
for iflg in flags:
    count += math.ceil(len(iflg)/2)

print(count)


Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_;i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define INF 10000000

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    REP(i,10){
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


N = ii()
A = li()

d = {}

for i in range(N):
    d[i + 1] = A[i]

d2 = sorted(d.items(), key=lambda x: x[1])

for i in range(N):
    print(d2[i][0], end=" ")
print()


Measured memory_bytes: 26268
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
	int w = 1;
	char str[1001] = { NULL };
	char answer[1001] = { NULL };

	scanf("%s", str);
	scanf("%d", &w);

	answer[0] = str[0];
	for (int i = 1; i < (strlen(str))/w + 1; i++)
	{
		answer[i] = str[i * w];
	}

	printf("%s", answer);

	return 0;

}

Measured memory_bytes: 128
import itertools


def main():
    s = input()
    ans = 0
    # '+'の数
    for i in range(len(s)):
        # '+'を挟み込み可能性のある場所の全通り
        for ind in itertools.combinations(range(1, len(s)), i):
            # '+'を挟み込んだ時の文字列のズレ幅
            c = 0
            st = s
            for j in ind:
                st = st[:j + c] + '+' + st[j + c:]
                c += 1
            ans += eval(st)
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main(int argc, const char *argv[]) {
  int h, w, n, a;
  cin >> h >> w >> n;
  vector<int> va;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    while (a--) va.push_back(i + 1);
  }

  for (int i = 0; i < h * w; ++i) {
    int r = i / w, c = i % w;
    cout << (r % 2 ? va[i] : va[(r + 1) * w - c - 1]);
    cout << (c == w - 1 ? '\n' : ' ');
  }

  return 0;
}

Measured memory_bytes: 3604
n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }.sort
f    = gets.to_s.split.map{|t| t.to_i }.sort.reverse

m = []
n.times do |i|
   m << [a[i] * f[i], f[i]]
end

m.sort_by!{|(af, _)| -af }

ma = m[0][0]
ans = (0 .. ma).bsearch do |x|
  
  k_x = 0
  m.each do |(m_i, f_i)|
    break if m_i <= x
    k_x += ( m_i - x + f_i - 1 ) / f_i
  end
  
  k_x <= k
end

puts ans

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

long long lowbit(long long i) {
    return i & -i;
}

long long get(vector<long long>& bit, long long index) {
    long long result = 0;
    while (index > 0) {
        result += bit[index];
        index -= lowbit(index);
    }
    return result;
}

void add(vector<long long>& bit, long long index, long long val) {
    while (index < bit.size()) {
        bit[index] += val;
        index += lowbit(index);
    }
}

int main() {
    long long n, k, result = 0;
    cin >> n >> k;
    vector<long long> bit(n + 2), a(n + 1), b(n + 1);
    for (long long i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] += a[i - 1] - k;
        b[i] = a[i];
    }
    sort(begin(b), end(b));
    for (long long i = 0; i <= n; i++) {
        auto it = upper_bound(begin(b), end(b), a[i]);
        result += get(bit, distance(begin(b), it));
        add(bit, distance(begin(b), it), 1);
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n/10 == 9 || n%10 == 9){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

import static java.lang.Math.ceil;
import static java.lang.Math.floor;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String S = scan.next();
        int N = S.length();
        char arrayS[] = S.toCharArray();
        int ans[] = new int[N];
        Arrays.fill(ans, 0);

        char prevS = 'R';
        int count = 0;

        for(int i = 0; i < N; i++) {
            if(prevS == 'R' && arrayS[i] == 'L') {
                ans[i-1] = (int) ceil(count / 2.0);
                ans[i] = (int) floor(count / 2.0);
                count = 0;
            }
            else if(arrayS[i] == 'R')
                count++;

            prevS = arrayS[i];
        }

        prevS = 'L';
        count = 0;
        for(int i = N - 1; i >= 0; i--) {
            if(prevS == 'L' && arrayS[i] == 'R') {
                ans[i+1] += ceil(count / 2.0);
                ans[i] += floor(count / 2.0);
                count = 0;
            }
            else if(arrayS[i] == 'L')
                count++;

            prevS = arrayS[i];
        }

        for(int i = 0; ; ) {
            os.print(ans[i]);

            if(++i < N)
                os.print(" ");
            else {
                os.println("");
                return;
            }
        }
    }
}

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

typedef struct hen_tag {
	int to;
	int cost;
	struct hen_tag* next;
} hen_t;

hen_t* mareitaso(int kitamuraeri,int hanazawakana) {
	hen_t* mizuhasikaori=(hen_t*)malloc(sizeof(hen_t));
	if(mizuhasikaori==NULL)exit(1);
	mizuhasikaori->to=kitamuraeri;
	mizuhasikaori->cost=hanazawakana;
	mizuhasikaori->next=NULL;
	return mizuhasikaori;
}

int N;
int C[1000];
hen_t* hen[1000];
hen_t** hen_next[1000];

int murakawarie(int cur,int from,int from_cost) {
	hen_t* i;
	int ret=0;
	if(from<0) {
		for(i=hen[cur];i!=NULL;i=i->next) {
			ret+=murakawarie(i->to,cur,i->cost);
		}
	} else {
		ret=from_cost;
		if(C[cur]==0) {
			int candidate=0;
			for(i=hen[cur];i!=NULL;i=i->next) {
				if(i->to!=from) {
					candidate+=murakawarie(i->to,cur,i->cost);
				}
			}
			if(candidate<ret)ret=candidate;
		}
	}
	return ret;
}

int main(void) {
	int i;
	if(scanf("%d",&N)!=1)return 1;
	for(i=1;i<N;i++) {
		if(scanf("%d",&C[i])!=1)return 1;
	}
	for(i=0;i<N;i++) {
		hen[i]=NULL;
		hen_next[i]=&hen[i];
	}
	for(i=0;i<N-1;i++) {
		int u,v,p;
		if(scanf("%d%d%d",&u,&v,&p)!=3)return 1;
		*hen_next[u]=mareitaso(v,p);
		hen_next[u]=&(*hen_next[u])->next;
		*hen_next[v]=mareitaso(u,p);
		hen_next[v]=&(*hen_next[v])->next;
	}
	printf("%d\n",murakawarie(0,-1,-1));
	for(i=0;i<N;i++) {
		hen_t *kitamuraeri;
		for(kitamuraeri=hen[i];kitamuraeri!=NULL;) {
			hen_t *tiharaminori=kitamuraeri->next;
			free(kitamuraeri);
			kitamuraeri=tiharaminori;
		}
	}
	return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

string S;

lint dp[114514][13];

lint make_num(int now, int surplus){
    if(now == S.size()){
        return surplus == 5;
    }else if(dp[now][surplus] != -1){
        return dp[now][surplus];
    }
    if(S[now] == '?'){
        lint ans = 0;
        for(int i = 0; i <= 9; i++){
            ans += make_num(now + 1, (surplus * 10 + i) % 13);
        }
        return dp[now][surplus] = ans % mod;
    }else{
        return dp[now][surplus] = make_num(now + 1, (surplus * 10 + (S[now] - '0')) % 13);
    }
}

int main(){
    cin >> S;
    memset(dp, -1, sizeof(dp));
    cout << make_num(0, 0) << endl;
}


Measured memory_bytes: 19968
#include<bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
int n,l;
cin>>n>>l;
string a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
string result="";
for(int i=0;i<n;i++){
result+=a[i];
}
cout<<result;

  return 0;
} 

Measured memory_bytes: 256
#include <cstdio>

int zero[7] = {1,1,1,1,1,1,0};
int one[7] = {0,1,1,0,0,0,0};
int two[7] = {1,1,0,1,1,0,1};
int three[7] = {1,1,1,1,0,0,1};
int four[7] = {0,1,1,0,0,1,1};
int five[7] = {1,0,1,1,0,1,1};
int six[7] = {1,0,1,1,1,1,1};
int seven[7] = {1,1,1,0,0,1,0};
int eight[7] = {1,1,1,1,1,1,1};
int nine[7] = {1,1,1,1,0,1,1};

int main(){
	int n;
	while(scanf("%d",&n)){
		if(n == -1)break;
		int seg[7]={0,0,0,0,0,0,0};
		for(int i=0;i<n;++i){
			int a;
			scanf("%d",&a);
			if(a==0){
				for(int i=0;i<7;++i){
					if(zero[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=zero[6-i];
			}else if(a==1){
				for(int i=0;i<7;++i){
					if(one[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=one[6-i];
			}else if(a==2){
				for(int i=0;i<7;++i){
					if(two[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=two[6-i];
			}else if(a==3){
				for(int i=0;i<7;++i){
					if(three[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=three[6-i];
			}else if(a==4){
				for(int i=0;i<7;++i){
					if(four[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=four[6-i];
			}else if(a==5){
				for(int i=0;i<7;++i){
					if(five[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=five[6-i];
			}else if(a==6){
				for(int i=0;i<7;++i){
					if(six[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=six[6-i];
			}else if(a==7){
				for(int i=0;i<7;++i){
					if(seven[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=seven[6-i];
			}else if(a==8){
				for(int i=0;i<7;++i){
					if(eight[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=eight[6-i];
			}else if(a==9){
				for(int i=0;i<7;++i){
					if(nine[6-i]==seg[i])printf("%d",0);
					else printf("%d",1);
				}
				for(int i=0;i<7;++i)seg[i]=nine[6-i];
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 1032
#include <stdio.h>

int main(void)
{
	int a[3] = {0};
	int i;
	int j;
	int temp = 0;
	
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	
	for (i = 0; i < 2; i++)
	{
		for (j = 2; j > i; j--)
		{
			if (a[j - 1] > a[j])
			{
				temp = a[j - 1];
				a[j - 1] = a[j];
				a[j] = temp;
			}
		}
	}
	
	printf("%d %d %d\n", a[0], a[1], a[2]);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <string.h>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
   	int a, b;
	cin >> a >> b;
	if (b%a) {
		cout << b-a;
	} 
	else {
		cout << a+b;
	}
	return 0;
}


Measured memory_bytes: 256
from scipy.sparse.csgraph import dijkstra as di
from collections import deque

def dfs(graph, start, n):
    queue = deque()
    tmp = []
    visited = [0] * n
    queue.append(start)
    visited[start] = 1

    while queue:
        a = queue.popleft()
        for j in range(n):
            if not graph[a][j]:
                continue
            elif graph[a][j] and not visited[j]:
                queue.append(j)
                visited[j] = visited[a] + 1
            elif graph[a][j] and visited[j]:
                if abs(visited[a] - visited[j]) != 1:
                    # print(a, j, visited[a], visited[j], start, visited)
                    return False
    return True

n = int(input())
ad_lst = [list(map(int, input())) for _ in range(n)]
p_route = di(ad_lst)
ans = 0
mx = [0,0]
for i in range(n):
    for j in range(n):
        if p_route[mx[0]][mx[1]] < p_route[i][j]:
            mx = [i,j]
print(int(p_route[mx[0]][mx[1]] + 1) if dfs(ad_lst, mx[0], n) else -1)


Measured memory_bytes: 19740
IDENTIFICATION DIVISION.
PROGRAM-ID. Crackers.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP     PIC X(100).
01 IN-N     PIC 9(3).
01 IN-K     PIC 9(3).
01 MAISU    PIC 9(3).
01 AMARI    PIC 9(2).
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO IN-N IN-K.
 
  DIVIDE IN-N BY IN-K GIVING MAISU REMAINDER AMARI.

  IF (AMARI = 0)
    DISPLAY '0'
  ELSE
    DISPLAY '1'
  END-IF.
 
MAIN-EXIT.
  STOP RUN.

Measured memory_bytes: 384
x,y = map(int, input().split())
a = {1:300000 , 2:200000, 3: 100000}
ans =0
for i in range(1,4):
  if i == x:
    ans += a[i]
  if i == y:
    ans += a[i]
print(ans + (400000 if x == y and x == 1 else 0))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  
  ll k1,k2,k3,k4;
  k1=a*c;
  k2=a*d;
  k3=b*c;
  k4=b*d;
  
  cout<<max(max(k1,k2),max(k3,k4))<<endl;
  
  return 0;
}

Measured memory_bytes: 3620