akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(p);
    cii(q);
    cii(r);
    int ans = min(p + q, min(q + r, r + p));
    co(ans);
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

double prob[3][2010][4];
double C[2010][2010];
double acc[2010];

int main(){
	  
  int N, M; cin >> N >> M;
  VVI xs(N, VI(3));
  REP(i,N) REP(j,3) cin >> xs[i][j];

  C[0][0] = 1.;
  FOR(i,1,2010){
	C[i][0] = C[i-1][0] * 2. / 3;
	C[i][i] = C[i-1][i-1] / 3.;
	FOR(j,1,i)
	  C[i][j] = C[i-1][j] * 2./3 + C[i-1][j-1] /3.;
  }
  acc[0] = C[M][0];
  FOR(i,1,M+1){
	acc[i] = acc[i-1] + C[M][i];
  }

  REP(t,3){
	REP(i,M+1){
	  int x = xs[0][t] * i;
	  prob[t][i][0] = prob[t][i][3] = 1.;
	  FOR(j,1,N){
		int l = min((x-1) / xs[j][t], M);
		double w = 0.;
		if(l * xs[j][t] < x){
		  w = acc[l];
		}
		vector<double> np(3);
		REP(k,3) np[k] = prob[t][i][k] * w;
		REP(k,2) np[k+1] += prob[t][i][k] * (1.-w);
		REP(k,3) prob[t][i][k] = np[k];
		prob[t][i][3] *= 1. - w;
	  }
	  prob[t][i][0] = prob[t][i][0] + prob[t][i][1] + prob[t][i][2];
	}
  }

  double ans = -100;
  REP(i,M+1) REP(j,M-i+1){
	int k = M - i - j;
	maxi(ans, prob[0][i][0] * 5 + prob[1][j][0] * 3 + prob[2][k][0] * 2
		 - prob[0][i][3] - prob[1][j][3] - prob[2][k][3]);
  }
  cout << fixed << setprecision(9) << ans << endl;

  return 0;
}

Measured memory_bytes: 26376
let () = Scanf.scanf "%d" @@ fun n ->
  print_endline @@
  match n mod 10 with
  | 2 | 4 | 5 | 7 | 9 -> "hon"
  | 0 | 1 | 6 | 8 -> "pon"
  | 3 -> "bon"


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

int main() {

  int a, b;
  cin >> a >> b;
  
  vector<double> tmp(2);
  for(int i = 1; i < 100000; i++) {
    tmp.at(0) = i * 0.08;
    tmp.at(1) = i * 0.1;
    if(tmp.at(0) >= a && tmp.at(0) < a+1) {
      if(tmp.at(1) >= b && tmp.at(1) < b+1) {
        cout << i << endl;
        return 0;
      }
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



bool is_prime(long long n) {
    if (n == 0 || n == 1) return false;
    for (long long i = 2; i*i <= n; ++i) {
        if (n%i ==  0) return false;
    }
    return true;
}



const long long MOD = 4294967311LL;

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

inline long long mul(long long a, long long b, long long m) {
    a = mod(a, m); b = mod(b, m);
    if (b == 0) return 0;
    long long res = mul(mod(a + a, m), b>>1, m);
    if (b & 1) res = mod(res + a, m);
    return res;
}

inline long long inv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a/b;
        a = mod(a - t * b, m); swap(a, b);
        u = mod(u - mul(t, v, m), m); swap(u, v);
    }
    return mod(u, m);
}


int N;
int o;
long long Y;

int main() {
    while (cin >> N) {
        long long res = 0;
        
        for (int i = 0; i < N; ++i) {
            cin >> o >> Y;
            
            if (o == 1) res = mod(res + Y, MOD);
            else if (o == 2) res = mod(res - Y, MOD);
            else if (o == 3) res = mul(res, Y, MOD);
            else if (o == 4) res = mul(res, inv(Y, MOD), MOD);
            
            //cout << res << endl;
        }
        
        while (res >= (1LL<<31)) res -= MOD;
        cout << res << endl;
    }
    
    return 0;
}


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

using namespace std;
#define LL long long
using VS = vector<string>;
using VI = vector<int>;
using VL = vector<LL>;
using VVI = vector<VI>;
using VVL = vector<VL>;
#define FOR(i,s,e) for(i = s; i < e; i++)
#define FORR(i,s,e) for(i = e-1; i >= s; i--)
const LL INF = (LL)1e16;
const LL MOD = (LL)1e9 + 7;

int main(){
  LL n,m,i,j,l,k,cost,d,ma = 256;
  while (1){
    cin >> n >> m;
    if (n == 0){
      return 0;
    }
    LL c[m],x[n];
    FOR(i,0,m) cin >> c[i];
    FOR(i,0,n) cin >> x[i];
    LL dp[n+1][ma];
    FOR(i,0,n+1)FOR(j,0,ma)dp[i][j] = -1;
    dp[0][128] = 0;
    FOR(i,0,n){
      FOR(j,0,ma){
        if (dp[i][j] < 0)continue;
        FOR(k,0,m){
          l = j+c[k];
          if (l < 0)l = 0;
          else if (l >= ma)l = 255;
          cost = (l-x[i])*(l-x[i]);
          d = dp[i][j]+cost;
          if (dp[i+1][l] < 0)dp[i+1][l] = d;
          else if (dp[i+1][l] > d) dp[i+1][l] = d;
        }
      }
    }
    LL ans = INF;
    FOR(i,0,ma){
      if (dp[n][i] >= 0 && dp[n][i] < ans) ans = dp[n][i];
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 43172
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int x, t;
  cin >> x >> t;

  cout << max(x - t, 0) << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<climits>
#include<algorithm>
#include<stack>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define PII pair<int,int>
#define MPII(a,b) make_pair((a),(b))

int M[1400][1400];
int dp[1400][1401] = {};

int main()
{
	int ans = 0;
	int H, W;
	cin >> H >> W;
	REP(i, H)REP(j, W)cin >> M[i][j];
	REP(j, W)if (M[0][j] == 0)dp[0][j] = 1;
	FOR(i, 1, H)REP(j, W)if (M[i][j] == 0)dp[i][j] = dp[i - 1][j] + 1;
	REP(i, H)
	{
		stack<PII> stk;
		REP(j, W + 1)
		{
			if (stk.empty() || stk.top().second < dp[i][j])
			{
				stk.push(MPII(j, dp[i][j]));
			}
			else if (stk.top().second > dp[i][j])
			{
				int temp;
				while (stk.top().second > dp[i][j])
				{
					int rect = (j - stk.top().first)*stk.top().second;
					ans = max(ans, rect);
					temp = stk.top().first;
					stk.pop();
					if (stk.empty())break;
				}
				stk.push(MPII(temp, dp[i][j]));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16212
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 0;
	vector<int> A, sum;
	vector<int> con0, con1, con;
	
	cin>>N;
	
	A.resize(N+1);
	sum.resize(N+1);
	con.resize(N+1);
	con0.resize(N+1);
	con1.resize(N+1);
	
	for(int i = 0; i <= N; i++){
		cin>>A[i];
		sum[i] = A[i];
	}
	
	for(int i = N; i >= 1; i--){
		sum[i-1] += sum[i];
	}
	
	for(int i = 0; i <= N; i++){ //cout<<"i = "<<i<<" "<<con[i]<<endl;
		if(i == 0) {
			if(A[0] >= 2) {
				cout<<-1<<endl;
				return 0;
			} else if(A[0] == 1) {
				if(N == 0) {
					cout<<1<<endl;
				} else {
					cout<<-1<<endl;
				}
				return 0;
			} else {
				con[i] = 1;
			}
		} else {
			
			con[i] += con[i-1];
		
			con[i] = min(con[i] * 2, sum[i]);
			
			con[i] -= A[i];
			
			if(con[i] < 0) {
				cout<<-1<<endl;
				return 0;
			}
		}
		
		ans += A[i];
		ans += con[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 7160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
    ll n, ans=0, sum=0;
    cin>>n;
    ll a[n];
    for(ll i=0; i<n; i++) cin>>a[i];
    for(ll i=n-2; i>=0; i--){
        ll x = a[i];
        sum = (sum + a[i+1]) % mod;
        ll prc = x * sum % mod;
        ans = (ans + prc) % mod;
    }
    cout<<ans;
}

Measured memory_bytes: 5124
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  u64 n;
  cin >> n;
  u64 a[n];
  u64 min_a = 1000000, max_a = 0;
  for (u64 i = 0; i < n; ++i) {
    cin >> a[i];
    min_a = min(min_a, a[i]);
    max_a = max(max_a, a[i]);
  }
  if (max_a - min_a >= 2) {
    cout << "No" << endl;
    return 0;
  }
  if (max_a == 1 || min_a == n-1) {
    cout << "Yes" << endl;
    return 0;
  }
  if (max_a == min_a) {
    if (max_a * 2 <= n) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  } else {
    u64 n_min = 0;
    for (u64 i = 0; i < n; ++i) {
      if (a[i] == min_a) {
        n_min++;
      }
    }
    u64 n_max = n - n_min;
    if (max_a <= n_min) {
      cout << "No" << endl;
      return 0;
    }
    u64 c_n = max_a - n_min;
    if (c_n * 2 <= n_max) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }


  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;
typedef pair<int,int> pi;


#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define REP(i, x) for(int i = 0; i < x; i++)
#define REPN(i, x) for(int i = x; i >= 0; i--)
#define REPVS(arr) for(auto &x : arr)
#define REPV(arr) for(auto x : arr)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", s.c_str())
#define F first
#define S second

const int INF = INT_MAX;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int a, b;
    si(a);
    si(b);
    pi(a*b);

    return 0;
}

Measured memory_bytes: 3724
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);

	private void doit(){
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [] data = new int[12];
			for(int i = 0 ; i < 12; i++){
				data[i] = sc.nextInt() - sc.nextInt();
			}
			int sum = 0;
			boolean flg= false;
			int ans = -1;
			for(int i = 0 ; i < 12; i++){
				sum += data[i];
				if(sum >= n){
					ans = i + 1;
					flg = true;
					break;
				}
			}
			if(flg){
				System.out.println(ans);
			}
			else{
				System.out.println("NA");
			}
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
	
	
}//end file

Measured memory_bytes: 32864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    int n;
    cin >> n;
    vector<int> a(n,0);
    for(int i = 1; i*i < n; i++){
        for(int j = 1; j*j < n; j++){
            for(int k = 1; k*k < n; k++){
                int can = i*i+j*j+k*k+i*j+j*k+i*k;
                if(can <= n){
                    can--;
                    a[can]++;
                }
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
'use strict';
(function(stdin) {
  var lines  = stdin.toString().split('\n');
  var param = lines[0].split(' ').map(Number);
  var result = (function(a,b,c) {
  	var count = 0;
  	for (var i = a; i < b + 1; i++){
  		if (c % i === 0) count++;
  	}
  	return count;
  }(param[0],param[1],param[2]
  ));
  console.log(result);
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
using Yorukatsu037.Questions;
using Yorukatsu037.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu037.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();
            yield return s.Contains('A') && s.Contains('B') ? "Yes" : "No";
        }
    }
}


namespace Yorukatsu037
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu037.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu037.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13268
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

using namespace std;
typedef long long ll;


void solve(long long N, long long K){
    int idx = 0;
    vector<int> a;
    while(N != 0) {
        a.push_back(N%K);
        N = N/K;
        idx++;
    }

    cout << idx << 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;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
for ai in range(n):
  for bi in range(ai+1,n):
    ok,ng = bi,n
    while ng-ok>1:
      mid = (ng+ok)//2
      if l[mid]<l[ai]+l[bi]:
        ok = mid
      else:
        ng = mid
    ans += ok-bi
print(ans)

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

typedef long long ll;
#define INF 1000000000

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    vector<int> dp(n, INF);

    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        //h.push_back(tmp); push_backは末尾に追加
        h[i] = tmp;
    }

    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= k && (i + j) < n; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            //printf("%d %d %d\n", i,j,dp[i + j]);
        }
    }
    
    cout << dp[n - 1] << endl;

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    int l,r,d,cnt=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;++i)
    {
        if(i%d==0)
            cnt++;
    }
    cout<<cnt<<endl;
}

int main()
{
    fast;
    int t;
    solve();
}




Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> L;
  REP(i,N){
    ll a;
    cin>>a;
    L.PB(a);
  }
  SORT(L);
  
  ll ans=0;
  REP(i,K) ans+=L[i];
  co(ans);
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;


ll dp[100010][13];
int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll no1=0,no2=0;
    ll n; cin>>n;
    vll a(n); REP(i,n) cin>>a[i];
    REP(i,n){
        if (no1 < a[i]){
            no1 = a[i];
        }
        else if(no2 < a[i]){
            no2 = a[i];
        }
    }
    REP(i,n){
        if (a[i]==no1) cout << no2 <<endl;
        else cout<<no1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

char win(char s) {
    if (s == 'r') return 'p';
    else if (s == 'p') return 's';
    else return 'r';
}

int main() {

    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    int plus[1000];
    plus['r'] = R;
    plus['p'] = P;
    plus['s'] = S;
    char result[N];
    long long score = 0;
    rep(i,N) {
        if (i < K) {
            result[i] = win(T[i]);
            score += plus[win(T[i])];
        } else {
            if (T[i - K] == T[i] && result[i - K] == win(T[i])) {
                result[i] = 'x';
            } else {
                result[i] = win(T[i]);
                score += plus[win(T[i])];

            }
        }
    }

    cout << score << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;
using i64 = long long;

int main() {
    i64 n;
    cin >> n;
    i64 ans = n - 1;
    for (i64 i = 1; i * i <= n; ++i) {
        if(n % i == 0) ans = min(ans, n / i + i - 2);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 2e5+10;
int arr[N];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    vi v;
    for(i = 0; i < n; i++){
        int in; cin>>in;
        arr[in]++;
        v.pb(in);
    }
    ll sum = 0;
    for(i = 1; i <= 2e5; i++){
        sum += 1LL*arr[i]*(arr[i]-1)/2;
    }
    for(i = 0; i < v.size(); i++){
        ll x = arr[ v[i] ];
        ll ans = sum - x*(x-1)/2;
        ans += (x-1)*(x-2)/2;
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define PI acos(-1.0)
int main()
{
    ll n;
    cin>>n;
    n%=10;
        if(n==3)
        {
            cout<<"bon";
        }
        else if(n==0 || n==1 || n==6 || n==8)
        {
            cout<<"pon";
        }
        else{
            cout<<"hon";
        }

}



Measured memory_bytes: 3592
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	ll a,b,k;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
		if(i%2==0){
			if(a%2) a-=1;
			b+=a/2;
			a/=2;
		}else{
			if(b%2) b-=1;
			a+=b/2;
			b/=2;
		}
	}
	cout<<a<<' '<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())
import sys
def bitlist(n, a, b):
  res = []
  for i in range(2**n):
    pattern = []
    for j in range(n):
      if (i >> j) & 1:
        pattern.insert(0, a)
      else:
        pattern.insert(0, b)
    res.append(pattern)
  return res

n = len(s)
lst = bitlist(n-1, "+", "-")
for i in range(2**n):
  calc = int(s[0])
  for j in range(n-1):
    if lst[i][j] == "+":
      calc += int(s[j+1])
    else:
      calc -= int(s[j+1])
  if calc == 7:
    res = s[0]
    for k in range(n-1):
      res += lst[i][k] + s[k+1]
    res += "=7"
    print(res)
    sys.exit()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

vector<ll> size(51);

ll ans(ll n, ll x){
  if (n == 0)
    return 1;

  if (x == 1)
    return 0;


  if (x <= size[n-1] + 1)
    return ans(n - 1, x - 1);

  if (x == size[n-1] + 2)
    return ans(n - 1, size[n-1]) + 1;

  if (x < size[n])
    return ans(n-1, size[n-1]) + 1 + ans(n-1, x - size[n-1] - 2);

  return 2*ans(n-1, size[n-1]) + 1;
}

int main(void){
  size[0] = 1;
  for (int i = 0; i < 50; i++){
    size[i + 1] = 2*size[i] + 3;
  }
  
  ll n, x;
  cin >> n >> x;
  
  cout << ans(n, x) << endl;

  return 0;
}


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

using namespace std;

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

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        
        if (a * 2 < b) {
            b = a * 2;
        }
        if (b * 2 < c) {
            c = b * 2;
        }
        if (c * 2 < d) {
            d = c * 2;
        }
        long count = 0;
        if (n >= 2) {
            count += (long)d * (n / 2);
            n %= 2;
        }
        
        if (n >= 1) {
            count += (long)c * n;
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
N = int(input())
DX = list(map(int, input().split()))
A = [int(input()) for i in range(N)]
D = DX[0]
X = DX[1]
fin = 0

for i in range(N):
    j = 0
    while j*A[i] + 1 <= D:
        j += 1
    else:
        fin = fin + j

print(fin + X)


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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int> H(N);
    int h;
    int s = 0;
    for(int i=0;i<N;i++){
        cin >> h;
        if(h>=K){
            s++;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int n,k;
   cin>>n>>k;
   vector<int> a;
   rep(i,n){
       int x;cin>>x;
       if(x<k)a.push_back(x);
   }
   int m=a.size();
   sort(a.begin(),a.end());
   bitset<5000> b[m][2];
   b[0][0]=1;
   b[m-1][1]=1;
   rep(i,m-1)b[i+1][0]=b[i][0]|(b[i][0]<<a[i]);
   rep(i,m-1)b[m-i-2][1]=b[m-i-1][1]|(b[m-i-1][1]<<a[m-i-1]);
   int ok=m,ng=-1;
   while(ok-ng>1){
       int mid=(ok+ng)/2;
        bool flag=false;
       REP(i,k-a[mid],k)rep(j,i+1){
           if(b[mid][0][j]&&b[mid][1][i-j]){
               flag=true;
               break;
           }
       }
       if(flag)ok=mid;
       else ng=mid;
   }
   cout<<ok<<endl;
   return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
struct po
{
	double x,y;
}q[511111];
int hq,tq=1;
double adx,ady;
int main()
{
	int n=io::F(),L=io::F();
	for(register int i=1;i<=n;++i)
	{
		int t=io::F(),v=io::F();
		adx+=v,ady+=t*(long long)v;
		while(1<tq&&(q[tq-1].y+ady)/(q[tq-1].x+adx)<(q[tq-2].y+ady)/(q[tq-2].x+adx))
		{
			if(q[tq-2].x+adx-L<=0)tq--;
				else
				{
					q[tq-2]=(po){L-adx,(q[tq-2].y-q[tq-1].y)/(q[tq-2].x-q[tq-1].x)*(L-(q[tq-1].x+adx))+q[tq-1].y};
					--tq;
					break;
				}
		}
		q[tq++]=(po){-adx,-ady};
		if(i==1){printf("%.9lf\n",(double)t);continue;}
		while(hq<tq&&q[hq+1].x+adx>=L)++hq;
		double ans=(ady+q[hq+1].y+(q[hq].y-q[hq+1].y)/(q[hq].x-q[hq+1].x)*(L-(q[hq+1].x+adx)))/L;
		printf("%.9lf\n",ans);
	}
	return 0;
}




Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,L,sum,mi=1e18,a[205];
signed main()
{
	cin>>n>>L;
	for(int i=1;i<=n;i++)
	{
		a[i]=L+i-1;
		mi=min(mi,abs(a[i]));
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
		if(mi==abs(a[i]))
		{
			sum-=a[i];
			break;
		}
	cout<<sum;
}

Measured memory_bytes: 256
D = {i:chr(96+i) for i in range(1,27)}
N = int(input())
A = []
while N>0:
    a = N%26
    if a==0:
        a = 26
        A.append(D[26])
    else:
        A.append(D[a])
    N = (N-a)//26
A = A[::-1]
print("".join(A))

Measured memory_bytes: 61976
unittest
{
	assert( [ "3 1" ].parse.expand.solve == "Yes" );
	assert( [ "1 2" ].parse.expand.solve == "No" );
	assert( [ "2 2" ].parse.expand.solve == "No" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return ( a % 2 == 1 && b % 2 == 1 ) ? "Yes" : "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    ll a,b;
    string s;
    cin>>a>>s;
    b=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
    cout<<(a*b)/100<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
	int n;
	cin >> n;
	if(n<3) cout << 0 << endl;
	else 
	{
		int a[n], cnt=0;
		for(int i=0; i<n; ++i) cin >> a[i];
		sort(a, a+n);
		for(int i=0; i<n-2; ++i)
		{
			for(int j=i+1; j<n-1; ++j)
			{
				for(int k=j+1; k<n; ++k)
				{
					if(a[i]+a[j]>a[k] && (a[i]!=a[j]) && (a[j]!=a[k]))
					{
						++cnt;
					} 
				}
			}
		}
		cout << cnt << endl;
	}
	return; 
}
int main()
{
	int t=1;
	//cin >> t;
	while(t--) solve();
	return 0; 
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll a[n],b[n],sum,ans=0,maki;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    vector<ll> v;
    if(k==0)v.pb(k);
    while(k){
        v.pb(k);
        v.pb(k-1);
        k-=(k&(-k));
    }
    maki=v.size();
    for(int i=0;i<maki;i++){
        sum=0;
        for(int j=0;j<n;j++){
            if((a[j]|v[i])==v[i]){
                sum+=b[j];
            }
        }
        ans=max(ans,sum);
    }
    cout << ans<<endl;

    return 0;
}


Measured memory_bytes: 1792
monster_size = int(input())
monster = list(map(int, input().split()))
hero = list(map(int, input().split()))

monster_all = sum(monster)

for i in range(monster_size):
    monster[i] = monster[i] - hero[i]
    if monster[i] < 0:
        monster[i+1] += monster[i]
        if monster[i+1] < 0:
            monster[i+1] = 0
        monster[i] = 0

print(monster_all - sum(monster))

Measured memory_bytes: 19116
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll x;
    cin>>x;
    ll m=100;
    ll cnt=0;
    while(m<x){
        m*=1.01;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();


		for(int i=0; i<10; i++) {
			x = r*x - D;
			System.out.println(x);
		}
	}

}


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

// よこ, たて
vector<pair<int, int>> v;
int ok=100000000;
int ng=-1;
void msearch(int i, int p, int bn, int t, int x, int move){
    if(move<ok){
        if(i==v.size()){
            if(ok>move+x){
                ok=move+x;
            }
        }else if(x==0){
            if(t+v[i].first>v[i].second){
                if(ng<p){
                    ng=p;
                }
            }else{
                t=v[i].second;
                x=v[i].first;
                move+=v[i].first;
                msearch(i+1, p+1, bn+1, t, x, move);
            }
        }else{
            //cout<<"x: "<<x<<" bn: "<<bn<<" vfront: "<<v[i].first<<" "<<v[i].second<<" t: "<<t<<endl;
            if(abs(x-v[i].first)*(bn+1)+t<=v[i].second && bn<3){
                msearch(i+1, p+1, bn+1, v[i].second, v[i].first, move+abs(x-v[i].first));
            }
            if(t+x*(bn+1)+v[i].first>v[i].second){
                if(ng<p){
                    ng=p;
                }
            }else{
                msearch(i+1, p+1, 1, v[i].second, v[i].first, move+x+v[i].first);
            }
        }
    }
}

int main(void){
    // Your code here!
    int n;
    while(cin>>n,n){
        v.resize(n);
        for(auto& a:v){
            cin>>a.first>>a.second;
        }
        msearch(0, 1, 0, 0, 0, (unsigned long long)0);
        if(ok==100000000){
            cout<<"NG "<<ng<<endl;
        }else{
            cout<<"OK "<<ok<<endl;
        }
        v.clear();
        ok=100000000;
        ng=-1;
    }
}



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

int main() {
  int N;
  cin >> N;
  
  vector<string> S(N);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
 
  sort(S.begin(), S.end());
  
  int ans = 1;
  
  for(int i = 0; i < N-1; i++) {
    if(S.at(i+1) != S.at(i)) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 9592
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    if (S == "AAA" || S == "BBB") {
        writeln("No");
    } else {
        writeln("Yes");
    }
}

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 ans =0;
    	
    	for(int i =1; i*i<=N; i++){
    	    ans = i*i;
    	}
    	
    	System.out.println(ans);
        
 	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;
const string sp = " ";
 
int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}
 
int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}
 
int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}
 
int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}
 
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
 
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
 
bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}
 
map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}
 
P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}
 
class unionfind {
private:
	int par[200010], rankth[200010], sizeth[200020];
public:
	void init(int n) {
		rep(i, n) {
			par[i] = i;
			rankth[i] = 0;
			sizeth[i] = 1;
		}
	}
	int root(int x) {
		while (par[x] != x) {
			x = par[x] = par[par[x]];
		}
		return x;
	}
 
	bool same(int x, int y) {
		return root(x) == root(y);
	}
 
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (rankth[x] < rankth[y]) {
			par[x] = y;
			sizeth[y] += sizeth[x];
		}
		else {
			par[y] = x;
			if (rankth[x] == rankth[y]) rankth[x]++;
			sizeth[x] += sizeth[y];
		}
	}
};

int n,p[200000];
int ta[200010];
int cnt;
int ans;

signed main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i];
		ta[p[i]]=i+1;
	}
	int j=0;
	for(int i=1;i<=n;i++){
		if(j<ta[i]) {
			j=ta[i];
			cnt++;
		}
		else {
			j=ta[i];
			ans=max(ans,cnt);
			cnt=1;
		}
	}
	ans=max(ans,cnt);
	cout<<n-ans<<endl;
}


Measured memory_bytes: 4352
import numpy as np

N = int(input())
A = tuple(map(int, input().split(' ')))
A = np.array(A, dtype=np.int64)
MOD = 10 ** 9 + 7

ans = 0
mask = 1

for i in range(60):
    ones = np.count_nonzero(A & mask)
    ans += (ones * (N - ones) % MOD) * (mask % MOD)
    ans %= MOD
    mask <<= 1

print(ans)


Measured memory_bytes: 68728
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int n, m, l; cin >> n >> m >> l;
	vector< vector<ll> > a(n, vector<ll>(m)), b(m, vector<ll>(l)), c(n, vector<ll>(l));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> a[i][j];
	for (int j = 0; j < m; j++)
		for (int k = 0; k < l; k++)
			cin >> b[j][k];
	for (int i = 0; i < n; i++)
		for (int k = 0; k < l; k++)
			for (int j = 0; j < m; j++)
				c[i][k] += a[i][j] * b[j][k];
	for (int i = 0; i < n; i++)
		for (int k = 0; k < l; k++)
			cout << c[i][k] << (k + 1 < l ? ' ' : '\n');
}

Measured memory_bytes: 1424
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int N = 1000000 + 5;

int main(){
    fast;
    ll s, w;
    cin >> s >> w;
    if(w >= s)
        cout << "unsafe";
    else
        cout << "safe";
    return 0;
}
//                                     #!!{*[$um1t_Kum@r]*}!!#


Measured memory_bytes: 3652
A, B = map(int, input().split())

def XOR(A):
    # 0からAまでの排他的論理和を求める
    if A%4 == 0:
        return A
    elif A%4 == 2:
        return A+1
    elif A%4 == 1:
        return 1
    else:
        return 0

fA = XOR(A-1)
fB = XOR(B)
print(fB^fA)


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

int main() {
	int n, m;
	cin >> n >> m;
	if (m == 0) {
		if (n == 1) cout << 0 << endl;
		else cout << pow(10, n - 1) << endl;
	}
	else {
		vector<pair<int, int>> vec(m);
		for (int i = 0; i < m; i++)
			cin >> vec.at(i).first >> vec.at(i).second;
		sort(vec.begin(), vec.end());
		int x = 0;
		bool finished = false;
		if (n != 1 && vec.at(0).first == 1 && vec.at(0).second == 0) cout << -1 << endl;
		else {
			if (vec.at(0).first > 1) x += pow(10, n - 1);
			if (m == 1) cout << x + (pow(10, n - vec.at(0).first) * vec.at(0).second) << endl;
			else {
				for (int i = 1; i < m; i++) {
					if (vec.at(i).first == vec.at(i - 1).first) {
						if (vec.at(i).second != vec.at(i - 1).second) {
							finished = true;
							break;
						}
					}
					else x += (pow(10, n - vec.at(i - 1).first) * vec.at(i - 1).second);
				}
				x += (pow(10, n - vec.at(m - 1).first) * vec.at(m - 1).second);
				if (finished == true) cout << -1 << endl;
				else cout << x << endl;
			}
		}
	}
}

Measured memory_bytes: 256