akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
const int mod = 1e9+7;
int n,d;
string s;
vector<vvi> dp;
int DigitSum(int pos=0,int sum=0,bool smaller_already=false){
    if(pos == n) return !sum;
    if(dp[pos][sum][smaller_already] != -1) return dp[pos][sum][smaller_already];
    int MaxDigit = smaller_already ? 9 : (s[pos]-'0');
    int cnt = 0;
    for(int i=0;i<=MaxDigit;++i)
        cnt = (cnt + DigitSum(pos+1,(sum+i)%d,smaller_already || (i < (s[pos]-'0'))))%mod;

    return dp[pos][sum][smaller_already] = cnt;
}
int main(){
    cin >> s;
    sci(d);
    n = s.length();
    dp.resize(n,vvi(d,vi(2,-1)));
    cout << (DigitSum() - 1 + mod)%mod<< endl;
}

Measured memory_bytes: 59312
N = int(input())
X = [None]*N
for k in range(N):
	X[k] = tuple(map(int,input().split()))
X.sort(key=lambda q: q[1])
time = 0
late = 0
for x in X:
	time += x[0]
	if time > x[1]:
		late = 1
		break
if late == 1:
	print("No")
else:
	print("Yes")

Measured memory_bytes: 31888
#include <iostream>
#include <vector>
#include <string>

using namespace std;
const int INFTY = 1001001001;

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i=0;i<N;++i){
        cin >> X[i];
    }
    int ans = INFTY, sum;
    for(int i=1;i<100;++i){
        sum = 0;
        for(int j=0;j<N;++j){
            sum += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int min(int a,int b)
{
	return a<b?a:b;
}
int main()
{
	int n,x,y;
	cin>>n>>x>>y;
	cout<<min(n*x,y);
	return 0;
}

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

int main()
{
    int n, m, a, b, cnt = 0;
    
    cin >> n >> m >> a >> b;

    int c[n];
    for( int i = 0; i < n; i++ )
        cin >> c[i];

    bool t[n];
    for( int i = 0; i < n; i++ )
        t[i] = 0;

    for( int i = 0; i < n; i++ )
    {
        if( c[i] >= a )
        {
            t[i] = 1;
            cnt++;
        }
        else
            break;
    }

    if( m <= n - cnt )
        cout << cnt << endl;
    else
    {
        for( int i = n - 1; i >= 0; i-- )
        {
            if( t[i] && c[i] <= b )
            {
                t[i] = 0;
                cnt--;
            }
            else if( t[i] && c[i] > b )
                break;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    char[] cs;

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

    void run() {
        FastReader sc = new FastReader();
        cs = sc.next().toCharArray();
        solve();
    }

    void solve() {
        boolean[] used = new boolean[26];
        for (int i = 0; i < cs.length; i++) {
            used[cs[i] - 'a'] = true;
        }
        for (int i = 0; i < used.length; i++) {
            if (!used[i]) {
                System.out.println((char)('a' + i));
                return;
            }
            if (i == used.length - 1) {
                System.out.println("None");
            }
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23252
// Problem : D - Wide Flip
// Contest : AtCoder - AtCoder Regular Contest 088
// URL : https://atcoder.jp/contests/arc088/tasks/arc088_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
string s;
bool check(int k)
{
	bool z=true,o=true;
	loop(i,sz(s))
	{
		if(i+k<sz(s)||i-k>=0)
		continue;
		z&=s[i]=='0';
		o&=s[i]=='1';
	}
	return z||o;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	cin>>s;
	int n=sz(s);
	int l=0,r=n;
	int ans=-1;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))
		{
			ckmax(ans,mid);
			l=mid+1;
			}
		else
		r=mid-1;
	}
	cout<<ans<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

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

  vector<vector<int>> res(h, vector<int>(w));
  int x = 0, y = 0;
  rep(i, n) rep(j, a[i]) {
    res[x][y] = i+1;
    if (x % 2 == 0) {
      if (y == w-1) ++x;
      else ++y;
    } else {
      if (y == 0) ++x;
      else --y;
    }
  }
  rep(i, h) {
    rep(j, w-1) printf("%d ", res[i][j]);
    printf("%d\n", res[i][w-1]);
  }
  return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 2e5 + 5;

ll n, a[nax];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n, greater<ll>());
	if(n == 2){
		cout << a[1] << '\n';
	}
	else if(n == 3){
		cout << a[1] + a[2] << '\n';
	}
	else{
		ll ans = a[1];
		ll cnt = 2;
		for(ll i = 2; i <= n; i++){
			if(cnt == n){
				break;
			}
			else if(cnt + 2 <= n){
				ans += a[i] * 2;
				cnt += 2;
			}
			else if(cnt + 1 <= n){
				ans += a[i];
				cnt++;
			}
		}
		cout << ans << '\n';
	}
}



Measured memory_bytes: 5204
#include <string.h>
#include <stdio.h>

int main()
{   int n;
    scanf("%d",&n);
    char s[51][51];
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }
   
    int a[51][51]={0};
    for(int i=0;i<n;i++){
        for(int j=0;j<strlen(s[i]);j++){
            a[i][s[i][j]-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        int tmp=51;
        for(int j=0;j<n;j++){
            if(tmp>a[j][i]){
                tmp=a[j][i];
            }
        }
        a[50][i]=tmp;
    } 
    /*for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            printf("%d",a[i][j]);
    }
    printf("\n");
    }
    */
    for(int i=0;i<26;i++){
        int cnt=0;
        while(a[50][i]>cnt){
            printf("%c",'a'+i);
            cnt++;
        }
    }
    

    return 0;
}


Measured memory_bytes: 128
import sys
 
if __name__ == '__main__':
  args = input().split()
  ret="No"
  if ((args[0] == args[1] or args[0] == args[2] or args[1] == args[2]) and (args[0] != args[1] or args[1] != args[2])):
    ret="Yes"
    
  print(ret)

Measured memory_bytes: 3060
import scala.annotation.tailrec
import scala.io.StdIn

object Main extends App {

  @tailrec
  def rec(acc:Long, num:Long):Long = {
    if(num == 0L) acc
    else rec(acc+1L, num/10L)
  }

  val n =StdIn.readLong
  val r = math.sqrt(n).toLong
  val ans = (2L to r)./:(rec(0, n))((acc,i) => {
    if(n % i == 0L) math.min(acc, rec(0, n/i))
    else acc
  })
  println(ans)
}

Measured memory_bytes: 31588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

const int MAXN = 1e5 + 1;
ll N, M, V, P;
ll A[MAXN];

bool chk(ll idx) {
    ll add = max(0LL, V - 1 - idx - (P - 1));
    // idx + 1 ~ N - P
    ll sum = 0;
    for(int i = idx + 1; i <= N - P; ++i) {
        if(A[idx] + M < A[i]) return false;
        sum += A[idx] + M - A[i];
    }
    return sum >= add * M;
}

int main() {
    FAST_IO();
    cin >> N >> M >> V >> P;
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    ll ans = -1;
    ll lo = 0, hi = N - 1;
    while(lo <= hi) {
        ll mid = (lo + hi) >> 1;
        if(chk(mid)) {
            ans = mid;
            hi = mid - 1;
        } else lo = mid + 1;
    }
    cout << N - ans << endl;
}

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

int main() {
  int A, B, ans;
  string op;
  cin >> A >> op >> B;

  if (op == "+") {
    ans = A + B;
  } else {
    ans = A - B;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	int c=sc.nextInt();
	if(a<b && b<c){
	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}
    
    }
}



Measured memory_bytes: 26348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  vector<long long>A(N);
  vector<long long>B(N);
  B.at(0) = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (i != 0){
      if (A.at(i) > A.at(i-1)){
        B.at(i) = 1;
      }
      else if (A.at(i) < A.at(i-1)){
        B.at(i) = -1;
      }
      else {
        B.at(i) = 0;
      }
    }
  }
  
  long long money = 1000;
  long long kabu = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0){
      if (B.at(i+1) > B.at(i)){
        kabu += money / A.at(i);
        money = money % A.at(i);
      }
    }
    else if (i != N-1){
      if (B.at(i-1) <= B.at(i) && B.at(i) > B.at(i+1)){
        money += kabu * A.at(i);
        kabu = 0;
      }
      else if (B.at(i-1) >= B.at(i) && B.at(i) < B.at(i+1)){
        kabu += money / A.at(i);
        money = money % A.at(i);
      }
    }
    else {
      money += kabu * A.at(i);
      kabu = 0;
    }   
  }
  long long C = 1000;
  cout << money << endl;
}
      
        
      




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

int main()
{
	ll x,a=0,b=0;
	cin>>x;
	if(500<=x)
       {
            a=x/500;
            x=x-(a*500);
       }
       if(x>=5)
       {
           b=x/5;
       }
       cout<<a*1000+b*5<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,c;
    Scd(a);

    printf ( a>1 && 105%a==0 ? "YES\n" : "NO\n");

    return 0;
}



Measured memory_bytes: 256
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();
	      String ans = "Odd";
	      if(a*b%2 == 0) {
	    	  ans = "Even";
	      }
	      System.out.println(ans);
	}
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
template<typename T>
struct BIT{
    private:
    vector<T> array;
    const int n;

    public:
    BIT(int _n):array(_n+1,0),n(_n) {}

    T sum(int i){
        T s=0;
        while(i>0){
            s+=array[i];
            i-=i&-i;
        }
        return s;
    }
    
    T sum(int i,int j){
        return sum(j)-sum(i-1);
    }

    void add(int i,T x){
        while(i<=n){
            array[i]+=x;
            i+=i&-i;
        }
    }
    void pr(int i){
        cout << array[i] << endl;
    }
};
int main(){
    int n,q;cin >> n >> q;
    int c,x,y;
    BIT<int> bit(n);
    while(q--){
        cin >> c >> x >> y;
        if(!c){
            bit.add(x,y);
        }
        else{
            cout << bit.sum(x,y) << endl;
        }
    }
}


Measured memory_bytes: 3120
import copy

n, x, m = map(int,input().split())

visited = [-1]*(m+1)
when = [-1]*(m+1)
ans = 0
i = 1
while i <= n:
    ans += x
    if x == 0:
        break
    if visited[x] > -1:
        cycle = (n - i) // (i - when[x])
        ans += cycle*(ans - visited[x])
        i += cycle*(i - when[x]) + 1
        visited = [-1]*(m+1)
        when = [-1]*(m+1)
        x **= 2
        x %= m    
        continue
    visited[x] = copy.deepcopy(ans)
    when[x] = copy.deepcopy(i)
    x **= 2
    x %= m
    i += 1


print(ans)

Measured memory_bytes: 72176
process.stdin.resume();
process.stdin.setEncoding('utf8');

const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

reader.on('line', s => {
  const RLs = `L${s}R`.split('LR').map(RL => `R${RL}L`).slice(1, -1);

  const numbers = RLs.map(RL => {
    const n  = RL.length;
    const nR = RL.match(/(R+)/).pop().length;
    const pR = nR % 2;
    const nL = n - nR;
    const pL = nL % 2;

    const result = [ ...new Array(n) ].map(_ => 0);

    switch (pR + pL) {
      case 0:
      case 2: {
        result[nR - 1] = result[nR] = n / 2;

        break; 
      }

      case 1: {
        result[nR - 1] = Math.floor(n / 2) + pR;
        result[nR]     = Math.floor(n / 2) + pL;

        break;
      }
    }

    return result;
  }).flatMap(xs => xs).join(' ');

  console.log(numbers);

  process.exit(0);
});


Measured memory_bytes: 52504
#!/usr/bin/env python3
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


y = make_divisors(int(input()))

if len(y) % 2 > 0:
    print(y[len(y) // 2] * 2 - 2)
else:
    print(y[len(y) // 2 - 1] + y[len(y) // 2] - 2)


Measured memory_bytes: 63756
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int sum = x;
    rep(i, n) {
        sum += (d - 1) / a[i] + 1;
    }
    put(sum)
    
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100000;

ll N,K,a[MAX_N+1];


int main(){
  cin>>N>>K;
  for(ll i=0;i<N;i++){
    cin>>a[i];
  }
  ll i=0,ans=0;
  while(N>0){
    if(i==0){
      N-=K;
      ans++;
    }
    else{
      N-=(K-1);
      ans++;
    }
    i++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOr(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FOrr(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////
const int N = 1e5+2;
int dp[N+1];
int a[N+1];
/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n;cin >> n;
	For(i,n)cin >> a[i];
	For(i,n)dp[i]=INF;
	dp[0]=0;
	FOr(i,0,n){
		for(int steps : {1,2}){
			dp[i+steps] = min(dp[i+steps],abs(a[i]-a[i+steps])+dp[i]);
		}
		//deb(i,dp[i]);
	}
	cout << dp[n-1] <<"\n";
}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=998244353;
const ll INF=9e18;
const long double PI = acos(-1.0);
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll dp[220000];

int main(){cout<<fixed<<setprecision(20);
		   ll n,k;
           cin>>n>>k;
           vll l(k),r(k);
           rep(i,0,k)cin>>l[i]>>r[i];
           //dp,imos
           dp[1]=1;
           dp[2]=-1;
           rep(i,1,n+1){
             dp[i]=(dp[i]+dp[i-1])%inf;
             rep(j,0,k){
              if(i+l[j]<n+2)dp[i+l[j]]=(dp[i+l[j]]+dp[i])%inf;
              if(i+r[j]+1<n+2)dp[i+r[j]+1]=(dp[i+r[j]+1]-dp[i])%inf;
             }
           }
           if(dp[n]<0)dp[n]+=inf;
           cout<<dp[n]<<endl;
}

Measured memory_bytes: 5172
#include<stdio.h>
#define N 100
int bubbleSort(int [],int);
int main(){
  int n=0,i,x[N],cnt=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  cnt=bubbleSort(x,n);

  printf("%d\n",cnt);
  
  return 0;
}

int bubbleSort(int a[],int b){
  int i,j,tmp;
  int on=1;
  int count=0;
  
  for(i=0;on;i++){
    on=0;
    for(j=b-1;j>0;j--){
      if(a[j]<a[j-1]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	on=1;
	count++;
      }
    }
  }
  printf("%d",a[0]);
  for(i=1;i<b;i++){
    printf(" %d",a[i]);
  }
  printf("\n");
  
  return count;
}

  
  
  



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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

int sum[100005];

void Main() {
    int n, q;
    string s;
    cin >> n >> q >> s;

    int cnt = 0;
    rep(i, s.length()) {
        sum[i] = cnt;
        if (i == 0)continue;
        if (s[i - 1] == 'A' && s[i] == 'C') {
            ++sum[i]; ++cnt;
        }
    }

    vint ans(q, 0);
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        --l; --r;
        if (l == 0)ans[i] = sum[r];
        else {
            ans[i] = sum[r] - sum[l];
        }
    }

    rep(i, q) {
        cout << ans[i] << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1872
/*JOI君は最低C枚のコインを得たい.
→1日でA枚のコイン、7日でB枚追加.

i) B = 0の場合:
	日数に関係なく得たコインの枚数がC枚に到達するまでAを足し続ける.　→　足した回数を出力すればよい.

ii) B ≠ 0の場合:
	C枚に達するまでAを足し続けるが、足した回数が7の倍数になれば、追加でBを足す.　→　足した回数を出力.

まとめると:
	・枚数がCに達するまでAを足す.　…　いつCに達するか分からない.　→　while文を使うべき.
	・もし足した回数が7の倍数になれば、Bを足す.
	・これらを実行し、回数や得たコインの枚数は何かの変数に入れる. 　→　得たコインの枚数がCを超えれば、breakする.
*/
#include <iostream>
using namespace std;

int main() {
	//入力.
	long A, B, C; cin >> A >> B >> C;
	//得たコインの枚数と、回数を記録する変数を用意.
	//0で初期化する必要がある.
	int sum = 0, ans = 0;
	//ログイン.
	while (true) {
		sum += A;
		ans++;
		if (ans % 7 == 0) sum += B;
		if (C <= sum) break;
	}
	//出力.
	cout << ans << endl;
}


Measured memory_bytes: 3088
import java.util.Scanner;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String s[] = new String[H];
        char S[][] = new char[H][W];
        int white = 0;
        boolean check[][] = new boolean[H+2][W+2];
        for (int i = 0; i < H; i++) {
            s[i] = sc.next();
        }
        for (int i = 0; i < H; i++) {
            S[i] = s[i].toCharArray();
        }
        
        for (int i = 1; i <=H; i++) {
            for (int j = 1; j <=W; j++) {
                if (S[i-1][j-1] == '.') {
                    check[i][j] = true;
                    white++;
                }
            }
        }
        boolean dp[][]=new boolean[H+2][W+2];
        dp[1][1]=true;
        for(int t=1;t<H*W;t++){
            boolean next[][]=new boolean[H+2][W+2];
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                next[i][j]=check[i][j]&&(dp[i-1][j]||dp[i][j-1]||dp[i][j+1]||dp[i+1][j]);
            }
        }
        if(next[H][W]==true){
            System.out.println(white-t-1);
            return;
        }
        dp=next;
        }
        System.out.println("-1");

    }
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}
ll comb(int a, int b)
{
    if (a < b)
        return 0;
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

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

    ll n, a, b; cin >> n >> a >> b;
    cout << ((modpow(2, n) - comb(n, a) + mod) % mod - comb(n, b) + mod) % mod - 1 << endl;
    return 0;
}

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == s[j]) {
				puts("no");
				return 0;
			}
		}
	}
	puts("yes");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<Integer>();
        for(int i=0; i<n; i++) {
            int tmp = sc.nextInt();
            a.add(tmp);
        }
        //降順にソート
        Collections.sort(a, Collections.reverseOrder());
    
        long ans = a.get(0);
        int roop = n-2;
        int j = 1;
        for(int i=0; i<roop;i++) {
            ans += a.get(j);
            if(i % 2 == 1) j++;
        }
		System.out.println(ans);
	}
}

Measured memory_bytes: 64608
// AtCoder template
// 見た奴全員saba!
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

// 最大公約数を求める
// 計算量O(logn)
template<class T>
T gcd(T a, T b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

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

    int n; cin >> n;
    ll a[n]; rep(i,n) cin >> a[i];
    vector<ll> a_gcd_l(n+1), a_gcd_r(n+1);
    a_gcd_l[0] = 0; a_gcd_l[n] = 0;
    rep(i,n) a_gcd_l[i+1] = gcd(a_gcd_l[i],a[i]);
    rep(i,n) a_gcd_r[n-i-1] = gcd(a_gcd_r[n-i],a[n-i-1]);
    ll ans = 0LL;
    rep(i,n){
        ans = max(ans, gcd(a_gcd_l[i], a_gcd_r[i+1]));
    }
    cout << ans << endl;
}

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

/*

there is at most k hole in the seq

and we can build all seq with the number of holes <= k

we have 1 seq with 0 holes

for a seq with i holes
we need select i holes from seq : C(n,i)
we need find all seq for n-i elements which sum is n
and every element is positive
it is C(n-1,n-i-1)

*/

const int MO=1e9+7;
const int M=2e5+5;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}

int inv[M],fa[M],ifa[M];
void init()
{
	fa[0]=ifa[0]=1;
	inv[1]=fa[1]=ifa[1]=1;
    for(int i=2;i<M;i++)
    {
    	fa[i]=mul(fa[i-1],i);
    	inv[i]=mul(MO-MO/i,inv[MO%i]);
    	ifa[i]=mul(inv[i],ifa[i-1]);
    }
}

int C(int n,int m)
{
	return mul(mul(fa[n],ifa[m]),ifa[n-m]);
}

int main()
{
	init();
	int n,k; scanf("%d%d",&n,&k);
	if(k>n-1) k=n-1;
	int ans=1;
	for(int i=1;i<=k;i++)
	{
		addv(ans,mul(C(n,i),C(n-1,n-i-1)));
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
#define N 200200

long long v[N], w[N];
long long ans, prv;
int i, n;
int main()
{
    cin >> n;
    ++n;
    for (i = 0; i < n; ++i)
        cin >> v[i];
    for (i = 1; i < n; ++i)
        cin >> w[i - 1];
    prv = 0;
    --n;
    for (i = 0; i < n; ++i){
        if (prv > v[i]){
            ans += v[i];
            prv = 0;
            v[i] = 0;
        }
        else{
            ans += prv;
            v[i] -= prv;
            prv = 0;
        }
        if (w[i] > v[i]){
            ans += v[i];
            prv = w[i] - v[i];
        }
        else{
            ans += w[i];
            prv = 0;
        }
    }
    ans += min(prv, v[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 5132
# 二次元累積和
# 写経
# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1014_abc075

def solve():
    from collections import namedtuple
    from operator import attrgetter
    import sys

    input = sys.stdin.readline

    Coordinates = namedtuple('Coordinates', ('x', 'y'))

    n, k = map(int, input().split())

    e = []
    for _ in range(n):
        x, y = map(int, input().split())
        e.append(Coordinates(x=x, y=y))
    x_asc = tuple(sorted(e, key=attrgetter('x')))  # x昇順
    y_asc = tuple(sorted(e, key=attrgetter('y')))  # y昇順

    # print(x_asc)
    # print(y_asc)

    tbl = tuple([0] * (n + 1) for _ in range(n + 1))
    for yi, py in enumerate(y_asc, 1):
        for xi, px in enumerate(x_asc, 1):
            tbl[xi][yi] = tbl[xi - 1][yi] + tbl[xi][yi - 1] - tbl[xi - 1][yi - 1] + (1 if py == px else 0)

    ans = float('inf')

    for left in range(1, n - (k - 1) + 1):
        for top in range(1, n - (k - 1) + 1):
            for right in range(left + k - 1, n + 1):
                for bottom in range(top + k - 1, n + 1):
                    if tbl[right][bottom] - tbl[left - 1][bottom] - tbl[right][top - 1] + tbl[left - 1][top - 1] >= k:
                        ans = min(ans,
                                  (y_asc[bottom - 1].y - y_asc[top - 1].y) * (x_asc[right - 1].x - x_asc[left - 1].x))
    print(ans)


if __name__ == '__main__':
    solve()


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

int main() {
  char b;
  cin>>b;
  if (b == 'A') cout<<'T'<< endl;
  else if (b == 'C') cout<<'G'<<endl;
  else if (b == 'G') cout<<'C'<<endl;
  else cout<<'A'<<endl;
}

Measured memory_bytes: 256
<?php
list($r, $D, $x) = explode(" ", fgets(STDIN));
$count = 0;
echo_weight_algae($r, $D, $x, $count);
function echo_weight_algae($r, $D, $x, $count){
	if($count<10){
		$count += 1;
		$x_next = $r*$x-$D;
		echo $x_next;
		echo "\n";
		echo_weight_algae($r, $D, $x_next, $count);
	}
}

?>

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define test() int t; cin>> t; while (t--)
#define scan(a, i) for (int j = 0; j < i; j++) cin>> a[j];
#define print(a, i) for (int j = 0; j < i; j++) cout<< a[j]<< endl;
int main() 
{
    fastio()
    int a, b, c;
    cin>> a>> b>> c;
    int sum = 0;
    for (int i = 1; i <= a; i++)
    {
        int d = 0;
        int j = i;
        while (j)
        {
            d = d + j % 10;
            j /= 10;
        }
        if (d <= c && d >= b)
            sum += i;
    }
    cout<< sum<< endl;
    return 0;
}


Measured memory_bytes: 256
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	int fi = 0;
	for(int i = 2 ;i*i <= n;i++){
		int cnt = 0;
		while(n%i == 0){
			cnt++;
			n /= i;
		}
		int ans = 0;
		for(int j = 1 ;j <= 1000;j++){
			if(cnt >= (j*(j+1)/2)){
				ans = j;
			}else{
				break;
			}
		}
		fi += ans;
	}
	if(n > 1){
		fi++;
	}
	cout << fi;
}
//.........	

Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;   cin >> s;
    int i;
    bool f = true;
    for (i = 1; i < s.length(); i+=2) {
        if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))
            f = false;
    }
    for (i = 0; i < s.length(); i+=2) {
        if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'))
            f = false;
    }

    if (f == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 760
n=int(input())
ans=[]
for i in range(1,n+1,2):
    cnt=0
    for j in range(1,n+1):
        if i%j==0:
            cnt+=1
    ans.append(cnt)
sum=0
for v in ans:
    if v==8:
        sum+=1
print(sum)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, c;
	int k;

	cin >> a >> b >> c;
	cin >> k;

	int k_table[11] = { 1,2,4,8,16,32,64,128,256,512,1024 };

	int best = 0;

	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; i + j <= k; j++)
		{
			int l = k - i - j;

			int sum = k_table[i] * a + k_table[j] * b + k_table[l] * c;

			if (sum > best)
				best = sum;
		}
	}

	cout << best << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[n],c[m],d[m];
    REP(i,n)cin>>a[i]>>b[i];
    REP(i,m)cin>>c[i]>>d[i];
    REP(i,n){
        int mindis=INT_MAX;
        int ans;
        REP(j,m){    
            int tmp=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(tmp<mindis){
                ans=j;
                mindis=tmp;
            }
            
        }
        cout<<ans+1<<endl;
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;


main()
{
        string s,t; cin>>s>>t;
        sort(all(s));
        sort(all(t));
        reverse(all(t));
        if(s<t)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define tddd tuple<double,double,double>
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<int,pair<int,int> > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 200005
typedef long long int ll;
ll fact[N],inv[N],finv[N];
ll pro(ll a,ll b)
{
    return (a*b)%M;
}
void buildfact()
{
    int i,q,r;
    fill(fact,fact+N,1);
    fill(inv,inv+N,1);
    fill(finv,finv+N,1);
    for(i=2;i<N;i++)
    {
        fact[i]=pro(fact[i-1],i);
        q=M/i,r=M%i;
        inv[i]=M-pro(q,inv[r]);
        finv[i]=pro(finv[i-1],inv[i]);
    }
    return ;
}
ll dp[N];
ll ncr(int n,int r)
{
    ll x;
    x=pro(finv[r],finv[n-r]);
    return pro(x,fact[n]);
}
int main()
{
    int n,k,i,a,j;
    in2(n,k);
    vi v(n);
    read(v,i,n);
    dp[0]=1;
    rep(i,n)
    {
        a=v[i]+1;
        for(j=k-a;j>=0;j--)
            dp[j+a]-=dp[j],dp[j+a]+=M,dp[j+a]%=M;
    }
    buildfact();
    ll ans=0;
    rep(i,k+1)
        ans+=pro(ncr(n+k-i-1,k-i),dp[i]);
    ans%=M;
    outl(ans);
}

Measured memory_bytes: 5760
// 'That's all it is. A leap of faith'

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

template<typename Type>
long long sz(Type x) {
    return ll(x.size());
}

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, ans = 0; cin >> n;

    for(long long a = 1; a <= n; a++) {
        for(long long b = 1; b <= n / a; b++) {
            if(a * b < n) {
                ans++;
            }
        }
    }

    cout << ans;

    return 0;
}


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

l = [int(x) for x in input().split()]
if(n<=2):
    print(0)
else:
    
    d = {}
    ss = set();
    for i in l:
        if( i in d.keys()):
            d[i]+=1;
        else:
            d[i] =1
            ss.add(i)
    s = list(ss)
    len = len(s)
    count = 0
    for i in range(len):
        for j in range(i+1,len):
            for k in range(j+1,len):
                if(s[i] + s[j] >s[k] and s[i] + s[k] > s[j] and s[j] + s[k] > s[i]):
                    count = count + d[s[i]] * d[s[j]] * d[s[k]]
    print(count)

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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    string s,t;
    cin>>s>>t;
    ll d=__gcd(n,m),ans=n*m/d;
    m/=d;d=n/d;
    bool maki=true;
    for(int i=0,j=0;i<n;i+=d,j+=m){
    	if(s[i]!=t[j])maki=false;
    }
    cout << ((maki)?ans:-1) <<endl;
    return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
mod = 10**9 + 7

fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, M + 1):
  fact.append((fact[-1] * i) % mod)
  inv.append((-inv[mod % i] * (mod // i)) % mod)
  factinv.append((factinv[-1] * inv[-1]) % mod)

ans = 0
for k in range(N+1):
  if k%2 == 0:
    ans = (ans+factinv[N-k]*factinv[k]%mod*fact[M-k]%mod)%mod
  else:
    ans = (ans-factinv[N-k]*factinv[k]%mod*fact[M-k]%mod)%mod
ans = ans*fact[N]%mod*fact[M]%mod*factinv[M-N]%mod*factinv[M-N]%mod
print(ans)


Measured memory_bytes: 181540
#include <stdio.h>
int main(void){
    int a,b,c,i;
    scanf("%d%d%d",&a,&b,&c);
    int size=c;
    for(i=0;;i++){
        if(size+b+c>a){
            printf("%d",i);
            break;
        }
        else size+=b+c;
    }
}


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

int main() {
  int N;
  cin >> N;
  ll A[N];
  for (int i = 0; i < N; i++) {
    ll tmp; cin >> tmp;
    if (tmp == 0) {
      cout << 0 << endl;
      return 0;
    }
    A[i] = tmp;
  }
  
  ll prod = A[0];
  for (int i = 1; i < N; i++) {
    // ここで1e10/prodとするとdoubleになってしまい
    // 桁落ちが起こって正しく条件分岐できなくなる
    if (A[i] <= 1000000000000000000/prod) {
      prod *= A[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << prod << endl;
}

Measured memory_bytes: 4368
#include<bits/stdc++.h>
#define ll long long
#define r(i,n) for(ll i=0;i<n;i++)
#define rp(i,a,b) for(ll i=a;i<b;i++)
#define ret return
#define rt ret
#define db double
#define p(x) cout<<(x)<<endl;
#define ce continue;
#define bl bool
#define r0 ret 0;
#define r1 ret 1;
#define elif else if
#define bk break;
#define A p("A")//roll call:点呼.
#define B p("B")
#define C p("C")
#define D p("D")
#define E p("E")
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define cn cin
#define n(a) a.size();
#define els else
#define vc vector
#define vd void
using namespace std;
void Justice(int g){if(g)p("YES")else p("NO")rt;}
void justice(int g){if(g)p("Yes")else p("No")rt;}
ll pow_mod(ll n,ll k,ll m){if(!k)r1 if((k%2))//戻値は(n^k)mod m;
rt (pow_mod(n,k-1,m)*(n%m))%m;if(!(k%2)){//戻値は(n^k)mod m;
ll t=pow_mod(n,k/2,m);rt (t*t)%m;}
r0
}//戻値は(n^k)mod m;
ll power(ll k){ll t=1;r(i,k+1)t*=2;ret t;}//この関数は2のk乗を返す.
ll comb(ll i,ll j){ll up=1;for(ll n=i;n>i-j;n--){up*=n;}ll down=1;for(ll r=j;r>=1;r--)down*=r;ret up/(down);}//nCr.
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)ret b;gcd(b,a%b);}
//set<ll>uuu;
//void prime(){bool x[(ll)1e6];memset(x,0,sizeof(x));rp(i,2,1e6)if(!x[i])for(ll j=i+i;j<(ll)1e6;j+=j)x[j]=1;vector<ll>sosu;ll t;rp(i,2,1e6)if(!x[i])sosu.push_back(i);rp(i,2,(ll)1e6){if(!x[i])uuu.insert(i);}ret;}
//ll ispn(ll k){if(uuu.find(k)!=uuu.end())ret 1;ret 0;}//素数判定.動作不良の可能性大.
//bl ispn2(ll k){if(k==1)rt 0;if(k==2||k==3)rt 1;rp(i,2,(ll)sqrt((db)k)+1)if(k%i==0)rt 0;rt 1;}
ll AmountOfDigits(ll k){ll t=0;while(k){t+=k%10;k/=10;}rt t;}
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
//srand((unsigned int)time(NULL));
const ll INF=(ll)1e18;
typedef pair<ll,ll> P;
typedef struct edge{ll to,cost;}EDGE;
int main(){
	while(1){
		ll n,c;
		cin>>n>>c;
vector<ll>s(n),t(n),ch(n);
r(i,n)cin>>s[i]>>t[i]>>ch[i];
ll time[100001];
ll tt[100001];
memset(time,0,sizeof(time));
rp(i,1,c+1){//CHANNEL
	memset(tt,0,sizeof(tt));
r(j,n)if(ch[j]==i)tt[s[j]-1]++,tt[t[j]]--;
ll g=0,sta=0,sum=0;
rp(ii,0,100001){tt[ii]+=sum,sum=tt[ii];
	if(tt[ii]&&!g){sta=ii;g=1;}
	elif(!tt[ii]&&g){
		time[sta]++;
		time[ii]--;
		g=0;
		}
	elif(!g&&!tt[ii])ce
	elif(g&&tt[ii])ce
	}//IMOSSING
}//REP
ll sum=0,mx=-(ll)1e18;
rp(i,0,100001){
time[i]+=sum,sum=time[i],mx=max(mx,time[i]);
}
p(mx)
		r0
	}}



Measured memory_bytes: 4096
#include <stdio.h>
#include <math.h>

int prime[65536];

int sosu ( int n ) {
	int i , lim = (int)(sqrt(n));
	for ( i = 2; i <= lim; i++ ) {
		if ( n % i == 0 ) return 0;
	}
	return 1;
}

void tmp(void) {
	int i;
	for ( i = 2; i < 50000; i++ ) {
		if ( sosu(i) ) {
			prime[i]++;
		}
	}
	return;
}

int main (void) {
	int n , i , j;
	tmp();
	
	while ( 1 ) {
		int count = 0 , ans;
		scanf("%d",&n);
		if ( n == 0 ) break;
		
		for ( i = 0; i <= n / 2; i++ ) {
			if ( prime[i] ) {
				ans = n - i;
				if ( prime[ans] ) {
					count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 600