akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
#include<unordered_map>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
    string n;
    cin>>n;
    if(n.size()==2){
        rep(i,n.size()){
            cout<<n[i];
        }
    }else if(n.size()==3){
        for(int i=n.size()-1;i>=0;i--){
            cout<<n[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();


int main(){
  int n;cin>>n;
  int min_num = n+1;
  int res=0;
  REP(i, n){
    int p;
    cin >> p; 
    if (p<min_num){
      min_num = p;
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
 
def gcd(a, b):
  while b > 0:
    a, b = b, a % b
  return a
  
ans = A[0]
for i in range(1, N):
  ans = gcd(ans, A[i])
    
print(ans)

Measured memory_bytes: 14252
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int a, b;
  while (cin >> a >> b, a) {
    vvi dp(a, vi(b));
    int n;
    cin >> n;
    while (n--) {
      int x, y;
      cin >> x >> y;
      dp[--x][--y] = -1;
    }
    dp[0][0] = 1;
    rep(i, a) rep(j, b) {
      if (dp[i][j] == -1) continue;
      if (i > 0) dp[i][j] += max(0LL, dp[i - 1][j]);
      if (j > 0) dp[i][j] += max(0LL, dp[i][j - 1]);
    }
    cout << dp[a - 1][b - 1] << endl;
  }
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;




void solve(){
  
  int n,k;
  cin>>n>>k;

  unordered_map<int,int> mp;
  rep(i,k) {
      int d;
      cin>>d;

      rep(j,d) {
          int x;
          cin>>x;

          mp[x]++;
      }
  }

  int ans = 0;
  for(int i=1; i<=n; i++) {
    if(mp[i] == 0) {
      ans++;
    }
  }

  cout<<ans<<endl;


 
}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3636
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cins(t);
    char prev=' ';
    int ans=0;
    for(int i=0; i<t.size(); i++) {
        if(t[i]=='?')
            t[i]='D';

        if(t[i]=='D') { 
            ans++;
            if(prev=='P')
                ans++;
        }

        prev=t[i];
    }
    cout<<t<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3732
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    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;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
const int maxn = 100005;
char str[maxn];
int col[maxn];
ull p[maxn];
ull base = 233;
int n;
ll ans = 0;
unordered_map<ull, ull>M;
void init()
{
    p[0] = 1;
    for(int i = 1; i <= 10000; i++)
    p[i] = p[i-1]*base;
}
void fun1()
{
    ull x = 0, y = 0;
    int x1 = 1, y1 = n;
    for(int i = 1; i <= n; i++)
    if(col[i] == 1)x += (ull)(str[i]-'a'+1)*p[x1], x1++;
    else y += (ull)(str[i]-'a'+1)*p[y1], y1--;
    M[y-x]++;
}
void fun2()
{
    ull x = 0, y = 0;
    int x1 = n, y1 = 1;
    for(int i = n*2; i > n; i--)
    if(col[i] == 1)x += (ull)(str[i]-'a'+1)*p[x1], x1--;
    else y += (ull)(str[i]-'a'+1)*p[y1], y1++;
    ans += M[x-y];
}
void dfs1(int cur)
{
    if(cur == n+1){fun1(); return ;}
    col[cur] = 1; dfs1(cur+1);
    col[cur] = 0; dfs1(cur+1);
}
void dfs2(int cur)
{
    if(cur == 2*n+1){fun2(); return ;}
    col[cur] = 1;dfs2(cur+1);
    col[cur] = 0;dfs2(cur+1);
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> str+1;
    init();
    dfs1(1);
    dfs2(n+1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 28916
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理

        int result = s.length() - (s.replace("BW", "").length() + s.replace("WB", "").length()) / 2;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 32524
n,k = map(int,input().split())
a = list(map(int,input().split()))
a *= 2
mod = 10**9+7
c = 0
d = 0
for i in range(n):
  for j in range(i+1,2*n):
    if a[i] > a[j]:
      if j >= n:
        d += 1
      else:
        c += 1
c = c*k%mod
d = d*k*(k-1)//2%mod
print((c+d)%mod)

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll fact(ll n){
  ll res=1;
  for(int i=n; i>=1; i--){
    res=(res*i)%MOD;
  }
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,m; cin>>n>>m;
  int d = abs(n-m);
  if(d>1){
    cout<<0<<endl;
    return 0;
  }
  ll ans = fact(n)*fact(m)%MOD;
  if(d==0) ans=ans*2%MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int cnt=0;
int main(){
  int i,j,N,A[1000000],ii,ij,ikey;
  int m=0,G[100],d=3;
  //array input
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  //shellsort
  G[0]=1;m++;
  //Make G
  while((G[m]=G[m-1]+d)<N&&m<100){
    m++;
    d*=3;
  }
  printf("%d\n",m);
  //---------
  
  for(i=m-1;i>=0;i--){
    printf("%d ",G[i]);
   
    //insertionSort
    ii=0,ikey=0,ij=0;
    for(ii=G[i];ii<N;ii++){
      ikey=A[ii];
      ij=ii-G[i];
      while(ij>=0&&A[ij]>ikey){
	A[ij+G[i]]=A[ij];
	ij=ij-G[i];
	cnt++;
      }
      A[ij+G[i]]=ikey;
    }
    //-------------
  }
  //------------------
  printf("\n");
  printf("%d\n",cnt);
  
  for(j=0;j<N;j++)printf("%d\n",A[j]);
  
  return 0;
}



Measured memory_bytes: 5668
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	int n;cin>>n;
	vi a(n);f(i,0,n-1)cin>>a[i];
	ll ans=0;
	f(i,1,n-1){
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans<<'\n';
}
int main()
{	Fast;
//	int t;cin>>t;
//	while(t--)
	solve();
}

Measured memory_bytes: 3968
#include <stdio.h>

main()
{
int X;
int Y;
int Z;
int T;
scanf("%d %d %d", &X, &Y, &Z);
T = X;
X = Y;
Y = T;
T = X;
X = Z;
Z = T;
printf("%d %d %d", X, Y, Z);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(ll i=a;i<=(ll)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int n;cin>>n;
    if(n==3||n==5||n==7) bye("YES")
    bye("NO")
}

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

int main() {

    int A, B, M;
    cin >> A >> B >> M;

    vector<int> a(A), b(B);
    int mia = INF, mib = INF;
    rep(i, A){
        cin >>a[i];
        mia = min(mia, a[i]);
    }
    rep(i, B) {
        cin >> b[i];
        mib = min(mib, b[i]);
    }

    int ans = mia + mib;
    rep(_,M){
        int x, y, c;
        cin >> x >> y >> c;

        x--, y--;
        ans = min(ans,a[x] + b[y] - c);
    }

    cout << ans << endl;

    return 0;
}


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

int main(void) {
    int n, d, x;
    cin >> n >> d >> x;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int i = 1; i <= d; i += a) {
            x++;
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    string s;
    cin >> s;
    bool isOK = false;
    if(s == "keyence") isOK = true;
    rep(i, s.length()){
        for(int j = 1; j <= s.length() - i; j++){
            string copied = s;
            copied.erase(i, j);
            if(copied == "keyence") isOK = true;
        }
    }

    if(isOK) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main()
{
  int N,cnt=1;
  cin>>N;
  vector<int> d(N);
  for(int ni=0;ni<N;ni++)
  {
    cin>>d.at(ni);
  }
  sort(d.begin(),d.end());
  if(N==1)
  {
    cout<<cnt<<endl;
    return 0;
  }
  for(int nj =1 ;nj<N;nj++)
  {
    if(d.at(nj-1)!=d.at(nj))
      cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			string s;
			cin >> s;
			if (s == "snuke") {
				char c = 'A' + j;
				cout << c << i + 1<< endl;
				return 0;
			}
		}
	}
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int ans = 1;
    for(int i=1; i<N; i++) if(A[i-1] >= A[i]) ans++;
    cout << ans << endl << N << endl;
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <fstream>

using namespace std;

const char WALL = '#';

int main() {
    vector<pair<int, int>> moves = {
            {0,  1},
            {0,  -1},
            {1,  0},
            {-1, 0},
    };
    int h, w;
    cin >> h >> w;
    vector<string> s(h + 2);
    s[0] = string(w + 2, WALL);
    s[h + 1] = string(w + 2, WALL);
    for (int i = 1; i <= h; ++i) {
        string ss;
        cin >> ss;
        s[i] = WALL + ss + WALL;
    }
    vector<tuple<int, int, int>> q((h + 2) * (w + 2));
    vector<vector<int>> used(h + 2, vector<int>(w + 2));
    int answer = 0;
    for (int sx = 1; sx <= h; ++sx) {
        for (int sy = 1; sy <= w; ++sy) {
            if (s[sx][sy] == WALL) {
                continue;
            }
            for (auto &row : used) {
                fill(row.begin(), row.end(), 0);
            }
            q.clear();
            q.emplace_back(sx, sy, 0);
            used[sx][sy] = true;
            for (int i = 0; i < (int) q.size(); ++i) {
                int x = get<0>(q[i]);
                int y = get<1>(q[i]);
                int d = get<2>(q[i]);
                for (auto move : moves) {
                    int xx = x + move.first;
                    int yy = y + move.second;
                    if (s[xx][yy] != WALL && !used[xx][yy]) {
                        used[xx][yy] = true;
                        q.emplace_back(xx, yy, d + 1);
                    }
                }
            }
            answer = max(answer, get<2>(q.back()));
        }
    }
    cout << answer << "\n";
    return 0;
}


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

long long N;

bool is_sgs(long long n)
{
    bool is3 = 0;
    bool is5 = 0;
    bool is7 =  0;
    bool isother = 0;
    while(n)
    {
        long long x = n % 10LL;
        is3 = is3 || x == 3LL;
        is5 = is5 || x == 5LL;
        is7 = is7 || x == 7LL;
        isother = isother || (x != 3LL && x!= 5LL && x!=7LL);
        n /= 10LL;
    }
    return is3 && is5 && is7 && !isother;
}

long long generate(long long n)
{
    if (n > N) return 0LL;
    long long x = 0LL;
    if (is_sgs(n)) x++;
    return x + generate(n*10LL + 3LL) + generate(n*10LL + 5LL) + generate(n*10LL + 7LL);
}

int main()
{
    scanf("%lld", &N);
    printf("%lld\n", generate(0));
    return 0;
}


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

int main()
{
	int c1, c2, c3;
	int n, max;

	while (cin>>c1>>c2>>c3) {
		n = 20-c1-c2;
		if (n<=3) {
			cout<<"NO"<<endl;
		}  else {
			max = n;
			if (n>=c1) max--;
			if (n>=c2) max--;
			if (n>=c3) max--;
	 		if ( (double)max / 7.0 >= 0.5 ) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

/**
 *
 * @author dannyyang
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int N=Integer.parseInt(input.nextLine());
        String word=input.nextLine();
        long dp[][]=new long[N+1][N+1];
        dp[N][0]=1;
        int count=1;
        long mod=1000000000+7;
        for(int i=N-1;i>=1;i--){
            long sum=0;
            
                
            if(word.charAt(i-1)=='<'){
                
                for(int j=count;j>=0;j--){
                    sum+=dp[i+1][j];
                    sum%=mod;
                    dp[i][j]=sum;
                   // System.out.print(dp[i][j]+" ");
                }
               // System.out.println();
            }
            else{
                for(int j=0;j<=count;j++){
                    dp[i][j]=sum;
                    sum+=dp[i+1][j];
                    sum%=mod;
                   // System.out.print(dp[i][j]+" ");
                }
              //  System.out.println();
            }
            count++;
            
        }
        long answer=0;
        for(int i=0;i<N;i++){
            answer+=dp[1][i];
            answer%=mod;
        }
        System.out.println(answer);
    }
    
}


Measured memory_bytes: 130496
n = int(input())
v = [(0,0,0)]+[tuple(map(int, input().split( ))) for i in range(n)]


for i in range(n):
    if (v[i+1][0]+v[i][0]+v[i+1][1]+v[i][1]+v[i+1][2]+v[i][2])%2:
        print("No")
        exit()
    if v[i+1][0]+v[i][0]<abs(v[i+1][1]-v[i][1])+abs(v[i+1][2]-v[i][2]):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 18176
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    REP(i, N) cin >> A[i];
    REP(i, M) cin >> B[i];

    ll ans = 0;
    vector<ll> acum1(N+1), acum2(M+1), acum3(M+1);
    REP(i, N) acum1[i+1] = acum1[i] + A[i];
    REP(i, M) acum2[i+1] = acum2[i] + B[i];
    
    REP(i, M+1) {
        acum3[i] = -acum2[M-i];
    }

    FOR(i, 0, N) {
        if(acum1[i] > K) continue;
        auto from_b = lower_bound(acum3.begin(), acum3.end(), -(K-acum1[i]));
        ll tmp = acum1[i] - *from_b;
        // cerr << "A: " << acum1[i] << " B: " << -*from_b << " num from B: " << int(acum3.end() - from_b) << endl;
        if(tmp <= K) {
            ans = max(ans, ll(i) + ll(acum3.end() - from_b - 1));
        }
    }

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

Measured memory_bytes: 10988
#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  int turn;
  int hanako_p=0,taro_p=0;
  std::cin >> turn;
  for(int i=0;i<turn;i++){
    std::string t,h;
    std::cin >> t >> h;
    if(t < h){
      hanako_p+=3;
    }else if(h < t){
      taro_p+=3;
    }else if(h == t){
      hanako_p++;
      taro_p++;
    }
  }
  std::cout << taro_p << " " << hanako_p << std::endl;
  return 0;
}

Measured memory_bytes: 3152
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	xs := make([]Point, n)
	ys := make([]Point, n)
	var x, y int
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		xs[i] = Point{i, x, y}
		ys[i] = Point{i, y, x}
	}
	sort.Sort(Points(xs))
	sort.Sort(Points(ys))

	edges := make([]Edge, 0)
	for i := 0; i < n-1; i++ {
		point1, point2 := xs[i], xs[i+1]
		e := Edge{
			from: point1.id,
			to:   point2.id,
			cost: point2.p1 - point1.p1,
		}
		edges = append(edges, e)

		point1, point2 = ys[i], ys[i+1]
		e = Edge{
			from: point1.id,
			to:   point2.id,
			cost: point2.p1 - point1.p1,
		}
		edges = append(edges, e)
	}
	sort.Sort(Edges(edges))

	uf := newUnionFind(n)

	ans := 0
	for _, e := range edges {
		if !uf.same(e.from, e.to) {
			ans += e.cost
			uf.unite(e.from, e.to)
		}
	}

	fmt.Println(ans)
}

// Edge .
type Edge struct {
	from, to, cost int
}

// Edges .
type Edges []Edge

func (e Edges) Len() int {
	return len(e)
}

func (e Edges) Less(i, j int) bool {
	return e[i].cost < e[j].cost
}

func (e Edges) Swap(i, j int) {
	e[i], e[j] = e[j], e[i]
}

// Point .
type Point struct {
	id, p1, p2 int
}

// Points .
type Points []Point

func (p Points) Len() int {
	return len(p)
}

func (p Points) Less(i, j int) bool {
	return p[i].p1 < p[j].p1
}

func (p Points) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

// UnionFind .
type UnionFind struct {
	par  []int
	rank []int
}

func newUnionFind(n int) UnionFind {
	uf := UnionFind{}
	uf.par = make([]int, n)
	uf.rank = make([]int, n)
	for i := 0; i < n; i++ {
		uf.par[i] = i
		uf.rank[i] = 0
	}
	return uf
}

func (u UnionFind) root(x int) int {
	if u.par[x] == x {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}

func (u UnionFind) same(x, y int) bool {
	return u.root(x) == u.root(y)
}

func (u UnionFind) unite(x, y int) {
	x = u.root(x)
	y = u.root(y)
	if x == y {
		return
	}

	if u.rank[x] < u.rank[y] {
		u.par[x] = y
	} else {
		u.par[y] = x
		if u.rank[x] == u.rank[y] {
			u.rank[x]++
		}
	}
}


Measured memory_bytes: 29056
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>
#include <tuple>

typedef long long ll;
#define rep(i, a, n) for(ll i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
class UnionFind {
public:
    vector<ll> par;
    void init(ll n) {
        rep(i, 0, n) {
            //par[i] == iのとき、iの親はiとなるから初期化では全て根であるとする。
            par.push_back(i);
        }
    }

    ll root(ll x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    // これは併合するために使う
    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        // 併合済ならばfalse
        if (x == y) return false;

        par[y] = x;
        return true;
    }

    bool isSame(ll x, ll y) {
        return root(x) == root(y);
    }
};
int main() {
    int V, E;;
    cin >> V >> E;
    UnionFind T;
    vector<tuple<int, int, int> > edges;
    rep(i, 0, E) {
        int s, t, w;
        cin >> s >> t >> w;
        tuple<int, int, int> tp = make_tuple(w, s, t); 
        edges.push_back(tp);
    }

    sort(edges.begin(), edges.end());
    T.init(V);
    int res = 0;
    rep(i, 0, edges.size()) {
        int s = get<1>(edges[i]);
        int t = get<2>(edges[i]);
        if (!T.isSame(s, t)) {
            res += get<0>(edges[i]);
            T.unite(s, t);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;
const int MOD = (int)1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<vector<vector<vector<int>>>> dp(n + 1, vector<vector<vector<int>>>(4, vector<vector<int>>(4, vector<int>(4, 0))));
    dp[0][3][3][3] = 1;
    for (int len = 0; len < n; len++)
    {
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    if (dp[len][i][j][k] == 0)
                        continue;
                    for (int a = 0; a < 4; a++)
                    {
                        if (a == 1 && i == 0 && k == 2)
                            continue;
                        if (a == 1 && i == 0 && j == 2)
                            continue;
                        if (a == 1 && j == 0 && k == 2)
                            continue;
                        if (a == 1 && j == 2 && k == 0)
                            continue;
                        if (a == 2 && j == 0 && k == 1)
                            continue;
                        dp[len + 1][j][k][a] += dp[len][i][j][k];
                        dp[len + 1][j][k][a] %= MOD;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                ans += dp[n][i][j][k];
                ans %= MOD;
            }
        }
    }
    OUT(ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
#define S second
#define F first
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	map<int, int> odd, even;
	vector<P> odd_v, even_v;
	rep(i, n)
	{
		int tmp;
		cin >> tmp;
		if (i % 2)
			odd[tmp]++;
		else
			even[tmp]++;
	}
	for (auto x : odd)
		odd_v.push_back({x.S, x.F});
	for (auto x : even)
		even_v.push_back({x.S, x.F});
	odd_v.push_back({0, 0});
	even_v.push_back({0, 0});
	sort(all(odd_v), greater<>());
	sort(all(even_v), greater<>());
	if (odd_v[0].S != even_v[0].S)
	{
		cout << n - (odd_v[0].F + even_v[0].F) << endl;
	}
	else
	{
		int tmp = max(odd_v[1].F + even_v[0].F, odd_v[0].first + even_v[1].first);
		cout << n - tmp << endl;
	}
	return 0;
}

Measured memory_bytes: 8884
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

long long gcd(long long a, long long b) {
    for(;;) {
        if(a == 0)
            return b;
        b %= a;
        if(b == 0)
            return a;
        a %= b;
    }
}

long long lcm(long long a, long long b) {
    long long temp = gcd(a, b);
    return temp ? (a / temp * b) : 0;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    if((B - A) % 2 == 0) {
        cout << "Alice" << endl;
        return 0;
    } else {
        cout << "Borys" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

kabu = 0
bmoney = 1000
smoney = 1000

a.each{|x|
  if smoney < kabu*x + bmoney
    smoney = kabu*x + bmoney
  end
  kabu = smoney/x
  bmoney = smoney - kabu*x
}

p smoney


Measured memory_bytes: 14384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        long o = a;
        a = Math.max(0, a - k);
        k = Math.max(0, k - o);
        b = Math.max(0, b - k);

        System.out.println(a + " " + b);
    }
}

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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K;
  	cin >> N >> K;
	string S;
    cin >> S;
  	bool isZero = false, isOne = false;
  	vector<int> start_index;
	//変化点 だけカウントすればいい？  	
    for(int i = 0;i < N;i++)
    {
      if(S[i] == '0')
      {
        if(!isZero) start_index.push_back(i);
        isZero = true;
        isOne = false;
      }
      else
      {
        if(!isOne) start_index.push_back(i);
        isZero = false;
        isOne = true;
      }
    }
    int max_length = 0, index;
  	for(int i = 0; i < start_index.size(); i++)
    {
      //cout << start_index[i + 2 * K] << ":" <<i + 2 * K << ":" << start_index.size() << endl; 
      if(S[start_index[i]] == '0')
      {
        if (i + 2 * K >= start_index.size()) index = N;
        else index = start_index[i + 2 * K];
        max_length = max(max_length, index - start_index[i]);
      }
      if(S[start_index[i]] == '1')
      {
        if (i + 2 * K + 1 >= start_index.size()) index = N;
        else index = start_index[i + 2 * K + 1];
        max_length = max(max_length, index - start_index[i]);
      }
    }
      
      cout << max_length << endl;
    
	
  return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IN(type, n) type n; cin >> n
using namespace std;

int main() {
  IN(int, N);
  vector<int> L(N);
  int count = 0;
  REP(i, N) {
    cin >> L.at(i);
  }
  for (int i = 0; i < N - 2; ++i) {
    for (int j = i + 1; j < N - 1; ++j) {
      for (int k = j + 1; k < N; ++k) {
        if (L.at(i) > L.at(j) && L.at(i) > L.at(k)) {
          if (L.at(i) < L.at(j) + L.at(k) && L.at(j) != L.at(k)) count++;
        } else if (L.at(j) > L.at(i) && L.at(j) > L.at(k)) {
          if (L.at(j) < L.at(i) + L.at(k) && L.at(i) != L.at(k)) count++;
        } else if (L.at(k) > L.at(j) && L.at(k) > L.at(i)) {
          if (L.at(k) < L.at(j) + L.at(i) && L.at(j) != L.at(i)) count++;
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;

pair <int,int> prv[3005][3005];
int dp[3005][3005];

/*

axyb
abyxb 

*/

main()
{
	string a , b;
	cin >> a >> b;
	
	
	for(int i = 1;  i <= (int)a.size(); i++)
	{
		for(int j = 1; j <= (int)b.size(); j++)
		{
			if( a[i - 1] == b[j - 1] && dp[i - 1][j - 1] + 1 >= dp[i][j] )
			{
				dp[i][j] = dp[i-1][j-1] + 1;
				prv[i][j] = mk(i-1 , j-1);
			}
			
			if( dp[i-1][j] >= dp[i][j] )
			{
				dp[i][j] = dp[i-1][j];
				prv[i][j] = mk(i-1 , j);
			}
			if (dp[i][j - 1] >= dp[i][j])
			{
				dp[i][j] = dp[i][j-1];
				prv[i][j] = mk(i , j-1);
			}
		}
	}
	
	
	//for(int i = 1; i <= a.size(); i++)
	//{
		//for(int j = 1; j <= b.size(); j++)
		//{
			////cout << "(" << prev[i][j].first << " " << prev[i][j].second << " " << dp[i][j] << ")";
			//cout << dp[i][j] << ' ';
		//}
		//cout << endl;
	//}
	
	
	
	
	string ans = "";
	
	int i = a.size() , j = b.size();

	
	while( 1 )
	{
		if (!dp[i][j]) break;
		//cout << i << ' ' << j << ' ' << dp[i][j] << endl;
		if( i == prv[i][j].first + 1 && j == prv[i][j].second + 1 )
		{
			ans = a[i - 1] + ans;
			i--;
			j--;
			continue;
		}
		int I = i , J = j;
		
		i = prv[I][J].first;
		j = prv[I][J].second;
	}
		
	
	cout << ans << endl;
}


Measured memory_bytes: 105984
#include<stdio.h>
static const int N = 501;


int main(){
  int M[N][N];
  int n, u, k, v; 
  int i, j;

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    for ( j = 0; j < n; j++ ){
      if ( j ) printf(" ");
      printf("%d", M[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2056
s=input("")
if s=="SUN":
    print("7")
elif s=="MON":
    print("6")
elif s=="TUE":
    print("5")
elif s=="WED":
    print("4")
elif s=="THU":
    print("3")
elif s=="FRI":
    print("2")
elif s=="SAT":
    print("1")


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();

    String S = fs.next(), T = fs.next();
    int A = fs.nextInt(), B = fs.nextInt();
    String U = fs.next();
    if (U.equals(S)) A--; else B--;
    System.out.println(A + " " + B);
  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
    return buffer[ptr++];
    else
    return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
    ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
    throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
    throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
      throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
    throw new NumberFormatException();
    return (int) nl;
  }

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

Measured memory_bytes: 22100
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, Y, x = -1, y = -1, z = -1;

  std::cin >> N >> Y;

  if (Y % 1000 == 0) {
    Y /= 1000;

    for (int i = 0; i <= N; i ++) {
      int NN = N - i, YY = Y - i * 10;

      assert(NN >= 0);

      if (YY < 0)
        continue;

      for (int j = 0; j <= NN; j ++) {
        int NNN = NN - j, YYY = YY - j * 5;
        
        if (YYY == NNN) {
          x = i;
          y = j;
          z = NNN;

          goto endloop;
        }
      }
    }
  }

 endloop:

  std::cout << x << ' ' << y << ' ' << z << std::endl;

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input/test (4).txt","r",stdin)
#define write freopen("output/test (4).txt","w",stdout)
#define fr first
#define sc second
#define ii pair < int , int >
#define mp make_pair
using namespace std;
int n,k;
int a[202000];
int main()
{
 ll sum = 0;
 cin>>n>>k;
 for(int i=0;i<n;i++)
 {
     scanf("%d",&a[i]);
     if(a[i] > 0)
        sum+=a[i];
 }
 /*
 for(int i=n;i<2*n;i++)
 {
     a[i] = a[i-n];
 }
 */
 ll sum2 = 0 , maxx = 0 , sum3 = 0;
 for(int i=0;i<k;i++)
 {
     if(a[i] < 0)
     sum2+=a[i];
     else
        sum3+=a[i];
 }
 maxx = max(maxx , sum+sum2);

 for(int i=k;i<n;i++)
 {
     if(a[i] < 0)
     sum2+=a[i];
     else
        sum3+=a[i];
     if(a[i-k]<0)
     sum2-=a[i-k];
     else
        sum3-=a[i-k];
     maxx = max(maxx , sum+sum2);
     maxx = max(maxx , sum-sum3);
 }
 cout<<maxx;
}


Measured memory_bytes: 640
r=lambda x:x*(u[x]<0)or r(u[x])
i=lambda:map(int,input().split()[:2])
n,m=i()
u=[-1]*-~n
while m:
 x,y=sorted(map(r,i()));m-=1
 if x!=y:u[x]+=u[y];u[y]=x
print(sum(i<0for i in u)-1)

Measured memory_bytes: 6900
N, M = map(int,input().split())
K = []
for i in range(M):
    tes = list(map(int,input().split()))[1:]
    K.append( int("".join(["1" if i in tes else "0" for i in range(1,N+1)]),2) )
P = list(map(int,input().split()))

isOn = lambda n,k,p: bin(n&k).count("1")%2 == p

ans = 0
for i in range(2**N):
    ks = [not(isOn(i,K[e],P[e])) for e in range(M)]
    if sum(ks) == 0:
       ans += 1 
print(ans)

Measured memory_bytes: 3064
N,M,V,P=map(int, input().split())
*A,=map(int, input().split())

A.sort()

#A[x]の問題が採用される可能性があるか？
def check(x):
    r = A[-P] #無投票でギリギリ採用される問題のスコア
    if A[x] + M < r:
        return False
    votes = M*V
    votes -= M # A[x]に投票
    votes -= M*(P-1) #上位の問題に投票
    votes -= M*x #下位の問題に投票
    #微妙な問題にギリギリ投票
    for i in range(x+1, N-P+1):
        votes -= A[x]+M - A[i]
    return votes <= 0

l,r=-1,N-1
while r-l>1:
    m=(l+r)//2
    if check(m):
        r=m
    else:
        l=m
print(N-r)


Measured memory_bytes: 62704
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n); (i) >= (m); i--)
#define rep(...) _overload3(__VA_ARGS__, FOR, REP, )(__VA_ARGS__)
#define repr(...) _overload3(__VA_ARGS__, FORR, REPR, )(__VA_ARGS__)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

vector<ll> divisor(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(ALL(ret));
  return (ret);
}

int main()
{
  ll N, result = -2;
  cin >> N;

  auto sq = sqrt(N);
  if (sq == floor(sq))
  {
    result += sq * 2;
  }else{
    auto dd = divisor(N);
    auto s = dd.size();
    result += dd[s / 2 - 1];
    result += dd[s / 2];
  }
  cout << result << '\n';

  return 0;
}


Measured memory_bytes: 384
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        a1 = [a[k][j:j+m] for k in range(i,i+m)]
        if a1 == b:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 39152
input()
S = [int(i) for i in input().split(" ")]
def func(arr, a=0):
    for i, j in enumerate(arr):
        if j%2 == 1:
            print(a)
            return
        else:
            arr[i] = j/2
    a += 1
    func(arr, a)
func(S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

// 見た個数、選んだ個数、重さ
ll dp[101][101][401];

int main(){	
	long long W;
	long long N;
	scanf("%lld",&N);
	vector<long long> w(N-1+1);
	vector<long long> v(N-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&w[i]);
		scanf("%lld",&v[i]);
		if (i > 0) w[i] -= w[0]-1;
	}
	ll w0 = w[0];
	w[0] = 1;
	// rep(i, N) {
	// 	cout << w[i] << endl;
	// }
	rep(i, 101) {
		rep(j, 101) {
			rep(k, 401) {
				dp[i][j][k] = -INF;
			}
		}
	}
	dp[0][0][0] = 0;
	rep(i, N) {
		rep(j, N+1) {
			rep(k, 401) {
				dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
				if (k-w[i]>=0 && j+1 <= N) dp[i+1][j+1][k] = max(dp[i][j+1][k], dp[i][j][k-w[i]]+v[i]);
			}
		}
	}
	ll res = 0;
	rep(j, N+1) {
		rep(k, 401) {
			if (k <= W-(w0-1)*j) res = max(res, dp[N][j][k]);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define intl long long
int main()
{
	intl n,k;
	cin>>n>>k;
	intl a[n+1];
	for(intl i=0;i<n;i++)
	{
		cin>>a[i];
	}
	intl dp[n+1];
	dp[0]=0;
	for(intl i=1;i<n;i++)
	{
		int t=1;
		int m=INT_MAX;
		int x=0;
		while(t<=k)
		{
			if(i-t>=0)
			{
			x=abs(a[i-t]-a[i])+dp[i-t];
			m=min(x,m);
		}else{
			break;
		}
		t++;
		}
		dp[i]=m;
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 5164
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define min(a, b) a < b ? a : b
#define max(a, b) a > b ? a : b

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a == 1) {
		if (b == 1) printf("Draw\n");
		else printf("Alice\n");
	} else if (b == 1) {
		printf("Bob\n");
	} else {
		if (a == b) {
			printf("Draw\n");
		} else if (a > b) {
			printf("Alice\n");
		} else {
			printf("Bob\n");
		}
	}

	return (0);
}

Measured memory_bytes: 128
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    elif H[i] == H[i+1]:
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 63856
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

template <typename T>
vector<vector<T> > vec2d_init(int x_len, int y_len){
    vector<vector<T> > vec(y_len, vector<T>(x_len, 0));
    return vec;
}
template <typename T>
vector<vector<T> > vec2d_sort(vector<vector<T> > vec, int index){
    sort(vec.begin(), vec.end(), [index](const vector <T>  a, const vector <T> b){return (a[index] < b[index]);});
    return vec;
}
template <typename T>
void vec2d_show(vector<vector<T> > vec){
    for(int i = 0; i < vec.size(); i++){
        for(int j = 0; j < vec[0].size(); j++){
            cout << vec[i][j] << " ";
        }
        cout << endl;
    }
}
int main(){
    int N;
    long long K;
    cin >> N >> K;
    auto vec = vec2d_init<int>(2, N);
    for(int i = 0; i < N; i++){
        cin >> vec[i][0] >> vec[i][1];
    }
    vec = vec2d_sort<int>(vec, 0);
    long long left = 0;
    for(int i = 0; i < N; i++){
        left += vec[i][1];
        if(left >= K){
            cout << vec[i][0] << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 11136