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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{

    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END
using P = pair<int, int>;
struct edge
{
    int from, to, cost;
};

signed main()
{
    int V, E, r;     //vは頂点数,Eは辺数
    vector<edge> es; //辺
    cin >> V >> E >> r;
    bool cycle = false;
    int d[V]; //最短距離
    fill(d, d + V, INF);
    d[r] = 0;

    rep(i, 0, E)
    {
        edge add;
        cin >> add.from; //出発点
        cin >> add.to;   //到着点
        cin >> add.cost; //コスト
        es.emplace_back(add);
    }

    rep(i, 0, V)
    {
        rep(j, 0, es.size())
        {
            edge e = es[j];
            if (d[e.from] != INF)
            {
                if (chmin(d[e.to], d[e.from] + e.cost))
                {
                    if (i == V - 1)
                    {
                        cout << "NEGATIVE CYCLE\n";
                        return 0;
                    }
                }
            }
        }
    }

    rep(i, 0, V)
    {
        if (d[i] == INF)
        {
            cout << "INF\n";
        }
        else
        {
            cout << d[i] << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
const ll MAX_V = 310;

int main() {
    ll n;
    cin >> n;
    
    vvl A(MAX_V, vl(MAX_V));
    vvl dist(MAX_V, vl(MAX_V));
    rep(u, n) {
        rep(v, n) {
            cin >> A[u][v];
            dist[u][v] = A[u][v];
        }
    }
 
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
 
    ll ans = 0;
    rep(u, n-1) {
        exrep(v, u+1, n-1) {
            if(dist[u][v] < A[u][v]) {
                out(-1);
                re0;
            } 
            ll flag = 0;
            rep(w, n) {
                if(w != u && w != v && dist[u][v] == dist[u][w] + dist[w][v]) {
                    flag = 1;
                }
            }
            if(!flag) {
                ans += dist[u][v];
            }
        }
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 1792
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .chars()
        .map(|x| x.to_string().parse::<i32>().unwrap())
        .collect::<Vec<_>>();
    // 総当たり
    for i in 0..1 << 4 {
        let ap = i & 0b1000 == 0;
        let bp = i & 0b0100 == 0;
        let cp = i & 0b0010 == 0;
        let dp = i & 0b0001 == 0;

        let a = if ap { list[0] } else { -list[0] };
        let b = if bp { list[1] } else { -list[1] };
        let c = if cp { list[2] } else { -list[2] };
        let d = if dp { list[3] } else { -list[3] };

        if a + b + c + d == 7 && ap {
            return format!(
                "{}{}{}{}{}{}{}=7",
                list[0],
                if bp { "+" } else { "-" },
                list[1],
                if cp { "+" } else { "-" },
                list[2],
                if dp { "+" } else { "-" },
                list[3]
            ).to_string();
        }
    }
    panic!("");
}

#[test]
fn test() {
    let tests = vec![("1222", "1+2+2+2=7"), ("0290", "0-2+9+0=7")];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>
 
using namespace std;
 
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"
 
typedef long long int  ll;
 
 
int main()
{
//	FAST;
	int n;
	cin >> n;
	int arr[100005];
 
	for(int i=1 ; i<=n ; i++)
		cin >> arr[i];
 
 
	int count = 0;
	int current = 1;
	while(count < n)
	{
		current = arr[current];
		if(current == 2)
		{
			cout << count+1;
			return 0;
		} 
		count++;
	}
	cout << "-1";
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int D = Integer.parseInt(st.nextToken());
        int T = Integer.parseInt(st.nextToken());
        int S = Integer.parseInt(st.nextToken());

        if(D <= T*S) {
            pw.println("Yes");
        } else {
            pw.println("No");
        }

        br.close();
        pw.close();
    }
}

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

void solve()
{
    string s;
    int n,w=0,r=0,ans=0 ;
    cin >> n >> s;
    for(int i=0 ; i<n ; i++){
        if(s[i]=='W')
        {
            w++;
        }
        else
        {
            r++;
        }
    } 
    if(r==0 || w==0){ cout << 0 << "\n" ; return;}
    for(int i=0 ; i<r ; i++){
          if(s[i]=='W') ans++;
    } 
 
    cout << ans << endl;
}

int main()
{
  int t=1;
  //cin >> t;
  while(t--)
    solve();
    return 0 ;
}
  

Measured memory_bytes: 3752
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, L;
    cin >> n >> L;
    
    string s[n];
    for (int i = 0; i < n; ++i) cin >> s[i];
    sort(s, s + n);
    
    for (int i = 0; i < n; ++i) cout << s[i];
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        if (x == 7 || x == 5 || x == 3) {
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}

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

using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	std::string s;

	std::cin >> s;

	char ch = s[0];
	u32 cnt = 0;

	std::vector<std::pair<u32, char>> v;
	v.reserve(s.size());

	for(u32 i=0; i<s.size(); i++)
	{
		if(s[i] == ch)
		{
			cnt++;
		}
		else
		{
			v.emplace_back(cnt, ch);
			ch = s[i];
			cnt = 1;
		}
	}

	v.emplace_back(cnt, ch);
 	u64 sum = 0;

	for(i64 i=0; i<i64(v.size()); i++)
	{
		auto c = v[i].second;
		long double num = v[i].first;

		u64 x = 0;
		if(c == '>')
		{
			if(i-1 >= 0 && num < v[i-1].first)
			{
				x = (num-1.f)/2 * (num);
			}
			else
			{
				x = num/2 * (num+1);
			}
		}
		else if(c == '<')
		{
			if(i+1 < i64(v.size()) && v[i+1].first >= num)
			{
				x = (num-1.f)/2 * (num);
			}
			else
			{
				x = num/2 * (num+1);
			}
		}

		std::clog << c << " : " << num << " x=" << x << "\n";
		sum += x;
	}

	std::cout << sum << "\n";
	
	return 0;
}

Measured memory_bytes: 4508
# ARC061A

import itertools

s = list(input())
n = len(s)
bin = list(itertools.product(['', '+'''], repeat=n - 1))
count = 0
for i in bin:
    t = []
    for j in range(n-1):
        t.append(s[j])
        t.append(i[j])
    t.append(s[-1])
    formula = ''.join(t)
    # print(t)
    count += eval(formula)
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll s=0;
  for (ll i=1; i<=N; i++) {
    if (i%3 == 0 || i%5 == 0) {
    }
      else {
       s = s+i;
      }
  }
  cout << s << endl;
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
   long long n1, n2, i, gcd, lcm;
  cin>>n1>>n2;
    gcd=__gcd(n1, n2) ;
    lcm = (n1 * n2) / gcd;
    cout<<lcm<<endl;
cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int data[11][500];

void make(int sum, int checked, int rev){
  data[rev][sum]++;
  for(int i = 0; i < 10; i++){
    if(!(checked & (1<<i))){
      make(sum+(rev+1)*i,checked+(1<<i),rev+1);
    }
  }
}
int main(){

  memset(data,0,sizeof(data));
  make(0,0,0);
  fill(data[0],data[0]+500,0);
  int n,s;
  while(cin >> n >> s){
    if(s >= 500 || n > 10) cout << "0" << endl;
    else cout << data[n][s] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
s = 0
l = [0 for i in range(n)]
l[0] = a[0]
for i in range(1, n):
    l[i] += l[i-1]
    l[i]%=mod
    l[i] += a[i]
    l[i]%=mod
# print(l)
for i in range(1, n):
    s+=((a[i]%mod)*(l[i-1]%mod))%mod
    s%=mod
print(s)
    

Measured memory_bytes: 31644
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  Int s;cin >> s;
  Int a[1000000] = {0};
  Int x = s;
  Int i = 1;
  a[x-1] = i;
  Int ans=0;
  bool flag = false;
  while(1){
    if(flag) break;
    i++;
    if(x%2==0){
      x/=2;
      if(a[x-1]==0) a[x-1] = i;
      else{
        ans = i;
        flag = true;
      }
    }
    else if(x%2==1){
      x=3*x+1;
      if(a[x-1]==0) a[x-1] = i;
      else{
        ans = i;
        flag = true;
      }
    }
    if(flag) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <functional>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<int> d1(n), d2(n);
	for(int i = 0; i < n; ++i) {
		cin >> d1[i] >> d2[i];
	}
	
	int cnt = 0;
	
	for(int i = 0; i < n; ++i) {
		if( d1[i] == d2[i] ) {
			cnt++;
		} else {
			cnt = 0;
		}
		
		if( cnt == 3 ) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#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 fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n, k;
    cin >> n >> k;
    vi x(n + 1);

    fo(i, n) cin >> x[i + 1];

    int covered = 0;

    fo(i, n) {
        covered += min(2 * abs(x[i + 1]), 2 * abs(x[i + 1] - k));
    }

    cout << covered << endl;

    return 0;
}

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

int main(){
  string s; cin >> s;
  rep(i,(int)s.size()){
    if(s[i]==',') cout << " ";
    else cout << s[i];
  }
  cout << endl;
  return 0;
}


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

int main() {
  int N, N1000, N100, N10, N1;
  cin >> N ;
  N1000 = N / 1000;
  N100 = (N % 1000)/100;
  N10 = (N % 100) / 10;
  N1 = N % 10;
  
  if (N1000 != N100){
    if(N100 == N10 && N10 == N1){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
  else if (N100 != N10){
    cout << "No" << endl;
  }
  else if(N1000 == N100 && N100 == N10){
      cout << "Yes" << endl;
  }
      else cout << "No" << endl;
  
  // ここにプログラムを追記
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:
#define error(args...) { vector<string> _debug = split(#args, ',');err(begin(_debug), args);}

vector<string> split(const string& s, char c){
	vector<string> v;stringstream ss(s);string x;
	while (getline(ss, x, c)) v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {cerr << endl;}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a,Args... args){
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " ",err(++it, args...);
}

ll n, mod;
ll power(ll a, ll idx){
	ll b = 1LL;
	while(idx){
		if(idx & 1) b = b * a % mod;
		a = a * a % mod;
		idx >>= 1;
	}
	return b;
}

const int limit = 2010;
ll C[limit][limit];
ll P[limit][limit];

void init(){
	rep(i,limit)rep(j,i+1){
		if(j == 0 or j == i)
			C[i][j] = 1LL;
		else
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	}
}


int main(void){
	cin >> n >> mod;
	init();
	
	ll ans = 0LL;	
	rep(i, n + 1){
		const int ni = n - i;
		ll cur = 0LL;
		rep(j, i + 1){
			const ll tmp = (power(2LL, j) + mod - 1) % mod;
			const ll unit = power(tmp, ni) % mod;
			const ll val = C[i][j] * unit % mod;
			if((i - j) % 2 == 1)
				cur = (cur + mod - val) % mod;
			else
				cur = (cur + val) % mod;	
		}

		cur = cur * C[n][i] % mod;
		cur = cur * power(2LL, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2) % mod;
		ans = (ans + cur) % mod;
	}

	cout << ans << endl;
	
	
	return 0;
}


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

long long g(long long n) {
	return (n % 2 ? n - 1 : 0) ^ (n % 4 / 2);
}

int main() {
	long long a, b;
	cin >> a >> b;
	cout << (g(b + 1) ^ g(a)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

vector<ll> fact(200010), invfact(200010);

ll extgcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll g = extgcd(b, a%b, x, y);
    ll nextx = y, nexty = x-(a/b)*y;
    x = nextx, y = nexty;
    return g;
}

ll nCr(int n, int r) {
    ll ret = fact[n];
    ret = ret * invfact[n-r] % MOD;
    ret = ret * invfact[r] % MOD;
    return ret;
}

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;
    fact[0] = 1;
    for (int i = 1; i <=200000; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }
    for (int i = 0; i <=200000; i++) {
        ll x, y;
        ll g = extgcd(fact[i], MOD, x, y);
        while (x < 0) x += MOD;
        x %= MOD;
        invfact[i] = x;
    }
    ll ans = 0;
    for (int i = B; i < W; i++) {
        ll tmp = nCr((H-A-1)+i, H-A-1);
        tmp = tmp * nCr((A-1)+(W-i-1), A-1) % MOD;
        ans = (ans + tmp) % MOD;
    }
    
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
import java.util.*;
class Main{
  public static void main(String[] a ){
    Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int t=sc.nextInt();
int ci;
int ti;
int ans=10000;
for(int i=0;i<n;i++){
ci=sc.nextInt();
ti=sc.nextInt();
if(ti<=t){
ans=Math.min(ans,ci);
}}
System.out.println(ans==10000?"TLE":ans);
}}

Measured memory_bytes: 22740
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



int main(){
 
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll a;
    if(d <= x) {
        a = x/d;
        k -= a;
        ll ans = x;
        ans -= a*d;
        if(k < 0){
            ll t = abs(k) * d;
            ans += t;
            cout << ans << endl;
            return 0;
        }
        if(k == 0 || k%2 == 0){
            cout << ans << endl;
            return 0;
        }else{
            ll temp = d-ans;
            cout << temp << endl;
            return 0;
        }

    }else{
        if(k%2 == 0){
            cout << x << endl;
        }else{
            cout << d-x << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3188
from heapq import heappush, heappushpop

N, M = map(int, input().split())
tasks = [[] for _ in range(M+1)]
for _ in range(N):
  a, b = map(int, input().split())
  if a <= M:
    tasks[M-a].append(b)

q = []
for day in range(M+1):
  for v in tasks[day]:
    if len(q) < day+1:
      heappush(q, v)
    else:
      heappushpop(q,v)
print(sum(q))      

Measured memory_bytes: 18412
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

const int maxn = 200000;
int f[maxn + 1], fi[maxn + 1];
int ncr(int n, int r) { return mul(f[n], mul(fi[r], fi[n - r])); }

void precompute()
{
    f[0] = 1;
    for (int i = 1; i <= maxn; ++i)
        f[i] = mul(f[i - 1], i);

    fi[maxn] = inv(f[maxn]);
    for (int i = maxn - 1; i >= 0; --i)
        fi[i] = mul(fi[i + 1], i + 1);
}

int g(int a, int b)
{
    return ncr(a + b - 2, a - 1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    precompute();
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int sol = sub(g(w, h), mul(g(h - a + 1, b), g(a, w - b + 1)));
    for (int i = 0; i < b - 1; ++i)
        subs(sol, mul(g(h - a + 1, i + 1), g(a - 1, w - i)));
    cout << sol;
}


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

int main()
{
  int H, N, dmg, sum = 0;

  cin >> H >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> dmg;
    sum += dmg;
  }

  cout << (sum >= H ? "Yes" : "No") << endl;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

string cv[60];

string wall(60, '.');

int main(void)
{
    int H, W;
    string s;

    cin >> H >> W;
    REP1(i, H) {
        cin >> s;
        cv[i] = "." + s + ".";
    }
    cv[0] = wall;
    cv[H+1] = wall;

    REP1(i, H) {
        REP1(j, W) {
            if(cv[i][j] == '#' 
                && cv[i - 1][j] == '.'
                && cv[i + 1][j] == '.'
                && cv[i][j - 1] == '.'
                && cv[i][j + 1] == '.') { 
//                cout << "i:" << i << " j:" << j << endl;
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
string S="MARCH";
char D[100001]={};
ll C[5]={};
int main() {

	cin>>N;
	ll Total=0;
	for(int i=0;i<N;i++){
		string str;
		cin>>str;
		for(int j=0;j<5;j++){
			if(str[0]==S[j])C[j]++;
		}
	}

	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				Total+=C[i]*C[j]*C[k];
			}
		}
	}
	cout<<Total<<endl;
 	return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
l = []
sum = abs(a-b) + abs(b-c)
l.append(sum)
sum = abs(a-c) + abs(c-b)
l.append(sum)
sum = abs(b-a) + abs(a-c)
l.append(sum)
sum = abs(b-c) + abs(c-a)
l.append(sum)
sum = abs(c-b) + abs(b-a)
l.append(sum)
sum = abs(c-a) + abs(a-b)
print(min(l))

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

int main() {
  int n,c=0,x=0,mm=0;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n;i++)
  {
    if(s[i]=='I')
    {
         x++;
    }
    mm=max(mm,x);
    if(s[i]=='D')
    {
      x--;
    }
  }

  
  cout<<mm<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 107
using namespace std;
int n,b[maxn],a[maxn],score;

template<typename type_of_scan>
inline void scan(type_of_scan &x){
	type_of_scan f=1;x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	x*=f;
}
template<typename Tops,typename... tops>
inline void scan(Tops &x,tops&... X){
	scan(x),scan(X...);
}

int main(){
	memset(a,127,sizeof(a));
	scan(n);
	for(int i=1;i<=n-1;i++){
		scan(b[i]),a[i]=min(a[i],b[i]);
		a[i+1]=min(a[i+1],b[i]);
		score+=a[i];
	}
	printf("%d\n",score+b[n-1]);
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
bool DEBUG = 0; void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void main(string[] args){ args ~= ["", ""]; string cmd = args[1]; if(cmd == "-debug") DEBUG = 1;
if(cmd == "-gen") gen; else if(cmd == "-jury") jury; else solve; } 
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ std.stdio.write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
void gen(){
}
void jury(){
}
void solve(){
    long a = scan!int, b = scan!int, c = scan!int, d = scan!int;
    long ans = max(a * c, a * d, b * c, b * d);

    ans.print;
}

Measured memory_bytes: 3288
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include <map>

using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)


int main(){
  long long n;
  cin >> n;
  long long res = 0;
  res += (n/500)*1000;
  n = n-n/500*500;
  res += (n/5)*5;
  cout << res << endl;;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# abc110 c

S = input().rstrip()
T = input().rstrip()
sm = {}

for i in range(len(S)):
    if S[i] in sm:
        sm[S[i]] = sm[S[i]] + 1
    else:
        sm[S[i]] = 1

st = {}
for i in range(len(T)):
    if T[i] in st:
        st[T[i]] = st[T[i]] + 1
    else:
        st[T[i]] = 1

sl = list(sm.values())
tl = list(st.values())
sl.sort()
tl.sort()

print('Yes' if sl == tl else 'No')


Measured memory_bytes: 3632
N,W = map(int,input().split())
weight = []
value = []
for i in range(N):
    w,v = map(int,input().split())
    weight.append(w)
    value.append(v)
dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1,N+1):
    for j in range(1,W+1):
        op1,op2 = 0,0
        if weight[i-1] <= j:
            op1 = value[i-1] + dp[i-1][j-weight[i-1]]
        op2 = dp[i-1][j]
        dp[i][j] = max(op1,op2)
print(dp[N][W])

Measured memory_bytes: 171784
from sys import stdin
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
while len(li) > 1:
    a = li[0] + li[1]
    li.pop(0)
    li.pop(0)
    b = a/2
    li.insert(0,b)
print(li[0])


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();

		Edge[] edge = new Edge[n];
		for(int i = 0;i < n;i++){				//頂点の作成と、一個前に戻る辺の作成
			edge[i] = new Edge();
			if(i != 0){
				edge[i].add(new P(i-1, 0));
			}
		}

		for(int i = 0;i < m;i++){
			int l = sc.nextInt()-1, r = sc.nextInt()-1,c = sc.nextInt();
			edge[l].add(new P(r, c));
		}
		System.out.println(dijkstra(edge,n));

	}


	static long dijkstra(Edge[] edge,int n){

		long[] d = new long[n];		//始点からの最短距離
		Arrays.fill(d, 1l << 60);
		d[0] = 0;
		PriorityQueue<P> q = new PriorityQueue<>(Comparator.comparingLong(p-> p.cost));			//costをソート
		q.add(new P(0,0));

		while(!q.isEmpty()){
			P current = q.remove();
			if(current.to == n-1){
				return current.cost;
			}
			if(current.cost != d[current.to]){
				continue;
			}
			for(P next: edge[current.to]){
				if(d[next.to] > current.cost + next.cost){
					d[next.to] = current.cost + next.cost;
					q.add(new P(next.to, current.cost+next.cost));
				}
			}


		}
		return -1;



	}



	static int upperbond(int k,int currentindex, ArrayList<Pair> a,ArrayList<Pair> b,int[] aa,int[] bb){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = a.size();

		while(max-min > 1){
			int mid = (max+min)/2;
			if(a.get(mid).from > k){
				max = mid;
			}else{
				min = mid;
			}
		}

		if(max == a.size()){
			max--;
		}
		for(int i = max; i>=0;i--){
			if(a.get(i).from <= bb[currentindex] && aa[currentindex] <= bb[a.get(i).end]){
				int tmp = a.get(i).end;
				a.get(i).end = a.get(currentindex).end;
				a.get(currentindex).end = tmp;

				return tmp;
			}
		}

		return -1;
	}

	static int lowerbond(int k, ArrayList<Integer> data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = data.size();

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data.get(mid) >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return data.get(min);
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






Measured memory_bytes: 109884
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, K, Q, A; cin >> N >> K >> Q;
  vector<int> P(N, K - Q); while (cin >> A) ++P[--A];
  for (int p : P) puts(p > 0 ? "Yes" : "No");}

Measured memory_bytes: 3776
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.endl(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  ll n;
  cin >> n;
  vecll a(n);
  vecll b(61, 0);
  REPe(e, a) {
    cin >> e;
    REP(bit, 61) {
      if ((e >> bit) & 1) {
        b[bit]++;
      }
    }
  }
  vecll powmod(61, 0);
  powmod[0] = 1LL;
  REP(i, 60) { powmod[i + 1] = powmod[i] * 2LL % MOD; }
  ll ans = 0;
  REP(i, 61) {
    ans += (powmod[i] * b[i] % MOD) * (n - b[i]) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int main()
{
 int N,M,X,Y;
 cin >> N >> M >> X >> Y;
 int Z=X+1;
 int x[N],y[M];
 int i;
 for(i=0;i<N;++i){
	cin >> x[i];
	if(x[i]>Z) Z=x[i]+1;
 }
 for(i=0;i<M;++i){
	cin >> y[i];
 	if(Z>y[i]){
		cout << "War" <<endl;
		return 0;
	}
 }
 if(Z>Y){
	cout << "War" <<endl;
 	return 0;
 }
 cout << "No War" << endl;
 return 0;
}
 
 


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007
#define NMAX 200000

signed main(){   
    int X,Y;
    cin>>X>>Y;

    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int x=i+j;
            int y=i*2+j*4;
            if(x==X&&y==Y){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  ll N,K;
  cin >> N >> K;
  if(K==1){
    cout << "0" << endl;
  }else if(K==2&&!(N%2)){
    cout << "0" << endl;
  }else{
    ll t = N%K;
    if(t<abs(t-K)){
      cout << t << endl;
    }else{
      cout << abs(t-K) << endl;
    }
  }
}


Measured memory_bytes: 256
N = int(input())

T = 0
X = 0
Y = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if (t - T) < abs(x-X) + abs(y-Y) or ((t - T) + abs(x-X) + abs(y-Y))%2 == 1:
        print("No")
        break
    T = t
    X = x
    Y = y
else:
    print("Yes")

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
int main() {
	char t[5]="",h[5]="";
	int hit,blow,i,j;
	for (; ~fscanf(stdin, "%s %s", t, h),(t[0]!='0'||h[0]!='0'); fprintf(stdout, "%d %d\n", hit, blow)) {
		hit = blow = 0;
		for (i = 0; i < 4; i++) if (t[i] == h[i]) hit++;
		for (i = 0; i < 4; i++)
			for (j = 0; j < 4; j++)
				if (t[i] == h[j]) blow++;
		memset(t, '\0', sizeof(t));
		memset(h, '\0', sizeof(h));
		blow -= hit;
	}
	return 0;
}

Measured memory_bytes: 544
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        //スタックサイズ2^24で処理を行う
        new Thread(null, () -> {
            int n;
            int k;
            List<Integer> as = new ArrayList<>();

            //try-with-resources文(カッコ内で宣言した変数はtry句を抜けると自動的に閉じられる)
            try (Scanner sc = new Scanner(System.in)) {
                n = sc.nextInt();
                k = sc.nextInt();
                for (int i = 0; i < n; i++) {
                    as.add(sc.nextInt() - 1);
                }
            }
            System.out.println(new Calculator(n, k, as).calculate());
        }, "", 1 << 24).start();
    }
}

/**
 * 計算クラス
 */
class Calculator {
    /**
     * 整数K
     */
    private int k;

    /**
     * 転送先を変えなければならないテレポータの数
     */
    private int answer = 0;

    /**
     * 計算済みかどうか
     */
    private boolean isCalculate = false;

    /**
     * ある町へ転送するテレポータが設置されている町のリスト
     */
    private List<List<Integer>> lists = new ArrayList<>();

    /**
     * コンストラクタ
     *
     * @param n  町の数
     * @param k  整数K
     * @param as 各町のテレポータの転送先リスト
     */
    Calculator(int n, int k, List<Integer> as) {
        this.k = k;
        for (int i = 0; i < n; i++) {
            this.lists.add(new ArrayList<>());
        }
        for (int i = 0; i < n; i++) {
            int j = as.get(i);
            if (0 < i) {
                this.lists.get(j).add(i);
            } else if (0 < j) {
                this.answer++;
            }
        }
    }

    /**
     * 転送先を変えなければならないテレポータの数を求める
     *
     * @return 転送先を変えなければならないテレポータの数
     */
    int calculate() {
        if (!this.isCalculate) {
            this.dfs(0, 0);
            this.isCalculate = true;
        }
        return this.answer;
    }

    /**
     * 転送回数を算出する
     *
     * @param a   着目する町
     * @param pre 1つ前の町
     * @return 転送回数
     */
    private int dfs(int a, int pre) {
        int h = 0;
        for (int i : this.lists.get(a)) {
            h = Math.max(h, this.dfs(i, a));
        }
        if (0 < pre && h == this.k - 1) {
            h = 0;
            this.answer++;
        } else {
            h++;
        }
        return h;
    }
}

Measured memory_bytes: 46852
#include <stdio.h>
#include <string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if (ch =='A') return 1;
	else if (ch =='C') return 2;
	else if (ch =='G') return 3;
	else if (ch =='T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum=0, p = 1, i;
	for (i=0;i < strlen(str); i++){
		sum += p*(getChar(str[i]));
		p *=5;
	}
	return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M-1));}

int find(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h],str)==0) return 1;
		else if ( strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;

		if (strcmp(H[h],str)==0){}
		else if ( strlen(H[h]) == 0) {
		  strcpy(H[h],str);
		  return 0;
	}
	}
	return 0;
}

int main(){
	int i,n,h;
	char str[L],com[9];
	for(i=0;i<M;i++) H[i][0]='\0';
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",com,str);
		if (com[0] == 'i'){
			insert(str);
		}else{
			if (find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
}

Measured memory_bytes: 17056
program string_equivalence
  integer :: n
  character(10) :: s = ""
  read(*,*) n
  call dfs(1,0)
contains
  recursive subroutine dfs(i,v)
    integer, intent(in) :: i, v
    integer :: j
    do j = 1, v+1
      s(i:i) = achar(j+96)
      if (i == n) then
        write(*,'(a)') trim(s)
      else
        call dfs(i+1,max(v,j))
      end if
    end do
  end
end program string_equivalence

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

int main(void){
int a[6],i,j;
  char A[4]= {"Yay!"};
  
  for(i=0;i<6;i++){
  	scanf("%d",&a[i]);
  }  
    for(i=0;i<6;i++){
        for(j=0;j<6;j++){
          if((a[j]-a[i])>a[5]){
          	strcpy(A,":(");
          }
        }
    }
  printf("%s\n",A);
}

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

int n, t, br=0, tr=0, x;

int main() {
    cin >> n >> t;
    for (int i=0; i<n; i++) {
        cin >> x;
        if (x > tr) {
            br += x-tr;
        }
        tr = x+t;
    }
    cout << tr-br;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int INF = 1000000000;

int f(vector <int> &memo, vector <vector<int>> &c, vector <int> &seen, int n);

int main(){
    int h, w; cin >> h >> w;
    vector <vector<int>> c(10);
    
    rep(i, 10){
        rep(j, 10){
            int _c; cin >> _c;
            c.at(i).push_back(_c);
        }
    }

    vector <vector<int>> A(h);

    rep(i, h){
        rep(j, w){
            int a; cin >> a;
            A.at(i).push_back(a);
        }
    }

    rep(k, 10){ //k = 間に挟むやつ　（ワーシャルフロイド法）
        rep(i, 10){
            rep(j, 10){
                c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(k) + c.at(k).at(j));
            }
        }
    }

    ll ans = 0;
    for(auto l_a: A){
        for(auto num: l_a){
            if(num != -1) ans += c.at(num).at(1);
        }
    }

    cout << ans << endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    vl a(n);
    NREP() {
        cin >> a[i];
    }

    sort(ALL(a));
    MSG(a[n-1] - a[0])
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))

dic = {}
for i in range(1, len(s)+1):
    dic[i] = s[i-1]

result = sorted(dic.items(), key=lambda x: x[1])
result = [str(d[0]) for d in result]
print(' '.join(result))


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


int main(){
	string s;
	cin >> s;
	if(s[5] == '1'){
		cout << "TBD" << endl;
	}
	else if(s[6] - '0' > 4){
		cout << "TBD" << endl;
	}
	else{
		cout << "Heisei" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = float('inf')
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    H,W,K = LI()
    x1,y1,x2,y2 = _LI()

    p = [SI() for _ in range(H)]

    d = [[INF] * W for _ in range(H)]
    d[x1][y1] = 0

    q = []
    q.append((0,x1,y1))
    while q:
        m,x,y =  heapq.heappop(q)
        if d[x][y] < m: continue
        for dx,dy in DD:
            for n in range(1,K+1):
                nx = x + dx * n
                ny = y + dy * n
                if not(0<=nx<H and 0<=ny<W): break
                if p[nx][ny] == '@': break
                if d[nx][ny] < m + 1: break
                if d[nx][ny] == m + 1: continue
                d[nx][ny] = m + 1
                q.append((m+1,nx,ny))
    if d[x2][y2] < INF:
        print(d[x2][y2])
    else:
        print(-1)



if __name__ == '__main__':
    main()

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

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int 			long long int
#define pll 			pair<ll , ll>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) {
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) {
	return mod_pow(a , mod-2);
}

void solve() {
    
    int n;
    
    string s;
    
    cin >> n;
    int c0  = 0;
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    
    
    for(int i = 0; i< n;++i) {
    	cin >> s;
    	
    	if(s[0] == 'A') {
    		c0++;
    	}
    	else if(s[0] == 'W') {
    		c1++;
    	}
    	else if(s[0] == 'T') {
    		c2++;
    	}
    	else {
    		c3++;
    	}
    }
    
    cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
    
}       

signed main() {
    fast;
    
    int t = 1;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
 
int main(){
 	 
  int a[3];
  int sum=0;
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  sum += a[2]-a[1];
  sum += a[1]-a[0];
  cout << sum << endl;
}

Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let n=nin()
  out(n*n*n)
}
main()


Measured memory_bytes: 7372