akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

set<ll> st;

ll dig(string& s) {
	ll res = 0;
	REP(i, s.size()) {
		res *= 10; 
		res += s[i] - '0';
		
	}
	return res;
}

void dfs(string s) {
	st.insert(dig(s));
	int n = s.size();
	if (n < 11) {
		int t = s.back() - '0';
		for(int i = -1; i <= 1; ++i) {
			int t2 = t + i;
			if (0 <= t2 && t2 <= 9) {
				s.push_back((char)(t2+'0'));
				dfs(s);
				s.pop_back();
			}
		}
	}
}

int main() {
	IOS;
	ll k;
	cin >> k;
	REP(i, 10) {
		string t(1,(char)(i+'0'));
		dfs(t);
	}
	ll cnt = 0;
	for (auto&& v : st) {
		if (cnt == k) {
			put(v);
			return 0;
		}
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 27520
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,k; cin>>n>>k;
    vector<int> h(n,0),dp(n+k-1,inf);
    rep(i,n) cin>>h[i];
    dp[0]=0;
    rep(i,n-1){
        rep(j,k){
            if(dp[i+j+1]>dp[i]+abs(h[i+j+1]-h[i]))
            dp[i+j+1]=dp[i]+abs(h[i+j+1]-h[i]);
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << 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;}

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") P("Cloudy");
  else if (s == "Cloudy") P("Rainy");
  else P("Sunny");

  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int cnt = 0, m = n;
  vector<pair<int, int>> pr(n * n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      pr[cnt++] = {i, j};
    }
  }
  vector<pair<int, int>> arr;
  for (int i = 0; i < n * n; i++) {
    int x;
    cin >> x;
    x--;
    arr.pb(pr[x]);
  }
  vector<vector<int>> cur(n + 1, vector<int>(n + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cur[i][j] = min({i - 1, n - i, j - 1, m - j});
    }
  }
  int ans = 0;
  vector<vector<bool>> used(n + 1, vector<bool>(n + 1));
  vector<pair<int, int>> delta = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
  for (auto it : arr) {
    used[it.F][it.S] = true;
    ans += cur[it.F][it.S];
    queue<pair<int, int>> q;
    for (auto kek : delta) {
      int a = it.F + kek.F, b = it.S + kek.S;
      if (a >= 1 && b >= 1 && a <= n && b <= m) {
        if (cur[a][b] > cur[it.F][it.S]) {
          q.push({a, b});
          cur[a][b] = cur[it.F][it.S];
        }
      }
    }
    while (!q.empty()) {
      pair<int, int> par = q.front();
      q.pop();
      for (auto kek : delta) {
        int a = par.F + kek.F, b = par.S + kek.S;
        if (a >= 1 && b >= 1 && a <= n && b <= m) {
          if (cur[a][b] > cur[par.F][par.S] + (!used[par.F][par.S])) {
            q.push({a, b});
            cur[a][b] = cur[par.F][par.S] + (!used[par.F][par.S]);
          }
        }  
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 8300
l, r = map(int, input().split())

if (r-l)//2019 >= 1:
    print(0)
else:
    ans = float('inf')
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i != j:
                ans = min(ans, (i*j)%2019)

    print(ans)


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

int main() {

  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U ;
      
  if(S==U){
    A--;
  }else{
    B--;
  }
  cout << A << " " << B << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#define ll long long 
using namespace std;

int main(){
	string s;
	cin >> s;

	bool flag1 = false;
	bool flag2 = false; 

	for (int i = 0; i < s.length(); ++i)
	{
		if(s[i] == 'C'){
			flag1 = true;
		}
		if(flag1 && s[i] == 'F'){
			flag2 = true;
		}
	}
	if(flag2){
		cout << "Yes" << endl; 
	}else{
		cout << "No" << endl;
	}


}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size() - 1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min + (max - min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n, vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());

}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	ll cnt = 0;
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1]) {
			cnt++;
			i++;
		}
	}
	cout << cnt;
	return 0;
}


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

using namespace std;

int main(){
	int H, W;
	int line = 0;

	string *C = NULL;

	cin >> H >> W;

	C = new string[H];

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

	for(int i = 0; i < 2 * H; i++){
		cout << C[line] << endl;
		if(i % 2 == 1){
			line++;
		}
	}

	delete[] C;

	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var K = parseInt(input[0][1], 10);
    var num = input[1].map(e => parseInt(e, 10));
    num.sort(compareFunc);
    var ans = 0;
    for (var i = 0; i < K; i++){
        ans += num[i];
    }
  console.log(ans);
}   

function compareFunc(a, b) {
    return a - b;
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29724
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll n;
    cin >> n;
    ll c;
    cin >> c;
    vll s(n);
    vvll d(c+1,vll(100001,0));
    ll tmax=0;
    rep(i,n){
        ll s;
        cin >> s;
        ll t;
        cin >> t;
        ll ch;
        cin >> ch;
        rep(j,t-s+1){
            d[ch][s+j-1]=1;
        }
        tmax=max(t,tmax);
    }
    ll chmax=0;
    repi(i,1,tmax+1){
        ll num=0;
        repi(j,1,c+1){
            if(d[j][i]==1) num++;
        }
        chmax=max(chmax,num);
    }
    cout<<chmax<<endl;
}

Measured memory_bytes: 26112
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string.h>
using namespace std;
using ll = long long;

int main()
{
  int x, y,s;
  while(cin>>x>>y>>s, x||y||s)
  {
    int ans=0;
    for(int i=1;i<1000;++i)
    {
      for(int j=i;j<1000;++j)
      {
        int pre=i*(100+x)/100+j*(100+x)/100;
        if(pre==s)
        {
          ans=max(ans, i*(100+y)/100+j*(100+y)/100);
        }
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    // Aの倍数の和をBで割った余りがCとなる
    // k* A %BとしてCが表せるか?
    for(int i = 0; i < B; i++) {
        if(i * A % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[5]={'a','e','i','o','u'};
int main()
{
    char c;
    c=getchar();
    for(int i=0;i<5;i++)
{
        if(c==a[i])
{
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;

constexpr int di = 700;

struct Query {
	int l, r, index;
	bool operator<(const Query&q)const {
		int a = l / di;
		int b = q.l / di;
		if (a < b)return true;
		else if (a > b)return false;
		if (a & 1)return -r < -q.r;
		else return r < q.r;
	}
};

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

	cin >> N >> K;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<Query>query(K);
	int cnt = 0;
	for (auto &i : query) {
		i.index = cnt++;
		cin >> i.l >> i.r;
		i.l--;
	}
	sort(query.begin(), query.end());
	vector<int>num(N + 1);
	int ans = 0;
	L = 0, R = 0;
	vector<int>ret(K);
	for (auto q : query) {
		while (q.l > L) {
			num[v[L]]--;
			if (num[v[L]] == 0)ans--;
			L++;
		}
		while (q.l < L) {
			L--;
			num[v[L]]++;
			if (num[v[L]] == 1)ans++;
		}
		while (q.r > R) {
			num[v[R]]++;
			if (num[v[R]] == 1)ans++;
			R++;
		}
		while (q.r < R) {
			R--;
			num[v[R]]--;
			if (num[v[R]] == 0)ans--;
		}
		ret[q.index] = ans;
	}
	for (auto i : ret)cout << i << endl;
}

Measured memory_bytes: 15484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

ll gcd(ll a, ll b) {
  if(a < b) gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  ll a,b;
  cin >>  a >> b;
  ll n=gcd(a,b);
  //  cout << n << endl;
  ll nn=n;
  ll ans=1;
  ll i=2;
  vector<ll> ret;
  if(n!=1) ret.pb(n);
  while(n>0){
    bool update=false;
    if(n % i == 0){
      ret.pb(i);
      update=true;
    }
    while(n % i == 0) {
      n/=i;
    }
    if(update && n!=1) ret.pb(n);
    i++;
    if(i*i>nn) break;
  }
  ll vn=ret.size();
  sort(ret.begin(), ret.end());
  bool is_prime[vn];
  ll p=0;
  rep(i,vn) is_prime[i]=true;
  rep(i,vn){
    if(is_prime[i]){
      //      cout << ret[i] << endl;
      for(ll j=i+1; j<vn; j++){
	if(!is_prime[j]) continue;
	if(ret[j]/ret[i]*ret[i]==ret[j])
	is_prime[j]=false;
      }
    }
  }
  rep(i,vn) if(is_prime[i]) ans++;
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] Ls = new int[101];
		for (int i = 0; i < 101; i++) {
		    Ls[i] = 0;
		}
		for (int i = 0; i < 2 * N; i++) {
		    Ls[sc.nextInt()]++;
		}
		int ans = 0;
		boolean lest = false;
		int lestLength = 0;
		for (int i = 0; i < 101; i++) {
		    int currentLength = Ls[i];
		    if (currentLength > 0) {
		        if (lest) {
		            ans += lestLength;
		            currentLength--;
		            lest = false;
		        }
		        ans += i * (currentLength / 2);
		        if (currentLength % 2 == 1) {
		            lest = true;
		            lestLength = i;
		        }
		    }
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 9940
A=[int(input()) for i in range(5)]
B=[10 if A[i]%10==0 else A[i]%10 for i in range(5)]
k=B.index(min(B))
C=[(A[i]-0.001)//10*10+10 for i in range(5)]
print(int(sum(C)-C[k]+A[k]))


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int ia = 0, ib = 0, ic = 0, Alen, Blen, Clen, x;
  char A[100], B[100], C[100], next;
  x = scanf("%s %s %s", A, B, C);

  Alen = strlen(A);
  Blen = strlen(B);
  Clen = strlen(C);

  next = A[0];
  while(1){
    if(next == 'a'){
      next = A[ia ++];
    }
    else if(next == 'b'){
      next = B[ib ++];
    }
    else if(next == 'c'){
      next = C[ic ++];
    }
    else{
      printf("too long\n");
      exit(1);
    }
    if(ia > Alen){
      printf("A\n");
      return 0;
    }
    if(ib > Blen){
      printf("B\n");
      return 0;
    }
    if(ic > Clen){
      printf("C\n");
      return 0;
    }
  }
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int n;
ll score[4][200000],memo[4][200000];
bool calc[4][200000];
ll dp(int type, int x){
    if(x==n)return score[type][x];
    else if(calc[type][x])return memo[type][x];
    else{
        calc[type][x]=true;
        ll res = 0;

        for(int i=1;i<=3;i++){
            if(i==type)continue;
            else{
                res = max(res,score[type][x]+dp(i,x+1));
            }
        }

        memo[type][x]=res;
        return res;
    }
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    for(int i=1;i<=n;i++)cin>>score[1][i]>>score[2][i]>>score[3][i];

    ll ans = 0;
    for(int i=1;i<=3;i++)ans=max(ans,dp(i,1));
    cout<<ans<<newl;
}



Measured memory_bytes: 18816
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second   
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef vector<int> vi;
typedef pair<int, int> pii; 
typedef pair<int , pii> piii ; 
typedef unsigned long long ull ;

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

void solve()
{
    int k;
    cin >> k;
    cout << a[k - 1];
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define ceil(x,m) ((x)+(m)-1)/(m)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   int len = v.size();
   s << "[";
   for (int i = 0; i < len; i++) { s << v[i]; if (i < len - 1) s << " "; }
   s << "]";
   return s;
}

vector<int> frac;
void init_frac(int N) {
   frac.push_back(1);
   for (int i = 1; i <= N; i++) {
      frac.push_back(mod(frac[i-1] * i));
   }
}

int powM(int x, int n) {
   int res = 1;
   while (n > 0) {
      if ((n & 1) == 1) {
         res = mod(res * x);
      }
      x = mod(x * x);
      n >>= 1;
   }
   return res;
}
int inverseM(int x) {
   return powM(x, MOD-2);
}

signed main()
{
   int n; cin >> n;
   vec<int> a(n);
   rep(i, 0, n) {
      cin >> a[i];
   }

   vec<int> b(n+1, 0);
   rep(i, 0, n) {
      b[i+1] = mod(b[i] + inverseM(i+1));
   }

   init_frac(n);

   int ans = 0;
   rep(i, 0, n) {
      ans += mod(mod(b[i+1] + b[n-i] - 1) * mod(a[i] * frac[n]));
      ans = mod(ans);
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 2936
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var str string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &str)
	s := strings.Split(str, "")
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &str)
	t := strings.Split(str, "")

	dp := make([][]int, len(s)+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, len(t)+1)
	}

	for i := 1; i < len(s)+1; i++ {
		for j := 1; j < len(t)+1; j++ {
			if s[i-1] == t[j-1] {
				dp[i][j] = dp[i-1][j-1] + 1
			} else {
				dp[i][j] = max(
					dp[i-1][j],
					dp[i][j-1],
				)
			}
		}
	}

	/*
		for i := 1; i < len(s)+1; i++ {
			for j := 1; j < len(t)+1; j++ {
				fmt.Print(dp[i][j], " ")
			}
			fmt.Println()
		}
	*/

	{
		var buffer bytes.Buffer
		i, j := len(s), len(t)
		for i > 0 && j > 0 {
			if dp[i][j] != dp[i-1][j] && dp[i][j] != dp[i][j-1] {
				buffer.WriteString(s[i-1])
				i, j = i-1, j-1
			} else if dp[i][j] == dp[i-1][j] {
				i = i - 1
			} else {
				j = j - 1
			}
		}
		fmt.Println(reverseString(buffer.String()))
	}

}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func reverseString(str string) string {
	rs := []rune(str)
	for i, j := 0, len(rs)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}


Measured memory_bytes: 75520
#include<iostream>
#include<string>
#include<map>
#include<string.h>
#include<vector>
#include<set>
#include<stdio.h>
#include<math.h>
//#include<algothm>
#include<queue>
typedef long long ll;
typedef long double ld;
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if((a>x) || (a+b<x))
		cout<<"NO"<<endl;
	else
		cout<<"YES"<<endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <cstdio>
#include <cstdlib>

#define N 10
#define D 30

static int  n;
static int  w;
static int  d;
static char a[ D ][ N + 1 ];

int
FSA (
  int p,
  int r
  )
{
  if ( r == d ) return ( p == w - 1 );

  if ( p > 0 && a[ r ][ p - 1 ] == '1' )
  {
    return
    FSA ( p - 1, r + 1 );
  }
  if ( p < n - 1 && a[ r ][ p ] == '1' )
  {
    return
    FSA ( p + 1, r + 1 );
  }

  return
  FSA ( p, r + 1 );
}

int
main ( )
{
  int i, j;

  for ( ; ; )
  {
    int m;

    scanf ( " %d", &n );
    if ( n == 0 ) break ;
    scanf ( " %d %d %d", &m, &w, &d );

    for ( i = 0; i < d; ++i )
    {
      scanf ( " %s", a[ i ] );
    }

    if ( FSA ( m - 1, 0 ) )
    {
      puts ( "0" );
      continue ;
    }
    for ( i = 0; i < d; ++i )
    {
      for ( j = 0; j < n - 1; ++j )
      {
        if ( ( j == 0 || a[ i ][ j - 1 ] == '0' )
          && ( a[ i ][ j ] == '0' )
          && ( j == n - 2 || a[ i ][ j + 1 ] == '0' ) )
        {
          a[ i ][ j ] = '1';
          if ( FSA ( m - 1, 0 ) )
          {
            printf ( "%d %d\n", i + 1, j + 1 );
            break ;
          }
          a[ i ][ j ] = '0';
        }
      }
      if ( j != n - 1 ) break ;
    }
    if ( i == d )
    {
      puts ( "1" );
      continue ;
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
def main():
    n=int(input())
    t = list(map(int,input().split()))
    m=int(input())
    p=[0 for i in range(m)]
    x=[0 for i in range(m)]
    for i in range(m):
        p[i],x[i] = map(int,input().split())
    
    for i in range(m):
        ans=sum(t)
        ans=ans+x[i]-t[p[i]-1]
        print(ans)
        
main()

Measured memory_bytes: 3064
N,K= map(int ,input().split())


A =list(map(int ,input().split()))


data_list=list(A)

min_index=data_list.index(min(data_list))+1

anser=0

if (N-1) % (K-1) == 0:
	print((N-1)//(K-1))
else:
  	print((N-1)//(K-1)+1)

Measured memory_bytes: 13880
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int l; cin>>l; cin.ignore();


    long long cube = (ll) l*(ll) l *(ll) l;
    long double v = (long double)cube/(long double)27;
    cout<<setprecision(10)<<v<<el;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int number[100];
  char operater[100];
  int n = 0; 
  while( scanf("%s", operater) != EOF ){

    if ( operater[0] == '+' ){
     number[n-2] = number[n-2] + number[n-1];
     n--;
    } else if ( operater[0] == '-' ){
      number[n-2] = number[n-2] - number[n-1];
      n--;
    } else if ( operater[0] == '*' ){
      number[n-2] = number[n-2] * number[n-1];
      n--;
    } else {
	number[n] = atoi(operater);
	n++;
    }

  }
  printf("%d\n",number[0]);
  return 0;
}

Measured memory_bytes: 548
a,b,c = map(int,input().split())

if (a<b<c or a==b<c):
    print(a,b,c)
elif (a<c<b or a==c<b):
    print(a,c,b)
elif (b<c<a or b==c<a):
    print(b,c,a)
elif (b<a<c or b==a<c):
    print(b,a,c)
elif (c<a<b or c==a<b):
    print(c,a,b)
else:
    print(c,b,a)


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll gcd(ll a, ll b){
  if(b > a)
    return gcd(b, a);
  if(b == 0)
    return a;
  
  return gcd(b, a%b);
}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  //b,a
  ll n, x;
  cin >> n >> x;
  vector<ll> city(n);
  
  REP(i,n)
    cin >> city[i];
  ll nowgcd = abs(city[0] - x);
  REP1(i,n){
    nowgcd = gcd(abs(city[i]-x), nowgcd);
  }
  
  cout << nowgcd << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
    #define ll long long
    #define f   first
    #define s   second
    #define pb          push_back
    #define mod         1000000007
    #define hell        998244353
    #define inf         1000000000000000000LL
    using namespace std;
    ll n,k,m,l,mx,sum,q;
    //ll dp[15][1005]
    void solve()
    {   ll a,b,x,y;
        cin>>a>>x>>b>>y;
        bool f=0;
        while(1)
        {
            if(f==0)
            {
                b-=x;
                if(b<=0) {cout<<"Yes\n";return;}
            }
            else
            {
                a-=y;
                if(a<=0) {cout<<"No\n";return;}
            }
            f^=1;
        }
        
    }    
    int main()
    {  
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        //cout<<primes.size();
        
        ll t=1;
        //cin>>t;
        while(t--)
            solve();

    }


Measured memory_bytes: 3608
#include <stdio.h>
int selectionsort(int a[],int n)
{
    int i,j,t,m=0,minj;
    for(i=0;i<n-1;i++)
    {
        minj=i;
        for(j=i;j<n;j++)
        {
            if(a[j]<a[minj]) minj=j;
        }
        t=a[i];a[i]=a[minj];a[minj]=t;
        if(i!=minj)m++;
    }
        return m;
}
int main()
{
    int a[100],n,i,m;
    scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&a[i]);
m=selectionsort(a,n);
for(i=0;i<n;i++)
{
    if(i>0) printf(" ");
    printf("%d",a[i]);
}
printf("\n");
printf("%d\n",m);
return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

vector<ll> m(1001,0);

ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

int main(){

    ll n; cin >> n;
    char mem;
    ll ans = 1;
    
    string s; cin >> s;
    
    mem = s[0];
    
    for(int i = 1; i < s.length(); i ++){
        if(s[i] == mem){
            //なんも
        }else{
            ans ++;
            mem = s[i];
        }
    }
    
    cout << ans;
    
    return 0;
}

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

using namespace std;

typedef long long LL;

#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int main(){
    string s;
    cin>>s;
    for(auto &it:s)if(it==',')it=' ';
    cout<<s<<endl;
    return 0;
}


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

#include <vector>

void func();

int main(){
    func();
}

void func(){
    int n;
    cin >> n;
    vector<int> v = {};
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());

    int a=0,b=0;
    for(int i = 0; i < n; i++)
    {
        if(i&1){
            a += v[i];
        }else{
            b += v[i];
        }
    }
    cout << max(a,b) - min(a,b) << "\n";
}



Measured memory_bytes: 256
n = int(input())
s = input()
q = int(input())
commands = []
for _ in range(q):
    com, x, y = input().split()
    commands.append((com, int(x), y))

size = 1
while size < n:
    size *= 2

# initialize
segment_tree = [0 for _ in range(2 * size - 1)]


def alphabet2bit(string):
    return 1 << (ord(string) - ord('a'))

def update(i, x, segment_tree):
    i += size - 1
    segment_tree[i] = alphabet2bit(x)
    while i > 0:
        i = (i - 1) // 2
        left = segment_tree[i * 2 + 1]
        right = segment_tree[i * 2 + 2]
        segment_tree[i] = left | right

def getSum(s, t, k, l, r, segment_tree):
    if r <= s or t <= l:
        return 0
    if s <= l and r <= t:
        return segment_tree[k]
    else:
        ask_left = getSum(s, t, k * 2 + 1, l, (l + r) // 2, segment_tree)
        ask_right = getSum(s, t, k * 2 + 2, (l + r) // 2, r, segment_tree)
        return ask_left | ask_right

for i in range(n):
    update(i, s[i], segment_tree)

for com, x, y in commands:
    if com == '1':
        update(x - 1, y, segment_tree)
    else:
        result = getSum(x - 1, int(y), 0, 0, size, segment_tree)
        print(bin(result).count('1'))

Measured memory_bytes: 118088
//q1
// pactice
 
#pragma warning(disable:4996)
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX_NUMBER 100000
#define MAX_STRING 1000000

	int anNumber[MAX_NUMBER+1];
	int anDiff[MAX_NUMBER];
//	int anBigger[MAX_NUMBER+1];
//	int anSmaller[MAX_NUMBER+1];
	char sInput[MAX_STRING+1]="";
	int compare(const int *val1, const int *val2);

int main() {
 
	char* psInput=NULL;
	int nNumberOfNumber=0;
	int nExtraNumber=0; // 初期座標
	int nMaxNum=0;
	int nTargetNum=0;

	int i=0;
	int nTemp=0;
	int nTempDiff=0;
	int nMinDiff=1100000000;
	int nStartPos=-1;
	int nSmallerIsOk=0;
	int nBiggerIsOk=0;
	int nOk=0;

	for(i=0;i<MAX_NUMBER;i++){
		anNumber[i]=0;
		anDiff[i]=0;
	}
	anNumber[MAX_NUMBER]=0;
	// read line 1
	gets(sInput);
	psInput = strtok(sInput," ");
	nNumberOfNumber=atoi(psInput);
	psInput = strtok(NULL," ");
	nExtraNumber=atoi(psInput);

	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<nNumberOfNumber;i++){
		anNumber[i]=atoi(psInput);
		if(nMaxNum<anNumber[i]){
			nMaxNum=anNumber[i];
		}
		psInput = strtok(NULL," ");
	}
	anNumber[nNumberOfNumber]=nExtraNumber;

    qsort(anNumber, nNumberOfNumber+1, sizeof(int),
        (int (*)(const void *, const void *))compare
    );
/*	for (i=0;i<nNumberOfNumber+1;i++){
		if(anNumber[i]==nExtraNumber){
			nStartPos=i;
			break;
		}
	}*/
	for (i=1;i<nNumberOfNumber+1;i++){
		nTempDiff=anNumber[i]-anNumber[i-1];
		anDiff[i-1]=nTempDiff;
		if(nTempDiff<nMinDiff){
			nMinDiff=nTempDiff;
		}
	}
	nTargetNum=nMinDiff;
	while(!nOk&&nTargetNum>1){
		nOk=1;
		for (i=0;i<nNumberOfNumber;i++){
			if(anDiff[i]%nTargetNum!=0){
				nOk=0;
				nTargetNum--;
				break;
			}
		}
	}
	printf("%d\n",nTargetNum);
	/*
	nTargetNum=nMaxNum+1;
	while(!nSmallerIsOk||!nBiggerIsOk){
		nSmallerIsOk=1;
		nBiggerIsOk=1;
		nTargetNum--;
		// 初期位置の左側を走査
		if(nStartPos>0){
			for(i=nStartPos-1;i>=0;i--){
				nTemp=nExtraNumber-anNumber[i];
				if(nTemp % nTargetNum!=0){
					nSmallerIsOk=0;
					break;
				}
			}
		}
		// 初期位置の右側を走査
		if(nSmallerIsOk>0&&nStartPos<nNumberOfNumber){
			for(i=nStartPos+1;i<=nNumberOfNumber;i++){
				nTemp=anNumber[i]-nExtraNumber;
				if(nTemp % nTargetNum!=0){
					nBiggerIsOk=0;
					break;
				}
			}
		}
	}
	printf("%d\n",nTargetNum);*/

	return 0;
}
int compare(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}


Measured memory_bytes: 2300
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n, i;
  string s;
  while(cin >> n,n){
    int sum = 1;
    int a=1, b=2, c=3, d=5, e=4, f=6, x;
    for(int j= 0; j<n; j++){
      cin >> s;
      if(s=="North"){x=a; a=b; b=f; f=d; d=x;}
      else if(s=="East"){x=a; a=e; e=f; f=c; c=x;}
      else if(s=="West"){x=a; a=c; c=f; f=e; e=x;}
      else if (s== "South"){x=a; a=d; d=f; f=b; b=x;}
      else if(s=="Right"){x=b; b=c; c=d; d=e; e=x;}
      else {x=d; d=c; c=b; b=e; e=x;}
      //cout<<a<<b<<c<<d<<e<<f<<endl;
      sum += a;
    }
    cout<<sum <<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int N,T; cin>>N>>T;
  vector<int> cn;

  int minC=INT_MAX;
  for (int i=0;i<N;i++) {
    int c,t; cin>>c>>t;

    if (t <= T) {
      minC = min(minC, c);
    }
  }

  if (minC == INT_MAX) {
    cout << "TLE" << endl;
  } else {
    cout << minC << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    vi b = a;
    sort(_all(b));

    int m1 = b[n-1], m2 = b[n-2];
    for(auto& e : a){
        int res = m1;
        if(e == m1){
            res = m2;
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 3200
from bisect import bisect_left as bl

def main():
  n, c = map(int, input().split())
  ranking = [(0, i) for i in range(n)]
  points = [0 for _ in range(n)]
  for _ in range(c):
    com = input().split()
    if com[0] == "1":
      m = int(com[1]) - 1
      print(ranking[m][-1] + 1, -ranking[m][0])
    else:
      t, p = map(int, com[1:])
      t -= 1
      point = points[t]
      index = bl(ranking, (point, t))
      ranking.pop(index)
      new_point = point - p
      new_index = bl(ranking, (new_point, t))
      ranking.insert(new_index, (new_point, t))
      points[t] = new_point

main()


Measured memory_bytes: 19988
#include <iostream>
using namespace std;
int main(void) {
  int c[9];
  for (int i = 0; i < 9; i++) {
    cin >> c[i];
  }
  if (c[3] - c[0] == c[4] - c[1] && c[4] - c[1] == c[5] - c[2]
    && c[3] - c[6] == c[4] - c[7] && c[4] - c[7] == c[5] - c[8]
    && c[1] - c[0] == c[4] - c[3] && c[4] - c[3] == c[7] - c[6]
    && c[1] - c[2] == c[4] - c[5] && c[4] - c[5] == c[7] - c[8]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;
    ll one = min(4*Q, min(2*H, S));
    ll two = min(2*one, D);
    out((N/2)*two+(N%2)*one);
}

int main() {
    fast_io;
    solve();
    return 0;
}

Measured memory_bytes: 256
def print_list(a):
    out = ''
    for ai in a:
        out += str(ai) + ' '
    else:
        out = out[:-1]
    print(out)

def selection_sort(a, n):
    cnt = 0
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        if i != minj:
            tmp = a[i]
            a[i] = a[minj]
            a[minj] = tmp
            cnt += 1

    print_list(a)
    print(str(cnt))
    return a

n = int(input())
a = list(map(int, input().split(' ')))

a = selection_sort(a, n)


Measured memory_bytes: 5596
<?php
$card = [];
$open_row = [];
$open_col = [];

$bingo = "No";
for ($i = 0;$i < 3;++$i) {
    $card[$i] = explode(" ",trim(fgets(STDIN)));
}

$n = trim(fgets(STDIN));
for ($i = 0;$i < $n;++$i) {
    $num = trim(fgets(STDIN));
    foreach($card as $row => $tmp) {
        foreach($tmp as $col => $cnum) {
            if ($num == $cnum) {
                $card[$row][$col] = 0;
            }
        }
    }
}

if (
    ($card[0][0] == 0 and $card[0][1] == 0 and $card[0][2] == 0)
    or ($card[1][0] == 0 and $card[1][1] == 0 and $card[1][2] == 0)
    or ($card[2][0] == 0 and $card[2][1] == 0 and $card[2][2] == 0)
    or ($card[0][0] == 0 and $card[1][0] == 0 and $card[2][0] == 0)
    or ($card[0][1] == 0 and $card[1][1] == 0 and $card[2][1] == 0)
    or ($card[0][2] == 0 and $card[1][2] == 0 and $card[2][2] == 0)
    or ($card[0][0] == 0 and $card[1][1] == 0 and $card[2][2] == 0)
    or ($card[0][2] == 0 and $card[1][1] == 0 and $card[2][0] == 0)
) {
    $bingo = "Yes";
}
echo $bingo.PHP_EOL;

Measured memory_bytes: 16364
#include<bits/stdc++.h>
using namespace std;
int m,n,q,A[20];
int ans(int x,int y){
  if(x==0)return 0;
if(y>=n)return 1;
  if(ans(x,y+1)==0 || ans(x-A[y],y+1)==0)return 0;
  else return 1;
}
  
int main(){ 
  cin>>n; 
  for(int i=0;i<n;i++)cin>>A[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>m;
    if(ans(m,0)==0)cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
n = int(input())
xyhs = [tuple(map(int,input().split())) for _ in range(n)]

idx = 0
while(xyhs[idx][2] == 0):
    idx+=1

for i in range(101):
    for j in range(101):
        nowh = xyhs[idx][2] + abs(i-xyhs[idx][0]) +abs(j-xyhs[idx][1])
        isCorrect = True
        for k in range(n):
            calch = max(nowh - abs(i-xyhs[k][0]) - abs(j-xyhs[k][1]),0)
            if calch != xyhs[k][2]:
                isCorrect = False
        
        if isCorrect:
            print(i,j,nowh)




Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long int A,B,C,D;

    cin >> A >> B >> C >>D;
    if(A+B > C+D){
        cout << "Left";
    }else if(A+B == C+D){
        cout << "Balanced";
    }else{
        cout << "Right";
    }
    return 0;
}

Measured memory_bytes: 256
def main():
	k,x = map(int,input().split())

	mae = x-k+1
	ato = x+k-1

	if mae <= -1000000:
		mae = -1000000
	if ato >= 1000000:
		ato = 1000000
	print(' '.join(map(str,list(range(mae,ato+1)))))

if __name__ == '__main__':
	main()

Measured memory_bytes: 38384