akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

struct NENDAI {
    string name;
    int start;
    int end;

    NENDAI(){}
    NENDAI(string name0, int base, int west) {
        name = name0;
        start = west - base + 1;
        end = west;
    }
};

int main(void) {
    while (1) {
        int n;
        int q;
        cin >> n >> q;
        if (n == 0 && q == 0) {
            break;
        }
        Vec<NENDAI> list(n);
        for (int i = 0; i < n; i++) {
            string name;
            int base;
            int west;
            cin >> name >> base >> west;
            NENDAI nendai(name, base, west);
            list[i] = nendai;
        }
        for (int i = 0; i < q; i++) {
            int toi;
            cin >> toi;
            bool found = false;
            for (int j = 0; j < n; j++) {
                if (toi >= list[j].start && toi <= list[j].end) {
                    cout << list[j].name << " " << toi - list[j].start + 1 <<endl;
                    found = true;
                    break;
                }
            }
            if (found == false) {
                cout << "Unknown" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3192
input_data=input()
 
a=input_data[0]
b=input_data[1]
c=input_data[2]
d=input_data[3]
 
if a==b :
    if c==d and a!=c :
            output="Yes"
    else :
        output="No"
    
else :
        if a==c and b==d :
            output="Yes"
    
        elif a==d and b==c :
            output="Yes"
        
        else :
            output="No"
           
print(output)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N,K; cin>>N>>K;
	int A[N];
	rep(i,0,N) cin>>A[i];
	long dp[N+1][K+1] = {}; dp[0][0] = 1;
	rep(i,0,N){
		long res = 0;
		rep(j,0,A[i]){
			(res += dp[i][j]) %= mod;
			dp[i+1][j] = res;
		}
		rep(j,A[i],K+1){
			(res += dp[i][j]) %= mod;
			dp[i+1][j] = res;
            (res += mod - dp[i][j-A[i]]) %= mod;
		}
	}cout<<dp[N][K]<<endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include  <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
#define endl '\n'
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> index_set;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using ii = pair<int,int>;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mod 1000000007
const int maxn = 1e5+10;
const int dod=(int)9e14;
const int e  = (int)2e64;

int main(){
    string s, t;
    cin >> s >> t;
    int ans = INT_MIN;
    for(int i = 0; i<(sz(s)+1) - sz(t); i++){
			int count = 0;
			for(int j = 0; j<sz(t); j++){
				if(s[i+j] == t[j])
					count++;
			}
			ans = max(ans, count);
		}
		cout << sz(t) -ans<< endl;
 
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(3*n);
  ll ans = 0;
  for(int i=0;i<3*n;i++) cin >> a[i];
  sort(a.begin(), a.end(), greater<ll>());
  for(int i=0;i<n;i++)ans += a[2*i+1];
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main(){
	int N, A, B, C;
	scanf("%d %d %d %d", &N, &A, &B, &C);
	int l[N];
	for (int i = 0; i < N; ++i) scanf("%d", l + i);
	int answer = 3000;
	for (int i = 0; i < 1 << 2*N; ++i){
		vector<int> rest;
		int synthesize[3] = {0, 0, 0};
		bool is_first[3] = {true, true, true};
		int cost = 0;
		for (int j = 0; j < N; ++j){
			int shozoku = (i >> 2*j) & 3;
			if(shozoku){
				shozoku--;
				if(!is_first[shozoku]) cost += 10;
				else is_first[shozoku] = false;
				synthesize[shozoku] += l[j];
			}
			else rest.push_back(l[j]);
		}
		vector<int> after_synthesizing;
		for (int j = 0; j < 3; ++j) if(synthesize[j]) after_synthesizing.push_back(synthesize[j]);
		for (int j = 0; j < rest.size(); ++j) after_synthesizing.push_back(rest[j]);
		sort(after_synthesizing.begin(), after_synthesizing.end());
		if(after_synthesizing.size() >= 3){
			for (int j = 0; j < after_synthesizing.size() - 2; ++j){
				for (int k = j + 1; k < after_synthesizing.size() - 1; ++k){
					for (int l = k + 1; l < after_synthesizing.size(); ++l){
						int cost_ = cost + abs(after_synthesizing[j] - C) + abs(after_synthesizing[k] - B) + abs(after_synthesizing[l] - A);
						if(answer > cost_) answer = cost_;
					}
				}
			}
		}
	}
	printf("%d\n", answer);
	return 0;
}

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

bool judge(int n, vector<vector<bool>> s, vector<int> p, int N, int M){
    vector<bool> onSwitch(N, false);
    for(int i=0; i<N; i++, n/=2){
        if(n%2==0) continue;
        onSwitch[i] = true;
    }

    vector<int> cnt(M, 0);
    for(int i=0; i<M; i++){
        for(int j=0; j<N; j++){
            if(onSwitch[j] && s[i][j]) cnt[i]++;
        }
        if(cnt[i]%2 != p[i]) return false;
    }
    return true;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> s(M, vector<bool>(N, false));
    for(int i=0; i<M; i++){
        int k;  cin >> k;
        for(int j=0; j<k; j++){
            int v;  cin >> v;
            s[i][--v] = true;
        }
    }
    vector<int> p(M,0);
    for(int i=0; i<M; i++){
        cin >> p[i];
    }

    int ans = 0;
    for(int i=0; i<(1<<N); i++){
        if(judge(i, s, p, N, M)) ans++;
    }
    cout << ans << endl;
}


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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split(' ');
            var N = r[0].ToInt();
            var dic = new Dictionary<string, int>();
            var max = 0;
            var S = new string[N];
            for (int i = 0; i < N; i++)
            {
                S[i] = Console.ReadLine();
            }
            for (int i = 0; i < N; i++)
            {
                var j = 0;
                dic[S[i]] = dic.TryGetValue(S[i], out j) ? j + 1 : 1;
                max = Math.Max(max, dic[S[i]]);
            }
            var list = new List<string>();
            foreach (var p in dic)
            {
                if (p.Value == max) list.Add(p.Key);
            }
            var array = list.ToArray();

            // Array.Sort(array, cmp);
            Array.Sort(array, StringComparer.OrdinalIgnoreCase);

            foreach (var a in array)
            {
                Console.WriteLine(a);
            }
            Console.ReadLine();
        }
    }
}

public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 46012
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  string S;
  cin >> S;
  if (S == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}



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

typedef pair<int, int> pii;
vector<pii> vs;

void preorder(int i)
{
  cout << " " << i;
  if (vs[i].first != -1)
    preorder(vs[i].first);
  if (vs[i].second != -1)
    preorder(vs[i].second);
}

void inorder(int i)
{
  if (vs[i].first != -1)
    inorder(vs[i].first);
  cout << " " << i;
  if (vs[i].second != -1)
    inorder(vs[i].second);
}

void postorder(int i)
{
  if (vs[i].first != -1)
    postorder(vs[i].first);
  if (vs[i].second != -1)
    postorder(vs[i].second);
  cout << " " << i;
}

int calc_root()
{
  int n = vs.size();
  vector<bool> done = vector<bool>(n, false);
  for (pii p : vs) {
    if (p.first != -1)  done[p.first] = true;
    if (p.second != -1) done[p.second] = true;
  }
  for (int i = 0; i < n; i++)
    if (!done[i])
      return i;
}

int main()
{
  int n; cin >> n;
  vs = vector<pii>(n);
  while (n--) {
    int id, l, r; cin >> id >> l >> r;
    vs[id] = make_pair(l, r);
  }

  int root = calc_root();

  cout << "Preorder" << endl;
  preorder(root); cout << endl;
  cout << "Inorder" << endl;
  inorder(root); cout << endl;
  cout << "Postorder" << endl;
  postorder(root); cout << endl;

  return EXIT_SUCCESS;
}



Measured memory_bytes: 3100
import sys
def main():
  a ,b ,c ,k = list(map(int,input().split()))
  if k > a:
    ans = a*1
    k-= a
  else:
    ans = (k)*1
    k = 0
#  print('a',k,ans)
  if k > b:
    k-= b
  else:
    k = 0
#  print('b',k,ans)
  if k > c and k>0:
    ans += (c)*-1
  else:
    ans += (k)*-1
    
  print(ans)   
#  print(k,ans)   
 
  
if __name__ == '__main__':
  main()


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

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    string a, b;
    cin >> a >> b;

    map<char,char> x, y;
    bool ans = true;
    for(int i = 0 ;i < a.size(); i++){
        if(x.count(a[i]) and x[a[i]] != b[i])ans = false;
        if(y.count(b[i]) and y[b[i]] != a[i])ans = false;
        x[a[i]] = b[i];
        y[b[i]] = a[i];
    }
    if(ans)cout << "Yes";
    else cout << "No";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 916
import std.stdio,
    std.array,
    std.conv,
    std.string,
    std.algorithm;

void main(){
  string s;
  for(;;){
    s=readln();
    if(stdin.eof()) break;
    string[] input = split(s);
    int a,b;
    a = to!int(input[0]);
    b = to!int(input[1]);
    int g = getgcd(a,b);
    int lcm = cast(int)getlcm(a,b,g);
    writefln("%d %d",g,lcm);
  }

}

int getgcd(int a,int b){
  int g,l;
  if(a > b){
    g = a;
    l = b;
  } else {
    l = a;
    g = b;
  }
  int r = g % l;
  while(r > 0){
    g = l;
    l = r;
    r = g % l;
  }
  return l;
}

double getlcm(int a,int b,int g){
  return (a / g) * b;
}

Measured memory_bytes: 2384
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	rep(i, N) cin >> v[i];

	sort(v.begin(), v.end());

	double ans = v[0];
	for(int i=1; i<N; i++) {
		ans = (ans + v[i])/2.0;
	}

	cout.precision(20);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
const int size=123456;
int N,ans;
int A[size],B[size];

int main(){

cin>>N;

for(int i=0; i<N; i++) scanf("%d",&A[i]);
for(int i=0; i<N; i++) B[A[i]]++;
for(int i=1; i<=100000; i++){
    if(B[i]>2){
        if(B[i]%2==0){
            B[i]=2;
        }else{
            B[i]=1;
        }
    }
}
int cnt=0;
for(int i=1; i<=100000; i++){
    if(B[i]==2) cnt++;
    ans+=B[i];
}

if(cnt%2==0) cout<<ans-cnt<<endl;
else cout<<ans-cnt-1<<endl;

return 0;
 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int N, K;
	cin >> N >> K;
	string s;
	cin >> s;
	vector<int> v;
	if (s[0] == '0') {
		v.push_back(0);
	}
	int num = 0;
	for (int i = 0; i < N; i++) {
		if (v.size() % 2 == 1) {
			if (s[i] == '0') {
				num++;
			}
			else {
				v.push_back(num);
				num = 1;
			}
		}
		else {
			if (s[i] == '0') {
				v.push_back(num);
				num = 1;
			}
			else {
				num++;
			}
		}
	}
	if (num > 0) {
		v.push_back(num);
	}
	if (v.size() % 2 == 0) {
		v.push_back(0);
	}
	auto sum = v;
	for (int i = 1; i < sum.size(); i++) {
		sum[i] += sum[i - 1];
	}
	int ans = 0;
	for (int i = 0; i + (K*2) < sum.size(); i+=2) {
		ans = max(ans, sum[i + (K * 2)] - (i==0?0:sum[i-1]));
	}
	if (ans == 0) {
		ans = sum[sum.size() - 1];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1272
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll X;
    cin >> X;
    ll n = 1;
    while(n*(n+1)/2 < X) {
        n++;
    }
    print(n);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld =long double;
const ld eps = 1e-9;

#define Seg_Max_N (1<<18) 

using Value = pair<long long int, long long int>;
const Value ini = (make_pair(-1e9, 1e9));
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	Value connect(const Value&l, const Value&r) {
		return make_pair(max(l.first, r.first), min(l.second, r.second));
	}
	// update k th element
	void update(int k, Value a) {
		k += N - 1;
		dat[k] = a;

		while (k > 0) {
			k = (k - 1) / 2;
			const Value al(dat[k * 2 + 1]);
			const Value ar(dat[k * 2 + 2]);
			dat[k] = connect(al, ar);
		}
	}
	// min [a, b)
	Value  query(int a, int b) { return query(a, b, 0, 0, N); }
	Value  query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return ini;
		if (a <= l and r <= b) return dat[k];
		const int m = (l + r) / 2;
		const Value al(query(a, b, k * 2 + 1, l, m));
		const Value ar(query(a, b, k * 2 + 2, m, r));
		return connect(al, ar);
	}
};


int main()
{
	while (true) {
		int N,M;cin>>N>>M;
		if(!N)break;
		segtree seg(M);
		seg.update(0,make_pair(0,0));
		int fin_ans=0;

		int sum=0;
		for (int i = 0; i < N; ++i) {
			int k;cin>>k;
			k%=M;

			sum=(sum+k)%M;
			int ans;
			auto rp=seg.query(sum+1,M);
			if (rp.first <0) {
				auto lp=seg.query(0,sum+1);
				ans= sum -lp.second;
			}
			else {
				ans=(sum +M)-rp.second;
			}
			seg.update(sum,make_pair(sum, sum));
			fin_ans=max(ans,fin_ans);
		}
		cout<<fin_ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 11288
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	char s[100],t[3];
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		strncpy(t,s+i,3);
		if(strcmp(t,"ABC")==0)
		ans++;
	}
	cout<<ans<<endl;
 } 

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = n;
        for (int i = 0; i <= n; i++) {
            int six = i;
            int nine = n - i;
            int cnt = 0;
            int num = 6;
            while (true) {
                if (num * 6 > six) {
                    break;
                }
                num *= 6;
            }
            while (true) {
                cnt += six / num;
                six %= num;
                num = num / 6;
                if (num == 1) {
                    cnt += six;
                    break;
                }
            }
            num = 9;
            // 最大まで上げる
            while (true) {
                if (num * 9 > nine) {
                    break;
                }
                num *= 9;
            }
            while (true) {
                cnt += nine / num;
                nine %= num;
                num = num / 9;
                if (num == 1) {
                    cnt += nine;
                    break;
                }
            }
            min = Math.min(cnt, min);

        }
        System.out.println(min);
        sc.close();
    }
}

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

using namespace std;

using int64 = long long;

struct Edge {
  int from, to;
  int id;
  int reverse_id;
};

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

  int n, m;
  cin >> n >> m;

  vector<vector<Edge>> graph(n);
  vector<Edge> edges;
  vector<int> is_actives(2 * m);
  vector<int> out_degrees(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--; v2--;
    Edge e1({v1, v2, 2 * i, 2 * i + 1});
    Edge e2({v2, v1, 2 * i + 1, 2 * i});
    graph[v1].push_back(e1);
    graph[v2].push_back(e2);
    edges.push_back(e1);
    edges.push_back(e2);
    is_actives[2 * i] = true;
    out_degrees[v1]++;
  }

  if (m % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> visited(n, 0);
  vector<int> used_edges(n, -1);
  function<void(int, int)> dfs =
      function<void(int, int)>([&] (int v, int parent) {
        visited[v] = 1;
        for (const auto& edge : graph[v]) {
          if (edge.to == parent) continue;
          if (visited[edge.to]) continue;
          used_edges[edge.to] = edge.id;
          dfs(edge.to, v);
        }

        if (out_degrees[v] % 2 == 1) {
          int edge_id = used_edges[v];
          if (edge_id < 0) return;  // SHOULD NOT HAPPEN
          int reverse_edge_id = edges[edge_id].reverse_id;
          if (is_actives[edge_id]) {
            out_degrees[edges[edge_id].from]--;
            out_degrees[edges[edge_id].to]++;
            is_actives[edge_id] = false;
            is_actives[reverse_edge_id] = true;
          } else {
            out_degrees[edges[edge_id].from]++;
            out_degrees[edges[edge_id].to]--;
            is_actives[edge_id] = true;
            is_actives[reverse_edge_id] = false;
          }
        }
      });
  
  dfs(0, -1);

  for (int i = 0; i < 2 * m; i++) {
    if (is_actives[i]) {
      cout << edges[i].from + 1 << " " << edges[i].to + 1 << endl;
    }
  }
}


Measured memory_bytes: 21740
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string ss;
    cin>>ss;
    int n=0,s=0,w=0,e=0;
    for(int i=0;i<ss.size();i++){
        if(ss[i]=='N')n=1;
        else if(ss[i]=='S')s=1;
        else if(ss[i]=='W')w=1;
        else e=1;
    }
    if(n==s&&w==e)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

	int ans = a * b;
	if (ans % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
//#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e6 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int x, y, z;
  cin >> x >> y >> z;
  int n = x + y + z;
  vector<vector<int>> vc(n, vector<int>(3));

  f(i,0,n)
    f(j,0,3)
      cin >> vc[i][j];

  sort(vc.begin(),vc.end(),[&](vector<int> a, vector<int> b){
       return a[0] - a[1] < b[0] - b[1];
  });

  ll ans = 0;

  priority_queue<ii, vector<ii>, greater<ii>> pq;

  f(i,0,y){
    pq.push(ii(vc[i][1] - vc[i][2], i));
    ans += vc[i][1];
  }
  vector<ll>  suff(n + 1), pref(n + 1);

  pref[y - 1] = ans;

  f(i,y,n){
    pq.push(ii(vc[i][1] - vc[i][2], i));
    ans += vc[i][1];
    int idx = pq.top().S; pq.pop();
    ans -= vc[idx][1];
    ans += vc[idx][2];
    pref[i] = ans;
  }
  while(pq.size())pq.pop();
  ans = 0;
  f(i,y+z,n){
    pq.push(ii(vc[i][0] - vc[i][2], i));
    ans += vc[i][0];
  }

  suff[y + z] = ans;

  for(int i = y + z - 1; i >= 0; --i){
    pq.push(ii(vc[i][0] - vc[i][2], i));
    ans += vc[i][0];
    int idx = pq.top().S; pq.pop();
    ans -= vc[idx][0];
    ans += vc[idx][2];
    suff[i] = ans;
  }
  ans = 0;

  f(i,y-1,y+z)
  ans=max(ans,pref[i] + suff[i + 1]);

  cout << ans << endl;



  return 0  ;
}


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

int main() {
  int s;
  cin>>s;
  vector<int> vec(1000000);
  vec.at(0)=s;
  for(int i=0;i<999999;i++){
    if(vec.at(i)%2==0){
      vec.at(i+1)=vec.at(i)/2;
    }
    else{
      vec.at(i+1)=vec.at(i)*3+1;
    }
  }
  if(s==1||s==2||s==4){
    cout<<4<<endl;
  }
  else{
  for(int i=0;i<1000000;i++){
    if(vec.at(i)==4){
      cout<<i+4<<endl;
      break;
    }}
  }
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int r;
	cin >> r;
	cout << fixed << setprecision(7) << 2 * 3.1415926535 * r << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int X,Y,Z; cin >> X >> Y >> Z;
    X -= Z;
    cout << X / (Y+Z) << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int M=998244353;
const int N=500005,E=524288;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int n,i,p[N],f[N],j,q[N],l,r,d[N],vis[N];
long long fa[N],ans;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int id(int x,int y)
{
	if(x<=0||y<=0||x>n||y>n)
		return n*n+1;
	return (x-1)*n+y;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n*n;++i)
		scanf("%d",&p[i]);
	for(i=1;i<=n;++i)
		for(j=1;j<=n;++j)
		{
			vis[id(i,j)]=min(min(i,n-i+1),min(j,n-j+1))-1;
			d[id(i,j)]=1;
		}
	for(i=1;i<=n*n;++i)
	{
		d[p[i]]=0;
		ans+=vis[p[i]];
		q[l=r=1]=p[i];
		while(l<=r)
		{
			for(j=0;j<4;++j)
			{
				int xx=(q[l]-1)/n+1+dx[j];
				int yy=(q[l]-1)%n+1+dy[j];
				if(vis[id(xx,yy)]>vis[q[l]]+d[q[l]])
				{
					vis[id(xx,yy)]=vis[q[l]]+d[q[l]];
					q[++r]=id(xx,yy);
				}
			}
			++l;
		}
	}
	cout<<ans;
}

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

int main() {
  int X;
  cin >> X;
  for (int x = X;; ++x) {
    vector<int> vec;
    for (int i = 1; i < x + 1; ++i) {
      if (x % i == 0) vec.push_back(i);
    }
    if (vec.size() == 2 && vec.at(0) == 1 && vec.at(1) == x) {
      cout << x << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import collections

def solve(T):
    ans = ""
    for t in T:
        if(t == "?"):
            ans += "D"
        else:
            ans += t
    return ans
def main():
    T = list(input())
    # solve()
    print(solve(T))

if __name__ == "__main__":
    main()


Measured memory_bytes: 11016
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define mp make_pair
 
using namespace std;

typedef long long ll;

int main(){
	int q,op;
	char s[100005], c;
	deque<char> Q;

	scanf("%s %d", s, &q);

	for(int i = 0; s[i]; i++)
		Q.push_back(s[i]);

	int rev = 0;
	while(q--) {
		scanf("%d", &op);
		if(op == 1) rev = 1 - rev;
		else {
			scanf("%d %c", &op, &c);
			if(rev == op-1) Q.push_front(c);
			else Q.push_back(c);
		}
	}

	if(!rev) {
		while(Q.size()) printf("%c", Q.front()), Q.pop_front();
	}
	else {
		while(Q.size()) printf("%c", Q.back()), Q.pop_back();
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] list = new int[26];
        int i, c;
        String str;
        
        //list = null;
        
        while(sc.hasNext()) {
        	str = sc.nextLine();
        	
        	for(i = 0; i < str.length(); i++) {
        		c = str.toLowerCase().charAt(i) - 97;
        		if(c >= 0) list[c]++;
        	}
        }
        
        for(i = 0; i < 26; i++) {
        	System.out.printf("%s : %d\n", (char)(i + 97), list[i]);
        }
    }
}


Measured memory_bytes: 30544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int xyh[110][3];
int N;

int main(void)
{
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> xyh[i][0] >> xyh[i][1] >> xyh[i][2];
    }
    int oxyh[3];
    oxyh[2] = 0;
    int h = 0;
    for (int x = 0; x <= 100; x++)
    {
        for (int y = 0; y <= 100; y++)
        {
            for (int i = 0; i < N; i++)
            {
                if (xyh[i][2] > 0 || i == N - 1)
                {
                    h = xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1]);
                    break;
                }
            }
            for (int i = 0; i < N; i++)
            {
                if (xyh[i][2] == max(h - abs(x - xyh[i][0]) - abs(y - xyh[i][1]), 0))
                {
                    if (i == N - 1 && h >= oxyh[2])
                    {
                        oxyh[0] = x;
                        oxyh[1] = y;
                        oxyh[2] = h;
                    }
                }
                else
                {
                    break;
                }
            }
        }
    }

    cout << oxyh[0] << " " << oxyh[1] << " " << oxyh[2];

    return 0;
}

Measured memory_bytes: 256
N,X = map(int,input().split(" "))
num = [0] * (N+1)
p = [0] * (N+1)
num[0] = 1
p[0] = 1

for i in range(1,N+1):
    num[i] = num[i-1] * 2 + 3
    p[i] = p[i-1] * 2 + 1


def dfs(n,x):
    if n == 0:
        if x == 0: return 0
        else: return 1
        
    if x >= (num[n]-1):
        return p[n]

    if x >= (num[n-1]) + 2:
        return p[n-1] + 1 + dfs(n-1,x-((num[n-1]) + 2))

    if x == (num[n-1]) + 1:
        return p[n-1]

    if x >= 2:
        return dfs(n-1,x-1)

    return 0

print(dfs(N,X))




Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void)
{
  int N, D, X, A;
  cin >> N;
  cin >> D >> X;
  for (int i=0;i<N;i++){
    cin >> A;
    X += D / A + ((D % A) ? 1 : 0);
  }
  cout << X << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        ll n,d;
        cin>>n>>d;
        ll ctr=0;
        while(n--){
            ll x,y;
            cin>>x>>y;
            if(x*x+y*y<=d*d)
                ctr++;
        }
        cout<<ctr<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    ve<ve<int>> g(4, vi(4,0));
    rep(i,3){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a][b] = 1;
        g[b][a] = 1;
    }
    
    vector<int> c(4);
    rep(i,4) c[i] = i;
    
    
    do{
        int aa = 1;
        rep(i,3) if(g[c[i]][c[i+1]] == 1) aa++;
        
        if(aa == 4){
            cout << "YES" << endl;
            return 0;
        }
        
        //outve(c);
    } while (next_permutation(all(c)));
    
    
    cout << "NO" << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#define MAX_N 200002

using namespace std;
typedef pair<int,int> P;
int road[MAX_N];
int rail[MAX_N];
map<P,int> cnt;
int n,k,l;
int a,b;
int road_find(int x)
{
    int tmp = x;
    while(road[tmp]!=tmp)tmp = road[tmp];
    road[x] = tmp;
    return tmp;
}

void road_unite(int x,int y)
{
    a = road_find(x);
    b = road_find(y);
    if(a == b)return;
    road[b] = a; 
}
int rail_find(int x)
{
    int tmp = x;
    while(rail[tmp]!=tmp)tmp = rail[tmp];
    rail[x] = tmp;
    return tmp;
}

void rail_unite(int x,int y)
{
    a = rail_find(x);
    b = rail_find(y);
    if(a == b)return;
    rail[b] = a; 
}

void solve()
{
    P p;
    for(int i = 1;i<=n;i++){
        road_find(i);
        rail_find(i);
    }

    for(int i = 1;i<=n;i++){
        p = P(road[i],rail[i]);
        if(cnt.find(p) == cnt.end())
            cnt[p] = 1;
        else
            cnt[p] = cnt[p] + 1;
    }
    for(int i = 1;i<=n;i++){
        cout<<cnt[P(road[i],rail[i])]<<" ";
    }
    cout<<endl;
}
int main()
{
    cin>>n>>k>>l;
    for(int i = 0;i<=n;i++){
        road[i] = i;
        rail[i] = i;
    }
    for(int i = 0;i<k;i++){
        cin>>a>>b;
        road_unite(a,b);
    }
    for(int i = 0;i<l;i++){
        cin>>a>>b;
        rail_unite(a,b);
    }
    solve();
    return 0;    
}


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

ll ans=1;
void mul(int x){ans=ans*x%MOD;}

int main(){
	int n,prev=0, x[3][3]={{0,3,6},{0,2,2},{0,1,3}};
	cin>>n;
	vector<string> s(2);
	cin>>s[0]>>s[1];
	
	rep(i,n){
		int type=(s[0][i]==s[1][i]?1:2);
		mul(x[prev][type]);
		prev=type;
		if(type==2)i++;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int a, b ;
  cin >> a >> b ;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    for (int i = 1; i < 1250; i++)
    {
        if ((int)(i * 0.08) == a && (int)(i * 0.1) == b)
        {
            printf("%d\n", i);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

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

using namespace std;

long long gcd (long long x,long long y)
{
	if(y==0)
		return x;    
	if(x<y)
		return gcd(y,x);    
	else
		return gcd(y,x%y); 
}

int main ()
{
	int n;
	long long t,a;
	scanf ("%d%lld",&n,&t);
	for (int i=2;i<=n;i++)
	{
		scanf ("%lld",&a);
		t=(t/gcd(t,a))*a;
	}
	printf ("%lld\n",t);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(a+b>=c) printf("%d",b+c);
	else
		printf("%d",a+b+b+1);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int key;
  node *left,*right,*p;
  node(){}
  node(int key):key(key){left=right=p=NULL;};
};
node *root;
void insert(node z){
  node *y=NULL;
  node *x=root;
  while(x!=NULL){
    y=x;
    if(z.key<x->key) x=x->left;
    else x=x->right;
  }
  z.p=y;
  if(y==NULL) root=new node(z);
  else if(z.key<y->key) y->left=new node(z);
  else y->right=new node(z);
}
void inorderTreeWalk(node *v){
  if(v==NULL) return;
  inorderTreeWalk(v->left);
  cout<<" "<<v->key;
  inorderTreeWalk(v->right);
}
void preorderTreeWalk(node *v){
  if(v==NULL) return;
  cout<<" "<<v->key;
  preorderTreeWalk(v->left);
  preorderTreeWalk(v->right);
}
signed main(){
  int n;cin>>n;root=NULL;
  for(int i=0;i<n;i++){
    string s;cin>>s;
    if(s=="print"){
      inorderTreeWalk(root);
      cout<<endl;
      preorderTreeWalk(root);
      cout<<endl;
      continue;
    }
    int x;cin>>x;
    insert(node(x));
  }
}


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

int main(){
    int n;
    cin>>n;
    
    vector<int> a(n), dp(n);
    
    for(int i = 0; i < n; i++) cin>>a[i];
    
    dp[0] = 0; dp[1] = abs(a[1] - a[0]);
    
    for(int i = 2; i < n; i++) 
        dp[i] = min(dp[i-1]+abs(a[i] - a[i-1]), dp[i-2]+abs(a[i] - a[i-2]));
    
    cout<<dp[n-1]<<endl;
    
    return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef pair<int, int> pii;
int main() {
  int n;
  while(cin>>n,n) {
    int ma = 0, p;
    REP(i,n) {
      int a,d1,d2;
      cin >> a >> d1 >> d2;
      if (ma < d1 + d2) {
        ma = d1 + d2;
        p = a;
      }
    }
    cout << p << " " << ma << endl;
  }
}

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

int main() {
  int N;
  using tsii=tuple<string,int,int>;
  cin>>N;
  vector<tsii> list(N);
  for(int i=0;i<N;i++){
    string s;
    int n;
    cin>>s>>n;
    list.at(i)=make_tuple(s,-n,i+1);
  }
  sort(list.begin(),list.end());
  for(tsii x:list){
    int y;
    tie(ignore,ignore,y)=x;
    cout<<y<<endl;
  }
}

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

def countingsort(A, B ,k):
    C = [0 for i in range(k + 1)]
    B = [0 for i in range(len(A))]

    for j in range(len(A)):
        C[A[j]] += 1

    for i in range(1,k+1):
        C[i] = C[i] + C[i-1]

    for j in range(n-1,-1,-1):
        c = C[A[j]] - 1
        B[c] = A[j]
        C[A[j]] -= 1

    return B

ans = []
ans = countingsort(sort_list,ans,max(sort_list))
print(' '.join([str(i) for i in ans]))



Measured memory_bytes: 242824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(a!=b)cout<<max(a,b)*2-1<<endl;
	else cout<<a*2<<endl;
	ggr;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int a = scanner.nextInt(), b = scanner.nextInt();
    	boolean flag = false;
    	for(int i=1;i<=100000;i++) {
    		if (Math.floor(1.* i *.08) == a && b == Math.floor(.1 * i)) {
    			System.out.println(i);
    			flag = true;
    			break;
    		}
    	}
    	if (!flag) {
    		System.out.println(-1);
    	}
    	}
    }


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

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	using vi = std::vector<int64_t>;
	using vvi = std::vector<vi>;
	using vvvi = std::vector<vvi>;
	vi H(N);
	for (auto& e: H) scanf("%lld", &e);

	vi height(H);
	height.push_back(0);
	std::sort(height.begin(), height.end());
	height.erase(std::unique(height.begin(), height.end()), height.end());

	const int size_h{(int)height.size()};
	vvvi dp(N, vvi(height.size(), vi(K + 1, 1ll << 50)));
	for (int i{}; i < size_h; i++)
		if (height[i] == H.front()) dp[0][i][0] = height[i];
		else dp[0][i][1] = height[i];

	for (int n_i{1}; n_i < N; n_i++)
	{
		vvi minUp(size_h + 1, vi(K + 1, 1ll << 50)), minLow(size_h + 1, vi(K + 1, 1ll << 50));
		// 上から
		for (int h_i{size_h - 1}; h_i >= 0; h_i--)
			for (int k_i{}; k_i <= K; k_i++)
				minUp[h_i][k_i] = std::min(dp[n_i - 1][h_i][k_i], minUp[h_i + 1][k_i]);
		// 下から
		for (int k_i{}; k_i <= K; k_i++)
			minLow[0][k_i] = dp[n_i - 1][0][k_i];
		for (int h_i{1}; h_i < size_h; h_i++)
			for (int k_i{}; k_i <= K; k_i++)
				minLow[h_i][k_i] = std::min(dp[n_i - 1][h_i][k_i] - height[h_i], minLow[h_i - 1][k_i]);
		for (int h_i{}; h_i < size_h; h_i++)
		{
			if (height[h_i] == H[n_i]) // 変えない
			{
				for (int k_i{}; k_i <= K; k_i++)
					dp[n_i][h_i][k_i] = std::min(minUp[h_i][k_i], minLow[h_i][k_i] + height[h_i]);
			}
			else	// 変える
			{
				for (int k_i{1}; k_i <= K; k_i++)
					dp[n_i][h_i][k_i] = std::min(minUp[h_i][k_i - 1], minLow[h_i][k_i - 1] + height[h_i]);
			}
		}
	}
	int64_t min{1ll << 60};
	for (auto& e: dp.back())
		for (auto& f: e)
				min = std::min(min, f);
	printf("%lld\n", min);

	return 0;
}

Measured memory_bytes: 216928
/*
Kaushal Jalan
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    //c_p_c();
    int k;
    cin>>k;
    int sum=0;
    for(int a=1;a<=k;a++)
    {
        for(int b=1;b<=k;b++)
        {
            for(int c=1;c<=k;c++)
            {
                sum+=__gcd(a,__gcd(b,c));
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3676
import java.util.*;
import java.io.*;

public class Main {
		public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		String S = br.readLine();
		String T = br.readLine();
		
		int Tstart = 0;
		Scompare: for(int t=N; t>0;t--){
			for(int s=0; s<N; s++){
				if(S.substring(s).contentEquals(T.substring(0,t))){
					Tstart = t;
					break Scompare;
				}
			}
		}
		
        System.out.print(2*N-Tstart);
    }
}

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

signed main() {
  int N, H;
  cin >> N >> H;
  
  vector<int> A(N);
  vector<int> B(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i) >> B.at(i);
  
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( B.at(i) <= A.back() || H <= 0 ) break;
    else{
      H -= B.at(i);
      ans++;
    }
  }
  
  if( H > 0 ) ans += ( H + A.back() - 1 ) / A.back();
  cout << ans << endl;
    
}
  

Measured memory_bytes: 1792
K = gets.to_i

runruns = Hash.new

(0..9).each do |n|
  runruns[n.to_s] = true
end

loop do
  keys = runruns.keys

  break if keys.size >= 2 * K

  keys.each do |k|
    case k[0]
    when '0'
      runruns['0' + k] = true
      runruns['1' + k] = true
    when '1'
      runruns['0' + k] = true
      runruns['1' + k] = true
      runruns['2' + k] = true
    when '2'
      runruns['1' + k] = true
      runruns['2' + k] = true
      runruns['3' + k] = true
    when '3'
      runruns['2' + k] = true
      runruns['3' + k] = true
      runruns['4' + k] = true
    when '4'
      runruns['3' + k] = true
      runruns['4' + k] = true
      runruns['5' + k] = true
    when '5'
      runruns['4' + k] = true
      runruns['5' + k] = true
      runruns['6' + k] = true
    when '6'
      runruns['5' + k] = true
      runruns['6' + k] = true
      runruns['7' + k] = true
    when '7'
      runruns['6' + k] = true
      runruns['7' + k] = true
      runruns['8' + k] = true
    when '8'
      runruns['7' + k] = true
      runruns['8' + k] = true
      runruns['9' + k] = true
    when '9'
      runruns['8' + k] = true
      runruns['9' + k] = true
    end
  end
end

list = runruns.keys.map(&:to_i).uniq.sort!

puts list[K]


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

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

  int cnt = 1;  // 電源タップ数
  int ans = 0;

  while(cnt < b) {
    cnt += a - 1;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[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'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%c", &t[0]);
  if(t[0]=='S')  printf("Cloudy\n");
  if(t[0]=='C')  printf("Rainy\n");
  if(t[0]=='R')  printf("Sunny\n");
  

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d\n", cnt);
   

return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
#define MAX 100010

int Dpow(int cnt, int b,int limit){
  //  min(cnt*2^b, limit)
  int i;
  long int s=cnt;
  for(i=0;i<b;i++){
    s*=2;
    if(s>limit){
      s=limit;
      break;
    }
  }
  return s;
}

int main(){
  if(df)printf("*** debug mode ***\n");
  int n,k;
  scanf("%d%d",&n,&k);
  char s[n+1];
  scanf(" %s",s);
  char mrr[2*n+1];
  int i;
  for(i=0;i<n;i++){
    mrr[i]=s[i];
    mrr[2*n-1-i]=s[i];
  }
  mrr[2*n]=s[n];
  if(df)printf("%s\n",mrr);
  int m=0;char c_min=mrr[0];
  for(i=0;i<n;i++){
    if(strcmp(mrr+i,mrr+m)<0) {
      m=i;
      c_min=s[i];
    }
  }
  if(df)printf("%d, %s\n",m,mrr+m);
  int cnt=0;
  for(i=0;i<n;i++){
    if(mrr[m+i]==c_min)cnt++;
    else break;
  }
  int dup=Dpow(cnt,k-1,n),j;
  if(df)printf("dup:%d  n:%d m:%d i:%d\n",dup,n,m,i);
  for(j=0;j<dup;j++){
    printf("%c",mrr[m]);
  }
  m+=i;
  for(i=0;i<n-dup;i++){
    printf("%c",mrr[m+i]);
  }
  

  return 0;
}


/// confirm df==0 ///


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

int main(){
  
  string s;
  cin>>s;
  int ans=0;
    for(int i=0 ;i<4;i++){
   if(s.at(i)=='-')  //==と=の違い
    ans--;
   else
    ans++;
  }
  cout<<ans<<endl;
  /*
   string s;
    cin >> s;
    int ans=0;
    for (int i = 0;i<4; i++) {
        if (s.at(i) == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
*/
 }

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

#define SZ(a) (int)a.size()
#define PB push_back
//#define cerr if(false)cerr
#define print(x) cerr<<"\n" << (#x) << " is " << (x) << endl;

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

typedef vector<int> vi;
typedef vector<ll> vll;

const int MAXN = 1000007;
const int INF = 1000303;
const int MOD = 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vi arr(n);
	for(auto &i : arr) cin >> i;
	sort(arr.begin(), arr.end());
	int k = MOD;
	int sum = 0;
	for(int i=1; i<=100; i++){
		sum = 0;
		for(auto x: arr){
			sum += (x-i)*(x-i);
		}
		k = min(k, sum);
	}
	cout << k << endl;
}


Measured memory_bytes: 256