akhauriyash/Code-Regression huggingface dataset:
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N,A,B;
  cin >> N >> A >> B;

  int rem = N % (A + B);
  int div = N / (A + B);
  if(rem >= A){
    cout << div * A + A << endl;
  }
  else{
    cout << div * A + rem << endl;
  }

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 384
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]
cc = inputs[0][2]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

if aa == bb and bb == cc
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());
        Integer m = Integer.parseInt(scanner.next());


        if (n.equals(m)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
fun main(args:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val items = readLine()!!.split(" ").map { it.toLong() }.toMutableList()
    val itemsMin = (1..itemCount).map { Long.MAX_VALUE }.toMutableList()
    itemsMin[items.lastIndex] = items.last()
    for(i in (0 until items.lastIndex).reversed()) {
        itemsMin[i] = Math.min(itemsMin[i + 1], items[i])
    }
    var ans = "Yes"
    items[0] = items[0] - 1
    for(i in (1 until items.size)) {
        if(items[i-1] > items[i]) {
            ans = "No"
            break
        }
        if(items[i-1] == items[i]) {
            continue
        }
        items[i] = items[i] - 1
        if(items[i] > itemsMin[i]) {
            ans = "No"
            break
        }
    }
    println(ans)

}



Measured memory_bytes: 58052
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    //int n=s.size();
    if(s.size()&1){
      cout<<"No"<<endl;
    }
    else
    {
      if(s.substr(0,n/2)== s.substr(n/2)){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }
    
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

string s,t;
int main(){
  cin >> s >> t;
  int x=(s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]);
  cout << x;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>



using namespace std;

int basutei[15]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};

int main(){
    int n;
    cin>>n;
    for(int roop=0; roop<n; roop++){
        int b,e;
        cin>>b>>e;
        int start1;
        int end1;
        for(int i=0; i<15; i++){
            if(basutei[i]==b){
                start1=i;
                break;
            }
        }
        
        for(int i=0; i<15; i++){
            if(basutei[(start1+i)%15]==e){
                end1=(start1+i)%15;
                break;
            }
        }
        int l1=0;
        if(end1<start1){
            l1=end1+15-start1;
        }else{
            l1=end1-start1;
        }
        
        //----------------------------------
        
        int start2;
        int end2;
        for(int i=15; i>=0; i--){
            if(basutei[i]==b){
                start2=i;
                break;
            }
        }
        
        for(int i=0; i<15; i++){
            if(basutei[(start2+i)%15]==e){
                end2=(start2+i)%15;
                break;
            }
        }
        
        int l2=0;
        if(end2<start2){
            l2=end2+15-start2;
        }else{
            l2=end2-start2;
        }
        if(l1<l2){
            cout<<basutei[start1];
            for(int i=start1+1; i<=start1+l1; i++){
                cout<<" "<<basutei[i%15];
            }
            cout<<endl;
        }else{
            cout<<basutei[start2];
            for(int i=start2+1; i<=start2+l2; i++){
                cout<<" "<<basutei[i%15];
            }
            cout<<endl;
            
        }
    }
}

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

#include <iostream>
#include <fstream>

#include <iostream>

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a,b;
        in>>a>>b;
        if(a%3 == 0 || b%3 == 0 || (a+b) % 3 == 0){
            out<<"Possible";
        }
        else{
            out<<"Impossible";
        }
	}
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
#define rep1(i,n) for (int i=1 ; i<=(n) ; ++i)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <string, string> P;

int main(){
  int x[5];
  rep(i,5){
    cin >> x[i];
    if(x[i]==0){
      cout << i+1 << endl;
    }
  }

  return 0;
}


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

int n,t,a,h;

int main(){
    cin>>n>>t>>a;
    double min=10000000;
    int ans;
    for(int i=0;i<n;i++){
        cin>>h;
        if(abs(a-t+h*0.006)<min){
            min=abs(a-t+h*0.006);
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    int N;
    cin >> N;
    int tmp = N / 2 + (N % 2);
    cout << tmp << endl;

    return 0;
}



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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    map<int, int> dict;
    vector<bool> ac(n+1, false);
    for(int i=0;i<m;i++)
    {
        int x;
        string z;
        cin >> x >> z;
        if(ac[x]) continue;
        if(z == "AC")
        {
            ac[x] = true;
        }
        else dict[x]+=1;
    }
    int nac=0, pen = 0;
    for(int i=1;i<=n;i++)
    {
        if(ac[i])
        {
            nac++;
            pen += dict[i];
        }
    }
    cout << nac << " " << pen << "\n"; 

    return 0;
}



Measured memory_bytes: 6528
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C] = input[0].map(Number);

  for (let i = A; i < A * B; i += A) {
    if (i % B === C) {
      return "YES";
    }
  }

  return "NO";
};

console.log(main(read()));


Measured memory_bytes: 29320
#include<bits/stdc++.h>
#define INF (1e9)
#define N 101
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;

int m,n,k1,s,t,flag;
vector<int> ei[N],eo[N];
string cond;
vector<P1> v[N];
map<int,P> pam[N];

int main(){
  cin>>m>>n;
  for(int i=0;i<m;i++){
    cin>>k1;
    for(int j=0;j<k1;j++){
      cin>>s>>cond>>t;
      if(cond[0]=='>')v[i].push_back(P1(s,P(t,INF)));
      else v[i].push_back(P1(s,P(0,t)));
    }
    sort(v[i].begin(),v[i].end());
  }
  
  for(int i=0;i<m;i++){
    for(int j=0;j<(int)v[i].size()-1;j++){
      if(v[i][j].first!=v[i][j+1].first)continue;
      int min1=v[i][j].second.first;
      int max1=v[i][j].second.second;
      int min2=v[i][j+1].second.first;
      int max2=v[i][j+1].second.second;
      if(max1<min2)flag=1;
      else{
	v[i][j]=P1(v[i][j+1].first,P(max(min1,min2),min(max1,max2)));
	v[i].erase(v[i].begin()+j+1);
	j--;
      }
    }
  }
  for(int i=0;i<m;i++)
    for(int j=0;j<(int)v[i].size();j++){
      int t1=v[i][j].first;
      int t2=v[i][j].second.first;
      int t3=v[i][j].second.second;
      pam[i].insert(make_pair(t1,P(t2,t3)));
    }
  for(int i=1;i<=n;i++){
    for(int j=0;j<m;j++){
      if(pam[j].find(i)==pam[j].end())continue;
      map<int,P>::iterator ite1=pam[j].find(i);
      for(int k=j+1;k<m;k++){
	if(pam[k].find(i)==pam[k].end())continue;
	if(j==k)continue;
	map<int,P>::iterator ite2=pam[k].find(i);
	int min1=(*ite1).second.first;
	int max1=(*ite1).second.second;
	int min2=(*ite2).second.first;
	int max2=(*ite2).second.second;
	if(max1<min2){
	  eo[j].push_back(k);
	  ei[k].push_back(j);
	}
	if(max2<min1){
	  eo[k].push_back(j);
	  ei[j].push_back(k);
	}
      }
    }
  }
  queue<int> S,L;
  for(int i=0;i<m;i++)
    if(!ei[i].size())S.push(i);
  while(!S.empty()){
    int t=S.front(); S.pop();
    L.push(t);
    for(int i=0;i<eo[t].size();i++){
      int out=eo[t][i];
      for(int k=0;k<ei[out].size();k++)
	if(ei[out][k]==t)ei[out].erase(ei[out].begin()+k);
      eo[t].erase(eo[t].begin()+i);
      i--;
      if(!ei[out].size())S.push(out);
    }
  }
  for(int i=0;i<m;i++)
    if(ei[i].size()||eo[i].size())flag=1;
  if(flag)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int b[100005];
int main(){
    int n;
    cin >> n;
    int a[n+2];
    a[0]=0;
    for(int i=1;i<n+1;i++){
        cin >> a[i];
        b[i] = b[i-1] + abs(a[i]-a[i-1]);
    }
    b[n+1] = b[n] + abs(a[0]-a[n]);
    a[n+1]=0;
    for(int i=1;i<n+1;i++)cout << b[n+1] - abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]) << endl;
}

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

int main() {
  int a;
  cin >> a;
  int b = a/100; //100の位
  int c = (a - b*100)/10;//10の位
  int d = (a - b*100 - c*10);
    
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
n = int(input())
p = [int(_) for _ in input().split()]
ans = 0

for i in range(1,n-1):
    if p[i-1] < p[i] and p[i] <= p[i+1]:
        ans = ans + 1
    elif p[i+1] < p[i] and p[i] <= p[i-1]:
        ans = ans + 1
        # print(p[i-1], p[i],p[i+1])

print(ans)
    

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
     
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      if(a <= 9 && b <= 9){
        System.out.println(a*b);
      }else{
        System.out.println(-1);
      }
      
      sc.close();
    }
}


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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll pat1 = b * d;
    ll pat2 = a * c;
    ll pat3 = b * c;
    ll pat4 = a * d;

    ll ans;
    ans = max(pat1, pat2);
    ans = max(ans, pat3);
    ans = max(ans, pat4);

    cout << ans << endl;

	return 0;
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010, mod = 1e9 + 7;

int n, m;
int a[N];
int fact[N], infact[N];

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = 1;
	res = (LL)fact[a] * infact[b] % mod * infact[a - b] % mod;
	return res;
}

void init(int n)
{
	fact[0] = infact[0] = 1;
	for (int i = 1; i <= n; i ++ )
	{
		fact[i] = (LL)fact[i - 1] * i % mod;
		infact[i] = (LL)infact[i - 1] * qp(i, mod - 2) % mod;
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	init(n);
	
	for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	
	int res = 0;
	sort(a + 1, a + 1 + n);
	for (int i = m; i <= n; i ++ ) res = (res + (LL)a[i] * C(i - 1, m - 1) % mod) % mod;
	reverse(a + 1, a + 1 + n);
	for (int i = m; i <= n; i ++ ) res = (res - (LL)a[i] * C(i - 1, m - 1) % mod) % mod;
	
	res = (res % mod + mod) % mod;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int n[3];
	cin >> n[0] >> n[1] >> n[2];
	sort(n, n + 3);
	cout << n[0] + n[1] << endl;
	return 0;
}

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

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

function<LL(LL, LL)> gcdlambda = [](LL n, LL m) { return __gcd(n, m); };

void solve(long long N, std::vector<long long> A) {
  vector<LL> front = {0};
  partial_sum(A.begin(), A.end(), back_inserter(front), gcdlambda);
  reverse(A.begin(), A.end());
  vector<LL> back = {0};
  partial_sum(A.begin(), A.end(), back_inserter(back), gcdlambda);
  LL maxim = 0;
  for (int i = 0; i < N; i++) {
    maxim = max(maxim, gcdlambda(front[i], back[N - i - 1]));
  }
  cout << maxim << endl;
}

int main() {
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


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

typedef struct{
	int key;
	int left;
	int right;
} Node;

void insert(Node*, int, int);
void print1(Node*, int);
void print2(Node*, int);

int main()
{
	char s[10];
	Node *t;
	int m;
	int a;
	int i;

	scanf("%d", &m);
	t=(Node*)malloc(sizeof(Node)*m);

	int count=0;
	for(i=0; i<m; i++){
		scanf("%s", &s);
		if(s[0]=='i'){ scanf("%d", &a); insert(t, count, a); count++; }
		if(s[0]=='p'){
			if(count>0) print1(t, 0);
			printf("\n");
			if(count>0) print2(t, 0);
			printf("\n");
		}
	}
	
	return 0;

}

void print1(Node *t, int p)
{
	if(t[p].left>=0) print1(t, t[p].left);
	printf(" %d", t[p].key);
	if(t[p].right>=0) print1(t, t[p].right);
}

void print2(Node *t, int p)
{
	printf(" %d", t[p].key);
	if(t[p].left>=0) print2(t, t[p].left);
	if(t[p].right>=0) print2(t, t[p].right);
}

void insert(Node *t, int count, int z)
{
	int x=0, y;
	if(count<1) x=-1;

	t[count].key = z;
	t[count].left = -1;
	t[count].right= -1;

	while(x>=0){
		y = x; // ???????¨????
		if(z < t[x].key)
			x = t[x].left; // ?????????????§????
		else 
			x = t[x].right; // ?????????????§????
	}

	if(count<1){}
	else if(z < t[y].key){
		t[y].left = count; // z ??? y ?????????????????????
	}
	else {
		t[y].right = count; // z ??? y ?????????????????????
	}
}

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

struct Card {
    char suit, value;
};

void bubbleSort(Card a[], int n) {
    for(int i = 0; i < n; i++) {
        for(int j = n - 1; j > i; j--) {
            if(a[j].value < a[j - 1].value) {
                swap(a[j], a[j - 1]);
            }
        }
    }
}

void selectionSort(Card a[], int n) {
    for(int i = 0; i < n; i++) {
        int minj = i;
        for(int j = i; j < n; j++) {
            if(a[j].value < a[minj].value)
                minj = j;
        }
        swap(a[i], a[minj]);
    }
}

void print(Card a[], int n) {
    for(int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << a[i].suit << a[i].value;
    }
    cout << endl;
}

bool isStable(Card C1[], Card C2[], int n) {
    for(int i = 0; i < n; i++) {
        if(C1[i].suit != C2[i].suit) 
            return false;
    }
    return true;
}

int main() {
    int n;
    Card C1[100], C2[100];
    
    cin >> n;
    
    for(int i = 0; i < n; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i = 0; i < n; i++) {
        C2[i] = C1[i];
    }
    
    bubbleSort(C1, n);
    selectionSort(C2, n);
    
    print(C1, n);
    cout << "Stable" << endl;
    print(C2, n);
    if(isStable(C1, C2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
        
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);


  int n, k;
  cin >> n >> k;

  cout << ((n + 1) / 2 >= k ? "YES" : "NO") << '\n';

  
  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 m=sc.nextInt();
      String po=sc.next();
      int num[]=new int[n+1];
      num[0]=0;
      for(int i=0;i<n-1;i++){
          num[i+1]=num[i]+((po.substring(i,i+2).equals("AC"))?1:0);
      }
      
      for(int i=0;i<m;i++){
      	int a=sc.nextInt();
        int b=sc.nextInt();
        System.out.println(num[b-1]-num[a-1]);
      }
    }
}


Measured memory_bytes: 65012
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,H; cin>>N>>H;
	vi B(N);
	int maxA = 0;
	rpz(i, N){
		int a,b; cin>>a>>b;
		B[i] = b;
		maxA = max(maxA, a);
	}
	sort(allr(B));
	int c;
	for(c=0; c<N && H>0 && B[c]>maxA; ++c) H -= B[c];
	if(H > 0) c += (H+maxA-1)/maxA;
	cout<< c <<endl;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

#list数を受け取る
n = int(input()) #6
li = list(map(int,input().split()))

DP = [None] * (n)
for i in range(n): #n = 6
    if i == 0:
        DP[i] = 0
    if i == 1:
        DP[i] = abs(li[i]-li[i-1])
    if i > 1:
        a = DP[i-2] + abs(li[i]-li[i-2])
        b = DP[i-1] + abs(li[i]-li[i-1])

        if a >= b:
            DP[i] = b
        else:
            DP[i] = a
    #print(DP)

print(DP[n-1])


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



int main(){
    int L, R;
    cin >> L >> R;
    if(L>=2019){
        R = R - 2019*(L/2019);
        L = L%2019;
    }
    int res = 2019;
    if(R>=2019){
        res = 0;
    }else{
        for(int i=L; i < R; i++){
            for(int j=i+1; j < R+1; j++){
                res = min(res, i*j%2019);
            }
        }
    }
    cout << res << endl;

}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<pair<int, int>> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i].first >> d[i].second;
  }
  for (int i = 0; i < n - 2; i++) {
    if (d[i].first == d[i].second && d[i + 1].first == d[i + 1].second && d[i + 2].first == d[i + 2].second) {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << '\n';
  return 0;
}

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

        int main() {         
	
			int64_t N, M;
			cin >> N >> M; 
            vector<int64_t> broken(N+1);
            vector<int64_t> answer(N+1);
          
       		for (int64_t i = 0; i < M; i++) {
                int64_t x; 
    			cin >> x;
                broken.at(x)=1; 
  	    	}
            
            answer.at(0)=1;
          	answer.at(1)= 1 - broken.at(1);
            for (int64_t i = 2; i < N+1; i++) { 
              answer.at(i) = (1 - broken.at(i-1))* answer.at(i-1)
                + (1 - broken.at(i-2))* answer.at(i-2); 
              answer.at(i) = answer.at(i) % 1000000007; 
            }
			cout<< answer.at(N)<<endl;
        }

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

void make_vec (vector<int> &ans) {
  int border = 10000 , tmp;

  for (int i = 1 ; i <= 50 ; i ++) {
    tmp = 6 * i * i;
    if (tmp > border) {
      continue;
    }
    ans.at(tmp - 1) ++;
  }

  for (int i = 1 ; i <= 100 ; i++) {
    for (int j = 1 ; j <= 100 ; j++) {
      tmp = (i + i + j) * (i + i + j) - (i * j + i * j + i * i);
      if (tmp > border) {
        continue;
      }
      if (i == j) {
        continue;
      }
      ans.at(tmp - 1) += 3;
    }
  }

  for (int i = 1 ; i <= 100 ; i ++) {
    for (int j = 1 ; j <= 100 ; j ++) {
      for (int k = 1 ; k <= 100 ; k ++) {
        tmp = (i + j + k) * (i + j + k) - (i * j + i * k + j * k);
        if (tmp > border) {
          continue;
        }
        if (!(i < j && j < k)) {
          continue;
        }
        ans.at(tmp - 1) += 6;
      }
    }
  }

}

void f (int n , vector<int> &ans) {
  for (int i = 0 ; i < n ; i ++) {
    cout << ans.at(i) << endl;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> ans(10000);
  make_vec(ans);

  f(n , ans);
}

Measured memory_bytes: 3636
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input().rstrip() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    c_most = c.most_common()
    ss = [cc[0] for cc in c_most if cc[1] == max_num]
    ss.sort()
    print("\n".join(ss))

if __name__ == "__main__":
    main()

Measured memory_bytes: 50280
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(mp(a,b),c)
#define pii pair<int,int>
#define piii pair<pii,int>
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pbc(x) __builtin_popcount(x)
#define clr(x) memset(x,0,sizeof x)
#define SIZE(x) (int)(x.size())
const int mod=1e9+7;
IL int pls(int x,int y){x+=y;return x>=mod?x-mod:x;}
IL int dec(int x,int y){x-=y;return x<0?x+mod:x;}
IL int mul(int x,int y){return 1ll*x*y%mod;}
IL int mul(int x,int y,int z){return mul(mul(x,y),z);}
IL int mul(int x,int y,int z,int p){return mul(mul(x,y),mul(z,p));}
IL void add(int &x,int y){x+=y;x=(x>=mod)?x-mod:x;}
IL int fpw(int x,int y,int r=1){for(;y;y>>=1,x=mul(x,x))if(y&1)r=mul(r,x);return r;}
IL int inv(int x){return fpw(x,mod-2);}
IL int gi(){int x;int _w=scanf("%d",&x);return x;}
IL void gi(int &x){int _w=scanf("%d",&x);}
IL void write(int x){printf("%d\n",x);}
void chkmax(int &x,int y){x=(x>y)?x:y;}
void chkmin(int &x,int y){x=(x<y)?x:y;}
const int INF=0x3f3f3f3f;
template<typename T>IL void debug(T x){cerr<<x;return;}
/* --------------------------------------------------------------------------------------------------------- */
int n,k;
const int maxn=5e5+10;
int a[maxn],p[maxn],deg[maxn],b[maxn];
vector<int>e[maxn];
int mn[maxn<<2];
void add(int p,int x,int y,int pos,int d){
	if(x==y){mn[p]=d;return;}
	int mid=(x+y)>>1;
	if(pos<=mid)add(p<<1,x,mid,pos,d);
	else add(p<<1|1,mid+1,y,pos,d);
	mn[p]=min(mn[p<<1],mn[p<<1|1]);
}
int qry(int p,int x,int y,int l,int r){
	if(x==l&&y==r)return mn[p];
	int mid=(x+y)>>1;
	if(r<=mid)return qry(p<<1,x,mid,l,r);
	else if(l>mid)return qry(p<<1|1,mid+1,y,l,r);
	else return min(qry(p<<1,x,mid,l,mid),qry(p<<1|1,mid+1,y,mid+1,r));
}
int main(){
#ifdef LOCAL
	freopen("/home/noilinux/Desktop/input.txt","r",stdin);
#endif
	memset(mn,0x3f,sizeof mn);
	n=gi();k=gi();
	rep(i,1,n)p[i]=gi(),a[p[i]]=i;
	repd(i,n,1){
		int pos;
		pos=qry(1,1,n,a[i],min(a[i]+k-1,n));
		if(pos!=INF)e[i].pb(pos),deg[pos]++;
		pos=qry(1,1,n,max(1,a[i]-k+1),a[i]);
		if(pos!=INF)e[i].pb(pos),deg[pos]++;
		add(1,1,n,a[i],i);
	}
	priority_queue<pii,vector<pii>,greater<pii> >q;
	for(int i=1;i<=n;++i)if(!deg[i])q.push({a[i],i});
	int cnt=0;
	while(q.size()){
		int t=q.top().se;q.pop();
		b[++cnt]=a[t];
		for(auto v:e[t]){
			deg[v]--;
			if(!deg[v])q.push({a[v],v});
		}
	}	
	rep(i,1,n)p[b[i]]=i;
	rep(i,1,n)printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 46464
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s.at(i) == 'L') {
				cout << "No" << endl; return 0;
			}
		}
		else {
			if (s.at(i) == 'R') {
				cout << "No" << endl; return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

#define int long long
#define trace(x) cerr << #x << ": " << x << " " << endl;


inline int add(int a, int b){a += b; if(a >= MOD)a -= MOD; return a;}
inline int sub(int a, int b){a -= b; if(a < 0)a += MOD; return a;}
inline int mul(int a, int b){return (int)((int) a * b %MOD);}


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

signed main()
{
    IOS
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n+1, 1);
    dp[0] = 0;
    REP(i, n-1)
    {
        // for(int x:dp)
        //     cout << x << " ";
        // cout << "\n";
        vector<int> ndp(n+1, 0);
        if(s[i] == '<')
        {
            FOR(k, 2, i+3, 1)
            {
                ndp[k] = sub(dp[k-1], dp[0]);

            }
        }
        else
        {
            FOR(k, 1, i+2, 1)
                ndp[k] = sub(dp[i+1], dp[k-1]);
            // ndp[i]+=dp[i];
        }
        // for(int x:ndp)
        //     cout << x << " ";
        // cout << "\n";
        FOR(k,1,i+3,1)
            ndp[k] = add(ndp[k], ndp[k-1]);
        dp = ndp;
        // for(int x:ndp)
        //     cout << x << " ";
        // cout  << "\n\n";
    }
    cout << dp[n] << "\n";
}

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

int main(){
  int N,Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> P(N,0);
  for(int i=1; i<N; i++){
    P.at(i)=P.at(i-1);
    if(S.at(i-1)=='A'&&S.at(i)=='C'){
      P.at(i)++;
    }
  }
  int l,r;
  for(int i=0; i<Q; i++){
    cin >> l >> r;
    cout << P.at(r-1)-P.at(l-1) << endl;
  }
}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int A,B,M,i,j,k,ans,a[100005],b[100005];
int main()
{
	scanf("%d%d%d",&A,&B,&M);
	j=k=1<<30;
	for(i=1;i<=A;++i)
	{
		scanf("%d",a+i);
		j=min(j,a[i]);
	}
	for(i=1;i<=B;++i)
	{
		scanf("%d",b+i);
		k=min(k,b[i]);
	}
	ans=j+k;
	while(M--)
	{
		scanf("%d%d%d",&i,&j,&k);
		ans=min(ans,a[i]+b[j]-k);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A, long long B, string S) {
    ll pass = 0;
    ll b_rank = 0;
    for (ll i = 0; i < N; i++) {
        if (S[i] == 'a' && pass < A + B) {
            cout << YES << endl;
            pass++;
        } else if (S[i] == 'b') {
            b_rank++;
            if (pass < A + B && b_rank <= B) {
                cout << YES << endl;
                pass++;
            } else {
                cout << NO << endl;
            }
        } else {
            cout << NO << endl;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  long long N;
  cin >> N;
  long long A;
  cin >> A;
  long long B;
  cin >> B;
  string S;
  cin >> S;
  solve(N, A, B, S);
  return 0;
}


Measured memory_bytes: 3788
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
)

func main() {
	N, M := ReadInt(), ReadInt()
	s := 1<<M - 1
	for i := 0; i < N; i++ {
		K := ReadInt()
		v := 0
		for j := 0; j < K; j++ {
			v |= 1 << (ReadInt() - 1)
		}
		s &= v
	}
	fmt.Println(bits.OnesCount(uint(s)))
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1844
package main

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

func main() {
	scanInit()

	n := nextInt()
	s := nextStr()
	t := nextStr()
	var tmp = make([]byte, 2*n)

	for i := 0; i < n+1; i++ {
		for j := 0; j < n; j++ {
			tmp[j] = s[j]
		}
		for j := 0; j < n; j++ {
			tmp[i+j] = t[j]
		}

		if strings.HasPrefix(string(tmp), s) {
			fmt.Println(i + n)
			return
		}
	}
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;

int main() {
    ll n, a, b;
    cin >> n;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            a = i;
            b = n / i;
        }
    }
    cout << SZ(to_string(max(a, b))) << "\n";
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var T = ReadLines(N);
            
            if (N == 1)
            {
                Println(T[0]);
                return;
            }

            var lcm = Lcm(T[0], T[1]);
            for (int i = 2; i < N; i++)
            {
                lcm = Lcm(lcm, T[i]);
            }
            Println(lcm);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11220
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0173

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    AM = 200
    PM = 300
    for line in sys.stdin:
        name, a, b, = line.split()
        print('{} {} {}'.format(name, int(a)+int(b), int(a)*AM+int(b)*PM))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7672
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*-------------------------------------------------------------------------------------------------------------------------------------*/
#define MOD 1000000007
#define endl "\n" 
#define int long long // remove when constraints are tight.
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

ll poww(long long a, long long n, long long m)
{
        long long ans = 1;
        long long mul = a;
        while (n != 0)
        {
                if (n % 2)
                {
                        ans = (ans * mul) % m;
                }
                mul = (mul * mul) % m;
                n /= 2;
        }
        return ans;
}
/* 
Fermat's little theorem: 
1) (a/b)%mod= (a*(poww(b,mod-2,mod)))%mod iff a%b==0
2) (a^b)%mod= (a^(b%(mod-1)))%mod iff mod is prime
*/
const int SZ=5e5+100;
ll factorial[SZ];
void precompute()
{
	factorial[0]=1;
	for(int i=1;i<SZ;i++)
	{
		factorial[i]=(factorial[i-1]*i)%MOD;
	}
}
ll InverseEuler(ll n, ll m)
{
    return poww(n, m - 2, m);
}
ll C(ll n, ll r, ll m)
{

    return (factorial[n] * ((InverseEuler(factorial[r], m) * InverseEuler(factorial[n - r], m)) % m)) % m;
}
int32_t main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	precompute();
	int n,k;
	cin>>n>>k;
	if(k>=n-1)
	{
		cout<<C(2*n-1,n-1,MOD)<<endl;
		return 0;
	}
	int ans=0;
	for(int i=0;i<=k;i++)
	{
		ans+=(C(n,i,MOD)*C(n-1,i,MOD))%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d){
		cout<<"Yes";
		return 0;
	}
	else if(abs(a-b)<=d&&abs(b-c)<=d){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
int main(){
    char c[1000];
    int ans=0;
    for(int i=0;i<1000;i++)c[i]='\0';
    scanf("%s",c);
    for(int i=1;c[i]!='\0';i++)if(c[i]<=c[i-1])ans++;
if(c[0]=='A')ans++;
    printf("%d\n",ans);
}

Measured memory_bytes: 2752
#include <iostream>  
#include <math.h>
using namespace std;  
int main()  
{   
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)>=0&&abs(a-c)<=d)
	cout<<"Yes";
	else if(abs(a-b)>=0&&abs(a-b)<=d&&abs(b-c)>=0&&abs(b-c)<=d)
	cout<<"Yes";
	else cout<<"No";
    return 0;  
}

Measured memory_bytes: 764
object Main extends App {

  import scala.io.StdIn._

  val s = readLine.trim.toCharArray
  val t = readLine.trim.toCharArray
  var count = 0.toChar
  for (i ← s.indices){
    if (s(i) >= 26) {
      for (j ← (i + 1) until s.length) {
        if (s(i) == s(j)) s(j) = count
      }
      s(i) = count
      count = (count + 1).toChar
    }
  }
  count = 0.toChar
  for (i ← t.indices){
    if (t(i) >= 26){
      for (j ← (i + 1) until t.length){
        if (t(i) == t(j)) t(j) = count
      }
      t(i) = count
      count = (count + 1).toChar
    }
  }
  println(
    if (s.zip(t).forall{case (cs, ct) ⇒ cs == ct}) "Yes"
    else "No"
  )
}


Measured memory_bytes: 42308
class Dice
  attr_reader :top, :bottom, :front, :back, :left, :right 

  def initialize(dice_numbers) 
    @top = dice_numbers[0]
    @back = dice_numbers[1]
    @right = dice_numbers[2]
    @left = dice_numbers[3]
    @front = dice_numbers[4]
    @bottom = dice_numbers[5]
  end

  def roll_dice(order_top, order_back)
      while true
        order = []
        order << ['N', 'W'].sample
        execute_order(order)
      break if @top == order_top && @back == order_back
    end
  end

  private 
  def move_north
    tmp = @top
    @top = @back
    @back = @bottom
    @bottom = @front
    @front = tmp
  end

  def move_west
    tmp = @top
    @top = @right
    @right = @bottom
    @bottom = @left
    @left = tmp
  end

  def execute_order(orders) 
      orders.each do |order|
        if order == "N"
          move_north
        elsif order == "S" 
          3.times do
            move_north
          end
        elsif order == "W"
          move_west
        elsif order == "E" 
          3.times do
            move_west
          end
        else
          puts "error!" 
        end
      end
  end
end

dice_numbers = gets.chomp.split.map(&:to_i)
n = gets.chomp.to_i
answers = []
n.times do
  orders = gets.chomp.split.map(&:to_i)
  dice = Dice.new(dice_numbers)
  dice.roll_dice(orders[0], orders[1])
  answers << dice.right
end
answers.each do |answer|
  puts answer
end

Measured memory_bytes: 8604