akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int S,W;cin >> S >> W;
    if(W >= S)cout << "unsafe" << endl;
    else{
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3636
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll X;
ll K;
vll ans;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> K;
    cin >> X;

    for( ll ki = 0 ; ki <K ; ki++ ){
        ans.push_back(X-ki);
    }
    for( ll ki = 1 ; ki <K ; ki++ ){
        ans.push_back(X+ki);
    }
    sort(ans.begin(),ans.end());

    rep(ai,ans.size()) cout << ans[ai] << " ";
 
    

}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	// INFILE();
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	scan(v);

	ll cost = 0;

	REP(i, 0, n) {
		if (i == n - 1) {
			break;
		}

		ll length = v[i + 1] - v[i];
		cost += min(a * length, b);
	}
	cout << cost << "\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  map<type_index, const char *const> m = {{typeid(int), "%d"},
                                          {typeid(ll), "%lld"},
                                          {typeid(double), "%lf"},
                                          {typeid(char), "%c"}};

  auto tFormat = m[typeid(T)];

  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


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

using namespace std;

using ll = long long;

ll solve(const string& s) {
    ll res = 0;
    ll cnt = 0;
    for (char c : s) {
        if (c == 'X') res += cnt;
        else cnt++;
    }
    return res;
}

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

    vector<string> v;
    string tmp = "";

    int n = s.size();
    for (int i = 0; i < n; ) {
        if (s[i] == 'A') {
            tmp += 'A';
            i++;
        } else if (s[i] == 'C') {
            if (tmp != "") v.push_back(tmp);
            tmp = "";
            i++;
        } else {
            if (i == n - 1 || s[i + 1] != 'C') {
                if (tmp != "") v.push_back(tmp);
                tmp = "";
                i++;
            } else {
                tmp += 'X';
                i += 2;
            }
        }
    }
    if (tmp != "") v.push_back(tmp);

    ll ans = 0;
    for (string& s2 : v) {
        ans += solve(s2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(x) cout << (x) << endl
const int INF = 1e+8+7;
ll n,m;
string s,t;
int d[100],dp1[500][500],dp2[500][500];

int main(){
  cin >> s >> t;
  pel(i,s.sz-t.sz,0){
    rep(j,0,t.sz){
      if(s[i+j] != '?' && s[i+j] != t[j])goto end;
    }
    rep(j,0,t.sz)s[i+j] = t[j];
    rep(j,0,s.sz)if(s[j] == '?')s[j] = 'a';
    print(s);
    return 0;
    end:;
  }
  print("UNRESTORABLE");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;
int n;
pii dat[2*MAX-1][2];

vector<int> ans;

void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i][0]={i,INF};
        dat[i][1]={i,INF};
    }
}

void update(int k,int a,int c){
    k+=n-1;
    dat[k][c]={k-(n-1),a};
    
    while(k>0){
        k=(k-1)/2;
        if(dat[k*2+1][c].second<dat[k*2+2][c].second) dat[k][c]=dat[k*2+1][c];
        else dat[k][c]=dat[k*2+2][c];
    }
}

pii query(int a,int b,int k,int l,int r,int c){
    
    if(r<=a||b<=l) return {-1,INF};
    if(a<=l&&r<=b) return dat[k][c];
    else{
        pii vl=query(a,b,2*k+1,l,(l+r)/2,c);
        pii vr=query(a,b,2*k+2,(l+r)/2,r,c);
        if(vl.second<vr.second) return vl;
        else return vr;
    }
}

priority_queue<pii,vector<pii>,greater<pii>> PQ;
map<pii,pair<pii,pii>> MA;

void devide(int s,int t){
    if(s%2==0){
        pii a=query(s/2,t/2+1,0,0,n,0),b=query(a.first,t/2+1,0,0,n,1);
        MA[{a.second,b.second}]={{s,t},{a.first*2,b.first*2+1}};
        PQ.push({a.second,b.second});
    }else{
        pii a=query(s/2,t/2,0,0,n,1),b=query(a.first+1,t/2+1,0,0,n,0);
        MA[{a.second,b.second}]={{s,t},{a.first*2+1,b.first*2}};
        PQ.push({a.second,b.second});
    }
}

void DFS(int s,int t){
    while(!PQ.empty()){
        pii x=PQ.top();PQ.pop();
        ans.push_back(x.first);ans.push_back(x.second);
        pii a=MA[x].first,b=MA[x].second;
        if(a.first<b.first-1) devide(a.first,b.first-1);
        if(b.first+1<b.second-1) devide(b.first+1,b.second-1);
        if(b.second+1<a.second) devide(b.second+1,a.second);
    }
}

int main(){
    
    int N;cin>>N;
    init(N/2);
    
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin>>P[i];
        update(i/2,P[i],i%2);
    }
    
    devide(0,N-1);
    
    DFS(0,N-1);
    
    for(int i=0;i<N;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}



Measured memory_bytes: 15728
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt - 1
  val st = Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray

  def f(i:Int):Int = {
    def rec(t:Int, i:Int):Int = {
      if(i == n) t
      else {
        val cost = st(i)(0)
        val start = st(i)(1)
        val f = st(i)(2)
        if(t < start) rec(start+cost, i+1)
        else if (t%f == 0) rec(t+cost, i+1)
        else {
          val v = f - (t % f)
          rec(t+v+cost, i+1)
        }
      }
    }
    rec(0,i)
  }

  val out = new java.io.PrintWriter(System.out)
  (0 to n).foreach(i => out.println(f(i)))
  out.flush
}

Measured memory_bytes: 25552
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
		int c=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
  		int d=Math.max(x,y);
        int k=Math.min(x,y);
  		long min=(long)Math.pow(10,18);
        long kei=0;
		for(int e=0;e<=d;e++){
            if(k-e<0){
              if(k==y){
               kei=a*(x-e)+c*2*e;
              }else{
               kei=b*(y-e)+c*2*e;
              }
            }else{
    		kei=a*(x-e)+b*(y-e)+c*2*e;
            }
          min=Math.min(min,kei);
    	}
   

    	System.out.println(min);
    }
}


Measured memory_bytes: 35384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c[5];
	cin>>a>>b;
	c[1]=a+b;
	c[2]=a-b;
	c[3]=a*b;
	sort(c+1,c+4);
	cout<<c[3];
	return 0;
}


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

int main(){
    int x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
      cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse (a.begin(),a.end());
  int alice =0,bob=0;
  for(int i=0;i<n;i++){
      if(i%2 == 0){
          alice +=a.at(i);
      }
      else {
          bob +=a.at(i);
      }
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int hour(int* hours, int* s)
{
    *hours = *s/3600;
    *s -= *hours * 3600;
}

int minute(int* minutes, int* s)
{
    *minutes = *s/60;
    *s -= *minutes * 60;
}

int main(int argc, char* argv[])
{
    int s;
    cin >> s;
    int hours, minutes, seconds;
    
    hour(&hours,&s);
    minute(&minutes,&s);
    seconds = s;
    cout << hours << ":" << minutes << ":" << seconds << endl;
}

Measured memory_bytes: 3108
n = int(input())
a = [int(i) for i in input().split(" ")]
m = max(a)
abs_min = m
abs_i = 0

for i in range(0, n):
    ab = abs((m + 1)//2 - a[i])
    if a[i] != m and abs_min > ab:
        abs_min = ab
        abs_i = i
        
print(m, a[abs_i])

Measured memory_bytes: 14052
#include<iostream>

using namespace std;

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

int solve(string a, string b, int k) {
  if (a.size() == 0u) return 0;
  if (a[a.size() - 1] >= b[b.size() - 1]) {
    return solve(a.substr(0, a.size() - 1), b.substr(0, b.size() - 1), k) * 10 + a[a.size() - 1] - b[b.size() - 1];
  }
  int res = -1000000000;
  if (k > 0) {
    res = solve(a.substr(0, a.size() - 1), b.substr(0, b.size() - 1), k - 1) * 10 + a[a.size() - 1] - b[b.size() - 1] + 10; 
  }
  for (int i = a.size() - 2; i >= 0; --i) {
    if (a[i] != '0') {
      --a[i];
      break;
    }
    a[i] = '9';
    if (k > 0) res = max(res, solve(a.substr(0, a.size() - 1), b.substr(0, b.size() - 1), k - 1) * 10 + a[a.size() - 1] - b[b.size() - 1] + 10);
  }
  return max(res, solve(a.substr(0, a.size() - 1), b.substr(0, b.size() - 1), k) * 10 + a[a.size() - 1] - b[b.size() - 1] + 10);
}

int main() {
  string a, b;
  int k;
  cin >> a >> b >> k;
  while (b.size() < a.size()) b = "0" + b;
  cout << solve(a, b, k) << endl;
  return 0;
}

Measured memory_bytes: 1212
n,a,b=map(int,input().split())
answer=0
if a==0:
    answer=0
elif b==0:
    answer=n
elif a==1 and b==1:
    answer=n//2
else:
    while n>a+b:
        answer+=n//(a+b)*a
        n-=n//(a+b)*(a+b)
    if n>a:
        answer+=a
    else:
        answer+=n
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;

int main(int argc, char const *argv[]) {
    ll N;
    std::cin >> N;
    ll x = N;
    bool flag;
    std::string str_x;
    while (true) {
        flag = true;
        str_x = std::to_string(x);
        for (size_t i = 0; i < str_x.size(); i++) {
            if (str_x[i] != str_x.back()) {
                flag = false;
                break;
            }
        }
        if (flag) {
            std::cout << x << '\n';
            break;
        }
        x++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	while(1){
		int n; cin >> n;
		if(!n) break;
		vector<vb> can(n,vb(n,false));
		rep(i,n) can[i][i] = true;
		vvl day(32);
		rep(i,n){
			ll m; cin >> m;
			rep(j,m){
				ll a; cin >> a;
				day[a].push_back(i);
			}
		}
		int ans = -1;
		rep(t,31){
			if(day[t].size() <= 1) continue;
			rep(i,n){
				for(auto j : day[t]){
					if(can[i][j]){
						for(auto k : day[t]){
							can[i][k] = true;
						}
					}
				}
			}
			rep(j,n){
				bool f = true;
				rep(i,n){
					if(!can[i][j]) f = false;
				}
				if(f) ans = t;
			}
			if(ans != -1) break;
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;




int main()
{
	int R, D, X;

	cin >> R >> D >> X; 

	int ans = X;
	for (int ni = 0; ni < 10; ni++){
		ans = R * ans - D;
		printf("%d\n", ans);
	}




	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace B___Foods_Loved_by_Everyone
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            var n = int.Parse(input[0]);
            var m = int.Parse(input[1]);
            var p = new List<int>();
            for (var i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');
                for (var j = 1; j <= int.Parse(input[0]); j++)
                {
                    p.Add(int.Parse(input[j]));
                }
            }
            var a = 0;
            var ans = 0;
            for (var i = 1; i <= m; i++)
            {
                for (var j = 0; j < p.Count; j++)
                {
                    if (p[j] == i)
                    {
                        a++;
                        if (a == n)
                        {
                            ans++;
                        }
                    }
                }
                a = 0;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

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

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

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  const char *ans[10][10]={
    "","0 1","0 1 2","0 1 2 3","0 1 2 3 4","0 1 2 3 4 5","0 1 2 3 4 5 6","0 1 2 3 4 5 6 7","0 1 2 3 4 5 6 7 8","0 1 2 3 4 5 6 7 8 9",
    "1 0","","1 2","1 2 3","1 2 3 4","1 2 3 4 5","1 2 3 4 5 6","1 2 3 4 5 6 7","1 2 3 4 5 6 7 8","1 2 3 4 5 6 7 8 9",
    "2 1 0","2 1","","2 3","2 3 4","2 3 4 5","2 3 4 5 6","2 3 4 5 6 7","2 3 4 5 6 7 8","2 3 4 5 6 7 8 9",
    "3 2 1 0","3 2 1","3 2","","3 4","3 4 5","3 4 5 6","3 4 5 6 7","3 4 5 6 7 8","3 4 5 6 7 8 9",
    "4 3 2 1 0","4 3 2 1","4 3 2","4 3","","4 5","4 5 6","4 5 6 7","4 5 6 7 8","4 5 6 7 8 9",
    "5 4 3 2 1 0","5 4 3 2 1","5 4 3 2","5 4 3","5 4","","5 6","5 6 7","5 6 7 8","5 6 7 8 9",
    "6 7 8 9 5 4 3 2 1 0","6 7 8 9 5 4 3 2 1","6 7 8 9 5 4 3 2","6 7 8 9 5 4 3","6 7 8 9 5 4","6 7 8 9 5","","6 7","6 7 8","6 7 8 9",
    "7 8 9 5 4 3 2 1 0","7 8 9 5 4 3 2 1","7 8 9 5 4 3 2","7 8 9 5 4 3","7 8 9 5 4","7 8 9 5","7 8 9 5 4 3 2 1 0 1 2 3 4 5 6","","7 8","7 8 9",
    "8 9 5 4 3 2 1 0","8 9 5 4 3 2 1","8 9 5 4 3 2","8 9 5 4 3","8 9 5 4","8 9 5","8 9 5 4 3 2 1 0 1 2 3 4 5 6","8 9 5 4 3 2 1 0 1 2 3 4 5 6 7","","8 9",
    "9 5 4 3 2 1 0","9 5 4 3 2 1","9 5 4 3 2","9 5 4 3","9 5 4","9 5","9 5 4 3 2 1 0 1 2 3 4 5 6","9 5 4 3 2 1 0 1 2 3 4 5 6 7","9 5 4 3 2 1 0 1 2 3 4 5 6 7 8","",
  };
  int n;
  scanf("%d",&n);
  while(n --> 0){
    int a,b;
    scanf("%d%d",&a,&b);
    puts(ans[a][b]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
const int N = 18;
int n, A, B;
vector <int> ans;
 
void f(int mask, int v, int u) {
	if (v == u)
		return;
	if (__builtin_popcount(mask) == 1) {
		ans.push_back(v);
		ans.push_back(u);
		return;
	}
	
	int indx = 0;
	for (int i = 0; i < n; i++)
		if ((mask & (1LL << i)) && (((1LL << i) & v) != ((1LL << i) & u)))
			indx = i;
	
	int w = v;
	for (int i = 0; i < n; i++)
		if ((mask & (1LL << i)) && i != indx) {
			w ^= (1LL << i);
			break;
		}
	
	mask ^= (1LL << indx);
	f(mask, v, w);
	f(mask, w ^ (1LL << indx), u);
}
 
int32_t main() {
	cin >> n >> A >> B;
	if ((__builtin_popcount(A) & 1) == (__builtin_popcount(B) & 1))
		return cout << "NO", 0;
		
	f((1LL << n) - 1, A, B);
	cout << "YES\n";
	for (int i : ans)
		cout << i << ' ';
}

Measured memory_bytes: 2164
//     . .. ... .... ..... be name khoda ..... .... ... .. .     \\

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

inline int in() { int x; scanf("%d", &x); return x; }
const int N = 200002;

vector <int> g[N];
int comp[N], cnt[N];
int a[N], p[N];
bool mark[N];

void dfs(int v, int c)
{
	comp[v] = c;
	mark[v] = true;
	for(int u : g[v])
		if(!mark[u])
			dfs(u, c);
}

bool cmp(int i, int j) { return a[i] < a[j]; }

int main()
{
	int n = in(), m = in();
	for(int i = 0; i < n; i++)
		a[p[i] = i] = in();
	while(m--)
	{
		int u = in(), v = in();
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int k = 0;
	for(int i = 0; i < n; i++)
		if(!mark[i])
			dfs(i, k++);
	if(k == 1)
	{
		cout << "0\n";
		return 0;
	}
	sort(p, p + n, cmp);
	int have = 0;
	int theI = -1;
	for(int i = 0; i < n; i++)
	{
		int v = p[i];
		cnt[comp[v]]++;
		if(cnt[comp[v]] == 1)
			have++;
		if(have == k && i >= 2 * k - 3)
		{
			theI = i;
			break;
		}
	}
	if(theI == -1)
	{
		cout << "Impossible\n";
		return 0;
	}
	long long res = 0;
	int nodes = theI + 1;
	for(int i = theI; i >= 0; i--)
	{
		int v = p[i];
		if(nodes > 2 * k - 2 && cnt[comp[v]] > 1)
		{
			cnt[comp[v]]--;
			nodes--;
		}
		else
			res += a[v];
	}
	cout << res << endl;
}


Measured memory_bytes: 10240
N = int(input())
h = list(input().split())
for i in range(len(h)):
  h[i] = int(h[i])
dp = [0 for i in range(N)]
dp[1] = abs(h[0] - h[1])
for i in range(2,N):
  dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]))
print(dp[N-1])

Measured memory_bytes: 11252
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;

int main(){
   int n;
   cin>>n;
   char s[110];
   for(int i=0;i<n;i++)cin>>s[i];
   int cnt[4]={0};
   for(int i=0;i<n;i++){
      if(s[i]=='P')cnt[0]=1;
      else if (s[i]=='W')cnt[1]=1;
      else if(s[i]=='G')cnt[2]=1;
      else cnt[3]=1;
   }
   if(cnt[0]==1 && cnt[1]==1 && cnt[2]==1 && cnt[3]==1)cout<<"Four"<<endl;
   else cout<<"Three"<<endl;

   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    ll a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans1 = 2*c*max(x,y);
    ll tmp;
    if(x > y) tmp = a;
    else tmp = b;
    ll ans2 = 2*c*min(x,y)+abs(x-y)*tmp;
    ll ans3 = a*x+b*y;
    cout << min(ans1,min(ans2,ans3)) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
struct Graph{
	static const int M=N*2;
	int cnt,y[M],nxt[M],fst[N],z[M];
	void clear(){
		cnt=1,clr(fst);
	}
	void add(int a,int b,int c){
		y[++cnt]=b,nxt[cnt]=fst[a],fst[a]=cnt,z[cnt]=c;
	}
}g;
int n;
int sz[N],mx[N];
int G=0;
void dfs(int x,int pre){
	sz[x]=1,mx[x]=0;
	for (int i=g.fst[x];i;i=g.nxt[i]){
		int y=g.y[i];
		if (y!=pre){
			dfs(y,x);
			sz[x]+=sz[y];
			mx[x]=max(mx[x],sz[y]);
		}
	}
	mx[x]=max(mx[x],n-sz[x]);
	if (!G||mx[x]<mx[G])
		G=x;
}
LL ans=0;
void Solve(int x,int pre,LL d){
	sz[x]=1,ans+=d*2;
	for (int i=g.fst[x];i;i=g.nxt[i]){
		int y=g.y[i];
		if (y!=pre)
			Solve(y,x,d+g.z[i]),sz[x]+=sz[y];
	}
}
int main(){
	n=read();
	For(i,1,n-1){
		int a=read(),b=read(),c=read();
		g.add(a,b,c),g.add(b,a,c);
	}
	dfs(1,0);
	Solve(G,0,0);
	int mi=1e9;
	int mxs=0;
	for (int i=g.fst[G];i;i=g.nxt[i])
		mxs=max(mxs,sz[g.y[i]]);
	if (mxs*2==n){
		for (int i=g.fst[G];i;i=g.nxt[i])
			if (sz[g.y[i]]==mxs){
				mi=g.z[i];
				break;
			}
	}
	else {
		for (int i=g.fst[G];i;i=g.nxt[i])
			mi=min(mi,g.z[i]);
	}
	ans-=mi;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7808
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();

      if(B/K*K<=B && B/K*K>=A){
    System.out.println("OK");
      }else{
	System.out.println("NG");
      }
      }
}


Measured memory_bytes: 35740
// ABC133-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

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

    int n;
    cin>>n;
    vector<int> dam(n);
    ll total=0;
    rep(i,n){
        int a;
        cin>>a;
        dam[i]=a;
        total+=a;
    }
    vector<ll> yama(n);
    yama[0]=total;
    for(int i=1;i<=n-2;i=i+2){
        yama[0]-=2*dam[i];
    }
    for(int i=1;i<=n-1;i++){
        yama[i]=2*dam[i-1]-yama[i-1];
    }
    rep(i,n) cout<<yama[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

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

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

int check (int year) {
    bool ret;
    if (year % 400 == 0) {
        ret = true; 
    } else if (year % 100 == 0) {
        ret = false; 
    } else if (year % 4 == 0) {
        ret = true; 
    } else {
        ret = false; 
    }
    return ret;
}

int main(void) {
    bool start = false;
    while (1) {
        int a;
        int b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        } else if (start) {
            cout << endl;
        }
        bool exist = false;
        for (int i = a; i <= b; i++) {
            if (check(i) == true) {
                cout << i << endl;
                exist = true;
            }
        }
        if (exist == false) {
            cout << "NA" << endl;
        }
        start = true;
    }
    return 0;
}

Measured memory_bytes: 3092
n,k=map(int,input().split())
s=input()

lr = 0
f=0

if s[0] == 'R':
  lr+=1
  f +=1
for i in range(n-1):
  if s[i] == 'L' and s[i+1] == 'R':
    lr += 1
if s[n-1]=='L':
  lr+=1
  f +=1

if k<lr-1:
  print(n-2*(lr-k)+f)
elif k==lr-1:
  print(n-1 if f>0 else n-2)
else:
  print(n-1)


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

int main(){
  int64_t N;
  cin>>N;
  vector<vector<int64_t>> A(N,vector<int64_t>(3));
  vector<int64_t> ve=A.at(0);
  for(int i=0;i<N;i++){
    cin>>A.at(i).at(0)>>A.at(i).at(1)>>A.at(i).at(2);
    if(A.at(i).at(2)!=0)
      ve=A.at(i);
  }
  int64_t x,y,h;
  for(int64_t i=0;i<=100;i++)
    for(int64_t j=0;j<=100;j++){
      int64_t H=ve.at(2)+abs(ve.at(0)-i)+abs(ve.at(1)-j);
      bool bo=false;
      for(vector<int64_t> &k:A)
        if(k.at(2)!=max(H-abs(k.at(0)-i)-abs(k.at(1)-j),(int64_t)0))
          bo=true;
      if(bo)
        continue;
      x=i;
      y=j;
      h=H;
      break;
    }
  cout<<x<<' '<<y<<' '<<h<<endl;
}

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

int main() { 
  int N, K;
  cin >> N >> K;
  
  string S;
  cin >> S;
  
  if (S.at(K-1) == 'A')
    S.at(K-1) = 'a';
  else if (S.at(K-1) == 'B')
    S.at(K-1) = 'b';
  else 
    S.at(K-1) = 'c';
  
  cout << S << endl;
}

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

const ll INF = 1e9+7;
const int MAXN = 1e5;
int N,M;
bool a[MAXN+2]={}; // broken
ll dp[MAXN+2]={};

int main() {
  cin >> N >> M;
  REP(i,M) {
    int idx;
    cin >> idx;
    a[idx+1] = true;  // 1段目->idx=2
  }
  dp[0] = 0;
  dp[1] = 1; // 0段目
  REP(i,N) {
    if (!a[i+1]) dp[i+2] += dp[i+1];
    if (!a[i]) dp[i+2] += dp[i];
    dp[i+2] %= INF;
  }
  cout << dp[N+1] << endl;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int h1=s.nextInt(),s1=s.nextInt(),h2=s.nextInt(),s2=s.nextInt();
        while(h1>0&&h2>0){
            h2-=s1;
            if(h2<=0){
                System.out.println("Yes");
                break;
            }
            h1-=s2;
               
        }
        if(h1<=0){
            System.out.println("No");
        }
        
    }
}


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


# コンビネーション
mod = 10**9+7
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 2*10**6+5 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

K = int(input())
S = input().rstrip()
L = len(S)

ans = 0
t25 = 1
t26 = pow(26, K, mod)
inv26 = pow(26, mod-2, mod)
for k in range(K+1):
    ans = (ans + t25 * t26 * cmb(k+L-1, k)) % mod
    t25 = t25 * 25 % mod
    t26 = t26 * inv26 % mod
print(ans)

Measured memory_bytes: 174328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,inf=mod*mod*3ll;;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N,K;
ll a[5005];
bool dp[5005][5005];
bool check(ll in){
    //trueなら必要　falseなら不必要
    if(a[in]>=K) return true;
    ll penta=a[in];
    swap(a[in],a[N-1]);
    memset(dp,false,sizeof(dp));
    dp[0][0]=true;
    if(a[0]<5003) dp[0][a[0]]=true;
    rep1(i,N){
        rep(k,5003){
            if(k-a[i]>=0){
                if(dp[i-1][k-a[i]]||dp[i-1][k]) dp[i][k]=true;
            }
            else{
                if(dp[i-1][k]) dp[i][k]=true;
            }
        }
    }
    for(ll y=K-penta;y<K;y++){
        if(dp[N-2][y]){
            swap(a[in],a[N-1]); 
            return true;
        }
    }
    swap(a[in],a[N-1]);
    return false;
}
bool isOK(ll index) {
    if(index<0) return true;
    if(index>N-1) return false;
    if(check(index)) return true;
    else return false;
}
ll bin_search(){
    ll ng=-1; 
    ll ok=N; 
    while (abs(ok-ng)>1) {
        ll mid=(ok+ng)/2;
        if (isOK(mid)) ok=mid;
        else ng=mid;
    }
    return ok;
}

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>K;
rep(i,N) cin>>a[i];
if(N==1){
    if(a[0]>=K) cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}
sort(a,a+N); 
ll ans=bin_search();
cout<<ans<<endl;

}
	


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)//sからnまでのループ
#define rep(i, n) rep2(i, 0, n)//0からnまでのループ

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int x;
    bool done = false;
    bool zero = false;
    long long int MAX = pow(10, 18);
    long double tot = 1;
 
 
    rep(i,n) {
        cin >> x;
        tot *= x;
        if (x == 0) {
            zero = true;
        }
        else if (tot > MAX || tot < 0) {
            done = true;
        }
    }
 
    if (zero) {
        cout << 0 << endl;
    }
    else if (done) {
        cout << -1 << endl;
    }
    else {
        cout << (long long int)tot << endl;
    }
 
 
}

Measured memory_bytes: 3612
#include <stdio.h>
#define mod 1000000007
 
int main(void){
  int N;
  scanf("%d",&N);
 
  int a[(N+1)/2];
  int A;
  for(int i = 0;i < (N+1)/2;i++) a[i] = 0;
  for(int i = 0;i < N;i++){
    scanf("%d",&A);
    a[A/2]++;
  }
 
  int flag = 1;
  int cnt = 0;
  for(int i = 0;i < (N+1)/2;i++){
    if(i == 0 && N%2 != 0){
      if(a[i] != 1)
        flag = 0;
    }else{
      if(a[i] != 2) flag = 0;
      else cnt++;
    }
  }
 
  long long ans = 1;
  while(cnt > 0){
    ans *= 2;
    ans %= mod;
    cnt--;
  }
  if(flag){
    printf("%lld\n",ans);
  }else{
    printf("0\n");
  }
 
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;


int main(){

    int n;
    int d;
    set<int> s;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> d;
        s.insert(d);
    }

    cout << s.size() <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <cmath>
 
using namespace std;
 
int main() 
{
   
   int n;
   long long int result=1;
   cin>>n;
   long long int input;
   long long int wrong=pow(10,18);
   bool hasZero = false;
   bool isBad = false;
   for (int i = 0; i < n; i++)
   {
       cin>>input;

      if (input == 0) {
          hasZero = true;
      }

       if (log10(input) + log10(result) > 18) {
           isBad = true;
       }
       result=result*input;
   }

   if (hasZero == true) {
       cout << 0;
       return 0;
   }


   if (result>wrong || isBad == true)
   {
   cout<<-1;
   }
   else
    {
    	cout<<result;
    }
}

Measured memory_bytes: 3500
s = [int(t) for t in list(input())]
n = len(s)
a = sum(s[0::2])
b = sum(s[1::2])
# print(a,b,n)
x = ((n+1)//2 - a) + b
y = a + (n//2-b)
print(min(x,y))

Measured memory_bytes: 4652
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

using namespace std;

vector<vector<char>> m;

int search(vector<vector<char>> M) {
  queue<tuple<int, int, int>> q;
  q.push(make_tuple(0, 0, 1));

  while (!q.empty()) {
    auto point = q.front();
    q.pop();

    int i = get<0>(point);
    int j = get<1>(point);
    int cost = get<2>(point);

    M[0][0] = 'X';

    vector<pair<int, int>> moves = {pair<int, int>(1, 0), pair<int, int>(-1, 0), pair<int, int>(0, 1), pair<int, int>(0, -1)};
    for (auto move: moves) {
      int di = move.first;
      int dj = move.second;

      int nexti = i + di;
      int nextj = j + dj;

      if (!(0 <= nexti && nexti < M.size() && 0 <= nextj && nextj < M[0].size())) {
	continue;
      }

      if (M[nexti][nextj] != '.') {
	continue;
      }

      if ((nexti + 1 == M.size()) && (nextj + 1 == M[0].size())) {
	return cost + 1;
      }

      M[nexti][nextj] = 'X';

      q.push(make_tuple(nexti, nextj, cost + 1));
    }
  }

  return -1;
}

int main() {
  int h, w;
  cin >> h >> w;

  m.resize(h);
  for (int i = 0; i < m.size(); i++) m[i].resize(w);

  for (int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      m[i][j] = s[j];
    }
  }

  int path = search(m);
  if (path == -1) {
    cout << path << endl;
    return 0;
  }

  int result = 0;
  for (int i = 0; i < m.size(); i++) {
    for (int j = 0; j < m[i].size(); j++) {
      if (m[i][j] == '.')
	result++;
    }
  }

  result -= path;
  cout << result << endl;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = defaultdict(int)
    temp = n
#     M = int(-(-n**0.5//1))+1
#     if m is not None:
#         M = min(m+1, M)
    M = 6
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    return arr

n = int(input())
a = [None]*n
m = [[0]*19 for _ in range(19)]
ab = [None]*n
for i in range(n):
    s = input()
    if "." in s:
        ind = s.index(".")
        vv = len(s) - s.index(".") - 1
        v = int(s[:ind])*10**(vv) + int(s[(ind+1):])
        v *= 10**(9-vv)
    else:
        v = int(s)*10**9
    d = factor(v, 5)
    d.setdefault(2,0)
    d.setdefault(5,0)
    a,b = max(0, 18-d[2]), max(0, 18-d[5])
    m[a][b] += 1
    ab[i] = (d[2],d[5])
def cumsum2(v):
    # v: h*wの2次元リスト
    h,w = len(v), len(v[0])
    v.insert(0, [0]*w)
    for l in v:
        l.insert(0, 0)
    for i in range(1,h+1):
        for j in range(1,w+1):
            v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1] + v[i][j]
    return v
m = cumsum2(m)
ans = 0
for a,b in ab:
#     print(a,b)
    ans += m[min(19,a+1)][min(19,b+1)]
    if a>=9 and b>=9:
        ans -= 1
print(ans//2)

Measured memory_bytes: 81800
#include<stdio.h>
#include<vector>
using namespace std;
struct kz
{
    int parent=-1;
    int left;
    int right;
}Tree[50];
void mmp1(int x)
{
    if(x==-1)
        return ;
   printf(" %d",x);
    mmp1(Tree[x].left);
    mmp1(Tree[x].right);
}
void mmp2(int x)
{
    if(x==-1)
        return ;
    mmp2(Tree[x].left);
    printf(" %d",x);
    mmp2(Tree[x].right);
}
void mmp3(int x)
{
        if(x==-1)
        return ;
    mmp3(Tree[x].left);
    mmp3(Tree[x].right);
    printf(" %d",x);

}
int main()
{
    int n,m;
    scanf("%d",&n);
    int l,r;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&m,&l,&r);
         Tree[m].left=l;
         Tree[m].right=r;
         Tree[r].parent=m;
         Tree[l].parent=m;
    }
    int s=0;
    for(int i=0;i<n;i++)
    {
        if(Tree[i].parent==-1)
        {
            s=i;
            break;
        }
    }
        printf("Preorder\n");
   mmp1(s);
   printf("\n");
   printf("Inorder\n");
   mmp2(s);
   printf("\n");
   printf("Postorder\n");
   mmp3(s);
   printf("\n");
    return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int s,d,g;
    s=b/k;
    d=s*k;
    if(a<=d && d<=b)
        cout<<"OK";
    else
        cout<<"NG";
}


Measured memory_bytes: 3636
/*Heroes Never Die!*/
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
#define MAXN 100006
ll A[MAXN],d[MAXN],n , res;
int main() {
    cin >> n;
    for( int i = 1 ; i <= n ; ++ i ) scanf("%lld",&A[i]);
    for( int i = 1 ; i <= n ; ++ i ) d[i] = A[i] - A[i-1] , res += (d[i]>0?d[i]:0);
    cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define vvv(type, c, m, n, l, i) vector<vector<vector<type>>> c(m, vector<vector<type>>(n, vector<type>(l, i)));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int m, f, r;
	int sum;
	while(true) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		sum = m + f;
		if (m == -1 || f == -1) P("F");
		else if (sum < 30) P("F");
		else if (80 <= sum) P("A");
		else if (65 <= sum) P("B");
		else if (50 <= sum) P("C");
		else if (30 <= sum && 50 <= r) P("C");
		else if (30 <= sum) P("D");
	}
	return 0;
}

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

int main(){
  int n,k,x,a=0;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> x;
    if(k-x > x){
      a = a + 2 * x;
    }
    else{
      a = a + 2 * (k - x);
    }
  }
  cout << a << endl;
}


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

int main() {

    int x;
    cin>>x;
    int count=0;
    int ans;
    int i=0;
    do {
        i++;
        count+=i;
        if(x<=count) {
            ans=i;
            break;
        }
    }while(1);
    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 200005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

vector<int> adj[MAX];
int st, e;
int vis[MAX];
int cnt;int offset;
void dfs(int node, int p) {
	if(vis[node]) {
		st = node;
		e = p;
		offset = vis[node] - 1;
		return;
	}
	
	vis[node] = cnt++;
	
	for(int i=0;i<adj[node].size();i++) {
		dfs(adj[node][i], node);
	}
	return;
}

vector<int> chain;
void get_chain(int node, int dest) {
	if(node == dest) {
		chain.PB(dest);
		return;
	}
	
	chain.PB(node);
	for(int i=0;i<adj[node].size();i++) {
		get_chain(adj[node][i], dest);
	}
}

int main() {
	LL n, k; int i;
	cin>>n>>k;
	
	int x;
	for(i=1;i<=n;i++) {
		cin>>x;
		adj[i].PB(x);
	}
	cnt = 1;
	
	dfs(1, 1);

	
	if(k < offset) {
		get_chain(1, st);
		cout<<chain[k]<<endl;
		return 0;
	}
	k-=offset;
	get_chain(st, e);
	int cn = chain.size();
	k = k % cn;
	
	
	cout<<chain[k]<<endl; 
	
    return 0;
}



Measured memory_bytes: 24896
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

vector<ll> divisor(ll n){
    vector<ll> v;
    for(ll i=1; i*i<=n; i++){
        if(n % i == 0){
            v.emplace_back(i);
            v.emplace_back(n / i);
        }
    }

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

    return v;
}

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

    ll n; cin>>n;

    auto v = divisor(n);

    int ans = inf;
    for(auto i : v){
        ll A = i;
        ll B = n / i;

        int adigit = 0;
        while(0 < A){
            adigit++;
            A /= 10;
        }

        int bdigit = 0;
        while(0 < B){
            bdigit++;
            B /= 10;
        }

        chmin(ans, max(adigit, bdigit));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
ball_nums = gets.split.map(&:to_i)
cnt_table = Array.new(n+1, 0)
ball_nums.each do |ball_num|
  cnt_table[ball_num] += 1
end
tmp = cnt_table.inject{|s, ele| s + ele * (ele - 1) / 2 }
ball_nums.each do |ball_num|
  result = tmp
  result -= cnt_table[ball_num] * (cnt_table[ball_num] - 1) / 2
  cnt_table[ball_num] -= 1
  result += cnt_table[ball_num] * (cnt_table[ball_num] - 1) / 2
  puts result
  cnt_table[ball_num] += 1
end

Measured memory_bytes: 23180
#include <math.h>
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <iostream>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main()
{
    int N,M;
    cin>>N>>M;
    vector<int> S(N);
    vector<int> T(M);
    FOR(i,0,N){
        cin >> S[i];
    }
    FOR(j,0,M){
        cin >> T[j];
    }
    int mod = 1000000007;
    vector<vector<int>> dp(1 + N, vector<int>(M + 1, 0));
    vector<map<int, int>> data(1 + M);
    dp[0][0] = 1;
    FOR(j,1,1+M){
        dp[0][j] = dp[0][j - 1];
    }
    FOR(i,1,1+N){
        dp[i][0] = dp[i - 1][0];
        data[0][S[i - 1]] = (data[0][S[i - 1]] + dp[i][0]) % mod;
        FOR(j,1,1+M){
            data[j][S[i-1]]=(data[j][S[i-1]]+dp[i-1][j])%mod;
            dp[i][j]=(data[j-1][T[j-1]]+dp[i][j-1])%mod;
        }
    }
    cout << dp[N][M] << endl;
}


Measured memory_bytes: 134784
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define INF 1e9 + 1
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, S[10100], q, T[510];
    cin >> n;
    REP(i, n) cin >> S[i];
    cin >> q;
    REP(i, q) cin >> T[i];
    int cnt = 0;
    REP(i, q) {
        REP(j, n) {
            if (T[i] == S[j]) {
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3108
def resolve():
    n, m = list(map(int, input().split()))
    xxx = sorted(list(map(int, input().split())))
    if n >= m:
        print(0)
    else:
        lll = sorted([xxx[i+1]-xxx[i] for i in range(m-1)])[::-1]
        print(xxx[m-1]-xxx[0] - sum(lll[:n-1]))
resolve()

Measured memory_bytes: 13968
#include <stdio.h>

  int main(void)
  {
    int i;
    int n;

    for ( i = 1;; i++) {
      scanf("%d", &n);
      if (n == 0) break;
      printf("Case %d: %d\n", i, n);
    }
    
    return 0;
  }


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

int main(){
  int N;
  cin >>N;
  
  int ans;
  if(N<2) ans = 1;
  else if(N<4) ans = 2;
  else if(N<8) ans = 4;
  else if(N<16) ans = 8;
  else if(N<32) ans = 16;
  else if(N<64) ans = 32;
  else ans = 64;
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256