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

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt(); 
        if(a<b && b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26208
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N, M, X, Y;
    io.read(N, M, X, Y);
    vector<int> x(N);
    vector<int> y(M);
    for(int i = 0; i < N; i++){
        io.read(x[i]);
    }
    for(int i = 0; i < M; i++){
        io.read(y[i]);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if(X < Y && x.back() < y.front() && X < y.front() && x.back() < Y) cout << "No War";
    else cout << "War";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

ll choose_2(ll x){
    return x*(x-1)/2;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
        a[i] -= 1;
    }
    vector<int> cnt(n);
    rep(i, n) cnt[a[i]]++;
    ll ttl = 0;
    rep(i, n) ttl += choose_2(cnt[i]);
    rep(i, n){
        ll ans = ttl;
        ans -= cnt[a[i]] - 1;
        cout << ans << endl;
    }

    return 0;
}

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

int N;
int A[100100];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> A[i+1];
    int ans = 0;
    rep(i, N+1) ans += abs(A[i+1]-A[i]);
    for (int i=1; i<=N; i++) {
        int sub = abs(A[i]-A[i-1])+abs(A[i+1]-A[i]);
        int add = abs(A[i+1]-A[i-1]);
        cout << ans-sub+add << endl;
    }
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    double ans = 0.0;
    
    for(int i = 1; i <= N; i++){
        long long sum = i;
        double prob = 1.0;
        
        while(sum > 0 && sum < K){
            sum *= 2;
            prob /= 2;
        }
        
        ans = ans + prob / N;
    }
    
    printf("%.12f\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int h,w,cnt['z'+5],t='a';

char c;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> h >> w;
    for(int i=1;i<=h*w;i++){
        cin >> c;
        cnt[c]++;
    }
    for(int i=1;i<=(h/2)*(w/2);i++){
        while(t<='z' && cnt[t]<4) t++;
        if(t>'z'){
            cout << "No";
            return 0;
        }
        cnt[t]-=4;
    }
    t='a';
    for(int i=1;i<=(h%2)*(w/2);i++){
        while(t<='z' && cnt[t]<2) t++;
        if(t>'z'){
            cout << "No";
            return 0;
        }
        cnt[t]-=2;
    }
    for(int i=1;i<=(h/2)*(w%2);i++){
        while(t<='z' && cnt[t]<2) t++;
        if(t>'z'){
            cout << "No";
            return 0;
        }
        cnt[t]-=2;
    }
    cout << "Yes";
}


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

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

int main(void) {
    int n, l, left, right, eat;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> l;
    left = l;
    right = l + n - 1;
    if (right <= 0) {
        eat = right;
    } else if (left >= 0) {
        eat = left;
    } else {
        eat = 0;
    }

    cout << (right + left) * (right - left + 1) / 2 - eat << "\n";
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
const ll MOD = 1000000007;

int main()
{
  FASTER;
  int n, k;
  cin >> n >> k;
  int x = (int) ceil(n / 2.0);
  if (x >= k){
    cout << "YES\n";
  }
  else {
    cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque
ddx = [0, 0, -1, 1]
ddy = [-1, 1, 0, 0]

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())

res = 0
inf = 9999999
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        dist = [[inf]*w for _ in range(h)]
        dist[i][j] = 0
        que = deque([[i, j]])
        while len(que):
            y, x = que.popleft()
            for dx, dy in zip(ddx, ddy):
                if x+dx < 0 or x+dx >= w or y+dy < 0 or y+dy >= h or s[y+dy][x+dx] == '#' or dist[y+dy][x+dx] < inf:
                    continue
                que.append([y+dy, x+dx])
                dist[y+dy][x+dx] = dist[y][x] + 1
        ma = 0
        for k in range(h):
            for l in range(w):
                if dist[k][l] < inf:
                    ma = max(ma, dist[k][l])
        res = max(ma, res)
print(res)



Measured memory_bytes: 48604
#include <iostream>
#include <cstring>
#include <cstdio>
#include<algorithm>
#include <queue>
#include <cmath>
#include <limits>
#include <map>
using namespace std;

int main(){
  int n;
  cin >> n;
  int A[n];
  int max=0,second=0;
  int place = 0;
  bool exist;
  for(int i = 0;i<n;i++){
    A[i] = 0;
  }
  for(int i = 0;i<n;i++){
    cin >> A[i];
    if(max<A[i]){
      second = max;
      max = A[i];
      exist = false;
    }else if(max == A[i]){
      exist = true;
    }else{
      if(second < A[i]){
        second = A[i];
      }
    }
  }
  for(int i = 0;i<n;i++){
    if(A[i] == max && exist){
      cout << max <<endl;
    }else if(A[i] == max && !exist){
       cout << second <<endl;
    }else{
      cout << max <<endl;
    }
  }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef unsigned long long llu;

using namespace std;

int main() {
    FIO
    int n;
    cin>>n;
    vector<int> sk(2*n);
    for(int i=0; i<2*n; i++)
        cin>>sk[i];
    int sum = 0;
    sort(sk.begin(), sk.end());
    for(int i=0; i<2*n; i+=2)
        sum += sk[i];
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
typedef long long LL;
const int maxn=1e5+5;
const LL mod=1e9+7;
int read() {
	char ch=getchar();int x=0,f=1;
	while(ch<'0' || ch>'9')	{if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int gcd_(int a,int b) {return b==0?a:gcd_(b,a%b);}
LL fpow(LL a,LL b) {
	LL res=1;
	while(b) {
		if(b&1) res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
char s[10][10];
int main() {
//	cout<<"Accepted!\n";
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;++i) {
		getchar();
		for(int j=1;j<=m;++j) cin>>s[i][j];
	}
	int x=pow(2,n),y=pow(2,m);
	int res=0;
	for(int i=0;i<x;++i) {
		for(int j=0;j<y;++j) {
			int cnt=0;
			int a[10],b[10];
			for(int pos=0;pos<n;++pos) {
				a[pos+1]=0;
				a[pos+1]=((i>>pos)&1);
			}
			for(int pos=0;pos<m;++pos) {
				b[pos+1]=0;
				b[pos+1]=((j>>pos)&1);
			}
			for(int px=1;px<=n;++px) {
				for(int py=1;py<=m;++py) {
					if(a[px]+b[py]==0) {
						if(s[px][py]=='#') cnt++;
					}
				} 
			}
			if(cnt==k) res++;
		}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 4096
import sys
input = sys.stdin.buffer.readline
 
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size
 
        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod
 
    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod
 
    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod
 
    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)
 
    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]
 
    def factInvN(self, n):
        if n < 0:
            return 0
        return self.factInv[n]
 
N = int(input())
MOD = 10**9 + 7
comb = Combination(N + 100)
 
edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    fr, to = map(int, input().split())
    edges[fr].append(to)
    edges[to].append(fr)
 
order = []
parent = [0] * (N + 1)
st = [1]
while st:
    now = st.pop()
    order.append(now)
    for to in edges[now]:
        if to == parent[now]:
            continue
        st.append(to)
        parent[to] = now
 
size = [1] * (N + 1)
for v in order[::-1]:
    size[parent[v]] += size[v]
 
dpLeaf = [1] * (N + 1)
for v in order[:: -1]:
    pr = parent[v]
    dpLeaf[v] = dpLeaf[v] * comb.fact[size[v] - 1] % MOD
    dpLeaf[pr] = dpLeaf[pr] * dpLeaf[v] * comb.factInv[size[v]] % MOD
 
ans = [0] * (N + 1)
ans[1] = dpLeaf[1]
for v in order[1:]:
    pr = parent[v]
    ans[v] = ans[pr] * comb.inv[N - size[v]] * size[v] % MOD
 
print(*(ans[1:]), sep='\n')

Measured memory_bytes: 86616
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 1003;
const int mod = (int) 1e9 + 7;

int n, m;
char a[N][N];
int dp[N][N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = n - 1; i >= 0; i--) {
		for (int j = m - 1; j >= 0; j--) {
			if (a[i][j] != '.')
				continue;
			if (i == n - 1 && j == m - 1) {
				dp[i][j] = 1;
			} else if (i == n - 1) {
				dp[i][j] = dp[i][j + 1];
			} else if (j == m - 1) {
				dp[i][j] = dp[i + 1][j];
			} else {
				dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
			}
		}
	}
	cout << dp[0][0] << endl;
	return 0;
}


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

int srh[101];

void search(string str, int i){
  if(str=="ru")srh[i]=1;
  else if(str=="lu")srh[i]=2;
  else if(str=="rd")srh[i]=3;
  else if(str=="ld")srh[i]=4;
}

int main (){
  int n,count;
  int i;
  string step;

  while(1){
    count=0;
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> step;
      search(step,i);
    }

    for(i=0;i<n-1;i++){
      if(srh[i]==1){
	if(srh[i+1]==2){
	  count++;
	}
      }else if(srh[i]==2){
	if(srh[i+1]==1){
	  count++;
	}
      }else if(srh[i]==3){
	if(srh[i+1]==4){
	  count++;
	}
      }else if(srh[i]==4){
	if(srh[i+1]==3){
	  count++;
	}
      }		    
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

#include <vector>

/*	verified : 2020/07/18
		AOJ, Disjoint Set: Union Find Tree
		http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
*/

struct union_find {
	long long N;					// the number of nodes
	long long M;					// the number of trees
	std::vector<long long> parent;	// parent[i] := the direct parent of i
	std::vector<long long> size;	// size[i] := the number of nodes in the tree containing i

	union_find(long long n) : N(n), M(n) {
		parent.resize(n, -1);
		size.resize(n, 1);
	}

	long long root(long long i) {
		if (parent[i] == -1) return i;
		else return parent[i] = root(parent[i]);
	}

	bool is_united(long long i, long long j) {
		return (root(i) == root(j));
	}

	// true : unite succeeded
	bool unite(long long i, long long j) {
		i = root(i); j = root(j);
		if (i == j) return false;
		if (size[i] < size[j]) std::swap(i, j);
		parent[j] = i;
		size[i] += size[j];
		M--;
		return true;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, m;
	cin >> n >> m;
	union_find uf(n);
	while (m--) {
		ll a, b;
		cin >> a >> b;
		uf.unite(a - 1, b - 1);
	}

	ll ans = 0;
	for (ll i = 0; i < n; i++) ans = max(ans, uf.size[i]);
	cout << ans << endl;
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
const int N = 1e5 + 7;



int main() {
	fastIO;
	string s;
	cin >> s;
	if (s.back() == 's') {
		s += "es";
	}
	else {
		s += "s";
	}
	cout << s;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,cnt=0,res=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=1;i--){
        if(a[i]>=a[i+1]) cnt++;
        else cnt=0;
        res=max(res,cnt);
    }
    cout<<res;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int a,b,c,d;
int e,f;

int main(){
	cin>>a>>b>>c>>d;
	e=c-a,f=d-b;
	
	if(e>0){
		for(int i=0;i<e;i++){
			cout<<'R';
		}
	}else{
		for(int i=0;i<e;i++){
			cout<<'L';
		}
	}
	
	if(f>0){
		for(int i=0;i<f;i++){
			cout<<'U';
		}
	}else{
		for(int i=0;i<f;i++){
			cout<<'D';
		}
	}
	
	if(e>0){
		for(int i=0;i<e;i++){
			cout<<'L';
		}
	}else{
		for(int i=0;i<e;i++){
			cout<<'R';
		}
	}
	
	if(f>0){
		for(int i=0;i<f;i++){
			cout<<'D';
		}
	}else{
		for(int i=0;i<f;i++){
			cout<<'U';
		}
	}
	
	if(f>0){
		cout<<'D';
	}else{
		cout<<'U';
	}	
	if(e>0){
		for(int i=0;i<=e;i++){
			cout<<'R';
		}
	}else{
		for(int i=0;i<=e;i++){
			cout<<'L';
		}
	}
	
	if(f>0){
		for(int i=0;i<=f;i++){
			cout<<'U';
		}
	}else{
		for(int i=0;i<=f;i++){
			cout<<'D';
		}
	}
	if(e>0){
		cout<<'L';
	}else{
		cout<<'R';
	}	
	
	
	
	if(f>0){
		cout<<'U';
	}else{
		cout<<'D';
	}
	if(e>0){
		for(int i=0;i<=e;i++){
			cout<<'L';
		}
	}else{
		for(int i=0;i<=e;i++){
			cout<<'R';
		}
	}
	
	if(f>0){
		for(int i=0;i<=f;i++){
			cout<<'D';
		}
	}else{
		for(int i=0;i<=f;i++){
			cout<<'U';
		}
	}
	if(e>0){
		cout<<'R';
	}else{
		cout<<'L';
	}
	cout<<endl;
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n;
int dp[100005];

int f(int x)
{
    if (x == 0)
        return 0;

    int& sol = dp[x];
    if (sol != -1)
        return sol;

    sol = 1 + f(x - 1);
    int a = 6;
    while (a <= x)
    {
        sol = min(sol, 1 + f(x - a));
        a *= 6;
    }
    int b = 9;
    while (b <= x)
    {
        sol = min(sol, 1 + f(x - b));
        b *= 9;
    }
    return sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    memset(dp, -1, sizeof dp);
    cout << f(n);
}


Measured memory_bytes: 3712
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        x: Chars
    }
    let x = (x as Vec<char>)
        .iter()
        .map(|&xi| xi.to_string())
        .collect::<Vec<String>>();
    if x.last().unwrap().to_string() == "s" {
        println!("{}es", x.join(""));
    } else {
        println!("{}s", x.join(""));
    }
}

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

int main() {
  int a[5],ans=0,b=10;
  for(int i=0; i<5; i++) {
    cin >> a[i];
    ans+=(a[i]+9)/10*10;
    b=min(b,(a[i]-1)%10+1);
  }
  cout << ans-10+b << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3

#!/usr/bin/env python3

X,N = map(int, input().split())
if N == 0:
    print(X)
    exit()

A = list(map(int, input().split()))
Min = 101

cnt = -200
for i in range(1,400):
    #print(cnt)
    if cnt in A:
        cnt += 1
        continue
    if abs(cnt-X) < Min:
        ans = cnt
        Min = abs(cnt-X)
    cnt += 1
print(ans)

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

using namespace std;

const int size = 1e5 + 7;
const int N = 104;
long long int dp[N][size];
int arr[N];
int mod = 1e9 + 7;

long long int solve(int k, int n) {
	if(n == 0){
		if(k == 0) return 1;
		else return 0;
	}
	// if(k == 0) return 1;
	if(k < 0) return 0;
	// if(k == 0 && n > 0) return 0;

	if(dp[n][k] != -1) return dp[n][k];

	long long int ans = 0;
	// cout<<arr[n-1]<<" ";
	for(int x=0;x<=arr[n-1];x++) {
		ans += solve(k-x, n-1)%mod;
		ans %= mod;
	}
	ans%=mod;
	dp[n][k] = ans;
	return ans;
}

int main() {
	for(int x=0;x<N;x++){
		for(int i=0;i<size;i++) dp[x][i] = -1;
	}
	int n, k;
	cin>>n>>k;
	memset(dp, 0, sizeof(dp));
	for(int x=0;x<n;x++) cin>>arr[x];
	for(int x=0;x<N;x++) dp[x][0] = 1;
	for(int x=1;x<size;x++) dp[0][x] = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			dp[i-1][j] += dp[i-1][j-1];
			// dp[i-1][j] %= mod;
		}
		for(int j=1;j<=k;j++){
			dp[i][j] += (dp[i-1][j] - ((j-arr[i-1] -1 >= 0)? dp[i-1][j-arr[i-1] -1]: 0))%mod;
			dp[i][j] %= mod;
		}
	}
	cout<<dp[n][k];
	return 0;
}  

Measured memory_bytes: 81536
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;
    cin >> r;
    cout << fixed << setprecision(6) << r * r * M_PI << " " << 2 * r * M_PI << "\n";
}

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

int main() {
string A,B,C;
cin >> A >> B >> C;
int D=A.size(),E=B.size();
  if(A.at(D-1)==B.at(0)&&B.at(E-1)==C.at(0)){
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A, B, C, ans;
map<int, int> mp;
int main(){
	cin >> A >> B >> C;
	while(true){
		if(A & 1 || B & 1 || C & 1)	break;
		ans++;
		if(mp[A] && mp[B] && mp[C]){
			puts("-1");
			return 0;
		}
		mp[A] = mp[B] = mp[C] = 1;
		int ta = A, tb = B, tc = C;
		A = (tb + tc) / 2;
		B = (ta + tc) / 2;
		C = (ta + tb) / 2;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>
#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 1000000007;
const ll INF = 0x3F3F3F3F;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline T Ckmax(T &x, T y)
{
    return x = std::max(x, y);
}
template <typename T>
inline T Ckmin(T &x, T y)
{
    return x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
inline T Pow(T x, T y)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= MOD;
        (x *= x) %= MOD;
        y /= 2;
    }
    return r % MOD;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll read(void)
{
    char x;
    while (x = getchar(), x != '-' && !isdigit(x))
        ;
    char flg = x == '-';
    ll num = (flg ? getchar() : x) - '0';
    while (isdigit(x = getchar()))
        (num *= 10) += x - '0';
    return flg ? -num : num;
}
const int N = 100 + 10;
int main()
{
	cinspu();
	int n;
	std::cin >> n;
	int a, b, c = 0, d = 0, e = 0;
	std::cin >> a >> b;
	while (n--)
	{
		int x;
		std::cin >> x;
		if (x <= a)
			++c;
		else if (x <= b)
			++d;
		else
			++e;
	}
	std::cout << Min(c, d, e) << std::endl;
	return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> A;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, M;
	priority_queue<int> Q;
	cin>>N>>M;
	A.resize(M);
	for(int i=0;i<M;i++) cin>>A[i];
	sort(A.begin(),A.end());
	for(int i=1;i<M;i++) Q.push(A[i-1]-A[i]);
	if(N>=M) cout<<"0\n";
	else {
		int ans=0;
		M-=N;
		while(M--) {
			ans-=Q.top();
			Q.pop();
		}
		cout<<ans<<'\n';
	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<char> chars = {'M', 'A', 'R', 'C', 'H'};
    map<char, ll> n_persons;

    string name;
    for(int i = 0; i < N; i++) {
        cin >> name;
        for(int j = 0; j < chars.size(); j++) {
            if(name.at(0) == chars.at(j)) {
                n_persons[chars.at(j)]++;
                break;
            }
        }
    }

    ll pattern = 0;
    for(int i=0; i<chars.size() - 2; i++){
        char ic = chars.at(i);
        for(int j=i+1; j<chars.size() - 1; j++){
            char jc = chars.at(j);
            for(int k=j+1; k<chars.size(); k++){
                char kc = chars.at(k);
                pattern += n_persons[ic] * n_persons[jc] * n_persons[kc];
            }
        }
    }
    cout << pattern << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    string s;
    cin>>s;
    ll n=s.length();
    for(int i=0;i<n;i++)
        cout<<"x";
    
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int day; cin>>day;
    if(day==25) cout<<"Christmas"<<endl;
    if(day==24) cout<<"Christmas Eve"<<endl;
    if(day==23) cout<<"Christmas Eve Eve" <<endl;
    if(day==22) cout<<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main (){
	int j;
	char character[200];
	scanf("%d", &j);
	getchar();
	
	
	scanf("%[^\n]", &character);
	int s = strlen(character);
	
	for(int i=0;i<j && character[i] != '\0';i++){
		printf("%c", character[i]);
	}
	if(s>j){
		printf("...");
	}
		
	return 0; 
}

Measured memory_bytes: 1668
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
typedef pair<int,int> P;
vector<string> ash;
int x,n,m,cap,inf=1e8,gas[302],dgas[302][302],d[6000];
string cst[3000][2];
struct edge{int to,cost;};
vector<edge> G[6000];
void dijkstra(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	rep(i,x) d[i]=inf;
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.sc;
		if(d[v]<p.fs) continue;
		rep(i,G[v].size()){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}
int main(){
	while(true){
		cin >> n >> m >> cap;
		if(n==0) break;
		string src,dest;
		cin >> src >> dest;
		ash.clear();
		rep(i,n){
			cin >> cst[i][0] >> cst[i][1] >> d[i];
			ash.push_back(cst[i][0]);
			ash.push_back(cst[i][1]);
		}
		sort(ash.begin(),ash.end());
		ash.erase(unique(ash.begin(),ash.end()),ash.end());
		x=ash.size();
//		rep(i,x) cout << i << " = " << ash[i] << endl;
//		cout << endl;
		rep(i,x) G[i].clear();
		rep(i,n){
			int c0=lower_bound(ash.begin(),ash.end(),cst[i][0])-ash.begin();
			int c1=lower_bound(ash.begin(),ash.end(),cst[i][1])-ash.begin();
			G[c0].push_back({c1,d[i]});
			G[c1].push_back({c0,d[i]});
		}
		rep(i,m){
			string sst;
			cin >> sst;
			gas[i]=lower_bound(ash.begin(),ash.end(),sst)-ash.begin();
		}
		gas[m]=lower_bound(ash.begin(),ash.end(),src)-ash.begin();
		gas[m+1]=lower_bound(ash.begin(),ash.end(),dest)-ash.begin();
//		rep(i,m+2) cout << "gas[i] = " << ash[gas[i]] << endl;
		rep(i,m+2){
			dijkstra(gas[i]);
			rep(j,m+2){
				if(d[gas[j]]<=cap*10) dgas[i][j]=d[gas[j]];
				else dgas[i][j]=inf;
			}
		}
/*		rep(i,m+2){
			rep(j,m+2) cout << dgas[i][j] << " ";
			cout << endl;
		}*/
		rep(i,m+2) rep(j,m+2) rep(k,m+2) dgas[j][k]=min(dgas[j][k],dgas[j][i]+dgas[i][k]);
		if(dgas[m][m+1]==inf) dgas[m][m+1]=-1;
		cout << dgas[m][m+1] << endl;
	}
}

Measured memory_bytes: 2584
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  t=S()

  for i in range(len(s)-len(t)+1)[::-1]:
    f=True
    for j in range(len(t)):
      # print(s[i+j],t[j])
      if s[i+j]!=t[j] and s[i+j]!='?':
        f=False
        break
    if f:
      return (s[:i]+t+s[i+len(t):]).replace('?','a')
  return 'UNRESTORABLE'

# main()
print(main())


Measured memory_bytes: 6224
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = math.MaxInt64 / 2

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = getInt()
	}

	ans := inf
	for i := 0; i < 2; i++ {
		sign := true
		if i == 1 {
			sign = false
		}
		sum := 0
		cnt := 0
		// out("-----")
		for j := 0; j < n; j++ {
			sum += a[j]
			x := a[j]
			if sign {
				if sum <= 0 {
					cnt += -sum + 1
					x += sum + 1
					sum = 1
				}
				sign = false
			} else {
				if sum >= 0 {
					cnt += sum + 1
					x -= sum + 1
					sum = -1
				}
				sign = true
			}
			// out(x, sum)
		}
		ans = min(ans, cnt)
	}
	out(ans)
}


Measured memory_bytes: 3072
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        PreparingBoxes solver = new PreparingBoxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class PreparingBoxes {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = Integer.parseInt(in.next());
            }

            List<Integer> list = new ArrayList<>();

            int[] b = new int[n + 1];
            for (int i = n; i >= 1; i--) {

                int t = i;
                int c = 0;
                while (t <= n) {
                    c += b[t];
                    t += i;
                }

                if (a[i] != (c % 2)) {
                    b[i] = 1;
                    list.add(i);
                }
            }

            if (list.size() > n) {
                out.println(-1);
                return;
            }

            Collections.sort(list);
            out.println(list.size());
            for (Integer i : list) {
                out.print(i + " ");
            }

        }

    }
}



Measured memory_bytes: 64256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long a=sc.nextLong(),b=sc.nextLong(),x=sc.nextLong();
        long ans = b/x-a/x;
        if(a%x==0)ans++;
        System.out.println(ans);


    }
}


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

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<long long int> adj[200001];
bool vis[200001];
#define ll long long int
#define ull unsigned long long int
#define MAX 1000000007
#define MOD 998244353

#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
ll arr[201];
ll sizes[201];
vector<pair<ll,pll> > edge;
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a;
        b/=2;
        a=a*a;
    }
    return(ans);
}

int main(){
    IO
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.size()<=n) cout<<s;
    else cout<<s.substr(0,n)+"...";
    return(0);
}


Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i] == T[i])
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

long fact(long n) {
    if (n == 1) return 1;
    else return n * fact(n - 1) % MOD;
}

int main() {
    long n, m;
    cin >> n >> m;
    if (abs(n - m) > 1) {
        cout << 0 << endl;
        return 0;
    }
    if (n == m) {
        cout << 2 * fact(n) * fact(m) % MOD << endl;
        return 0;
    }
    cout << fact(n) * fact(m) % MOD << endl;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int D;
    cin >> D;
    cout << "Christmas";
    if(D == 25) cout << endl;
    else{
        int a = 25 - D;
        REP(i, a) cout << " " << "Eve";
        cout << endl;
    }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let s: String = read();
    println!("{}", s.chars().filter(|&c| c == '1').count());
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,s=0;
	cin>>a>>b>>c>>d;
	if(a>=b) s+=b;
	else s+=a;
	if(c>=d) s+=d;
	else s+=c;
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    ll n,k;cin >> n >> k;
    vec<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    function<ll(ll,ll,ll)> fi=[&](ll l,ll r,ll t){//t以上の最小のindexを変えす
        if(r-l==1)return r;
        ll m=(r+l)/2;
        if(a[m]<t)return fi(m,r,t);
        else return fi(l,m,t);
    };
    /*
    k番目の値がm以下
    ⇔m以下の値がk個以上
    m以下の値がk個未満⇔k番目はm以上

    a[i]と積を取ってm以下になるものの個数(0~i-1番目)を数える
    a[i]=0:mの正負による
    a[i]>0:m>=a[i]a[j] m/a[i]>=a[j]  aの0~i-1番目をにぶたんすればいい:O(logN)
    a[i]<0:m>=a[i]a[j] m/a[i]<=a[j] これもにぶたんで良さそう

    これを各iに対してやってO(NlogN)
    さらにmをにぶたんしてO(log(max{a[i]^2}))
    ぎり間に合う?
    定数倍を考えても1e8回くらいの計算がいる…
    書いてみるか！w
    */
    function <ll(ll,ll)> ans=[&](ll l,ll r){
        if(r-l==1)return r;
        ll m=(l+r)/2;
        ll cnt=0;
        rep2(i,1,n){
            if(a[i]==0){
                if(m>=0)cnt+=i;
            }else if(a[i]>0){
                ll s;
                if(m>=0)s=m/a[i];
                else s=(m-a[i]+1)/a[i];
                //s以下のa[j]の個数をcntに加える
                cnt+=fi(-1,i,s+1);
            }else{
                ll s;
                if(m>=0)s=m/a[i];
                else s=(abs(m)+abs(a[i])-1)/abs(a[i]);
                cnt+=max(0,i-fi(-1,i,s));
            }
        }
        if(cnt>=k)return ans(l,m);
        else return ans(m,r);
    };

    ll res=ans(-9223372036854775800LL,9223372036854775800LL);
    cout << res << endl;
}

Measured memory_bytes: 4784
// 拡張ユークリッドの互除法
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cassert>

#include<vector>
#include<queue>
#include<set>

using namespace std;

int extGCD(int a,int b,int &x,int &y);

int main(void)
{
	int a, b;
	int x, y, z;

	cin >> a >> b;

	z = extGCD(a, b, x, y);

	printf("%d %d\n", x, y);

	return 0;
 }

// 拡張ユークリッドの互除法を実施する関数
 int extGCD(int a,int b,int &x,int &y)
 {
	 // b == 0のとき gcd = a
     int d = a;

     if( b != 0 )
	 {
         //ここでgcdが求まる（ b=0になる ）まで潜る
         //さかのぼりながらx yを更新してゆく
         d = extGCD(b, a%b ,y, x);

         //y= x' - (a / b) * y'
         //xは1つ前のy yは一つ前のx
         y -= ( a / b ) * x;
     }
     else
	 {
         // gcdが求まるとき ( b == 0のとき )　x = 1,y = 0 にする
         x = 1;
		 y = 0;
     }

	 //gcdを返す
     return d;
 }



Measured memory_bytes: 3240
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATheNumberOfEvenPairs solver = new ATheNumberOfEvenPairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATheNumberOfEvenPairs {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt();
            int b = s.nextInt();
            int ans = (a * (a - 1)) / 2;
            ans += (b * (b - 1)) / 2;
            out.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

map <int, int> ss;
int a[nax];
int b[nax];
int ca[nax];
int cb[nax];
int n;

pair < int, int> c[nax];
pair <int, int> d[nax];
int top;

int main () {
    scanf("%d", &n);

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%d %d", a + i, b + i);
        ca[i] = a[i];
        cb[i] = b[i];
        c[i] = make_pair(a[i], b[i]);
    }

    sort(ca + 1, ca + 1 + n);
    sort(cb + 1, cb + 1 + n);

    sort(c + 1, c + 1 + n);


    int cR = c[1].second;
    int cL = c[1].first;
    for (int i = 2 ; i <= n ; ++ i) {

        if (c[i].first > cR) {
            d[++ top] = make_pair(cL, cR);
            cR = c[i].second;
            cL = c[i].first;
        } else {
            cR = max(cR, c[i].second);
        }
    }

    d[++ top] = make_pair(cL, cR);


    long long ans = 0;
    if (n % 2) {
        for (int i = 1 ; i <= top ; ++ i) {
            int l = d[i].first, r = d[i].second;

            int min_bound = ca[(n + 1) / 2];
            int max_bound = cb[(n + 1) / 2];

            l = max(l, min_bound);
            r = min(r, max_bound);

            if (l > r) continue;

            ans += r - l + 1;
        }

        cout << ans;
    } else {

        #define int long long

        int l_min = INT_MAX, l_max = INT_MIN;

        for (int i = 1 ; i <= top ; ++ i) {
            int l = d[i].first, r = d[i].second;

            int min_bound = ca[n / 2];
            int max_bound = cb[n / 2];

            l = max(l, min_bound);
            r = min(r, max_bound);

            if (l > r) continue;

            l_min = min(l_min, l);
            l_max = max(l_max, r);

        }


        int r_min = INT_MAX, r_max = INT_MIN;


        for (int i = 1 ; i <= top ; ++ i) {
            int l = d[i].first, r = d[i].second;
            int min_bound = ca[n / 2 + 1];
            int max_bound = cb[n / 2 + 1];

            l = max(l, min_bound);
            r = min(r, max_bound);

            if (l > r) continue;

            r_min = min(r_min, l);
            r_max = max(r_max, r);

        }


        //cout << r_max << ' ' << r_min << endl;

        int all = r_max + l_max - r_min - l_min;

        cout << all + 1;
    }


}
/*
    Good Luck
        -Lucina
*/


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

int Selection_sort(int A[], int N)
{
	int c = 0;
	for (int i = 0; i < N; i++)
	{
		int	mini = i;
		for (int j = i; j < N; j++)
		{
			if (A[j] < A[mini])
			{
				mini = j;
			}
		}
		if (i != mini)
		{
			swap(A[i], A[mini]);
			c++;
		}
	}
	for (int i = 0; i < N; i++)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << "\n";
	return c;
}
int main()
{
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++)
		cin >> A[i];
	
	int c = Selection_sort(A, N);
	cout << c << endl;
}




Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x[5];
  cin>>x[0]>>x[1]>>x[2]>>x[3]>>x[4];
  for(int i=0;i<5;i++){
    if(x[i]==0){
      cout<< i+1;
      break;
    }
  }
}

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

using namespace std;

int main()
{
   int a,b;
    scanf("%d%d",&a,&b);
  
  if(a>=13)
     printf("%d",b);
  
  else if(a>=6 && a<=12)
       printf("%d",b/2);
  
  else
     printf("0");
}

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

unordered_map <int,double> dp[3000];

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

	int n;
	double t;
	vector <double> p;

	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		p.push_back(t);
	}

	dp[0][0] = 1;
	for(int i=0;i<n;i++)
	{
		for(auto it : dp[i])
		{
			dp[i+1][it.first - 1] += it.second*(1 - p[i]);
			dp[i+1][it.first + 1] += it.second*(p[i]);
		}
	}

	double res = 0;

	for(auto it : dp[n])
	{
		if(it.first > 0)
		{
			res += it.second;
		}
	}

	cout << fixed;
	cout.precision(9);
	
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 194176
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a;
    cin >> a;
    if(a<1000){
        cout << "ABC" << endl;
        return 0;
    }
    cout << "ABD" << endl;
    return 0;
}


Measured memory_bytes: 256