akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (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 FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


int checker(std::vector<int>& h, int a, int b, int k)
{
    int sum = 0;
    for (int i = 0; i < h.size(); i++) {
        sum += (max((int)0, (h[i] - b * k + a - b - 1))) / (a - b);
    }
    return (sum <= k) ? 1 : 0;
}


signed main()
{
    int n, a, b;
    cin >> n >> a >> b;
    std::vector<int> h(n);
    int sum = 0;
    int ma = 0;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        sum += h[i];
        chmax(ma, h[i]);
    }

    std::sort(all(h));
    int ng = -1;
    int ok = ma;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (checker(h, a, b, mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
    return 0;
}

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

mod = int(1e9+7)
def comb(n, r, mod):
    bunsi = 1
    bunbo = 1
    for i in range(r):
        bunsi = (bunsi * (n - i)) % mod
        bunbo = (bunbo * (r - i)) % mod
    return (bunsi*pow(bunbo, mod-2, mod)) % mod

print((pow(2, n, mod)-1 - (comb(n, a, mod)+comb(n, b, mod)))%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    string a;
    cin>>a;
    int x=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='B')
            x++;
        else
            x--;
    }
    if(x<0)
        cout<<"Yes";
    else
        cout<<"No";
} 



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
import numpy as np
a = sorted(A)
b = sorted(B)
a = np.array(a)
b = np.array(b)
A = np.array(A)
B = np.array(B)
if (a<=b).sum()!=N:
  print('No')

else:
  bx = np.argsort(B)
  A = A[bx]
  ax = np.argsort(A)
  dic = {}
  for i,x in enumerate(ax):
    dic[x]=i
    
  m = 0
  c = 0
  while True:
    m = dic[m]
    c += 1
    
    if (m==0) and (c!=N):
      print('Yes')
      exit()
    elif (c==N):
      break
      
  judge = False
  for i in range(N-1):
    if b[i]>=a[i+1]:
      judge = True
      break
      
  if judge:
    print('Yes')
  else:
    print('No')

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

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

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

    ll l = lcm(n,m);
    ll g = gcd(n,m);

    bool ans = true;

    for (ll i = 0; i < g; i++){
        if (s[i*(n/g)] != t[i*(m/g)]){
            ans = false;
            break;
        }
    }

    if (ans){
        cout << l << endl;
    }
    else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 3756
# import sys
# input = sys.stdin.readline
# import re
import collections
import bisect
import math
import fractions
import collections
import itertools
from functools import reduce

def main():
    k, a, b = input_list()
    if b - a > 2:
        bis = a
        k -= a - 1
        if k % 2 == 1:
            bis += 1
            k -= 1
        bis += (k//2)*(b-a)
        print(bis)
    else:
        print(k+1)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == '__main__':
    main()



Measured memory_bytes: 77168
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  if(n==3){
    cout<<"2 5 63"<<endl;
    return 0;
  }
  vector<Int> ans({2,3,4,9});
  const Int MAX = 30000;
  Int x=8;
  while((Int)ans.size()+2<=n&&x+2<=MAX){
    ans.emplace_back(x);
    ans.emplace_back(x+2);
    x+=6;
  }
  x=15;
  while((Int)ans.size()+2<=n&&x+6<=MAX){
    ans.emplace_back(x);
    ans.emplace_back(x+6);
    x+=12;
  }
  x=6;
  while((Int)ans.size()+1<=n&&x<=MAX){
    ans.emplace_back(x);
    x+=6;
  }
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define EPS 1e-6
using namespace std;
using p = complex<double>;

int n;
vector<p> v;
p rot[2] = {p(0, 1), p(0, -1)};

int solve();
int count(p now);

int main() {
  while(1) {
    cin >> n;
    if(n == 0) break;
    v.resize(n);
    for(int i = 0; i < n; ++i) {
      double x, y;
      cin >> x >> y;
      v[i] = p(x, y);
    }
    cout << solve() << endl;
  }
  return 0;
}

int solve() {
  int ans = 1;
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
      if(abs(v[i] - v[j]) <= 2.0 + EPS)
        for(int t = 0; t < 2; ++t) {
          p rotatep = (v[j] - v[i]) * rot[t];
          double len = 0;
          len = sqrt(4.0 - pow(abs(v[i] - v[j]), 2));
          rotatep *= len / abs(rotatep);
          rotatep += v[i];
          p nowp = (rotatep - v[j]);
          nowp /= 2;
          ans = max(ans, count(v[j] + nowp));
        }
  return ans;
}

int count(p now) {
  int ans = 0;
  for(int i = 0; i < n; ++i)
    if(abs(now - v[i]) <= 1.0 + EPS) ++ans;
  return ans;
}


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



int main() {
    int N;
    cin >> N;

    vector<vector<int>> G(N+1);
    rep(i, N) {
        int u, k, vi;
        cin >> u >> k;
        rep(j, k) cin >> vi, G[u].push_back(vi);
    }

    int dist[N+1], d=0;
    rep(i, N+1) dist[i] = -1;

    queue<int> que;
    que.push(1);
    dist[1] = 0;

    while (que.size() > 0) {
        int v = que.front();
        que.pop();

        for (auto next_v: G[v]) {
            if (dist[next_v] == -1) {
                que.push(next_v);
                dist[next_v] = dist[v] + 1;
            }
        }
    }

    for (int i=1; i<=N; i++) cout << i << " " << dist[i] << endl;

    return 0;
}




Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 2e5 + 10, inf = 1e9 + 10;
string a, b;
int d[4000][4000], n, m, mx[4000][4000];
pair <int, int> p[4000][4000], id[4000][4000];
vector <char> ans;
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    cin >> a >> b;
    n = a.size();
    m = b.size();
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            int x = i + 1;
            int y = j + 1;


            if(x == y && x == 1)d[x][y] = (a[i] == b[j]);
            else if(a[i] == b[j])
            {
                d[x][y] = d[x - 1][y - 1] + 1;
                p[x][y] = id[x - 1][y - 1];
            }
            else
            {
                if(d[x][y - 1] > d[x - 1][y])
                {
                    d[x][y] = d[x][y - 1];
                    p[x][y] = id[x][y - 1];
                }
                else
                {
                    d[x][y] = d[x - 1][y];
                    p[x][y] = id[x - 1][y];
                }
            }

            if(mx[x - 1][y] > mx[x][y - 1])
            {
                mx[x][y] = mx[x - 1][y];
                id[x][y] = id[x - 1][y];
            }
            else
            {
                mx[x][y] = mx[x][y - 1];
                id[x][y] = id[x][y - 1];
            }
            if(a[i] == b[j] && d[x][y] > mx[i][j])
            {
                mx[x][y] = d[x][y];
                id[x][y] = mp(x, y);
            }
        }
    }
    int x = n, y = m;
    if(a[n - 1] == b[m - 1])ans.pb(a[n - 1]);
    while(1)
    {

        int X = x, Y = y;
        x = p[X][Y].f;
        y = p[X][Y].s;
        if(x == 0 || y == 0)break;
        ans.pb(a[x - 1]);
    }
    for(int i = ans.size() - 1; i >= 0; i--)cout << ans[i];
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> diff(n - 1);
    string ans = "Yes";
    for (auto i = 0; i < n; i++)
    {
        int hi;
        cin >> hi;
        h[i] = hi;
    }

    for (auto i = n-1; i>=1; i--)
    {
        if(h[i-1] > h[i]){
            h[i-1] -= 1;
        }
    }
    

    for (auto i = 0; i < n-1; i++)
    {
        if(h[i] > h[i+1]){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k,q = iim()
l = [k]*n
for i in range(q):
    p = ii()
    l[p-1] += 1

for j in l:
    if j < q+1:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 6580
#include<iostream>

int main(){

    while(true){
        int a, b;
        char c;
        std::cin >> a >> c >> b;

        if(c == '?'){
            break;
        }else if(c == '+'){
            std::cout << a + b << std::endl;
        }else if(c == '-'){
            std::cout << a - b << std::endl;
        }else if(c == '*'){
            std::cout << a * b << std::endl;
        }else{
            std::cout << a / b << std::endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(ll i = b; i < e; i++)
#define forg(i, b, e, m)	for(ll i = b; i < e; i+=m)
//ll in(){ll r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd1.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	ll n;
	bool ce = false;
	ll a;
	cin>>n;
	ll im = 0;
	ll su = 0, mi = MOD;
	while(n--)
	{
		cin>>a;
		im += (a < 0);
		mi = min(mi, abs(a));
		su += abs(a);
		if(a == 0)
			ce = true;
	}
	//cout<<im<<' '<<mi<<' '<<su<<' ';
	cout<<su + (im&1 && !ce?-2*mi:0)<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constralls?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs ll?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main{

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String a = fs.next();
        String b = fs.next();
        int ans = 0;
        for(int i = 0; i < a.length(); i++){
            if(a.charAt(i) != b.charAt(i)) ans++;
        }
        System.out.println(ans);
    }

    static void sort(int[] a){
        ArrayList<Integer>l = new ArrayList<>();
        for(int i: a)
            l.add(i);
        Collections.sort(l);
        for(int i = 0; i < a.length; i++)
            a[i] = l.get(i);
    }

    static class FastScanner{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next(){
            while(!st.hasMoreTokens())
                try{
                    st = new StringTokenizer(br.readLine());
                } catch(IOException e){
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt(){
            return Integer.parseInt(next());
        }
        int[] readArray(int n){
            int[] a = new int[n];
            for(int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        long nextLong(){
            return Long.parseLong(next());
        }
    }
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a - c) <= d || (abs(a - b) <=d && abs(b - c) <= d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int H, W, N;
int ix, iy;
string S, T;

bool solve() {
  // left, right
  int left = 0, right = W;
  if (S[N - 1] == 'L') ++left;
  if (S[N - 1] == 'R') --right;
  for (int i = N - 2; i >= 0; --i) {
    if (T[i] == 'L')
      right = min(right + 1, W);
    else if (T[i] == 'R')
      left = max(0, left - 1);
    if (S[i] == 'L')
      left = left + 1;
    else if (S[i] == 'R')
      right = right - 1;
    if (left >= right) return false;
  }
  if (iy < left || iy >= right) return false;

  // up, down
  left = 0, right = H;
  if (S[N - 1] == 'U') ++left;
  if (S[N - 1] == 'D') --right;
  for (int i = N - 2; i >= 0; --i) {
    if (T[i] == 'U')
      right = min(right + 1, H);
    else if (T[i] == 'D')
      left = max(0, left - 1);
    if (S[i] == 'U')
      left = left + 1;
    else if (S[i] == 'D')
      right = right - 1;
    if (left >= right) return false;
  }
  if (ix < left || ix >= right) return false;

  return true;
}

int main() {
  cin >> H >> W >> N >> ix >> iy >> S >> T;
  --ix, --iy;
  if (solve())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

const int LIM = 1000000000;

long long S;
int remain;

int main(){
	scanf("%lld", &S);
	remain = S % LIM;
	remain = (LIM - remain) % LIM;
	
	// x_3 y_2 - x_2 y_3 = S
	printf("0 0 1 %lld %lld %lld\n", LIM, (S + remain) / LIM, remain);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    int n;
    scanf("%d",&n);
    double x[n];
    char u[n][4];
    for(int i=0;i<n;i++){
        scanf("%lf",&x[i]);
        scanf("%s",u[i]);
    }
    double ans=0;

    for(int i=0;i<n;i++){
        if(strcmp(u[i],"JPY")==0)
            ans+=x[i];
        else
            ans+=x[i]*380000;
    }        

    printf("%lf",ans);

    return 0;
}

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

int main() {
  int n,m,a,b;
  cin>>n;
  a=10000000;b=0;
  for(int i=0;i<n;i++){
    cin>>m;
    a=min(a,m);
    b=max(b,m);
  }
  cout<<b-a<<endl;
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n, 0);
    int tmp;
    rep(i, 0, q){
        cin >> tmp;
        a[tmp - 1]++;
    }
    rep(i, 0, n){
        if(q - a[i] <= k - 1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  vector<vector<int>> BINGO(3, vector<int>(3, false));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
    for (int j = 0; j < 3; j++) {
      if (A.at(0).at(j) == b.at(i)) BINGO.at(0).at(j) = true;
      if (A.at(1).at(j) == b.at(i)) BINGO.at(1).at(j) = true;
      if (A.at(2).at(j) == b.at(i)) BINGO.at(2).at(j) = true;
    }
  }

  bool ans = false;

  for (int i = 0; i < 3; i++) {
    if (BINGO.at(0).at(i) && BINGO.at(1).at(i) && BINGO.at(2).at(i)) {
      ans = true;
      break;
    }
    else if (BINGO.at(i).at(0) && BINGO.at(i).at(1) && BINGO.at(i).at(2)) {
      ans = true;
      break;
    }
  }
  if (!ans) {
    if (BINGO.at(0).at(0) && BINGO.at(1).at(1) && BINGO.at(2).at(2)) {
      ans = true;
    }
    else if (BINGO.at(0).at(2) && BINGO.at(1).at(1) && BINGO.at(2).at(0)) {
      ans = true;
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3636
N = int(input())


def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


A = divisor(N)
A = [i - 1 for i in A]

ans = 0
for a in A:
    if a == 0:
        continue
    if N // a == N % a:
        ans += a

print(ans)

Measured memory_bytes: 67224
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	A := []int{}
	for i := 0; i < N; i++ {
		A = append(A, fsc.NextInt())
	}
	sort.Ints(A)
	result := 0
	for _, v := range A {
		result += v - 1
	}
	fmt.Println(result)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll tre[1010][1010];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	rep(i, h) {
		rep(j, w) {
			if (i < h - b) {
				if (j < w - a)tre[i][j] = 0;
				else {
					tre[i][j] = 1;
				}
			}
			else {
				if (j < w - a)tre[i][j] = 1;
				else {
					tre[i][j] = 0;
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << tre[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

int main()
{
    int arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    int flag=0;
    if(arr[0]==5)flag++;
    if(arr[1]==5)flag++;
    if(arr[2]==7)flag++;
    if(flag==3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray();

            var min = new int?();

            for (int i = 0; i < s.Length - 2; i++)
            {
                var c = new char[] { s[i], s[i + 1], s[i + 2] };
                var str = new string(c);

                var val = Math.Abs(int.Parse(str) - 753);
                if (val < min || min == null)
                {
                    min = val;
                }
            }

            Console.WriteLine(min);
        }
    }
}


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

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int N_MAX = 1e5+10;
const int A_MAX = 1e9;

int N, K, S;
int A[N_MAX];

int main()
{
	scanf("%d %d %d", &N, &K, &S);

	for( int i = 0; i < N; i++ )
	{
		if( i < K )
		{
			A[i] = S;
		}
		else
		{
			A[i] = (S == A_MAX) ? 1 : A_MAX;
		}
	}

	printf("%d", A[0]);
	for( int i = 1; i < N; i++ )
	{
		printf(" %d", A[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string T;
  cin >> T;
  int size;
  size = T.size();

  if(size == 1){
    if(T.at(0) == '?'){
      T.at(0) = 'D';
    }
  }
  else if(size != 1){
    for(int i = 0; i < size; i++ ){
      if(T.at(i) == '?'){
        T.at(i) = 'D';
      }
    }
  }
  cout << T << endl;
}

  
  

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	string a, b;
	cin>>a>>b;
	int na, nb;
	cin>>na>>nb;
	string t;
	cin>>t;
	if(t == a)
		na--;
	if(t == b)
		nb--;
	cout<<na<<" "<<nb;
}


Measured memory_bytes: 256
"""
NTC here
"""
 

#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase

def iin(): return int(input())
 
 
def lin(): return list(map(int, input().split()))

def main():
    T = 1
    while T:
        md = 10**9+7
        T-=1
        n, k = lin()
        ans = [0]*(n+1)

        l, h = 0, n
        s1, s2 = 0, n
        for i in range(n+1):
            ans[i]+=s2-s1+1
            l+=1
            h-=1
            s1+=l
            s2+=h
        print(sum(ans[k-1:])%md) 
        # print(ans)
        








# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 67944
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

const int N(309);

int n;
double a, b, c, m;
double ans;
double f[N][N][N];

double dp(int a, int b, int c)
{
	if (a == 0 && b == 0 && c == 0) return 0;
	if (f[a][b][c] >= 0) return f[a][b][c];
	double d = a + b + c, ans = n / d;
	if (a)
	{
		ans += dp(a - 1, b, c) * a / d;
	}
	if (b)
	{
		ans += dp(a + 1, b - 1, c) * b / d;
	}
	if (c)
	{
		ans += dp(a, b + 1, c - 1) * c / d;
	}
	f[a][b][c] = ans;
	return ans;
}
int main()
{
	cin>>n;
	memset(f, -1, sizeof(f));
	for (int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		m += x;
		if(x == 1) a++;
		else if (x == 2) b++;
		else if (x == 3) c++;
	}
	printf("%.7lf\n",dp(a, b, c));
	return 0;
}

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

long long N;
int dfs(string s){
  long long n = atoll(s.c_str());
  if(n > N) return 0;
  
  char t753 = 0;
  int res = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '7') t753 |= 1 << 2;
    if(s[i] == '5') t753 |= 1 << 1;
    if(s[i] == '3') t753 |= 1;
  }
  if(t753 == 7) res += 1;
  
  if(s == "0") s = "";
  res += dfs(s + '7');
  res += dfs(s + '5');
  res += dfs(s + '3');
  
  return res;
  
}

int main(){
  cin >> N;
  
  cout << dfs("0") << endl;
}

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

using namespace std;

const int N = 5000 + 77;
int n , X , Y;
int a[N] , b[N] , F[N];
long long dp[N][N];
int main() {
   memset(dp , 63 , sizeof(dp));
   for(int i = 0;i < N;++ i)
      dp[0][i] = 0;
   scanf("%d" , & n);
   scanf("%d %d" , & X , & Y);
   for(int i = 1;i <= n;++ i)
      scanf("%d" , a + i);
   for(int i = 1;i <= n;++ i) {
      for(int j = i;j <= n;++ j)
         dp[i][j] = 0;
      for(int j = 1;j < i;++ j)
         F[i] += (a[j] > a[i]);
      b[i] = i;
      for(int j = i;j > 1;-- j)
         if(a[b[j]] < a[b[j - 1]])
            swap(b[j] , b[j - 1]);
      for(int j = 2;j <= i;++ j) {
         int t = i - j + 1;
         int pos = b[i - t + 1];
         int leftmore = F[pos];
         int rightmore = t - 1 - F[pos];
         int rightless = i - pos - rightmore;
         dp[i][t] = dp[pos - 1][leftmore + 1] + rightless * 1ll * Y;
         if(rightless == 0)
            dp[i][t] = min(dp[i][t] , dp[i][t + 1]);
         else
            dp[i][t] = min(dp[i][t] , dp[i][t + 1] + X);
      }
   }

   printf("%lld\n" , dp[n][1]);
   return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m;
  cin >> n >> m;
  vector<long> v(m);
  rep(i, m) {
    long p, y;
    cin >> p >> y;
    v[i] = (p << 32) | y;
  }

  vector<long> sorted_v(v);
  sort(sorted_v.begin(), sorted_v.end());

  vector<size_t> head(n+1, m+1); // for cache
  rep(i, m) {
    const long p = v[i] >> 32;
    if (head[p] > m) {
      auto it = lower_bound(sorted_v.begin(), sorted_v.end(), p << 32);
      head[p] = distance(sorted_v.begin(), it);
    }
    auto it = lower_bound(sorted_v.begin(), sorted_v.end(), v[i]);
    auto d = distance(sorted_v.begin(), it);
    printf("%06ld%06ld\n", p, d - head[p] + 1); 
  }
  return 0;
}


Measured memory_bytes: 3840
S = input()
T = input()

m = {}
n = {}
for s, t in zip(S, T):
    if s in m and m[s] != t:
        print("No")
        break
    else:
        m[s] = t

    if t in n and n[t] != s:
        print("No")
        break
    else:
        n[t] = s
else:
    print("Yes")


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

int main() {
 int n ;
  cin >>n;
 vector<int> d(n);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  
  cout <<d.at(n/2) - d.at(n/2-1);
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define INF (int)1e9

void warshall_floyd(int m, int p, int q, std::vector<std::vector<int> > &dp) { 
    for (int i = 0; i < m; i++) {
        dp[i][i] = 0;
    }
    for (int k = 0; k < m; k++) {
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                dp[i][j] = std::min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    return;
}

int main(void) {
    int n;
    int m;
    int a;
    int b;
    int cost;
    int time;
    int k;
    int p;
    int q;
    int r;

    while (true) {
        std::cin >> n >> m;
        if (n == 0 && m == 0) {
            break; 
        }
        std::vector<std::vector<int> > vcost(m, std::vector<int>(m, INF));
        std::vector<std::vector<int> > vtime(m, std::vector<int>(m, INF));

        for (int i = 0; i < n; i++) {
            std::cin >> a >> b >> cost >> time;
            --a;
            --b;
            vcost[a][b] = cost; 
            vcost[b][a] = cost; 
            vtime[a][b] = time; 
            vtime[b][a] = time; 
        }

        warshall_floyd(m, p, q, vcost); 
        warshall_floyd(m, p, q, vtime); 
        std::cin >> k;
        for (int i = 0; i < k; i++) {
            std::cin >> p >> q >> r;
            --p;
            --q;
            if (r == 0) {
                std::cout << vcost[p][q] << std::endl;            
            } else {
                std::cout << vtime[p][q] << std::endl;            
            }
        }
    } return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if (s.size()<=n)
    cout<<s<<endl;
    else
    {
        for (int i=0;i<n;i++)
        cout<<s[i];
        cout<<"...";
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    good = [True] * N

    for Ai1, Bi1 in zip(A, B):
        Ai = Ai1 - 1
        Bi = Bi1 - 1
        if H[Ai] > H[Bi]:
            good[Bi] = False
        elif H[Ai] < H[Bi]:
            good[Ai] = False
        else:
            good[Ai] = False
            good[Bi] = False

    print(good.count(True))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()


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

#define forn(i,n) for(int i = 0;i<n;i++)
#define forne(i,j,n) for(int i = j;i<n;i++)
typedef long long ll;
const unsigned int mod = 1000000007;
const int INF = 1000000001;
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// typedef pair<int,int> pii;
// vector<vector<ll>> adj(100000);
// vector<ll> ans(100000,0);
// ll minans = 1;


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

string s;
cin>>s;
if(s == "ABC") cout<<"ARC"<<endl;
else cout<<"ABC"<<endl;


}

Measured memory_bytes: 3612
#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 drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//


int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();

  bool ok = true;
  rep(i, n) if (s[0] != s[i]) ok = false;
  if (ok) {
    ll ans = (ll)n*k/2;
    cout << ans << endl;
    return 0;
  }

  int x = 0;
  int cnt = 1;
  char now = s[0];
  for (int i = 1; i <= n-1; i++) {
    if (s[i] == now) cnt++;
    else {
      x += cnt/2;
      now = s[i];
      cnt = 1;
    }
  }
  x += cnt/2;
  ll ans = 0;
  ans += (ll)x * k;
  if (s[0] == s[n-1]) {
    int l = 1, r = 1; 
    char nl = s[0], nr = s[n-1];
    for (int i = 1; i < n; i++) {
      if (s[i] == nl) l++;
      else break;
    }
    for (int i = n-2; i >= 0; i--) {
      if (s[i] == nr) r++;
      else break;
    }
    if ((l+r)%2 == 0) ans += k-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
# Selection sort
def selection_sort(A,N):
    counter = 0
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if not i == minj:
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            counter += 1
    return counter
N = int(input())
A = [int(i) for i in input().split(' ')]
c = selection_sort(A,N)
print(' '.join(list(map(str, A))))
print(c)


Measured memory_bytes: 7744
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
#define mem(a, b) memset(a, b, sizeof a)

using namespace std;
const int MI = 1e6;
int read() {
	static streambuf* in = cin.rdbuf();
	#define gc (p1 == p2 && (p2 = (p1 = buf) + in -> sgetn(buf, MI), p1 == p2) ? -1 : *p1++)
	static char buf[MI], *p1, *p2;
	int c = gc, r = 0;
	while(c < 48) c = gc;
	while(c > 47) r += c & 15, c = gc;
	return r;
}
int main() {
	#ifdef local
		freopen("in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0), cin.tie(0);
	return puts(read() % 9 ? "No" : "Yes"), 0;
}

Measured memory_bytes: 3836
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt();
		int max = stdIn.nextInt();
		int min = max;
		long sum = max;

		for (int i = 1, tmp = 0; i < n; i++) {
			tmp = stdIn.nextInt();
			if(max < tmp) {
				max = tmp;
			}
			if(min > tmp) {
				min = tmp;
			}
			sum += tmp;
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

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

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] str = stdR.readLine().split(" ");
        int A = Integer.parseInt(str[0]);
        int B = Integer.parseInt(str[1]);
        int K = Integer.parseInt(str[2]);
        int num = 1;
        int count = 0;
        ArrayList<Integer> ast = new ArrayList<Integer>();
        while(num <= Math.min(A, B)) {
            if(A % num == 0 && B % num == 0) {
                ast.add(num);
            }
            num++;
        }
        System.out.println(ast.get(ast.size() - K));
    }
}


Measured memory_bytes: 22612
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int A[2003];
int dpZ[2003];
int dpW[2003];
int N, Z, W;
int dpfW(int);
int dpfZ(int w){
	int &ret = dpZ[w];
	if(~ret) return ret;
	int nw= w ? A[w] : W;
	ret = abs(A[N]-nw);
	for(int i=w+1;i<N;i++){
		ret=max(ret,dpfW(i));
	}
	return ret;
}
int dpfW(int z){
	int &ret = dpW[z];
	if(~ret) return ret;
	int nz= z ? A[z] : Z;
	ret = abs(nz-A[N]);
	for(int i=z+1;i<N;i++){
		ret=min(ret,dpfZ(i));
	}
	return ret;
}

int main(){
	scanf("%d %d %d",&N,&Z,&W);
	for(int i=1;i<=N;i++) scanf("%d",A+i);
	memset(dpZ,-1,sizeof dpZ);
	memset(dpW,-1,sizeof dpW);
	printf("%d",dpfZ(0));
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  for(int i = 0; i < n; i++) p[i]--;
  for(int i = 0; i < n; i++) if(p[p[i]] == i) ans++;
  cout << ans / 2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <map>
#include <cctype>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;

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

int main()
{
  cout << setprecision(6);
  cout << setiosflags(ios::scientific);
  cout.flags(ios::fixed);

  int counts[100+1];
  memset(counts, 0, sizeof(counts));
  int num=0;
  while(cin >> num){
    counts[num]++;
  }

  int maxNum=0;
  REP(i,101)
    maxNum = max(maxNum,counts[i]);

  REP(i,101){
    if(counts[i]==maxNum){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 1160
import itertools

A, B, C, D = [int(s) for s in list(input())]

symbols = ['+', '-']
for s1, s2, s3 in itertools.product(symbols, symbols, symbols):
    N = 0
    N = A + B if s1 == '+' else A - B
    N = N + C if s2 == '+' else N - C
    N = N + D if s3 == '+' else N - D
    if N == 7:
        print('{}{}{}{}{}{}{}={}'.format(A, s1, B, s2, C, s3, D, N))
        break


Measured memory_bytes: 3064
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define For(i,a,b) for(i=(a); i<(b); i++)
#define rep(i,n) for(i=0; i<(n); i++)
#define Nfor(i,a,b) for(i=(a)-1; i>=(b); i--)
#define dep(i,n) for(i=(n-1);i>=0; i--)
#define mp make_pair
#define pb push_back
#define Auto(a) for(auto &val : a)
#define X first
#define Y second
#define MOD 1000000007
#define MOD1 998244353
#define iterate(A, i) for(auto i = A.begin(); i!=A.end(); i++)
#define mset(A,val,n) memset(A, val, n*sizeof(int))
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<bool> vb;
typedef vector<vector<bool> > vvb;
typedef pair<int, int> pii;
typedef vector<vector<pair<int, int> > > vvp;

int power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y>0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x)%p;} return res;}
int modInverse(ll n) {ll p = MOD;return power(n, p-2, p);}
int min(int a, int b, int c) { return min(a, min(b, c)); }
int max(int a, int b, int c) { return max(a, max(b, c)); }
inline void swap(int &a, int &b) { int t = a; a = b; b = t;}
bool cmp(int a, int b){return a>b;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, i, j;
    cin>>n>>m;
    vector<string> s(n);
    rep(i, n) cin>>s[i];
    ll dp[n][m];
    rep(i,n){
        rep(j,m){
            dp[i][j] = 0;
            if(i==0&&j==0) dp[i][j] = 1;
            if(i-1>=0) dp[i][j]+=dp[i-1][j];
            if(j-1>=0) dp[i][j]+=dp[i][j-1];
            if(s[i][j]=='#') dp[i][j] = 0;
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[n-1][m-1];
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
signed main()
{   
      senky_bansal
      IIIT_ALLAHABAD
      
      ll l,r;
      cin>>l>>r;
      ll l1 = l;
      ll r1 = r;
      l%=2019;
      r%=2019;
      ll ans= 1e18;
         for(int i=l;i<r;i++)
         {
             for(int j=i+1;j<=r;j++)
             {
                 ll p = (i*j)%2019;
                 ans=min(ans,p);
             }
         }
         if((r1/2019)>(l1/2019))
         cout<<"0";
         else
         cout<<ans;
}









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

int main() {
    int numElements;
    cin >> numElements;
    vector<long long> sequence(numElements);
    for(int i = 0; i < numElements; i++) {
    	scanf("%lld",&sequence[i]);
    }

    long long memo[numElements][numElements];
    memset(memo, 0, sizeof(memo));

    for(int i = numElements-1; i >= 0; i--) {
        for(int j = i; j < numElements; j++) {
            if(i == j) {
                memo[i][j] = sequence[i];
            } else {
                memo[i][j] = max(sequence[i] - memo[i+1][j], sequence[j] - memo[i][j-1]);
            }
        }
    }
	
	printf("%lld\n",memo[0][numElements-1]);
    
    return 0;
}

Measured memory_bytes: 73556
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  
  cin >>N;
  vector<int>vec(4);
  vec.at(0)=105;
  vec.at(1)=135;
  vec.at(2)=165;
  vec.at(3)=195;
  if(N<105) {
    cout<< 0<< endl;
  }
else if((N>=105) &&(N<135)) {
  cout<< 1<< endl;
}
  else if((N>=135) &&(N<165)) {
  cout<< 2<< endl;
}
  else if((N>=165) &&(N<189)) {
  cout<< 3<< endl;
}
  else if((N>=189) &&(N<195)) {
  cout<< 4<< endl;
    
}
  else if(N>=195) {
    cout<< 5<< endl;
  
}
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;

    ll ans = 0;
    rep(i,N){
        ll h;
        cin>>h;
        if(h>=K){
            ans++;
        }
    }
    
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3608