akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  def nextInt() = sc.next.toInt

  val n = nextInt
  val s = List.fill(n)(nextInt)

  val q = nextInt
  val t = Seq.fill(q)(nextInt)

  val c = (0 /: t) { (c, e) =>
    def find(xs: List[Int]): Boolean = xs match {
      case x :: xs =>
        if (x == e) true
        else find(xs)
      case Nil => false
    }
    if (find(s)) c + 1
    else c
  }
  println(c)
}



Measured memory_bytes: 58736
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using System.IO;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var n = consoleReader.Int;
            if (n % 7 == 0) return "Yes";
            while (n >= 0)
            {
                if(n % 4 == 0) return "Yes";
                n -= 7;
            }
            return "No";
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private Queue<string> queue = new Queue<string>();
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (queue.Count > 0) return queue.Dequeue();
                var line = textReader.ReadLine().Split();
                for (int i = 1; i < line.Length; i++) queue.Enqueue(line[i]);
                return line[0];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

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

int main(){
  int a,b,c;cin>>a>>b>>c;
  int cnt=0;
  
  if(a==b&&a!=c)cnt=1;
  if(b==c&&b!=a)cnt=1;
  if(a==c&&a!=b)cnt=1;
  
  if(cnt)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint, k = rint;
	long[] hs = rlong(n);
	hs.sort!"a>b"();

	long ans = 0;
	foreach(i, h; hs) if(i >= k) ans += h;
	
	ans.writeln;
}

Measured memory_bytes: 9364
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct edge{ll to, cost;};

typedef pair<ll,ll> P;

ll V;
vector<edge> G_y[100001];
vector<edge> G_s[100001];
ll d_s[100001];
ll d_t[100001];


int main(void){

  ll n,m,s,t;
  cin>>n>>m>>s>>t;

  rep(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    struct edge e;
    e.to=v; e.cost=a;
    G_y[u].pb(e);
    e.to=u; e.cost=a;
    G_y[v].pb(e);

    e.to=v; e.cost=b;
    G_s[u].pb(e);
    e.to=u; e.cost=b;
    G_s[v].pb(e);


  }
  rep1(i,n){
    d_s[i]=bit(60);
    d_t[i]=bit(60);
  }
  d_s[s]=0;
  d_t[t]=0;

  vector<ll> d_all(100001,bit(60));
  vector<ll> d_ans(0);

  priority_queue<P,vector<P>,greater<P> > que_s;
  priority_queue<P,vector<P>,greater<P> > que_t;

  que_s.push(P(0,s));
  while(!que_s.empty()){
    P p=que_s.top(); que_s.pop();
    ll v=p.second;
    if (d_s[v] < p.first) continue;
    rep(i,G_y[v].size()){
      edge e = G_y[v][i];
      if (d_s[e.to] > d_s[v] + e.cost){
        d_s[e.to]=d_s[v] + e.cost;
        que_s.push( P(d_s[e.to],e.to) );
      }
    }
  }
  /*
  rep1(i,n){
    cout << i << ":" << d_s[i] << endl;
  }
  */
  que_t.push(P(0,t));
  while(!que_t.empty()){
    P p=que_t.top(); que_t.pop();
    ll v=p.second;
    if (d_t[v] < p.first) continue;
    rep(i,G_s[v].size()){
      edge e = G_s[v][i];
      if (d_t[e.to] > d_t[v] + e.cost){
        d_t[e.to]=d_t[v] + e.cost;
        que_t.push( P(d_t[e.to],e.to) );
      }
    }
  }
  ///*
  rep1(i,n){
    //cout << i << ":" << d_t[i] << endl;
    d_all[i]=d_s[i]+d_t[i];
  }
  //*/
  ll temp_min=bit(60);
  for(ll i=n;i>=1;i--){
    if(d_all[i] < temp_min){
      temp_min=d_all[i];
      d_ans.pb(temp_min);
    }
    else{
      d_ans.pb(temp_min);
    }
  }

  rep1(i,n){
    //auto itr_b=d_all.begin()+1;
    //itr_b+=(i-1);
    //auto itr_e=d_all.end();
    cout << 1000000000000000LL - d_ans[n-i] << endl;
  }

  /*
  rep1(i,n){
    cout << i << endl;
    rep(j,G_y[i].size()){
      cout << G_y[i][j].to << "-" << G_y[i][j].cost << "/" << G_s[i][j].cost << endl;
    }
  }
  */



  return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if(a >= b){
        for(int i = 0;i < a;i++){
            cout << b;
        }
    }else{
        for(int i = 0;i < b;i++){
            cout << a;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int a[4],b[4];
	for(;cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3];){
		int x=0,y=0;
		rep(i,4)if(a[i]==b[i])x++;
		rep(i,4)rep(j,4)if(i!=j&&a[i]==b[j])y++;
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std ;
int main () {
  long long  N , A , B ;
  cin >> N >> A >> B ;
  long long ans = 0 ;
  if(A>B) ans = 0 ;
  else ans =max(ans,(N-2)*(B-A)+1) ;
  cout << ans << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
  }

  ll ans = 0;
  rep(i, n) {
    bool f = true;
    rep(j, n) {
      rep(k, n) {
        if (s[(k+i)%n][j] != s[(j+i)%n][k]) {
          f = false;
          goto end;
        }
      }

    }
end:
    if (f) ans++;
  }
  cout << ans*n << endl;
}


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

int main(){

    while(1){

        int n; cin >> n;
        if(!n) break;
        vector<int> a(17);
        for(int i = 1; i <= 17; i++){
            a[i - 1] = i * i;
        }


        vector<vector<int> > dp(18, vector<int> (1000, 0));
        dp[0][0] = 1;
        for(int i = 0; i < 17; i++){
            for(int j = 0; j < 500; j++){
                for(int k = 0;;k++){

                    int next_n = j + k * a[i];
                    if(next_n > n) break;

                    dp[i + 1][next_n] += dp[i][j];

                }
            }
        }

        cout << dp[17][n] << endl;
    }
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int x,y;
  cin >> x >> y;
  bool flag = false;
  rep(i,0,x+1){
    if(2*i + 4*(x-i) == y) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
def Joulist(N,m):#mのk乗としてN以下のもののリスト
    ans = []
    i = m//3
    while i<=N:
        ans.append(i)
        i *= m
    return ans
    
#1円は考えず、N//3円を2円＆3円で引き出してから帳尻を合わせる
N=int(input())
DP = [1000000] * (N//3 + 1)#0円から33333円まで
DP[0] = 0
for i in range(2,N//3 + 1):
    kouho = Joulist(i,6)+Joulist(i,9)
    DP[i] = min([DP[i-k] for k in kouho]) + 1
if N!=3:print(DP[N//3] + N%3)
else:print(3)

Measured memory_bytes: 3316
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let n = stdin.lock().gets().parse::<u32>().unwrap();
    let gen = (n - 1) / 999;
    if gen < 24 {
        println!("AB{}", (b'C' + gen as u8) as char);
    } else {
        panic!("Too future");
    }
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define fi first
#define se second
#define LL long long

using namespace std;
const int maxn = 2e5 + 5;
typedef pair<int, int> P;

char s[maxn], p[maxn];

int main() {
#ifdef TT
    freopen("xxx.in", "r", stdin);
#endif // TT
    int n, m, i, x, y, g;
    scanf("%d%d", &n, &m);
    scanf("%s", s);
    scanf("%s", p);
    g = __gcd(n, m);
    x = n / g;
    y = m / g;
    for(i = 0;i < g; i++) {
        if(s[i * x] != p[i * y]) return puts("-1"), 0;
    }
    printf("%lld\n", (LL)n * m / g);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

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

	//std::ifstream in("../../test.txt");
	//std::cin.rdbuf(in.rdbuf());

	ll N, X;
	cin >> N >> X;

	vl L(N);
	ll sum = 0;
	ll count = 1;
	rep(i, N) {
		cin >> L[i];
	}

	rep(i, N) {
		sum += L[i];
		if (sum <= X) count++;
	}

	cout << count << endl;


	return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <vector>
using namespace std;
#define MAXN 101

bool find(vector<int> v, int j){
    bool e = false;
    for(vector<int>::iterator it = v.begin(); it!=v.end(); ++it){
        if (*it == j) e = true;
    }
    return e;
}

int main(){
    vector<int> adj[MAXN];
    int n; cin >> n;
    for(int i=1; i<=n; ++i){
        int l, m; cin >> l >> m;
        for(int j=0; j<m; ++j){
            int k; cin >> k;
            adj[l].push_back(k);
        }
    }
    
    for(int i=1; i<=n; ++i){
        for(int j=1; j<n; ++j){
            cout << (find(adj[i], j) ? 1 : 0 ) << " ";
        }
        cout << (find(adj[i], n) ? 1:0) << endl;
    }
}

Measured memory_bytes: 1216
n = int(input())

while n % 2 == 0:
    n //= 2
while n % 5 == 0:
    n //= 5
if n == 1:
    print(1)
else:
    X = [n for i in range(n)]
    
    j = 1
    s = 1
    post = []
    m = 0
    while True:
        s *= 10
        s %= n
        post.append(s)
        X[s] = min(j, X[s])
        m += 1
        if s == 1:
            break
    ans = 0
    while True:
        if ans > 0:
            break
        pre = post
        post = []
        j += 1
        for p in pre:
            pp = (p + 1) % n
            if pp == 0:
                X[0] = j
                ans = j
                break
            if X[pp] == n:
                for i in range(m):
                    post.append(pp)
                    X[pp] = j
                    pp *= 10
                    pp %= n
    print(ans)

Measured memory_bytes: 12944
s = input().split()
stack = []
for i in s:
    if i == '+':
        a = int(stack.pop())
        b = int(stack.pop())
        stack.append(a + b)
    elif i == '-':
        a = int(stack.pop())
        b = int(stack.pop())
        stack.append(b - a)
    elif i == '*':
        a = int(stack.pop())
        b = int(stack.pop())
        stack.append(a * b)
    else:
        stack.append(i)

print(stack[0])


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <math.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;


int main() {

	// 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> X(N);

	for (int i = 0; i < N; i++)
	{
		cin >> X.at(i);
	}

	long long res = INF;

	for (int i = 1; i <= 100; i++)
	{
		long long tmp = 0;
		for (int j = 0; j < N; j++) {
			tmp += pow(i - X.at(j), 2.0);
		}

		chmin(res, tmp);
	}

	cout << res << endl;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void) {
	int dataset_num,cur_data;
	unsigned int chunks[9];
	int i,j;
	int key,sum;
	scanf("%d",&dataset_num);
	for(cur_data=0;cur_data<dataset_num;cur_data++) {
		for(i=0;i<9;i++)scanf("%x",&chunks[i]);
		key=0;
		for(i=0;i<32;i++) {
			for(sum=0,j=0;j<8;j++)sum+=chunks[j];
			if((sum & (1<<i))!=(chunks[8] & (1<<i)))key|=1<<i;
			for(j=0;j<9;j++)chunks[j]^=(key & 1<<i);
		}
		printf("%x\n",key);
	}
	return 0;
}

Measured memory_bytes: 0
sx,sy,tx,ty=map(int,input().split())

ans=[]

#sの上->tの左 ↑→
sx1=sx
sy1=sy+1
tx1=tx-1
ty1=ty
ans.append('U')
ans.extend(['U']*(ty1-sy1))
ans.extend(['R']*(tx1-sx1))
ans.append('R')

#tの下->sの右  ↓←
sx2=sx+1
sy2=sy
tx2=tx
ty2=ty-1
ans.append('D')
ans.extend(['D']*(ty2-sy2))
ans.extend(['L']*(tx2-sx2))
ans.append('L')

#sの下->tの右 ↓→↑←
sx3=sx
sy3=sy-1
tx3=tx+1
ty3=ty
ans.append('D')
ans.extend(['R']*(tx3-sx3))
ans.extend(['U']*(ty3-sy3))
ans.append('L')

#tの上->sの左 ↑←↓→
sx4=sx-1
sy4=sy
tx4=tx
ty4=ty+1
ans.append('U')
ans.extend(['L']*(tx4-sx4))
ans.extend(['D']*(ty4-sy4))
ans.append('R')

print(''.join(ans))


Measured memory_bytes: 3372
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
int al[26][200001];

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    al[int(s[i] - 'a')][i]++;
    for(int j = 0; j < 26; j++){
      if(i > 0)al[j][i] = al[j][i] + al[j][i - 1];
    }
  }
  ll res = 1;
  for(int i = 1; i < s.size(); i++){
    res += i - al[s[i] - 'a'][i - 1];
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 20868
function Main(input) {
  input = input.split('\n');

  N = parseInt(input[0], 10);
  A = input[1].split(' ');

  var S = Array(N + 1);
  for(var x = 0; x < N; x++) {
    S[A[x]] = x + 1;
  }
  S.shift();

  console.log(S.join(' '));
  /*
  for(var x = 0; x < N; x++) {
    console.log(S[x]);
  }
  */


}
Main(require('fs').readFileSync('/dev/stdin', 'utf-8'));


Measured memory_bytes: 34048
#include <iostream>
#include <list>
#include <string>
#include <tuple>
using namespace std;

int main()
{
	int N, M;
	cin >> N;
	int T[100];
	int sum = 0;
	string str = "";
	for (size_t i = 0; i < N; i++)
	{
		cin >> T[i];
		sum += T[i];
	}
	cin >> M;
	for (size_t i = 0; i < M; i++)
	{
		int P, X;
		cin >> P >> X;
		str += to_string(sum - T[P-1] + X) + "\n";
	}
	cout << str;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  string s; cin >> s;
  int ans = 0;
  rep(i, 4) ans += s[i] == '+' ? 1 : -1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{

  string s;
  cin >> s;
  ll k;
  cin >> k;

  ll h = 0;
  ll count2 = 0;
  ll isonlyONe = true;


  for (ll i = 0; i < s.size(); ++i) {
    if (s[i] != '1') {
      if (isonlyONe == true)isonlyONe = false;

      string ss = "";
      ss += s[i];
      // cerr << ss <<endl;
      h = stoi(ss);
      break;
    }
    if (i ==k-1)break;
  }

  if (isonlyONe)h = 1;


  cout << h;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
constexpr int MAXN = (1 << 20) + 5;
constexpr int MOD = 1e9 + 7;
constexpr double eps = 1e-6;
constexpr int INF = 1e9 + 7;
int dir[4][2] = { { -1,0 },{ 0,1 },{ 1,0 },{ 0,-1 } };

typedef complex<int> point;
typedef complex<int> vec;

#define x real()
#define y imag()

point r[105], b[105];
int g[105][105],ny,nx,mk[105];
int cx[105], cy[105];

int path(int u)
{
	for (int v = 0; v < ny; v++)
	{
		if (g[u][v] && !mk[v])
		{
			mk[v] = 1;
			if (cy[v] == -1 || path(cy[v]))
			{
				cx[u] = v;
				cy[v] = u;
				return 1;
			}
		}
	}
	return 0;
}
int MaxMatch()
{
	int res = 0;
	memset(cx, 0xff, sizeof(cx));
	memset(cy, 0xff, sizeof(cy));
	for (int i = 0; i < nx; i++)
	{
		if (cx[i] == -1)
		{
			memset(mk, 0, sizeof(mk));
			res += path(i);
		}
	}
	return res;
}
int main()
{
	//freopen("in.in", "r", stdin);&
	//freopen("out.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);

	int n;
	cin >> n;
	nx = ny = n;
	for (int i = 0; i < n; i++)
	{
		int p,q;
		cin >> p >> q;
		r[i] = complex<int>(p,q);
	}
	for (int i = 0; i < n; i++)
	{
		int p,q;
		cin >> p >> q;
		b[i] = complex<int>(p,q);
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (r[i].x < b[j].x&&r[i].y < b[j].y)
				g[i][j] = 1;

	int ans = MaxMatch();
	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a,int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(void) {
	int seq[100];
	int n;
	int i,j;
	int min_i;
	int swap_count = 0;

	scanf("%d",&n);
	for (i = 0;i < n;++i) {
		scanf("%d",seq + i);
	}
	// selection sort
	for (i = 0;i < n - 1;++i) {
		min_i = i;
		for (j = i + 1;j < n;++j) {
			if (seq[j] < seq[min_i]) {
				min_i = j;
			}
		}
		if (i != min_i) {
			swap(seq + i,seq + min_i);
			++swap_count;
		}
	}
	for (i = 0;i < n;++i) {
		printf("%d",seq[i]);
		printf(i == n - 1 ? "\n" : " ");
	}
	printf("%d\n",swap_count);
	return 0;
}

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

int H,W;

char map[105][105];

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

void stamp_a(int i,int j,char fruit);

int main()
{
	int ans;
	for(;;)
	{
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)
			break;
		for(int i=0;i<H;i++)
			scanf("%s",map[i]);
		ans=0;
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
			{
				if(map[i][j] == '@')
				{
					stamp_a(i,j,'@');
					ans++;
				}
				if(map[i][j] == '#')
				{
					stamp_a(i,j,'#');
					ans++;
				}
				if(map[i][j] == '*')
				{
					stamp_a(i,j,'*');
					ans++;
				}
			}
		printf("%d\n",ans);
	}
	return 0;
}

void stamp_a(int i,int j,char fruit)
{
	map[i][j] = 'a';
	int x,y;
	for(int k=0;k<4;k++)
	{
		x = i + dx[k];
		y = j + dy[k];
		if(x >= 0 && x < H && y >= 0 && y < W && map[x][y] == fruit)
			stamp_a(x,y,fruit);
	}
}

Measured memory_bytes: 1504
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

int dp[60];

int main()
{
	int w(0),n(0);
	REP(i, 60){
		dp[i] = i;
	}
	cin >> n >> w;
	REP(i, w){
		int a, b;
		char c;
		scanf("%d,%d", &a,&b);
		swap(dp[a], dp[b]);
	}
	REP(i, n){
		cout << dp[i+1] << endl;
	}
}

Measured memory_bytes: 1236
H, W = map(int, input().split())
S = [input() for i in range(H)]
offset_h = (-1,-1,-1,0,0,1,1,1)
offset_w = (-1,0,1,-1,1,-1,0,1)
for h in range(H):
  for w in range(W):
    if S[h][w] == "#":
      print("#", end="")
    else:
      bomb = 0
      for i,j in zip(offset_h, offset_w):
        if h+i >= 0 and h+i < H and w+j >=0 and w+j < W and S[h+i][w+j]=="#":
          bomb += 1
            
      print(bomb, end="")
     
  print("")
    


Measured memory_bytes: 3444
a = [int(i) for i in input().split()] 
b = [int(i) for i in input().split()] 
c = [int(i) for i in input().split()] 
b.append(a[2])
c.append(a[3])
if max(b) >= min(c):
 print('War')
else:
 print('No War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector <ll> nwin(N, 0);
    ll A, score;
    REP(i, Q) {
        cin >> A;
        nwin[A-1] += 1;
    }
    REP(i, N) {
        score = K - Q + nwin[i];
        if (score > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
int main()
{
	int n;
	long long k;
	ios::sync_with_stdio(false);
	cin>>n>>k;
	vector<long double>v;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		v.push_back(t);
	}
	sort(v.begin(),v.end());
	long long l=-1e18,r=1e18+1;
	auto check=[&](long long t){
		long long c=0;
		long double x=t;
		for(int i=0;i<n;i++){
			if(v[i]==0){
				if(x>=0)c+=i;
				continue;
			}
			if(v[i]>0){
				//t*x<=c;
				c+=upper_bound(v.begin(),v.begin()+i,x/v[i])-v.begin();
			}
			else {
				//t>=c/x
				c+=i-(lower_bound(v.begin(),v.begin()+i,x/v[i])-v.begin());
			}
		}
		return c>=k;
	};
	long long ans;
	while(l<r){
		long long mid=l+(r-l)/2;
		if(check(mid)){
			r=mid;
			ans=mid;
		}
		else {
			l=mid+1;
		}
	}
	cout<<ans<<'\n';
} 

Measured memory_bytes: 6512
def f1():
	L.sort(key = (lambda x: - x[1]//(x[0] - w1 + 40)))
	ans = 0
	w2 = 0
	i = 0
	while i < N:
		w2 = w2 + L[i][0]
		if w2 > W:
			break
		ans = ans + L[i][1]
		i = i + 1
	
	return ans
	
def f3():
	L.sort(key = (lambda x: - x[1]//x[0]))
	ans = 0
	w2 = 0
	i = 0
	while i < N:
		w2 = w2 + L[i][0]
		if w2 > W:
			break
		ans = ans + L[i][1]
		i = i + 1
	
	return ans
def f2():
	dp = [[0] * (W + 1) for i in range(N + 1)]
	for n in range(1,N + 1):
		w,v = L[n - 1]
		if w > W:
			continue
		for m in range(w):
			dp[n][m] = dp[n - 1][m]
		for m in range(w,W + 1):
			dp[n][m] = max(dp[n - 1][m - w] + v, dp[n - 1][m])
	return max(dp[-1])
	
N,W = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]
w1 = L[0][0]
if w1 > 10000000:
	print(f1())
elif W > 10000000:
	print(f3())
else:
	print(f2())


Measured memory_bytes: 13172
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (l, r, d) = readIs()
  println(r / d - (l - 1) / d)
}


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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll k, n;
    cin >> k >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }

    ll ans = a[n - 1] - a[0];

    for(ll i = 0;i < n - 1;i++){
        ans = min(ans, k - ( - a[i] + a[i + 1]));
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1792
class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

    def __init__(self):
        self.stack = []

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value)


sequence = raw_input().split()
operators = {"*": "*", "+": "+", "-": "-"}
stack = MyStack()
for s in sequence:
    if s in operators:
        value2 = stack.pop()
        value1 = stack.pop()
        stack.push(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s)

print(stack.pop())

Measured memory_bytes: 6436
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 200000 + 3;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

int ans, n, k, x, a[maxn], b[maxn];

bool cmp(int i, int j){
	return i > j;
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> x, b[x]++;
	sort(b, b + n, cmp);
	for(int i = k; i < maxn; i++)
		ans += b[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
n = [0 for i in range(N + 1)]
count = 1
n[A[0]] = 1
for i in range(1, N):
    if A[i] != A[i - 1]: count += 1
    n[A[i]] += 1
n.sort()
if count <= K:
    print(0)
else:
    for i in range(N + 1):
        if n[i] != 0:
            key = i
            break
    print(sum(n[key:key + count - K]))


Measured memory_bytes: 25716
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> lay;
vector<ll> p;
ll n, k;

//level n ,layer x

ll fun(ll n, ll x)
{
	if (x == 0)
		return 0;
	if (n == 0)
		return 1;
	if (x <= lay[n - 1] + 1)
		return fun(n - 1, x - 1);
	else
		return p[n - 1] + 1 + fun(n - 1, x - 1 - (lay[n - 1] + 1));
}

int main()
{
	cin >> n >> k;
	lay.push_back(1),p.push_back(1);
	for (int i = 1; i <= n; i++)
	{
		ll l = lay[i - 1] * 2 + 3;
		ll pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
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; }

const int NIL = -1;
const int INF = (1<<21);
const long long MOD = 1e9+7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};


int main() {
  int N; cin >> N;
  int V[N], C[N];
  for (int i = 0; i < N; ++i) cin >> V[i];
  for (int i = 0; i < N; ++i) cin >> C[i];
  int ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit) {
    int x = 0;
    int y = 0;
    for (int i = 0; i < N; ++i) {
      if (bit & (1<<i)) {
        x += V[i];
        y += C[i];
      }
    }
    ans = max(ans, x-y);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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(){
	/*100^3??\???????????§??¨??¢?´¢??§??????*/
	while(1){
		int a,b;
		cin >> a >> b;
		if(a==0&&b==0) break;
		ll int cnt = 0;
		FOR(i,1,a+1){
			FOR(j,i+1,a+1){
				FOR(k,j+1,a+1){
					if(i+j+k==b) cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1156
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, long long d, std::vector<long long> x, std::vector<long long> y){
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        cnt += x[i] * x[i] + y[i] * y[i] <= d * d;
    }
    cout << cnt << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<long long> X(N);
    std::vector<long long> Y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
    }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  string s; cin >> s;
  if (s[2] == s[3] and s[4] == s[5]) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}



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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  getline(cin,s);
  rep(i,s.size()){
    if(s[i] >= 'a' && s[i] <= 'z'){
      s[i] = 'A'+s[i]-'a';
    }
  }
  cout << s <<endl;
  return 0;
}

Measured memory_bytes: 3076
import math
a,b,h,m = map(int,input().split())
h = h + m/60
Ac = a*math.cos(30*h*math.pi/180)
As = a*math.sin(30*h*math.pi/180)
Bc = b*math.cos(6*m*math.pi/180)
Bs = b*math.sin(6*m*math.pi/180)
x = (abs(As-Bs))
y = (abs(Ac-Bc))
print(math.sqrt(x**2+y**2))

Measured memory_bytes: 9524
#include<iostream>
using namespace std;
#include<string>
#include<cstdio>
#include<cstring>
#include<map>
#include<queue>
#include<algorithm>

typedef pair<string,int> P;

int main()
{
  string body;
  int check = 0;

  while(1){
    cin >> body;
    if(body == "0")return 0;

    map<string,int> used;

    queue<P> que;

    que.push(P(body,0));
    while(!que.empty()){
      P p = que.front();que.pop();
      string now = p.first;
      int co = p.second;
      int c = 1;
      for(int i = 0;i < body.size();i++){
        if(now[0] == now[i+1])c++;
      }
      if(c == body.size()){
        cout << co << endl;
        check = 1;
        break;
      }
      if(used[now] == 1)continue;
      used[now] = 1;

      for(int i = 0;i < body.size()-1;i++){
        string next = now;
        if(next[i] == next[i+1])continue;
        if((next[i] == 'r' && next[i+1] == 'b') || (next[i] == 'b' && next[i+1] == 'r')){
          next[i] = 'g';
          next[i+1] = 'g';
          que.push(P(next,co+1));
        }
        if((next[i] == 'r' && next[i+1] == 'g') || (next[i] == 'g' && next[i+1] == 'r')){
          next[i] = 'b';
          next[i+1] = 'b';
          que.push(P(next,co+1));
        }
        if((next[i] == 'g' && next[i+1] == 'b') || (next[i] == 'b' && next[i+1] == 'g')){
          next[i] = 'r';
          next[i+1] = 'r';
          que.push(P(next,co+1));
        }
      }
    }
    if(check == 0)cout << "NA" << endl;
    check = 0;
  }
}

Measured memory_bytes: 3400
import java.util.*;
import java.math.*;

class Main
{
	public static void main(String[] args)
	{
		int K;
		double N,n=0,m;
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		BigDecimal Ans = BigDecimal.valueOf(0);
		BigDecimal One = BigDecimal.valueOf(1);
		BigDecimal num = new BigDecimal(N);
		for(int i=1;i<=N;i++)
		{
			if(i<K)
			{
				n = Math.log(K)/Math.log(2)-Math.log(i)/Math.log(2);
				n = Math.ceil(n);
				BigDecimal comp = new BigDecimal(Double.toString(Math.pow(0.5,n)));
				Ans = Ans.add(comp);
			}
			else
			{
				Ans = Ans.add(One);
			}
		}
		Ans = Ans.divide(num,12,BigDecimal.ROUND_HALF_UP);
		System.out.println(Ans);
	}
}


Measured memory_bytes: 24628
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int, int> pint;
queue<pint> nowque, nexque;
int h, w;
int castle[1002][1002] = {};
bool inq[1002][1002] = {};
char str[1001];

const int dir[9] = { -1,-1,0,1,1,0,-1,1,-1 };
inline bool check(int i,int j)
{
	if (castle[i][j] == 0)return false;
	int c = 0;
	for (int k = 0; k < 8; ++k)
	{
		if (castle[i + dir[k]][j + dir[k + 1]] == 0)++c;
	}
	if (c >= castle[i][j])
	{
		inq[i][j] = true;
		return true;
	}
	return false;
}

int main()
{
	scanf("%d %d", &h, &w);
	for (int i = 1; i <= h; ++i)
	{
		scanf("%s",str);
		for (int j = 1; j <= w; ++j)
		{
			castle[i][j] = ((str[j - 1] == '.') ? 0 : (str[j - 1] - '0'));
			if (castle[i][j] == 0)
			{
				nowque.emplace(i, j);
			}
		}
	}
	int time = 0;
	for (; true; ++time)
	{
		while (!nowque.empty())
		{
			pint x = nowque.front(); nowque.pop();
			for (int k = 0; k < 8; ++k)
			{
				if (!inq[x.first + dir[k]][x.second + dir[k + 1]])
				{
					if (check(x.first + dir[k], x.second + dir[k + 1]))
					{
						nexque.emplace(x.first + dir[k], x.second + dir[k + 1]);
					}
				}
			}
		}
		nowque = nexque;
		while (!nexque.empty())
		{
			pint y = nexque.front(); nexque.pop();
			castle[y.first][y.second] = 0;
		}
		if (nowque.empty())break;
	}
	printf("%d\n",time);
	return 0;
}

Measured memory_bytes: 7696
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    print(YES if (('W' in S) == ('E' in S))  and (('N' in S) == ('S' in S)) else NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    string T; cin >> T;

    REP(i,T.size()){
        if(T[i]=='?'){
            T[i]='D';
        }
    }

    cout << T << endl;

    return 0;
}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L=A+B, R=C+D;
  if(L>R){
    cout << "Left" << endl;
    return 0;
  }else if(L<R){
    cout << "Right" << endl;
    return 0;
  }
  cout << "Balanced" << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.split.map(&:to_i)
$co = 0

class Array
  def merge_sort
    merge = ->(a, b) {
      result = []
      while a.size > 0 and b.size > 0
        result.push((a[0] < b[0]) ? a.shift : b.shift)
      end
      result + a + b
    }
    
    l = length
    return self if l <= 1
    q = l / 2
    $co += l
    merge.call(self[0...q].merge_sort, self[q..-1].merge_sort)
  end
end

puts s.merge_sort.join(" ")
puts $co


Measured memory_bytes: 78080
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[]) . show

solver [a,b,c] = answer
  where
    answer = minimum $ map func [0..52]
    func x = sum $ map (func2 x) [a,b,c]
func2 x n  
  | x < n      = n - x 
  | odd(x - n) = 1 + (x-n+1)`div`2
  | otherwise  = (x-n)`div`2
  


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

// 

public class Program_ABC114_B // ←Class名変更！！
{
    public static void Main()
    {
        var s = Rs();
        var ans = 753;
        for (int i = 0; i < s.Length-2; i++)
        {
            var si = new String(new[] { s[i], s[i + 1], s[i + 2] });
            var ii = int.Parse(si);
            var ab = Abs(ii - 753);
            if (ab<ans)
            {
                ans = ab;
            }
        }

        WriteLine($"{ans}");
    } // Main

    public static string Rs() { return ReadLine(); }
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
    public static char[] Rca() { return ReadLine().ToCharArray(); }
}     // Class


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

int main() {
  int N, A;
  cin >> N  >> A ;
  
 if(N <= A)
 {
   cout << "Yes" << endl;
 }
  else if(N%500 <= A)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}  

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use proconio::marker::Usize1;
use proconio::{fastout, input};
use std::vec::*;

macro_rules! echo {
  {$x:expr} => {println!("{}", $x)}
}

macro_rules! chmax {
  {$x:expr, $y:expr} => {
    $x = std::cmp::max($x, $y)
  }
}

macro_rules! chmin {
  {$x:expr, $y:expr} => {
    $x = std::cmp::min($x, $y)
  }
}

#[allow(unused_variables)]
#[fastout]
fn main() {
  let n: usize;
  input! {
    n: usize,
  }
  let mut ans = 0;
  for _ in 0..n {
    input! {
      l: usize,
      r: usize
    }
    ans += r - l + 1;
  }
  echo!(ans);
}


Measured memory_bytes: 2196