akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)

#define STR(s) string s;cin>>s

int main(){
  STR(s); int n = SZ(s);
  string t = s; REP(i, n){t[i] = 'g';}
  int p = 0, g = 0, ans = 0;
  REP(i, n){
    if (p < g){
      t[i] = 'p';
      p++;
    }
    else {
      g++;
    }
    if (s[i] == 'p' && t[i] == 'g'){
      ans--;
    }
    else if (s[i] == 'g' && t[i] == 'p'){
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,s_1,s_2,s_3;
  cin >> s;
  s_1 = s/100;
  s_2 = (s-s_1*100)/10;
  s_3 = s-100*s_1-10*s_2;
  cout << s_1 + s_2 + s_3 << endl;
}

Measured memory_bytes: 256
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

a,p=input_list()
print((a*3+p)//2)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller(char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n,m;
    cin>>n>>m;
    vi a(m);
    rep(i,m) cin>>a[i];
    ll sum=0;
    rep(i,m) sum+=a[i];
    ll ans=n-sum;
    if(ans<0) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
using namespace std;
main(){
  string moji;
  int a;
  cin >> moji;
  a=moji.size();
  for(int i=0;i<a;i++){
    if(moji[i]=='A'){
      moji[i]+=23;
    }
    else if(moji[i]=='B'){
      moji[i]+=23;
    }
    else if(moji[i]=='C'){
      moji[i]+=23;
    }
    else{
      moji[i]=moji[i]-3;
    }
  }
  cout << moji << endl;
}

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

long long max(long long a,long long b)
{
    if(a>=b)
     return a;

    return b;
}
int main()
{
    int n;
    cin>>n;
  vector<int> turn;

  int arr[200001]={};

  for(int i=0;i<n;i++)
  {
    int a;
     cin>>a;
     arr[a]++;
    turn.push_back(a);
  }
   
    long long ways[200001];
     long long alter[200001];

    long long sum=0;

   for(int i=0;i<200001;i++)
 {
     long long a= arr[i];
     long long b= ((long long)a*(a-1))/2;

    //if(a>0)
    //cout<<i<<" "<<a<<endl;

    ways[i]=max(0,b);

    if(arr[i]>=3){
 
   long long c= arr[i]-1;
     long long d= ((long long)c*(c-1))/2;
     alter[i]=max(0,d);
   }

  else
   alter[i]=0;

   sum+=ways[i];
 }

  //cout<<sum<<endl;

  for(int i=0;i<n;i++)
  cout<< sum-ways[turn[i]]+alter[turn[i]]<<endl;
 




return 0;
}


Measured memory_bytes: 7412
//arc061_c.cpp
//Sat Jun 23 08:33:00 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using ll=long long;

ll rec(ll num, string S){
	ll ans = 0;
	if (S == ""){
		return num;
	}
	for (int i=1;i<=S.size();i++){
		ans = ans + rec(num + stoll(S.substr(0,i)),S.substr(i));
	}
	return ans;
}

int main(){
	string s;
	cin >> s;
	ll ans = rec(0,s);

	cout << ans << endl;
}




Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, c, k = MI()

    T = [-1] * n
    for i in range(n):
        T[i] = II()
    T = sorted(T)

    bus_cnt = 1
    person_cnt = 0
    th = T[0] + k
    for i in T:
        # print(i, th, bus_cnt, person_cnt)
        if i > th or person_cnt + 1 > c:
            bus_cnt += 1
            person_cnt = 1
            th = i + k
        else:
            person_cnt += 1
    print(bus_cnt)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 8240
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];

  rep(i,n){
    rep(j,n){
      vector<int>b=a;
      swap(b[i],b[j]);
      bool ok=true;
      rep(k,n-1){
        if(b[k]>b[k+1])ok=false;
      }
      if(ok){
        cout<<"YES"<<endl;
        return(0);
      }
    }
  }
  cout<<"NO"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, 0, n){
        cin >> t[i];
    }
    int ans = 0;
    sort(all(t));
    int cnt = 0, st = -1;
    t.push_back(INF);
    rep(i, 0, t.size()){
        if(st != -1){
            if(st + k >= t[i] && cnt < c){
                cnt++;
            }else{
                cnt = 0;
                st = -1;
                ans++;
            }
        }
        if(st == -1){
            cnt = 1;
            st = t[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
// AOJ 2809: Graduation Ceremony
// 2018.1.4 bal4u@uu

#include <stdio.h>

#define MAX 2002

char s[MAX];
short u[MAX], d[MAX], l[MAX], r[MAX];
int dx[4] = { 0,1,0,-1};	// URDL
int dy[4] = {-1,0,1, 0};
int tr['Z'];

int main()
{
	int k, i, j, t, j2, dir, ans;
	char *p;

	tr['U'] = 0, tr['R'] = 1, tr['D'] = 2, tr['L'] = 3;

	scanf("%s%d", s, &k);
	p = s; while (*p) {
		dir = tr[*p++];
		j2 = j = k; while (j--) {
			t = -d[j]; if (t > u[j2]) t = u[j2]; u[j2] = t + dy[dir];
			t = -l[j]; if (t < r[j2]) t = r[j2]; r[j2] = t + dx[dir];
			t = -u[j]; if (t < d[j2]) t = d[j2]; d[j2] = t + dy[dir];
			t = -r[j]; if (t > l[j2]) t = l[j2]; l[j2] = t + dx[dir];
			j2--;
		}
		l[0] += dx[dir], r[0] = l[0];
		d[0] += dy[dir], u[0] = d[0];
	}
	ans = 0;
	for (i = 0; i <= k; i++) {
		j  = -l[i];   if (j  < r[i  ]) j  = r[i];
		j2 = -u[k-i]; if (j2 < d[k-i]) j2 = d[k-i];
		j += j2;
		if (j > ans) ans = j;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 1860
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;

int main()
{
	string s;
	cin>>s;
	if(s=="SUN") puts("7");
	else if(s=="MON") puts("6");
	else if(s=="TUE") puts("5");
	else if(s=="WED") puts("4");
	else if(s=="THU") puts("3");
	else if(s=="FRI") puts("2");
	else if(s=="SAT") puts("1");
	return 0;
}


Measured memory_bytes: 256
<?php
list($r,$c) = explode(" ",trim(fgets(STDIN)));
for($i = 0; $i < $r; $i++){
    $arr[$i] = explode(" ",trim(fgets(STDIN)));
    array_push($arr[$i],array_sum($arr[$i]));
    echo implode(" ",$arr[$i])."\n";
}
$arr[$r] = array_fill(0,($c+1),0);
for($i = 0; $i < $r; $i++){
    for($j = 0; $j < $c + 1; $j++){
        $arr[$r][$j] += $arr[$i][$j];
    }
}
echo implode(" ",$arr[$r])."\n";

Measured memory_bytes: 17292
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	long long a,b,c;
	cin>>a>>b>>c;
	
	if(c-a-b<0){
		cout<<"No"<<endl;
		return 0;
	}
	
	if(4*a*b<(c-a-b)*(c-a-b)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#coding: euc-jp
class Main
  def self.main
    n, m = Func.read1
    a, b = Func.read2(n)
    a, b = [a, b].mysort
    count = 0
    shop = 0
    price = 0
    while count < m
      if m - count > b[shop] then
        price += a[shop] * b[shop]
        count += b[shop]
      else
        price += a[shop] * (m - count)
        count += (m - count)
      end
      shop += 1
    end
    Func.write(price)
  end
end

module Function
  def read1
    return gets.chomp.split.map(&:to_i)
  end
  def read2(t)
    return t.times.map{gets.chomp.split.map(&:to_i)}.transpose
  end
  def write(ins)
    puts ins
  end
end

module Conv
  def mysort
    return self.transpose.sort{|a, b| a[0] <=> b[0]}.transpose
  end
end

class Func
  extend Function
end

class Array
  include Conv
end

Main.main


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

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    set<int> values; // insert するときに重複を取り除いてくれます
    for (int i = 0; i < N; ++i) {
        values.insert(d[i]); // 挿入します
    }

    // set のサイズを出力します
    cout << values.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s[100005];
int main()
{
	int n,a[3];
	cin >> n >> a[0] >> a[1] >> a[2];
	for (int i=0;i<n;i++)
	cin >> s[i];
	vector<char> v;
	for (int i=0;i<n;i++)
	{
		if (!a[s[i][0]-'A'] && !a[s[i][1]-'A'])
		{
			cout << "No";
			return 0;
		}
		if (a[s[i][0]-'A']>a[s[i][1]-'A'])
		swap(s[i][0],s[i][1]);
		char add=s[i][0];
		if (a[s[i][0]-'A']==1 && a[s[i][1]-'A']==1 && i!=n-1 && s[i+1].find(add)==-1)
		add=s[i][1];
		v.push_back(add);
		a[add-'A']++;
		a[(s[i][0]^s[i][1]^add)-'A']--;
	}
	cout << "Yes";
	for (char c:v)
	cout << endl << c;
}

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int res = 0;
  for (int i = l; i <= r; ++i) {
    if (i % d == 0) ++res;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3532
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    final long MOD = (long)1e9 + 7;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] arr = new long[n+1];

        for (int i=1; i<=n; i++) {
            arr[i] = arr[i-1] + i;
        }

//        System.out.println(arr[n]);

        long ans = 0;

        for (int i=k; i<=n; i++) {
            long max = arr[n] - arr[n-i];
            long min = arr[i-1];
//            System.out.println(max);
//            System.out.println(min);
            ans += (max - min + 1);
            ans %= MOD;
        }

        System.out.println(ans % MOD + 1);

    }
}


Measured memory_bytes: 37256
#include<bits/stdc++.h>
    #define ull unsigned long long
    # define ll long long
    # define mod 1000000007LL 
    using namespace std;
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll n;
        cin>>n;
        ll arr[n];
        for(int i=0;i<n;i++)
        cin>>arr[i];
        bool flag=0;
        ll cost=1000;
        ll share=0;
        for(int i=0;i<n-1;i++)
        {
            if(arr[i]<arr[i+1])
            {
                share=cost/arr[i];
                cost=cost%arr[i];
                cost=cost+share*arr[i+1];
                //cout<<share;
            }
            
        }
        cout<<cost;


        
        return 0;
    }


Measured memory_bytes: 3612
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int n,i,j,x=1;
    cin>>n;
    char arr[n];
    cin>>arr;
    for(i=0;i<n-1;i++)
    {
        if(arr[i]!=arr[i+1])
            x++;
    }
    cout<<x<<endl;
}


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

int main(){
    long long n;
    long long d;
    cin >> n >> d;

    long long cnt = 0;
    for(long long i = 0; i < n; i++){
        long long x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    long long X;
    cin >> X;
    long long answer = 2 * (X / 11);

    if (X % 11 > 0)
        answer++;

    if (X % 11 > 6)
        answer++;

    cout << answer << '\n';
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

va = v[::2]
vb = v[1::2]

va_ = Counter(va).most_common()
vb_ = Counter(vb).most_common()

if va_[0][0] == vb_[0][0]:
    if len(va_) == 1 or len(vb_) == 1:
        if len(va_) == 1 and len(vb_) == 1:
            print(len(v) // 2)
        elif len(va_) == 1:
            if va_[0][0] == vb_[0][0]:
                print(len(vb) - vb_[1][1])
            else:
                print(len(vb) - vb_[0][1])
        else:
            if va_[0][0] == vb_[0][0]:
                print(len(va) - va_[1][1])
            else:
                print(len(va) - va_[0][1])
        exit()
    if va_[0][1] + vb_[1][1] > va_[1][1] + vb_[0][1]:
        print(len(va) - va_[0][1] + len(vb) - vb_[1][1])
    else:
        print(len(va) - va_[1][1] + len(vb) - vb_[0][1])
else:
    print(len(va) - va_[0][1] + len(vb) - vb_[0][1])


Measured memory_bytes: 21084
#include <iostream>
using namespace std;
int main() {
	int n,a[100],num=0;
	cin>>n;
	for(int i=0; i<n;i++) {
		cin>>a[i];
		int tmp=a[i],j;
		for (j=i-1;j>=0 && tmp<a[j];j--) a[j+1]=a[j],num++;
		a[j+1]=tmp;
	}
	for (int i=0;i<n-1;i++) cout<<a[i]<<" ";
	cout<<a[n-1]<<endl<<num<<endl;
	return 0;
}

Measured memory_bytes: 3080
while line = gets
  x1, y1, x2, y2, x3, y3, xp, yp = line.chomp.split.map(&:to_f)
  xg = (x1+x2+x3)/3
  yg = (y1+y2+y3)/3
  v12 = [x2-x1, y2-y1]
  v23 = [x3-x2, y3-y2]
  v31 = [x1-x3, y1-y3]
  v1p = [xp-x1, yp-y1]
  v2p = [xp-x2, yp-y2]
  v3p = [xp-x3, yp-y3]
  v1g = [xg-x1, yg-y1]
  v2g = [xg-x2, yg-y2]
  v3g = [xg-x3, yg-y3]
  z1 = v12[0] * v2p[1] - v12[1] * v2p[0]
  z2 = v23[0] * v3p[1] - v23[1] * v3p[0]
  z3 = v31[0] * v1p[1] - v31[1] * v1p[0]
  g1 = v12[0] * v2g[1] - v12[1] * v2g[0]
  g2 = v23[0] * v3g[1] - v23[1] * v3g[0]
  g3 = v31[0] * v1g[1] - v31[1] * v1g[0]
  f1 = z1 * g1 > 0
  f2 = z2 * g2 > 0
  f3 = z3 * g3 > 0
  if (f1 && f2 && f3) then
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 8664
N = int(input())
a = list(map(int, input().split()))

count = [0] * 10**5

for e in a :
    if e != 0 :
        count[e - 1] += 1
    count[e] += 1
    if e != 10**5 - 1 :
        count[e + 1] += 1

print(max(count))


Measured memory_bytes: 13964
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
int i,j,it,now,k,n,dp[5005],a[5005],rs;
long long sum;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>n>>k;
	for(i=1;i<=n;++i)
	cin>>a[i],sum+=a[i];
	if(sum<k)
	return cout<<n<<'\n',0;
	sort(a+1,a+n+1);
	int st=1,dr=n;
	while(st<=dr){
    	it=(st+dr)/2;
    	memset(dp,0,sizeof(dp));
    	for(dp[0]=i=1;i<=n;++i){
    		if(i==it)
			continue;
			for(j=k;j>=0;--j)
        	if(dp[j] && j+a[i]<=k)
			dp[j+a[i]]=1;
    	}
    	for(i=0;i<k;++i)
    	if(dp[i] && i+a[it]>=k)
		i=INF;
    	if(i==k)
		rs=it,st=it+1;
    	else
		dr=it-1;
	}
	cout<<rs;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int A,B;
scanf("%d%d",&A,&B);

if(A <= 5){
printf("%d\n", 0);
}

if(6 <= A && A <= 12){
printf("%d\n", B/2);
}

if(13 <= A){
printf("%d\n", B);
}

return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int d[5][1000];
int x,y;
int sx,sy,gx,gy;
char c;
int nx[5][1000],ny[5][1000],n[5];
int now,next;

int dis(int ay,int ax,int by,int bx){return abs(ay-by)+abs(ax-bx);}

int main(){
  while(scanf("%d %d",&x,&y) && (x||y)){
    for(int i=0;i<5;i++)n[i] = 0;
    
    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	scanf(" %c ",&c);
	if(c!='.'){
	  if(c=='S'){
	    sx = j;
	    sy = i;
	  }else if(c=='G'){
	    gx = j;
	    gy = i;
	  }else{
	    int a = c-'1';
	    nx[a][n[a]] = j;
	    ny[a][n[a]] = i;
	    n[a]++;
	  }
	}
      }
    }
    
    int type = -1,res = 1<<30;
    for(int i=0;i<5;i++){
      for(int j=0;j<5;j++)
	for(int k=0;k<n[j];k++)d[j][k] = 1<<30;

      now = i;
      for(int j=0;j<5;j++){
	next = (now+1)%5;
	if(j==0){
	  for(int k=0;k<n[next];k++){
	    d[next][k] = min(d[next][k],dis(sy,sx,ny[next][k],nx[next][k]));
	  }
	}else if(j==4){
	  int m = 1<<30;
	  for(int k=0;k<n[now];k++){
	    m = min(m,d[now][k] + dis(gy,gx,ny[now][k],nx[now][k]) );
	  }
	  if(m<res){
	    type = i;
	    res = m;
	  }
	}else{
	  for(int k=0;k<n[now];k++){
	    for(int l=0;l<n[next];l++){
	      d[next][l] = min(d[next][l],d[now][k] + dis(ny[now][k],nx[now][k],ny[next][l],nx[next][l]));
	    }
	  }
	}
	now = next;
      }
    }
    if(type<0)printf("NA\n");
    else printf("%d %d\n",type+1,res);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string S; cin >> S;
    int ans = 0;
    rep(i, 10) {
        rep(j, 10) {
            rep(k, 10) {
                bool ok[3] = {};
                rep(t, n) {
                    if(!ok[0]) {
                        if(S[t] == i + '0') ok[0] = true;
                    } else if(!ok[1]) {
                        if(S[t] == j + '0') ok[1] = true;
                    } else if(!ok[2]) {
                        if(S[t] == k + '0') ok[2] = true;
                    }
                    if(ok[0] && ok[1] && ok[2]) {
                        ans++;
                        break;
                    }

                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
   public static void main(String[]args){
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int D = sc.nextInt();
      if(A >C){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   }
}
      

Measured memory_bytes: 23764
n,a,b = map(int,input().split())

answer = 0
if (b-a) % 2 == 0:
    answer = (b - a)//2
else:
    chousei = min(a-1,n-b)+1
    if a-1 < n-b:
        a = 1
        b -= chousei
        answer = (b - a)//2
        answer += chousei
    else:
        a += chousei
        b = n
        answer = (b - a)//2
        answer += chousei

print(answer)

Measured memory_bytes: 3064
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

#define ll long long
#define MAX_VALUE (50)

using namespace std;

// set_kに含まれている値でのみ割れるときの有向グラフを構築する
int** construct_g(vector<int> set_k) {
	int** g = new int* [MAX_VALUE + 1];
	for (int i = 0; i <= MAX_VALUE; ++i) {
		g[i] = new int[MAX_VALUE + 1];
		for (int j = 0; j <= MAX_VALUE; ++j)
			g[i][j] = 0;
	}
	for (int k : set_k)
		for (int i = 0; i <= MAX_VALUE; ++i)
			g[i][i % k] = 1;
	return g;
}

// 与えられたグラフgについて、i->jが到達可能か、を調べる
int** WF(int** g) {
	int** res = new int* [MAX_VALUE + 1];
	for (int i = 0; i <= MAX_VALUE; ++i) {
		res[i] = new int[MAX_VALUE + 1];
		for (int j = 0; j <= MAX_VALUE; ++j)
			res[i][j] = g[i][j];
		res[i][i] = 1;
	}
	for (int k = 0; k <= MAX_VALUE; ++k)
		for (int i = 0; i <= MAX_VALUE; ++i)
			for (int j = 0; j <= MAX_VALUE; ++j)
				if (res[i][k] && res[k][j])
					res[i][j] = 1;
	return res;
}

signed main() {
	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	// -1判定を行う
	for (int i = 0; i < n; ++i) {
		if (a[i] == b[i]) continue;
		if ((a[i] - 1) / 2 < b[i]) {
			cout << -1 << endl; exit(0);
		}
	}
	// 解く
	vector<int> need;
	for (int kmax = 48; kmax >= 0; --kmax) {
		vector<int> kset;
		for (int k = 1; k <= kmax; ++k) kset.push_back(k);
		for (int k : need) kset.push_back(k);
		int** g = WF(construct_g(kset));
		bool ok = true;
		for (int i = 0; i < n; ++i)
			ok &= g[a[i]][b[i]];
		if (!ok) need.push_back(kmax + 1);
	}
	ll ans = 0;
	for (int s : need) ans += (1LL << s);
	cout << ans << endl;
	return 0;
}

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

const int INF = 1e8;
const int MAX_N = 1e6;

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

    vector<int> sum(201, 0);
    for (int i = 1; i <= 200; ++i) {
        sum.at(i) = i * (i + 1) * (i + 2) / 6;
    }

    vector<vector<int> > dp(2, vector<int>(MAX_N, INF));
    dp.at(0).at(0) = 0;
    dp.at(1).at(0) = 0;
    dp.at(0).at(1) = 1;
    dp.at(1).at(1) = 1;
    for (int i = 0; i < MAX_N; ++i) {
        for (auto &x : sum) {
            if (i + x >= MAX_N) break;
            dp.at(0).at(i + x) = min(dp.at(0).at(i + x), dp.at(0).at(i) + 1);
            if (x % 2 == 0) continue;
            dp.at(1).at(i + x) = min(dp.at(1).at(i + x), dp.at(1).at(i) + 1);
        }
    }

    while (true) {
        int N;
        cin >> N;
        if (N == 0) break;
        cout << dp.at(0).at(N) << ' ' << dp.at(1).at(N) << endl;
    }

    return 0;
}


Measured memory_bytes: 14376
while(True):
    m, f, r = map(int, input().split())
    if(m == f == r == -1): break
    score = m + f

    if(m==-1 or f==-1): print('F')
    elif(score >= 80): print('A')
    elif(score >= 65): print('B')
    elif(score >= 50): print('C')
    elif(score >= 30):
        if(r >= 50): print('C')
        else: print('D')
    else: print('F')

Measured memory_bytes: 7652
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

string s;

int chk(int l, int r)
{
	for (; l <= r; ++l, --r)
		if (s[l] != s[r]) return 0;
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> s;
	if (!chk(0, s.length() - 1)) { cout << "No"; return 0; }
	if (!chk(0, (s.length() - 1 / 2) - 1)) { cout << "No"; return 0; }
	if (!chk((s.length() + 3) / 2 - 1, s.length() - 1)) { cout << "No"; return 0; }
	cout << "Yes";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
	double x1,y1,x2,y2,x,y;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	x=x2-x1;
	y=y2-y1;
	

	printf("%f",sqrt(x*x+y*y));
	return 0;
}



Measured memory_bytes: 2048
import sys
import bisect
iuput=sys.stdin.readline
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
s=bisect.bisect_left(A,0,lo=0,hi=len(A))
t=bisect.bisect_right(A,0,lo=0,hi=len(A))
An=A[0:s]
Ap=A[t:n]
if k<=s*(n-t):
  #二分探査
  ng=-10**19
  ok=1
  while ok-ng!=1:
    #積がmid以下になる組み合わせの数をカウント
    mid=(ok+ng)//2
    c=0
    j=0
    for i in range(s):
      if j<n-t:
        while An[i]*Ap[j]>mid:
          j=j+1
          if j==n-t:
            break
      if An[i]*Ap[-1]>mid:
        j=n-t
      c=c+(n-t-j)
    if c<k:
      ng=mid
    else:
      ok=mid
  print(ok)
elif k<=n*(n-1)//2-((n-t)*(n-t-1)//2)-s*(s-1)//2:
  print(0)
else:
  k=n*(n-1)//2-k+1#大きい順にk番目
  Ann=[0]*s
  for i in range(s):
    Ann[i]=An[i]*-1
  Ann=Ann[::-1]
  App=[0]*(n-t)
  for i in range(n-t):
    App[i]=Ap[i]*-1
  App=App[::-1]
  ng=-10**19
  ok=1
  while ok-ng!=1:
    #積がmid以下になる組み合わせの数をカウント
    mid=(ok+ng)//2
    c=0
    j=0
    for i in range(s):
      if j<s:
        while An[i]*Ann[j]>mid:
          j=j+1
          if j==s:
            break
      if An[i]*Ann[-1]>mid:
        j=s
      c=c+(s-j)
    cc=0
    for i in range(s):
      if An[i]*A[i]*-1<=mid:
        cc=cc+1
    j=0
    for i in range(n-t):
      if j<n-t:
        while App[i]*Ap[j]>mid:
          j=j+1
          if j==n-t:
            break
      if App[i]*Ap[-1]>mid:
        j=n-t
      c=c+(n-t-j)
    for i in range(n-t):
      if Ap[i]*Ap[i]*-1<=mid:
        cc=cc+1
    c=(c-cc)//2
    if c<k:
      ng=mid
    else:
      ok=mid
  print(-1*ok)

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF 2000000000
#define int long long
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
int a[100000];

int partition(int p,int r){
	int x=a[r];
	int i=p-1;
	lps(j,p,r){
		if(a[j]<=x){
			i++;
			swap(a[i],a[j]);
		}
	}
	swap(a[i+1],a[r]);
return i+1;
}

signed main(){
	int n;
	cin>>n;
	lp(i,n) cin>>a[i];
	int p=partition(0,n-1);
	lp(i,n){
		if(i) cout<<" ";
		if(i==p) cout<<"["<<a[i]<<"]";
		else cout<<a[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
#include<string.h>
int main()
{
    int x,y,i,j,sum,t,min,max;
    scanf("%d%d",&x,&y);
    y = y+1;
    char lon[x][y],to[y];
    for(i=0;i<x;i++)
    {
        scanf("%s", lon[i]);
    }
    for(i=0;i<x;i++)
    {
        for(j=i+1;j<x;j++)
        {
            if(strcmp(lon[i],lon[j])>0)
            {
                strcpy(to,lon[i]);
                strcpy(lon[i],lon[j]);
                strcpy(lon[j],to);
            }
        }
    }
    for(i=0;i<x;i++)
    {
        printf("%s",lon[i]);
    }
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300 + 10;
typedef long long ll;
const ll mod = 998244353;
int tot, K;
char s[maxn];
int a[maxn];
ll f[maxn][maxn][maxn];
ll ans;
inline ll norm(const ll & x) { return x >= mod ? x - mod : x;}
int main()
{
	scanf("%s%d", s + 1, &K);
	K = min(K, 300);
	int len = strlen(s + 1);
	reverse(s + 1, s + len + 1); 
	int cur = 0;
	for(int i = 1; i <= len; ++i)
		if(s[i] == '0')
		{
			a[++tot] = cur;
			cur = 0;
		}
		else
			++cur;
	a[++tot] = cur;
	f[0][0][0] = 1;
	for(int i = 1; i <= tot; ++i)
		for(int k = 0; k <= K; ++k)
		{
			for(int j = k; ~j; --j)
				f[i][j][k] = norm(f[i - 1][j][k] + f[i][j + 1][k]);
			for(int j = 0; j <= k; ++j)
			{
				/*
				for(int jd = j; jd <= k; ++jd)
					f[i][j][k] = (f[i][j][k] + f[i - 1][jd][k]) % mod;
				*/
				int lim = min(j, a[i]);
				for(int jd = 1; jd <= lim; ++jd)
					f[i][j][k] = norm(f[i][j][k] + f[i - 1][j - jd][k - jd]);
			}
		}
	for(int k = 0; k <= K; ++k)
		ans = norm(ans + f[tot][0][k]);
	cout << ans << endl;
	return 0;
}
	

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

typedef long long LL;
const int N=3e5+10;
LL n,m,w;
int r[N];
int c[N];
int qr[N],qc[N];
int r_max,c_max;
int main(){
    scanf("%lld%lld%lld",&n,&m,&w);
    for(LL i=0;i<w;++i){
        int a,b;
        scanf("%d%d",&a,&b);
        r[a]++;
        c[b]++;
        r_max=max(r_max,r[a]);
        c_max=max(c_max,c[b]);
        qr[i]=a;
        qc[i]=b;
    }
    LL R=0,C=0;
    for(int i=1;i<=n;++i){
        if(r_max==r[i]) R++;
    }
    for(int i=1;i<=m;++i){
        if(c_max==c[i]) C++;
    }
    LL cnt=0;
    for(LL i=0;i<w;++i){
        int a,b;
        a=qr[i];
        b=qc[i];
        if(r[a]==r_max&&c[b]==c_max) cnt++;
    }
    LL t=R*C;
    LL res=r_max+c_max;
    if(t==cnt) res--;
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n , -1), rank(n, 0) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 0); }

    int root(int x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]); //ここで経路圧縮
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind tree(2 * N);
    vi p(N);
    rep(i, N) {
        cin >> p[i];
        tree.unite(p[i] - 1, i + N);
    }
    rep(j, M) {
        int x, y; cin >> x >> y;
        x--; y--;
        tree.unite(x + N, y + N);
    }

    int ans = 0;
    rep(i, N) {
        if (tree.same(i , i + N)) ans ++;
    }

    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    list<int> l;
    string op;
    for(int i=0; i<n; ++i) {
        cin >> op;
        if(op == "deleteFirst") {
            l.pop_front();
        } else if(op == "deleteLast") {
            l.pop_back();
        } else {
            int x;
            cin >> x;
            if(op == "insert") {
                l.push_front(x);
            } else {
                for(auto it = l.begin(); it != l.end(); ++it) {
                    if(*it == x) {
                        l.erase(it);
                        break;
                    }
                }
            }
        }
    }
    for(auto it = l.begin(); it != l.end(); ++it) {
        if(it != l.begin()) {
            cout << ' ';
        }
        cout << *it;
    }
    cout << endl;
}


Measured memory_bytes: 34252
#include<bits/stdc++.h>
using namespace std;
int i,j,n,ans;
int a[60],b[60];
map<int,map<int,int> >m;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(i!=j)
				m[a[i]-a[j]][b[i]-b[j]]++,ans=max(ans,m[a[i]-a[j]][b[i]-b[j]]);
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 640
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;

char buf[100000+10];
int n, k, r, s, p;

const char *hands = "rsp";

inline ll calc(char cpu, char man) {
  if(cpu == 'r' && man == 'p') return p;
  if(cpu == 's' && man == 'r') return r;
  if(cpu == 'p' && man == 's') return s;
  return 0;
}

ll memo[200000+5][5];
ll go(int pos, int last) {
  ll &res = memo[pos][last];
  if(res < 0) {
    if(pos >= n) {
      res = 0;
    } else {
      res = 0;
      REP(i, 3) {
        if(last == i) {
          continue;
        }
        ll cur = calc(buf[pos], hands[i]);
        ll tmp = cur + go(pos + k, i);
        res = max(res, cur + tmp);
      }
    }
  }
  return res;
}

int main(void) {
  cin >> n >> k >> r >> s >> p >> buf;
  ll res = 0;
  memset(memo, -1, sizeof memo);
  REP(i, k) {
    ll maxi = -1;
    REP(j, 3) {
      ll tmp = go(i, j);
      maxi = max(tmp, maxi);
    }
    res += maxi;
  }
  cout << res/2 << endl;
  return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n;
int h[20],zx[20],yx[20],l[20];
int dt[10][10];
int f=0;
void dfs(int p){
    if(f) return;
    if(p==8){
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(dt[i][j]) cout<<"Q";
                else cout<<'.';
            }
            cout<<"\n";
        }
        f=1;
        return;
    }
    if(h[p]){
        dfs(p+1);
        return;
    }
    for(int i=0;i<8;i++){
        if(!l[i]&&!zx[p+i]&&!yx[p-i+7]){
            dt[p][i]=1;
            l[i]=1;
            zx[p+i]=1;
            yx[p-i+7]=1;
            dfs(p+1);
            dt[p][i]=0;
            l[i]=0;
            zx[p+i]=0;
            yx[p-i+7]=0;
        }
    }
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        h[a]=1;
        l[b]=1;
        yx[a-b+7]=1;
        zx[a+b]=1;
        dt[a][b]=1;
    }
    dfs(0);
    return 0;
}

Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        int m = Integer.valueOf(arr01[0]);
        int d = Integer.valueOf(arr01[1]);

        //        System.out.println(m + " " + d + " " + d1 + " " + d2);

        int cnt = 0;

        for (int i = 1; i <= m; i++) {
            for (int j = 22; j <= d; j++) {

                int d1 = Integer.valueOf(String.valueOf(j).substring(0, 1));
                int d2 = Integer.valueOf(String.valueOf(j).substring(1, 2));

                if (i == d1 * d2 && d2 > 1) {

//                    System.out.println(i + " " + j + " " + d1 + " " + d2);
                    cnt += 1;
                }
            }
        }

        System.out.println(cnt);

    }

}


Measured memory_bytes: 21844
/**
  @file b.cpp
  @title B - Tap Dance
  @url https://atcoder.jp/contests/abc141/tasks/abc141_b
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  string S;
  cin >> S;
  int N = (int)S.size();

  bool flag = true;
  for (int i = 1; i <= N; i++) {
    if (i % 2 == 0 && S[i - 1] == 'R') {
      flag = false;
    } else if (i % 2 != 0 && S[i - 1] == 'L') {
      flag = false;
    }
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,s=0;
	cin>>n;
	for(int i=1; i <= n; i++)
		if(i % 3 != 0 && i % 5 !=0)
			s+=i;
		cout<<s;
	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int n,m,ans[100005];
vector<int>g[100005];
#define INF 0x3f3f3f3f
struct mzls
{
	int a,b;
	bool operator < (const mzls &x) const
	{
		return x.a<a;
	}
}as;
priority_queue<mzls>que;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		ans[i]=INF;
	}
	ans[n]=INF;
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&as.b,&as.a);
		que.push(as);
		ans[as.b]=as.a;
	}
	while(!que.empty())
	{
		as=que.top();
		que.pop();
		int u=as.b;
		for(int i=0;i<g[u].size();i++)
		{
			int v=g[u][i];
			if(ans[v]==INF)
			{
				ans[v]=ans[u]+1;
				as.b=v,as.a=ans[v];
				que.push(as);
			}
			if(!((ans[v]-ans[u])==1||(ans[v]-ans[u])==-1))
			{
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes\n");
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
}//


Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    if (k == 0) ans = n*n;
    else FOR(i,k+1,n+1) {
            if (n/i*i+k<=n) {
                //cerr << n/i*i+k << endl;
                ans += n/i * (i-k) + (n-n/i*i-k+1);
            } else {
                ans += n/i * (i-k);
            }
            //cerr << ans << endl;
        }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

h,w,k = map(int,input().split())
mat = [input() for i in range(h)]
r = [0 for i in range(h)]
c = [0 for i in range(w)]
black = 0
for i in range(h):
    for j in range(w):
        if mat[i][j]=="#":
            r[i] += 1
            c[j] += 1
            black += 1

ans = 0
for i in range(h):
    for combr in combinations(range(h),i):
        for j in range(w):
            for combc in combinations(range(w),j):
                temp = 0
                for x in combr:
                    temp += r[x]
                for y in combc:
                    temp += c[y]
                overlap = 0
                for x in combr:
                    for y in combc:
                        if mat[x][y]=="#":
                            overlap += 1
                if black+overlap-temp==k:
                    ans += 1

print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
	vector<vector<LL>> v(3, vector<LL>(3));

	REP(i, 3) {
		REP(j, 3) {
			cin >> v[i][j];
		}
	}

	REP(i, 3) {
		while(true){
			if (v[i][0] >= 1 &&
				v[i][1] >= 1 &&
				v[i][2] >= 1) {
				v[i][0]--;
				v[i][1]--;
				v[i][2]--;
			}
			else {
				break;
			}
		}
	}
	REP(i, 3) {
		while (true) {
			if (v[0][i] >= 1 &&
				v[1][i] >= 1 &&
				v[2][i] >= 1) {
				v[0][i]--;
				v[1][i]--;
				v[2][i]--;
			}
			else {
				break;
			}
		}
	}

	bool  flag = true;
	REP(i, 3) {
		REP(j, 3) {
			if (v[i][j]!=0) {
				flag = false;
			}
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define int long long
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
void foo(){
    int a, b;
    cin>>a>>b;
    string x = to_string(a)+to_string(b);
    int ans = 0;
    for(int i = 0; i < x.size(); i++){
        ans=ans*10+x[i]-'0';
    }
    if((int)sqrt(ans)==sqrt(ans))cout<<"Yes\n";
    else cout<<"No\n";   
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

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

int main(){
  int N;
  cin >> N;
  vector<string> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
    sort(v[i].begin(),v[i].end());
  }
  sort(v.begin(),v.end());
  long long count=1;
  long long sum=0;
  for (int i=1;i<N;i++){
    if (v[i-1]==v[i]){
      count++;
    }
    else {
      sum+=count*(count-1)/2;
      count=1;
    }
    if (i==N-1){
      sum+=count*(count-1)/2;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;cin>>n;
    int res = 0;
    bool pls = false;
    for(int i=n.size()-1;i>=0;i--) {
        int now = n[i] - '0';
        if (pls) now++;
        if (now>5) {
            res += 10-now;
            pls = true;
        }
        else if (now==5&&i>0 && n[i-1]-'0'>=5) {
            res += 5;
            pls = true;
        }
        else {
            res += now;
            pls = false;
        }
    }
    if (pls) res++;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1948
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long int w;
	cin>>w;
	vector<long long int > arr(1000*100+1,INT_MAX);
	arr[0]=0;
	
	for(int i=0;i<n;i++){
		long long int temp,v;
		cin>>temp>>v;
		for(int j=1000*100;j>=0;j--){
			if(j>=v){arr[j]=min(arr[j],arr[j-v]+temp);}
			else{break;}
			}
		
		
		//long long int maxi=INT_MIN;
		//for(int i=0;i<w+1;i++){
			//cout<<arr[i]<<endl;
			//maxi=max(maxi,arr[i]);
			}
		for(int i=1000*100;i>=0;i--){
			if(arr[i]<=w){cout<<i<<endl;break;}
			}
		//cout<<maxi<<endl;
	
	}


Measured memory_bytes: 1024
'use strict'
const main = (input: string) => {
    const std: string[] = input.split(' ')
    const a: number = ~~std.shift()
    const b: number = ~~std.shift()
    if (a === b) {
        console.log(Array(b).fill(a).join(''))
        return
    }
    const as = Array(a).fill(b).join('')
    const bs = Array(b).fill(a).join('')
    console.log(as < bs ? as : bs)    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
# Selection Sort
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    min_idx = i
    # i番目以降での最小を探す
    for j in range(i, N):
        if A[j] < A[min_idx]:
            min_idx = j

    if i != min_idx:
        A[i], A[min_idx] = A[min_idx], A[i]
        cnt += 1

print(*A)
print(cnt)



Measured memory_bytes: 5608
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	final static PrintStream so = System.out;
	final static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String str = sc.next();
		boolean n = str.contains("N");
		boolean s = str.contains("S");
		boolean e = str.contains("E");
		boolean w = str.contains("W");
		
		so.println(n^s || e^w ? "No" : "Yes");
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<int>V(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
	}
	while (true) {
		sort(V.begin(), V.end());
		V.erase(remove(V.begin(), V.end(), 0),V.end());
		for (int i = 1; i < V.size(); ++i) {
			if (V[0] == 1) {
				V[i] = 0;
			}
			else {
				V[i] = V[i] % V[0];
			}
		}
		if (V.size() == 1)break;
	}
	cout << V[0] << endl;
	return 0;
}


Measured memory_bytes: 640