akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int S = 0, T = 0;
  REP(i, 4){
    int a; cin >> a;
    S += a;  
  }
  REP(i, 4){
    int b; cin >> b;
    T += b;
  }
  if(S >= T){
    cout << S << endl;
  }else{
    cout << T << endl;
  }
}


Measured memory_bytes: 3140
/**
 *   created: 21 July 2019  12:00:05
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vl v(n+1),v2(n);
		rep(i,0,n+1){
			cin>>v[i];
			// v2[i] = v[i];
		}
		rep(i,0,n)
			cin>>v2[i];
		ll res=0;
		rep(i,0,n){
			res += min(v2[i],v[i]);
			v2[i] -= min(v2[i],v[i]);
			if(v2[i]){
				res += min(v2[i],v[i+1]);
				v[i+1] -= min(v2[i],v[i+1]);
			}
		}
		cout<<res;

	}
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	string s;
	while (getline(cin, s)){
		int n = s.length();
		while (1){
			if (s.find("the") != string::npos)break;
			if (s.find("this") != string::npos)break;
			if (s.find("that") != string::npos)break;
			REP(i, n){
				if ('a' <= s[i] && s[i] <= 'z'){
					s[i]++;
					if (s[i] > 'z')s[i] -= 26;
				}
			}
		}
		cout<<s<<endl;
	}
}

Measured memory_bytes: 3060
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;


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

  int N;
  string A, B;
  cin >> N >> A >> B;

  if (N == 1) {
    cout << 3 << endl;
    return 0;
  }

  ll pat = 0;
  bool cont;
  int i = 0;

  if (A[0] == B[0]) {
    pat = 3;
    i = 1;
    cont = false;
  } else {
    pat = 6;
    i = 2;
    cont = true;
  }

  for (; i < N; i++) {
    if (A[i] == B[i]) {
      if (cont) {
        pat *= 1;
      } else {
        pat *= 2;
      }
      cont = false;
    } else {
      if (cont) {
        pat *= 3;
      } else {
        pat *= 2;
      }
      i++;
      cont = true;
    }
    pat %= 1000000007;
  }

  cout << pat << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007


int main (){
  int N,M;
  cin>>N>>M;
  vector<int>ten(N);
  vector<int>tenten(N,0);
  rep(i,N) cin>>ten[i];
  rep(i,M){
    int a,b;
    cin>>a>>b;
    if(ten[a-1]>=ten[b-1]){
      tenten[b-1]=1;
    }
    if(ten[a-1]<=ten[b-1]){
      tenten[a-1]=1;
    }
  }
  int ans=0;
  rep(i,N){
    if(tenten[i]==0) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 4052
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+7 + 9)




//cout<<fixed<<setprecision(10);
int main(){
    int n;
    cin>>n;
    n--;
    vector<int> c(n),s(n),f(n);
    rep(i,n){
        cin>>c[i]>>s[i]>>f[i];
    }
    int ans=0;
    rep(j,n){
        ans=0;
        for(int i=j;i<n;i++){
            if(ans<=s[i]){
                ans=s[i]+c[i];
            }
            else{
                int k=(ans-s[i])/f[i];
                if((ans-s[i])%f[i]!=0) k++;
                ans=s[i]+k*f[i]+c[i];
            }
        }
        cout<<ans<<endl;
    }
    cout<<0<<endl;

    return 0;
}



Measured memory_bytes: 3636
from itertools import product

n, m = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

cnt = 0
for pat in product([0, 1], repeat=n):
    for ksi, pi in zip(ks, p):
        tmp = sum(pat[ksij - 1] for ksij in ksi[1:])
        if  tmp % 2 != pi:
            break
    else:
        cnt += 1
print(cnt)


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

int main()
{
	while (true)
	{
		int nM, nF, nR;
		cin >> nM >> nF >> nR;
		int nSum = 0;
		nSum = nM + nF;
		if (-1 == nM && -1 == nF && -1 == nR)
		{
			break;
		}
		if (-1 == nM || -1 == nF)
		{
			cout << "F" << endl;
		}
		else if (nSum >= 80)
		{
			cout << "A" << endl;
		}
		else if (nSum >= 65)
		{
			cout << "B" << endl;
		}
		else if (nSum >= 50 || nR >= 50)
		{
			cout << "C" << endl;
		}
		else if (nSum >= 30)
		{
			cout << "D" << endl;
		}
		else
		{
			cout << "F" << endl;
		}
	}

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

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

long long N;
const char numbers[3] = {'7', '5', '3'};

int dfs(string s) {
    int count = 0;
    if (s != "" && stoll(s) > N) return 0;
    int n = s.size();
    bool flags[3] = {0};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) if (s[i] == numbers[j]) flags[j] = 1;
        if (flags[0] && flags[1] && flags[2]){
            count++;
            break;
        }
    }

    //生成
    count += dfs(s+"7");
    count += dfs(s+"5");
    count += dfs(s+"3");
    return count;
}

int main() {
    string s; cin >> s;
    N = stoi(s);
    cout << dfs("") << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#include<set>
#include<stdlib.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
vector<long long> Prime;
void SieveOfEratosthenes(long long e) //setup vector<long long>Prime(~x)
{
	bool *x=new bool[e];
	for (long long i = 0; i <= e; i++)x[i] = false;
	for (long long i = 2; i <= e; i++)
	{
		if (x[i]);
		else
		{
			Prime.push_back(i);
			for (long long l = i; l <= e; l += i)x[l] = true;
		}
	}
	return;
}
struct XY
{
	int x;
	int y;
};
int in()
{
	int x;
	cin >> x;
	return x;
}
/*
(char)'1' - (int)48 = (int)1;
???1111181
*/
////////////////////////////////////////////////////



int main()
{
	SieveOfEratosthenes(500000);
	int n,p;
	while (cin>>n>>p&&n!=-1)
	{
		vector<long long>::iterator now=lower_bound(Prime.begin(),Prime.end(),n),ri,le;
		if (binary_search(Prime.begin(), Prime.end(), n))now++;
		vector<long long > ans;
		ri = now;
		le = now;
		rep(i, 200)
		{
			le = ri;
			rep(l, 200)
			{
				ans.push_back(*le + *ri);
				le++;
			}
			ri++;
		}
		sort(ans.begin(), ans.end());
		cout << ans[p-1] << endl;
	}
}

Measured memory_bytes: 2740
#include <stdio.h>
int main() {
  int N,K;
  char S[51];
  scanf("%d" "%d",&N,&K);
  scanf("%s\n",S);
  if (S[K-1] == 'A') {
    S[K-1] = 'a';
  }else if (S[K-1]=='B') {
    S[K-1] = 'b';
  }else{
    S[K-1] = 'c';
  }
  printf("%s\n",S);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end(), std::greater<int>());
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) ans += a[i];
        else ans -= a[i];
    }
    cout << ans << endl;
}


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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (const auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
//#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;

const int N = 2005, MOD = 1e9 + 7, INF = 1e9 + 5;
int dp[N];

int add(int x, int y) { return ((x % MOD) + (y % MOD)) % MOD; }

int f(int i) {
    if (i == 0) return 1;
    if (dp[i] != -1) return dp[i];
    int res = 0;
    for (int j = i; j >= 3; j--) res = add(res, f(i - j));
    return dp[i] = res;
}

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int s;
    cin >> s;
    memset(dp, -1, sizeof dp);
    cout << f(s) % MOD;
}

Measured memory_bytes: 3644
import sys
readline = sys.stdin.readline

V, E, r = map(int, readline().split())
inf = 10**10
edges = [[] for _ in [None]*V]

for _ in [None]*E:
    s, t, d = map(int, readline().split())
    edges[s].append((t, d))


def bellman_ford(n, edges, start):
    vertices = [inf] * n
    vertices[start] = 0
    reached = {start}

    for i in range(n):
        flag = 0
        for v in reached.copy():
            cost = vertices[v]
            for dist, _cost in edges[v]:
                newcost = cost + _cost
                if vertices[dist] > newcost:
                    vertices[dist] = newcost
                    reached.add(dist)
                    flag = 1
        if flag == 0:
            return vertices
    else:
        return None

result = bellman_ford(V, edges, r)
if result:
    print("\n".join([str(n) if n!=inf else "INF" for n in result]))
else:
    print("NEGATIVE CYCLE")

Measured memory_bytes: 8080
package main

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

type Entry struct {
    name  string
    value int
}

type List []Entry

func (l List) Len() int {
    return len(l)
}

func (l List) Swap(i, j int) {
    l[i], l[j] = l[j], l[i]
}

func (l List) Less(i, j int) bool {
    if l[i].value == l[j].value {
        return (l[i].name < l[j].name)
    } else {
        return (l[i].value > l[j].value)
    }
}

// input process
var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func nextText() string {
    sc.Scan()
    return sc.Text()
}

func main() {
  // input
  sc.Split(bufio.ScanWords)
  n := nextInt()

  // store to map
  var atob map[string]int = map[string]int{}

  for i := 0; i < n; i++ {
    str := nextText()
    atob[str] += 1
  }

  a := List{}
  for k, v := range atob {
      e := Entry{k, v}
      a = append(a, e)
  }
  sort.Sort(a)
  max := a[0].value
  for i := 0; i < len(a); i++ {
    if a[i].value != max {
      break
    }
    fmt.Println(a[i].name)
  }
}


Measured memory_bytes: 37376
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vll x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}
//=======================================================================================================

int main()
{
    ll r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<vector<int>> G(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
  }
  vector<int> path;
  vector<int> curPath;
  vector<bool> inPath(n);
  vector<bool> vis(n);
  bool loop = false;
  auto dfs = [&](auto dfs, int cur) -> void {
    if(loop) return;
    if(inPath[cur]) {
      loop = true;
      auto itr = find(all(path), cur);
      int sz = path.end() - itr;
      curPath = vector<int>(sz);
      copy(itr, path.end(), curPath.begin());
      return;
    }
    if(vis[cur]) return;
    vis[cur] = true;
    inPath[cur] = true;
    path.push_back(cur);
    for(int ne: G[cur]) {
      dfs(dfs, ne);
      if(loop) return;
    }
    inPath[cur] = false;
    path.pop_back();
  };
  rep(i, n) {
    rep(j, n) inPath[j] = false;
    dfs(dfs, i);
  }
  if(!loop) cout << -1 << "\n";
  else {
    bool updated = true;
    while(updated) {
      updated = false;
      set<int> se;
      for(int v: curPath) se.insert(v);
      int sz = curPath.size();
      rep(i, sz) {
        int v = curPath[i];
        for(int ne: G[v]) {
          if(se.count(ne) && ne!=curPath[(i+1)%sz]) {
            vector<int> newCurPath;
            int j = find(all(curPath), ne) - begin(curPath);
            while(j != i) {
              newCurPath.push_back(curPath[j]);
              (j+=1)%=sz;
            }
            newCurPath.push_back(curPath[j]);
            curPath = vector<int>(newCurPath.size());
            copy(all(newCurPath), begin(curPath));
            updated = true;
          }
          if(updated) break;
        }
        if(updated) break;
      }
    }
    cout << curPath.size() << "\n";
    for(int v: curPath) cout << v+1 << "\n";
  }
  return 0;
}


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

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    ll x;
    cin >> x;
    if(x==1)
    {
        cout << '0' << endl;
    }
    else
    {
        cout << '1' << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); 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()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int a[10], b[10];

int main(){
  REP(i,10) a[i] = getInt();
  REP(i,10) b[i] = getInt();
  sort(a, a+10); sort(b, b+10);
  cout << a[9] + a[8] + a[7] << " " << b[9] + b[8] + b[7] << endl;
  return 0;
}

Measured memory_bytes: 0
var
 n,i,x,s:longint;
 a:array[0..100001] of int64;
procedure kp(l,r:longint);
var
 i,j,t,m:longint;
begin
 i:=l; j:=r;
 m:=a[(l+r) div 2];
 repeat
  while a[i]<m do inc(i);
  while a[j]>m do dec(j);
  if i<=j then
   begin
    t:=a[i]; a[i]:=a[j]; a[j]:=t; 
    inc(i); dec(j);
   end;  
 until i>j;
 if l<j then kp(l,j);
 if i<r then kp(i,r);
end; 
begin
 readln(n);
 for i:=1 to n do 
  readln(a[i]);
 kp(1,n);
 x:=1;
 for i:=2 to n do
  if a[i]=a[i-1] then inc(x)
   else
    begin
     if odd(x) then inc(s);
     x:=1;
    end; 
 if odd(x) then inc(s);
 writeln(s);
end.

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

int main() {
	int N;
	int an[100010];
	int count = 1;
	int index = 0;
	bool check = false;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> an[i];
	}

	for (int i = 0; i < N; i++) {
		if (an[index] == 2) {
			check = true;
			break;
		}
		count++;
		index = an[index] - 1;
	}

	if (check) cout << count << endl;
	else cout << -1 << endl;

	return 0;
}


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

int main(void) {
    char a, b;
    bool ans;
    cin >> a >> b;
    ans = (b == 'H' ? true : false);
    if (a == 'D') ans = !ans;
    cout << (ans == true ? 'H' : 'D') << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NMC = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NMC[0], M = NMC[1], C = NMC[2];
        var B = ReadLine().Split().Select(int.Parse).ToArray();
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            var A = ReadLine().Split().Select(int.Parse).ToArray();
            int score = 0;
            for (int j = 0; j < M; j++)
            {
                score += A[j] * B[j];
            }
            if (score > -C) ans++;
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 28324
import sys
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n = int(sys.stdin.readline())
t = [int(x) for x in sys.stdin.readlines()]
total_lcm = 1
for i in t:
    total_lcm = lcm(total_lcm, i)
print(total_lcm)

Measured memory_bytes: 5304
import java.util.Scanner;

//Hit and Blow
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			char[] r = sc.next().toCharArray();
			char[] a = sc.next().toCharArray();
			if(r.length==1)break;
			int h = 0;
			int b = 0;
			int[] c1 = new int[10];
			int[] c2 = new int[10];
			for(int i=0;i<4;i++){
				if(r[i]==a[i]){
					h++;
					continue;
				}
				c1[r[i]-'0']++;
				c2[a[i]-'0']++;
			}
			for(int i=0;i<10;i++)b+=Math.min(c1[i], c2[i]);
			System.out.println(h+" "+b);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	double ah, aa, bh, ba;
	double ka, kb;
	cin >> ah >> aa >> bh >> ba;
	ka = ceil(bh / aa);
	kb = ceil(ah / ba);
	if (ka <= kb)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int C = scanner.nextInt();
		int D = scanner.nextInt();

		int S = (A * B >= C * D) ? A * B : C * D;
		System.out.println(S);
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  int ans = 0;
  int first_b = 0;
  int last_a = 0;
  int ab = 0;
  rep(i, n){
    string s;
    cin >> s;
    rep(i, s.size()-1){
      if(s[i] == 'A' & s[i+1] == 'B'){
        ans++;
      }
    }
    if(s[0] == 'B' && s[s.size() - 1] == 'A'){
      ab++;
    }else if(s[0] == 'B'){
      first_b++;
    }
    else if(s[s.size()-1] == 'A'){
      last_a++;
    }
  }
  if(ab > 0){
    ans += ab -1;
    if(first_b > 0){
      ans++;
      first_b--;
    }
    if(last_a > 0){
      ans++;
      last_a--;
    }
  }
  cout << ans + min(first_b, last_a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    double x, yen;
    char u[4];

    scanf("%d", &n);

    yen = 0;
    for (int i=0; i<n; i++) {
        scanf("%lf%s", &x, u);

        if (u[0]=='J')  yen += x;
        else            yen += x*380000.0;
    }

    printf("%f\n", yen);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V v(n);
  REP(i, n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int a = 0, b = 0;
  for (int i = n-1; i >= 0; i-=2) {
    a += v[i];
  }
  for (int i = n-2; i >= 0; i-=2) {
    b += v[i];
  }
  dump(a-b);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
  int x[10000], i = 0, j = 0;
  while(1){
    scanf("%d", &x[i]);
    if (x[i] == 0) {
      break;
    }
    i++;
  }
  for (; j < i; j++) {
    printf("Case %d: %d\n", j + 1, x[j]);
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define DEKAI 1000000007
#define INF (1<<28)
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */


signed main(){

	int n;

	cin>>n;


	cout<<n/30<<" "<<(n%30)*2<<endl;



  	return 0;
}


Measured memory_bytes: 3136
import qualified Data.List as List

main :: IO ()
main = do
  n <- readLn
  as <- map read . words <$> getLine
  print $ solve n as


solve :: Int -> [Int] -> Int
solve n as =
  if ok as
  then foldl (\x y -> mod (x*y) 1000000007) 1 $ replicate (div n 2) 2
  else 0
  where
    ok as =
      let
        as' = map (\s -> (head s, length s)) . List.group . List.sort $ as
      in
        case head as' of
          (0, 1) ->
            (all (\(_, x) -> x == 2) $ tail as') &&
            [0,2..n-1] == map fst as'
          (0, _) -> False
          _ ->
            (all (\(_, x) -> x == 2) $ tail as') &&
            [1,3..n] == map fst as'


Measured memory_bytes: 36604
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,a[20][2];vector<vector<int>> dp;
signed main(){
  cin>>n;int ans = INF;
  rep(i,2)rep(j,n)cin>>a[j][i];
  dp.resize((1<<n)+1, vector<int>(55, INF));
  dp[0][0] = 0;
  rep(bit, 1<<n){
    int cnt = 0;
    rep(j,n)if((bit&(1<<j)))cnt++;
    int c = cnt;vector<P> ord;
    rep(j,n){
      if(!(bit&1<<j)){
        ord.push_back(P(j, c));c++;
      }
    }
    rep(i,51){
      if(dp[bit][i] == INF)continue;
      for(auto p : ord){
        int s = a[p.first][abs(cnt-p.first)%2];
        if(s >= i)chmin(dp[bit | (1<<p.first)][s], dp[bit][i] + abs(p.second - cnt));
      }
    }

  }
  rep(i,51)chmin(ans, dp[(1<<n)-1][i]);
  if(ans < INF)cout << ans << endl;
  else cout << -1 << endl;
}



Measured memory_bytes: 121216
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long [] health = new long[n];
        PriorityQueue<Long> healths = new PriorityQueue<>();

        for (int i = 0; i < n; ++i) {
            health[i] = scanner.nextLong();
            healths.add(health[i]);

        }
        long min1 = healths.poll();
        long min2 = healths.poll();
        for (int i = 0; i < n; ++i) {
            health[i] %= min1;
        }
        for (int i = 0; i < n; ++i) {
            if (health[i] != 0 && (min2 > health[i] || min2 % min1 == 0)) {
                min2 = health[i];
            }
        }

  //      System.out.println("min1: " + min1 + " min2: " + min2);
        while (min1 >= 1 && min2 >= 1) {
            if (min1 > min2) {
                long tmp = min1;
                min1 = min2;
                min2 = tmp;
            }
            if (min2 % min1 == 0) {
                System.out.println(min1);
                return;
            }
            min2 = min2 % min1;
        }
        System.out.println(Math.min(min1, min2));


    }

}


Measured memory_bytes: 62572
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
//#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,num[30],f[17][(1<<16)+5],a[30],ans;
inline void add(int &x,int k){
	x+=k;x-=(x>=mod)?mod:0;x+=(x<0)?mod:0;
}
int ksm(ll x,int k){
	int sum=1;
	while (k){
		if (k&1) sum=sum*x%mod;
		x=x*x%mod;k>>=1;
	}
	return sum;
}
int fac[1<<17],inv[1<<17];
int C(int n,int m){return (n<m||m<0)?0:1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
void init(int x){
	fac[0]=1;F(i,1,x) fac[i]=1LL*fac[i-1]*i%mod;
	inv[x]=ksm(fac[x],mod-2);D(i,x-1,0) inv[i]=1LL*inv[i+1]*(i+1)%mod;
}
signed main(){
	n=read();m=read();init(1<<16);
	F(i,1,m) a[i]=read();
	reverse(a+1,a+m+1);
	num[0]=1;F(i,1,n) num[i]=num[i-1]*2;
	f[0][0]=1;
	F(i,0,m-1){
		F(j,0,num[n]-1){
			add(f[i+1][j],f[i][j]);
			F(k,0,n-1){
				if ((num[k]&j)==0&&num[n]-j-a[i+1]+1-num[k]>=0){ 
					add(f[i+1][j|num[k]],1LL*C(num[n]-j-a[i+1],num[k]-1)*f[i][j]%mod*fac[num[k]]%mod);
				}
			}
		}
	}
	int p=0;
	F(i,0,num[n]-1){
		p=0;
		F(j,0,n-1) if (i&num[j]) p++;
		if (p&1) add(ans,-1LL*fac[num[n]-i-1]*f[m][i]%mod);
		else add(ans,1LL*fac[num[n]-i-1]*f[m][i]%mod);
	}
	ans=1LL*ans*num[n]%mod;
	wrn(ans);
	return 0;
}

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

int main(){

    int ans;

  for(int i = 0; i < 3; ++i){
      int a;
      cin >> a;
      ans += a;
  }  

  if(ans >= 22)cout << "bust" << endl;
  else cout << "win" << endl;

}

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

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	long numOfSou(int level) {
		if (level == 0) {
			return 1;
		} else {
			return 2 * numOfSou(level - 1) + 3;
		}

	}

	long f(int n, long x) {

		if (n == 0 && x == 1) {
			return 1;
		}
		else if (x == 1) {
			return 0;
		}

		long nos = numOfSou(n - 1);

		if (x <= nos + 1) {
			return f(n - 1, x - 1);
		} else if (x == nos + 2) {
			return f(n - 1, nos) + 1;
		} else if (x <= 2 * nos + 2) {
			return f(n - 1, nos) + 1 + f(n - 1, (x - (nos + 2)));
		} else {
			return 2 * f(n - 1, nos) + 1;
		}

	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		long X = sc.nextLong();

		sc.close();

		out.println(f(N, X));

	}

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

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    ll a, b, x, ans;
    cin >> a >> b >> x;
    if (a > 0){
        ans = b/x - (a-1)/x;
    }
    else{
        ans = b/x + 1;
    }
    cout << ans << endl;
}


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

// main
int main(){
    int n; cin >> n;
    P max_num = {1, 0};
    for(int i = 1; i <= n; ++i){
        int count = 0;
        while(true){
            if( (i % (int)pow(2, count+1)) == 0){
                ++count;
            }else{
                break;
            }
        }
        if(max_num.second < count){
            max_num = P(i, count);
        }
    }
    cout << max_num.first << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=1e6+10;
ll sum_M[MAXN],sum_D[MAXN],sum[MAXN];
char s[MAXN];
int n,q_sum,x;
void solve(int x)
{
	ll ans=0;
	for (int i=1;i<=n;i++)
	 if (s[i]=='C') {
	 	ans+=(sum_D[i]-sum_D[max(i-x,0)])*sum_M[i]-(sum[i]-sum[max(i-x,0)]);
	 }
	printf("%lld\n",ans); 
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	for (int i=n;i>=1;i--) s[i]=s[i-1];
	for (int i=1;i<=n;i++)
	{
		sum_D[i]=sum_D[i-1]; sum_M[i]=sum_M[i-1];
		if (s[i]=='D') sum_D[i]++; else if (s[i]=='M') sum_M[i]++;
	}
	for (int i=1;i<=n;i++) {
		sum[i]=sum[i-1]; 
		if (s[i]=='D') sum[i]+=sum_M[i];
	}
	scanf("%d",&q_sum);
	for (int i=1;i<=q_sum;i++) {
		scanf("%d",&x); solve(x);
	}
}

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

long long slv(long long r, long long c, long long v)
{
	long long X = r/2, Y = c/2;
	return min(
		max(max(abs(X*c-v), abs((r-X)*c-v)), abs(X*c-(r-X)*c)),
		max(max(abs(Y*r-v), abs((c-Y)*r-v)), abs(Y*r-(c-Y)*r))
	);
}

int main()
{
	long long r, c; scanf("%lld%lld", &r, &c);
	long long ans = 1ll<<62;
	for (int i = 1;i <= r;i++) ans = min(ans, slv(r-i, c, i*c));
	for (int i = 1;i <= c;i++) ans = min(ans, slv(c-i, r, i*r));
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll long long

int main() {
    //入力
    string s;
    cin >> s;

    int ans = 0;
    int Rcnt = 0;
    rep(i, s.size()) {
        if (s[i] == 'R') {
            ++Rcnt;
        }
        else {
            ans = max(ans, Rcnt);
            Rcnt = 0;
        }
    }
    ans = max(ans, Rcnt);

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


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) {
    cin >> i;
  }

  bool ans = true;

  for (auto i = 0; i < n; ++i) {
    if (a[i] & 1) {
      continue;
    }

    if (a[i] % 3 != 0 && a[i] % 5 != 0) {
      ans = false;
      break;
    }
  }

  if (ans) {
    print("APPROVED");
  } else {
    print("DENIED");
  }

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


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

int main() {
	int l[10],v1,v2,sum;
	float x;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",l,l+1,l+2,l+3,l+4,l+5,l+6,l+7,l+8,l+9,&v1,&v2)+1){
		for(int i=1;i<10;++i){
			l[i] += l[i-1];
		}
		
		x = (float)l[9] * v1 / (v1+v2);
		for(int i=0;i<10;++i){
			if(x<=l[i]){
				cout<<i+1<<endl;
				break;
			}
		}
	}
	return 0;
}

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

blue_list=list()
for i in range (N):
    N_ = str(input())
    blue_list.append(N_)

M = int(input())
red_list=list()
for i in range (M):
    M_ = str(input())
    red_list.append(M_) 

output_final=0
for i in range (0,N):
    objective=blue_list[i]
    plus=blue_list.count(objective)
    minus=red_list.count(objective)
    output=plus-minus
    if output>=output_final:
        output_final=output
print (output_final)
  

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int N,K;
int H[100000];

int main(){
    int ans=0;
    cin>>N>>K;
    rep(i,N){
        cin>>H[i];
        if(H[i]>=K){
            ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int A, B;
    cin >> A >> B;
    int AB = A + B;
    if(A%3==0||B%3==0||AB%3==0)cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var x,ans int
  fmt.Scan(&x)

  for x>499 {
    x -= 500
    ans += 1000
  }

  for x > 4 {
    x -= 5
    ans += 5
  }
  fmt.Println(ans)

}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
inline int read(){
	int ret=0,p=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){if (ch=='-') p=-1;ch=getchar();}
	while (ch>='0' && ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*p;
}
int n,m;
int a[100000+3],fa[100000+3];
int roo[100000+3];
int tmp[100000+3],p;
int getfa(int x){
	p=0;
	while (fa[x]!=0){
		tmp[++p]=x;
		x=fa[x];
	}
	for (int i=1;i<=p;i++) fa[tmp[i]]=x;
	return x;
}
int main(){
	n=read();
	m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int j=1;j<=m;j++){
		int u=read(),v=read();
		int fu=getfa(u),fv=getfa(v);
		if (fu!=fv) fa[fu]=fv;
	}
	for (int i=1;i<=n;i++) roo[i]=getfa(i);
	int ans=0;
	for (int i=1;i<=n;i++){
		if (roo[i]==roo[a[i]]) ans++;
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<tuple<string,int,int>> x(n);
  for(int i=0;i<n;i++){
    cin>>get<0>(x.at(i))>>get<1>(x.at(i));
    get<1>(x.at(i))=(-1)*get<1>(x.at(i));
    get<2>(x.at(i))=i+1;
  }
  sort(x.begin(),x.end());
  for(int j=0;j<n;j++)cout<<get<2>(x.at(j))<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>
#include <numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int>P;


int main(){
    ll a,b,x,cnt=0;
    cin>>a>>b>>x;
    cnt=(b/x)-(a/x);
    
    if(a%x==0)cnt++;
    cout<<cnt<<endl;
    return 0;

}

Measured memory_bytes: 256
from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  g[a-1].append(b)
  g[b-1].append(a)
q=deque()
q.append(1)
check=[0]*n
check[0]=1
ans=[0]*n
while len(q)!=0:
  v=q.popleft()
  for u in g[v-1]:
    if check[u-1]==0:
      check[u-1]=1
      ans[u-1]=v
      q.append(u)
print("Yes")
for i in range(1,n):
  print(ans[i])

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

using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	string s;
	int w;
	cin >> s >> w;

	string ans = "";
	for (int i = 0; i < s.size(); i += w) {
		ans += s.substr(i, w)[0];
	}

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


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

tmp = 0

for i in range(N):
    if A[i]==B[i]:
        continue
    elif A[i]<B[i]:
        tmp += (B[i]-A[i])//2
    else:
        tmp += B[i]-A[i]
if tmp>=0:
    print('Yes')
else:
    print('No')

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    vector<ll> dp(N,INF_LL);
    dp[0] = 0;

    rep(i,N-1)
    {
        chmin(dp[i+1], dp[i]+abs(h[i+1]-h[i]) );
        if( i+2 < N ) chmin(dp[i+2], dp[i]+abs(h[i+2]-h[i]) );
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
#coding:utf-8

k, n = map(int, input().split())
a = list(map(int, input().split()))
dist = []

#逆周りの方が距離が短く済むので、距離を2倍にして考える
#池の一周の長さ+a[0]を座標として追加
a.append(a[0] + k)

#距離が最大になる経路は通らないので除外する
for i in range(n):
    dist.append(a[i+1] - a[i])

#print(a, dist)
#池の一周の長さから、距離が最大になるところを除外したものが最短
print(k - max(dist))

Measured memory_bytes: 26420
N = int(input())
a = list(map(int, list(input())))

while N != 0:
	digit = 1
	while digit < N // 2:
		digit *= 2

	x = []
	for i in range(digit, N):
		x.append(abs(a[i - digit] - a[i]))

	a = x
	N -= digit
	if len(x) == 1:
		break

print(a[0])

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

int main(){
  ll ans=0;
  ll n,i,j;
  cin >> n;
  ll x[n+1]={0};
  for(i=1;i<=n;i++){
    for(j=1;j*i<=n;j++){
      x[j*i]+=1;
    }
    ans+=x[i]*i;
  }
  cout << ans;
}

Measured memory_bytes: 81756
#include <bits/stdc++.h>
#define ff first
#define ss second
#define int long long
#define all(x) (x).begin(), (x).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
#define pii pair<int, int>

using namespace std;

const int mxn = 1e5 + 5;
int n, w, wv[105][2], dp[mxn][105] = {};

int recurse(int idx, int wt)
{
    if (idx == n)
        return 0;
    if (dp[wt][idx] != -1)
        return dp[wt][idx];
    int ans = 0;
    if (wv[idx][0] <= wt)
        ans = max(ans, recurse(idx + 1, wt - wv[idx][0]) + wv[idx][1]);
    ans = max(ans, recurse(idx + 1, wt));
    return dp[wt][idx] = ans;
}

void solve()
{
    cin >> n >> w;
    for (int i = 0; i < n; i++)
        cin >> wv[i][0] >> wv[i][1];
    memset(dp, -1, sizeof dp);
    cout << recurse(0, w);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 85696
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    string s;
    cin >> s;
    int n = s.size();

    int ans[100010] = {0};

    int r=0,l=0;
    for(int i = 0;i < n;i++){
        if(s[i] == 'R' && l != 0){
            if((r+l)%2 == 0){
                ans[i-l] = (r+l)/2;
                ans[i-l-1] = (r+l)/2;
            }else if(r%2 == 0){
                ans[i-l] = (r+l)/2+1;
                ans[i-l-1] = (r+l)/2;
            }else{
                ans[i-l] = (r+l)/2;
                ans[i-l-1] = (r+l)/2+1;
            }
            // rep(i,n)cerr << ans[i] << " ";
            // cerr << endl;
            l = 0;
            r = 1;
        }else if(i == n-1){
            l++;
            if((r+l)%2 == 0){
                ans[i-l+1] = (r+l)/2;
                ans[i-l] = (r+l)/2;
            }else if(r%2 == 0){
                ans[i-l+1] = (r+l)/2+1;
                ans[i-l] = (r+l)/2;
            }else{
                ans[i-l+1] = (r+l)/2;
                ans[i-l] = (r+l)/2+1;
            }
        }else{
            if(s[i] == 'R')r++;
            else l++;
        }
    }



    rep(i,n){
        cout << ans[i] << " ";
    }cout << endl;
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc136.contest.atcoder.jp/tasks/abc136_b


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout << max({a*c,a*d,b*c,d*b}) << endl;
    return 0;
    
}


Measured memory_bytes: 3648