akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():
    K = in_n()
    N = 50

    q, r = divmod(K, N)
    ans = np.full(N, N + q)
    cnt = N - r
    ans[:cnt] -= N - (cnt - 1)
    ans[cnt:] += cnt

    print(N)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27168
def rectangle_cutting(w, h, x, y)
  area = w * h / 2.0
  div = w == x * 2 && h == y * 2 ? 1 : 0
  [area, div]
end

w, h, x, y = gets.split.map(&:to_i)
ans = rectangle_cutting(w, h, x, y)
puts "#{ans[0]} #{ans[1]}"


Measured memory_bytes: 1788
N,K,Q = map(int,input().split())

L = [0 for _ in range(N)]

for _ in range(Q):
  k = int(input())
  L[k-1] +=1

s = sum(L)

for i in range(N):
  if K + L[i] -s <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 4672
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

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

	vector<ll> a(N + 1);
	repn(i, N) cin >> a[i];

	sort(++a.begin(), a.end());

	vector<ll> s(N + 1, 0);
	repn(i, N) s[i] = s[i - 1] + a[i];

	auto itr = upper_bound(++s.begin(), s.end(), x);
	ll id = distance(s.begin(), itr);

	ll ans;
	if (id <= N) { ans = id - 1; }
	else if (s[N] < x) { ans = N - 1; }
	else { ans = N; }

	cout << ans;

	

	system("PAUSE");

}





Measured memory_bytes: 504
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N, K;
	cin >> N >> K;
	
	VI X(N), Y(N);
	VI xary, yary;
	REP(i, N) {
		cin >> X[i] >> Y[i];
		xary.push_back(X[i]);
		yary.push_back(Y[i]);
	}
	SORT(xary);
	SORT(yary);

	int ans = 1LL * (xary[N - 1] - xary[0])*(yary[N - 1] - yary[0]);

	REP(xi, N) {
		FOR(xj, xi + 1, N) {
			REP(yi, N) {
				FOR(yj, yi + 1, N) {

					int num = 0;
					int lx = xary[xi],rx = xary[xj];
					int by = yary[yi],uy = yary[yj];

					REP(i, N) {
						if (lx <= X[i] && X[i] <= rx && by <= Y[i] && Y[i] <= uy) {
							num++;
						}
					}
					if (num >= K)ans = min(ans, 1LL * (rx - lx)*(uy - by));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <queue>
#define ll long long
#define MAX_V 10000
#define INF -1
#define LL 100
using namespace std;

int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int s,t;
    s=a*60+b;
    t=c*60+d;
    cout<<t-s-e<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vector<ll> x(N);
    vector<ll> y(M);
    ll XMax = X;
    for(ll i = 0; i<N; i++){
        cin>>x[i];
        XMax = max({XMax,x[i]});
    }
    ll YMin = Y;
    for(ll i = 0; i<M; i++){
        cin>>y[i];
        YMin = min({YMin,y[i]});
    }
    
    if(XMax<YMin)puts("No War");
    else puts("War");
    return 0;
}

    
    



Measured memory_bytes: 256
/*
 * Author : Sadi
 * Sun 05/07/2020
 * 18:11:35.87
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    int mod = n % 1000;
    if(mod == 0) cout << 0 << endl;
    else cout << 1000 - mod << endl;
    return 0;
}


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline
import numpy as np
n = int(input())
f = [list(map(int,input().split())) for i in range(n)]
p = [list(map(int,input().split())) for i in range(n)]
fra1 = [0] * 10
fra1[0] = 1
fra2 = [0] * 10
f1 = np.array(f)

def profit(op): #利益出す
    a = 0
    for i in range(n):
        a += p[i][int(op[i])]
    return a

def re(time,fra,op):
    if fra[time-1] == 1:
        op1 = op + f1[:,time-1]
    else:
        op1 = op
    
    if time == 10:
        if sum(fra) == 0:
            return -(10 ** 10)
        else:
            ans = profit(op1)
            return ans
    else:
        fra[time] = 1
        ans1 = re(time+1,fra,op1)

        fra[time] = 0
        ans2 = re(time+1,fra,op1)

        return max(ans1,ans2)

ope = np.zeros(n)



a1 = re(1,fra1,ope)
a2 = re(1,fra2,ope)

print(max(a1,a2))

Measured memory_bytes: 12512
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

const int MAXN = 1e5+5;
vector<int> graph[MAXN];
int dp[MAXN];
int n, m, ans;

int DP(int curr)
{
    if(dp[curr] != -1) return dp[curr];
    dp[curr] = 0;
    for(auto& neighbor : graph[curr])
    {
        dp[curr] = max(dp[curr], DP(neighbor) + 1);
    }
    ans = max(ans, dp[curr]);
    return dp[curr];
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    cin >> n >> m;
    for(int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
    }
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i <= n; ++i) DP(i);
    cout << ans << "\n";
    return 0; 
}


Measured memory_bytes: 7552
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
#define debug(output) cout<<#output<<"= "<<output<<endl
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
lint solve(int n,lint k,vector<lint> a){
    lint sm=0;
    vector<int> memo(64,0);
    rep(i,n){
        sm+=a[i];
        rep(j,64){
            memo[j]+=a[i]%2;a[i]/=2;
        }
    }
    lint dp=0;lint use=0;
    vector<int> kbit;
    lint buf=k;
    while(buf>0){
        kbit.push_back(buf%2);buf/=2;
    }
    reverse(ALL(kbit));
    int keta=kbit.size();
    if(n-memo[keta-1]>memo[keta-1]){
        use=(n-2*memo[keta-1])*(1ll<<(keta-1));
    }
    rep1(i,keta-1){
        if(n-memo[keta-i-1]>memo[keta-i-1]){
            if(kbit[i]){
                dp=max(use,dp+(n-2*memo[keta-i-1])*(1ll<<(keta-i-1)));
                use+=(n-2*memo[keta-i-1])*(1ll<<(keta-i-1));
            }
            else{
                dp+=(n-2*memo[keta-i-1])*(1ll<<(keta-i-1));
            }
        }
        else if(kbit[i]){
            dp=max(dp,use);
        }
    }
    /*
    debug(use);
    debug(keta);
    debug(memo[0]);
    */
    return sm+max(dp,use);
}
signed main(){
  lint n,k;cin>>n>>k;
  vector<lint> a(n);
  rep(i,n)cin>>a[i];
  cout<<solve(n,k,a)<<"\n";
  return 0;
}

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

using ll = long long;
using namespace std;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int n, pre, pn, ans;
    ans = 0;
    cin >> n >> pre >> pn;
    for (int i = 0; i < n - 2; i++) {
        int next;
        cin >> next;

        int minimum = min(pre, min(pn, next));
        int maximum = max(pre, max(pn, next));
        if (minimum < pn && pn < maximum) {
            ans++;
        }

        pre = pn;
        pn = next;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N >= M:
    print(0)
else:
    X = sorted(X)
    L = []
    for i in range(0, M-1):
        L.append(X[i+1] - X[i])
    L = sorted(L, reverse = True)
    S = 0
    for i in range(N-1):
        S += L[i]
    res = X[M-1] - X[0] - S
    print(res)

Measured memory_bytes: 13960
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 aa, bb, tt, ans = 0;
	cin >> aa >> bb >> tt;
	for(int64 ii = aa;ii <= tt;ii += aa)
	{
		ans += bb;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
using namespace std;
int main()
{
	ll n,k,i,j;double res=0.0;
	cin>>n>>k;
	rep(i,1,n+1)
	{
	  double p=1.0/n;
	  ll x=i;
	  while(x<k)
	  {
	  	x*=2;p/=2;
	  }	
	  res+=p;	  
	}
	printf("%.12f\n",res);
 	
	
	
	
	
	
 return 0;
}

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

using ll = long long;

ll gcd(ll a, ll b) {
  while (b != 0) {
    ll r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll n = gcd(a, b);
  int ans = 1;

  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      ++ans;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n != 1) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n, i;
        n = cin.nextInt();
        Card[] A = new Card[n];
        Card[] B = new Card[n];
        for (i = 0; i < n; i++) {
            String card = cin.next();
            A[i] = new Card();
            B[i] = new Card();
            B[i].suit = A[i].suit = card.charAt(0);
            B[i].value = A[i].value = card.charAt(1) - '0';
            B[i].inputTime = A[i].inputTime = i;
        }
        
        bubbleSort(A, n);
        sectionSort(B, n);
        
        printCard(A, n);
        checkStable(A, n);
        printCard(B, n);
        checkStable(B, n);
    }
    static void bubbleSort(Card[] A, int n) {
        int i = 0, j = 0;
        boolean flag = true;
        while (flag) {
            flag = false;
            for (j = n - 1; j > i; j--) {
                if (A[j].value < A[j - 1].value) {
                    Card temp = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = temp;
                    flag = true;
                }
            }
            i++;
        }
    }
    static void sectionSort(Card[] A, int n) {
        int i, j, min;
        for (i = 0; i < n; i++) {
            min = i;
            for (j = i; j < n; j++) {
                if (A[j].value < A[min].value) {
                    min = j;
                }
            }
            if (min != i) {
                Card temp = A[i];
                A[i] = A[min];
                A[min] = temp;
            }
        }
    }
    static void printCard(Card[] A, int n) {
        int i;
        for (i = 0; i < n; i++) {
            if (i != 0) System.out.print(" ");
            System.out.print(A[i].suit + "" + A[i].value);
        }
        System.out.println();
    }
    static void checkStable(Card[] A, int n) {
        int i;
        boolean flag = true;
        for (i = 0; i < n - 1; i++) {
            if (A[i].value == A[i + 1].value && A[i].inputTime > A[i + 1].inputTime) {
                flag = false;
                break;
            }
        }
        if (flag) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
    }
    
}

class Card {
    char suit;
    int value;
    int inputTime;
}


Measured memory_bytes: 26364
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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

const int mx = 25;
int dist[mx][mx], n, m;
char c[mx][mx];

void dfs ( int i, int j, int d )
{
    if ( dist[i][j] > d ) dist[i][j] = d;
    else return;

    for ( int k = 0; k < 4; k++ ) {
        int x = dx[k] + i;
        int y = dy[k] + j;

        if ( x <= n && x >= 1 && y <= m && y >= 1 && c[x][y] != '#' ) {
            dfs ( x, y, d+1 );
        }
    }
}


int main()
{
    optimize();

    int ans = 0;
    cin >> n >> m;

    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= m; j++ ) {
            cin >> c[i][j];
        }
    }

    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= m; j++ ) {
            for ( int k = 1; k <= n; k++ ) {
                for ( int l = 1; l <= m; l++ ) {
                    dist[k][l] = inf;
                }
            }

            dist[i][j] = inf;
            if ( c[i][j] != '#' ) dfs ( i, j, 0 );

            for ( int k = 1; k <= n; k++ ) {
                for ( int l = 1; l <= m; l++ ) {
                    if ( dist[k][l] != inf ) ans = max ( ans, dist[k][l] );
                }
            }
        }
    }

    cout << ans << endl;


    return 0;
}


















Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x,y,dx,dy,bx,by,s=0,f,min;
  scanf("%*d %*d %d",&n);
  scanf("%d %d",&bx,&by);
  while(--n){
    scanf("%d %d",&x,&y);
    dx=x-bx;
    dy=y-by;
    bx=x;
    by=y;
    if(dx*dy>0)f=1;
    else       f=0;
    min=dx=abs(dx);
    dy=abs(dy);
    if(min>dy)min=dy;
    s+=dx+dy-min*f;
  }
  printf("%d\n",s);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> xs(n);
  for(int i=0 ;i<n ;i++){
    long x;
    cin >> x;
    xs[i] = x;
  }
  vector<int> temp;
  temp.insert(temp.begin(),xs.begin(),xs.end());
  sort(temp.begin(),temp.end());
  int mid = temp[n/2];
  for(int x:xs){
    if(x<mid){
      cout << mid << endl;
    }else{
      cout << temp[n/2-1] << endl;
    }
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n; cin >> n;
  V a(n); cin >> a;
  
  ll ans = 0;
  rep(i, n) {
    if (i % 2 == 0 && a[i] % 2 == 1) ++ans;
  }

  cout << ans << '\n';
  return 0;
}


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

using namespace std;
int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if (a1 + a2 + a3 > 21)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
#define rep(i, s, n) for(int i = s;i<n;i++)

template<typename T>
bool vector_finder(std::vector<T> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

int main(void) {
    vector<long long int> list;
    int n;

    cin >> n;

    list.push_back(n);

    while (1) {
        n = (n % 2 == 0) ? n / 2 : 3 * n + 1;
        if (vector_finder<long long int>(list, n)) {
            cout << list.size() + 1 << endl;
            return 0;
        } else {
            list.push_back(n);
        }
    }
}


Measured memory_bytes: 256
n = int(input())
l_t = []
l_pos = []

l_pos.append([0, 0])
l_t.append(0)
# input
for i in range(n):
    a, b, c = (list)(map(int, input().split()))
    l_t.append(a)
    l_pos.append([b, c])


def manhattan(pos1, pos2):
    return abs(pos1[0]-pos2[0]) + abs(pos1[1]-pos2[1])


# check
ans = 'Yes'
for i in range(n):
    dis = manhattan(l_pos[i], l_pos[i+1])
    time = abs(l_t[i+1]-l_t[i])
    if dis > time:
        ans = 'No'
        break
    elif dis % 2 != time % 2:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 20836
/* 
   AOJ 1276
   Prime Gap
   2015/7/23
*/

#include<stdio.h>
#define MAX_PRIME 1500000

void get_prime_list(int* prime_list)
{
  int i, j;

  for(i = 0; i < MAX_PRIME; i++)
    {
      prime_list[i] = 1;
    }

  prime_list[0] = 0;
  prime_list[1] = 0;

  for(i = 0; i < MAX_PRIME; i++)
    {

      if(prime_list[i] == 1)
	{
	  for(j = i; i * j < MAX_PRIME && 0 < i * j; j++)
	    {
	      prime_list[i * j] = 0;
	    }
	}
    }
  
}

int count_length(int* prime_list)
{
  
}

int ans_f(int n, int* prime_list)
{
  int i, u_count = 0, d_count = 0;

  for(i = n; prime_list[i] != 1; i++)
    {
      u_count++;
    }

  for(i = n; prime_list[i] != 1; i--)
    {
      d_count++;
    }

  return u_count + d_count;
}


int main(void)
{
  int n, length, prime_list[MAX_PRIME];

  get_prime_list(prime_list);

  while(1)
    {
      scanf("%d", &n);
      if(n == 0)
	{
	  break;
	}
      length = ans_f(n, prime_list);
      printf("%d\n", length);
    }
  return 0;
}

Measured memory_bytes: 6456
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
#define MAX_N 255
using namespace std;

int p[8] = {1, 0, -1, 0, 1, 1, -1, -1}, q[8] = {0, 1, 0, -1, 1, -1, 1, -1};
string grid[MAX_N];

int search(int n) {
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < 8; k++) {
	int count = 0;
	int x = i, y = j;
	for ( ; ; ) {
	  if (x < 0 || y < 0 || x >= n || y >= n || grid[x][y] == '0') break;
	  count++;
	  x += p[k];
	  y += q[k];
	}
	maxi = max(maxi, count);
      }
    }
  }
  return maxi;
}

void init() {
  for (int i = 0; i < MAX_N; i++) {
    grid[i] = "\0";
  }
}

int main() {
  while (true) {
    init();
    int n;
    cin >> n;
    if (n == 0) return 0;
    for (int i = 0; i < n; i++) {
      cin >> grid[i];
    }

    int ans = search(n);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3272
<?php
  fscanf(STDIN, "%s", $S);
  $n = strlen($S);
  if ($n === 1) {
    echo "1";
    exit;
  }
  if ($n === 2) {
    if ($S[0] === $S[1]) {
      echo "1";
    } else {
      echo "2";
    }
    exit;
  }
 
  // 1文字目
  $dp[0] = 1;
  // 2文字目
  if ($S[0] === $S[1]) {
    $dp[1] = 1;
  } else {
    $dp[1] = 2;
  }
  // 3文字目
  if ($S[0] !== $S[1] && $S[1] !== $S[2]) {
      $dp[2] = 3;
  } else {
      $dp[2] = 2;
  }
  for ($i = 3; $i < $n; $i++) {
      if ($S[$i - 1] === $S[$i]) {
          $dp[$i] = $dp[$i - 3] + 2;
      } else {
          $dp[$i] = $dp[$i - 1] + 1;
      }
  }
  echo $dp[$n - 1];


Measured memory_bytes: 12788
a,b = map(int,input().split())
a0 = int(a/0.08)
a1 = int((a+2)/0.08)
def tmp():
    for i in range(a0,a1):
        if int(i *0.08) == a and int(i*0.1)==b:
            return i
    return -1
print(tmp())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  string S;
  cin >> S;
  
  int ans = 700;
  rep(i,3) {
    if (S[i] == 'o') ans += 100;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int h,w,i,j,k;
	char a[120][120];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++) scanf("%s", a[i]);
	for(i=0;i<h;i++)
	{
		k=1;
		for(j=0;j<w;j++)
		{
			if(a[i][j]!='.' && a[i][j]!='\0') k=0;
		}
		if(k==1)
		{
			for(j=0;j<w;j++) a[i][j]='\0';
		}
	}
	
	for(j=0;j<w;j++)
	{
		k=1;
		for(i=0;i<h;i++)
		{
			if(a[i][j]!='.' && a[i][j]!='\0') k=0;
		}
		if(k==1)
		{
			for(i=0;i<h;i++) a[i][j]='\0';
		}
	}
	
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(a[i][j]!='\0') printf("%c",a[i][j]);
		}
		printf("\n");
	}
	
	return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std; 
    
    
    
    int main() {
    int n,x;
    while(true){	
    cin >> n >> x;
    if(n == 0 && x == 0)	return 0;
    int count = 0;
    
    for(int i = 1; i <= n; i++){
    	for(int j = i+1; j <= n; j++){
    		int k = x - (i + j);
    		if(k > j && k <= n)	count++;
    	}
    }
    cout << count << endl; 
    }
     return 0;
    }
    


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<int,int> pt;
const int N=1e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************

//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
LL qpow(LL a,LL p)
{
    LL res=1;
    while(p){
        if(p&1) res=res*a%mod;
        a=a*a%mod;
        p>>=1;
    }
    return res;
}
LL inv(LL a)
{
    return qpow(a,mod-2);
}
int main()
{
    LL n,a,b;
    rrr(n,a,b);
    LL ans=qpow(2,n);
    ans=(ans+mod-1)%mod;
    LL t1=1,t2=1;
    FOR(i,1,a){
        t1=t1*(n-i+1)%mod;
        t1=t1*inv(i)%mod;
    }
    FOR(i,1,b){
        t2=t2*(n-i+1)%mod;
        t2=t2*inv(i)%mod;
    }
    ans=(ans+mod-t1+mod-t2)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  ll a[n+1]={};
  ll m,M;
  cin>>a[1];
  m=a[1];
  M=a[1];
  for(int i=2;i<=n;i++){
    cin>>a[i];
    m=min(m,a[i]);
    M=max(M,a[i]);
  }
  cout<<M-m<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

const ll INF = 1e9;
const long long INFL = 1LL<<60;

constexpr double PI = acos(-1);

int main() {
  int a, b, x;
  cin >> a >> b >> x;

  double rad;
  if (2 * x <= a * a * b) {
    rad = atan2(a * b * b, 2 * x);
  } else {
    rad = atan2(2 * b - 2 * x / double(a * a), a);
  }

  printf("%.10lf\n", rad * 180.0 / PI);

  return 0;
}


Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=100000000000000000;
ll are=1000000007;

int main() {
    while  (true){
        int n;
        cin >> n;
        if (n==0) break;
        vector<pp> a(n);
        rep(i,n){
            a.at(i).first=0;
            int u=0,y=0;
            cin >> a.at(i).second;
            rep(j,4){
                cin >> u >> y;
                a.at(i).first+=u*60+y;
            }
        }
        sort(a.begin(),a.end());
        cout << a.at(0).second << endl << a.at(1).second << endl <<  a.at(n-2).second << endl;
    }
}



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

int main() {
  int n;
  cin >> n;
  int ans[100000] = {0};
  for(int i = 1;i*i<=n;i++){
    for(int j = 1;j*j<=n;j++){
      for(int k = 1;k*k<=n;k++){
        int total = i*i+k*k+j*j+i*j+i*k+j*k;
        ans[total]++;
      }
    }
  }
  for(int i = 1; i <=n;i++){
    cout << ans[i] << endl;
  }
}


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

const int sz=2e5+100;

int main()
{

    int a,b,c,i,j,k,q,p,x,y,ct,ct1,l,r,x1,y1,mn,h,sum1,in,z,mid,mx,tot,n,m;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    
    cin>>str;

    int len=str.length();
    string ans;
    if(str[len-1]=='s') ans=str.substr(0,len)+"es";
    else  ans=str.substr(0,len)+"s";

    cout<<ans<<endl;
    
    
}



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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =998244353;
const ll maxn=100000;

int main()
{		
	
   
    IOS
    
    ll a,b;
    cin>>a>>b;
    if(a==b)
        cout<<1<<endl;
    else if((a+b)%2==0)
        cout<<(a+b)/2<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;

    
    



    
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N, M, Q;
ll a[55], b[55], c[55], d[55];
vector<ll> A;
ll dfs(ll prev){
	ll ret = 0;
	ll size = A.size();
	if(size == N){
		REP(i,0,Q){
			ret += (A[b[i]] - A[a[i]] == c[i]) * d[i];
		}
		return ret;
	}
	REP(i, prev, M+1){
		A.push_back(i);
		ret = max(dfs(i), ret);
		A.pop_back();
	}
	return ret;
}
int main(){
	cin >> N >> M >> Q;
	REP(i,0,Q){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}

	ll ans = dfs(1);
	p(ans);
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int INF = 3000000;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int min_num = INF, cnt = 0;
    rep(i, n){
        if (chmin(min_num, p[i])) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int ans=0;
    int a;
    if(n>=2000) ans=1;
    else{
        a=n/100;
        n=n%100;
        if(a*5>=n) ans=1;
    }
    cout<<ans;
}


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

int main() {
  int n, k;
  cin>>n>>k;
  int v[n];
  for (int i=0; i<n; i++) cin>>v[i];
  long long ans = -1e8;
  for (int left=0; left<=n; left++) {
    for (int right=0; left+right<=min(n, k); right++) {
      long long tmp = 0;
      vector<int> minus;
      for (int i=0; i<left; i++) {
        tmp += v[i];
        if (v[i] < 0) {
          minus.push_back(v[i]);
        }
      }
      for (int i=0; i<right; i++) {
        tmp += v[n-1-i];
        if (v[n-1-i] < 0) {
          minus.push_back(v[n-1-i]);
        }
      }
      sort(minus.begin(), minus.end());
      for (int i=0; i<k-(left+right); i++) {
        if (i >= minus.size()) {
          break;
        }
        tmp -= minus[i];
      }
      ans = max(tmp, ans);
    }
  }
  cout<<ans<<endl;
}

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

const int MOD = 1e9 + 7, MAX = 2002, MAX_N = 200000;
int A[MAX * 2][MAX * 2], B[MAX * 2][MAX * 2];
pair<short, short> P[MAX_N];
long long sum_1 = 0, sum_2 = 0, sum_3 = 0;

int main(){
	int n; cin >> n;
	for (int i = 1; i < MAX * 2; i++)
	{
		B[i][0] = B[0][i] = 1;
	}
	for (int i = 1; i < MAX * 2; i++)
	{
		long long x;
		for (int j = 1; j < MAX * 2; j++){
			x = (B[i-1][j] + B[i][j-1]) % MOD;
			B[i][j] = x;
		}
	}

	for (int i = 0; i < n; i++)
	{
		short a, b; cin >> a >> b;
		P[i] = make_pair(a, b);
		sum_1 = (sum_1 + B[a * 2][b * 2]) % MOD;
		A[2001 - a][2001 - b] += 1;
	}

	for (int i = 1; i < MAX * 2; i++)
	{
		long long x;
		for (int j = 1; j < MAX * 2; j++){
			x = (A[i][j] + A[i-1][j] + A[i][j-1]) % MOD;
			A[i][j] = x;
		}
	}
	
	for (int i = 0; i < n; i++)
	{
		sum_2 = (sum_2 + A[2001 + P[i].first][2001 + P[i].second]) % MOD;
	}
	long long ans = (sum_2 + MOD - sum_1) * (MOD + 1) / 2 % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 126336
#include <stdio.h>
#include <string.h>
int main(){
  int a,b,len;
  char s[20];
  scanf("%d%d%s",&a,&b,s);
  len = strlen(s);
  for(int i=0;i<a;i++){
    if(s[i]=='-'){
      printf("No");
      return 0;
    }
  }
  if(s[a]!='-'){
    printf("No");
    return 0;
  }
  for(int i=a+1;i<a+b+1;i++){
    if(s[i]=='-'){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int dp[100001];
  dp[0] = 0;
  dp[1] = 1;
  int c[12] = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
  for (int i = 2; i <= 100000; i++) {
    dp[i] = i;
    for (int j = 0; j < 12; j++) {
      if (i >= c[j]) {
        dp[i] = min(dp[i],dp[i-c[j]] + 1);
      }
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
namespace ABC125_A
{
    using static System.Console;
    using System.Linq;
    using System.Collections.Generic;

    public class Program
    {
        static void Main(string[] args)
        {
            var line = ReadInputsAsInt().ToList();

            WriteLine(Solve(line[0], line[1], line[2]));
        }

        public static int Solve(int a, int b, int t) => b * (int)((t + 0.5) / (double)a);

        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if((v - w) * t >= abs(b - a))pf("YES");
    else pf("NO");
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <cmath>
#include <vector>
#include <string>
using namespace std;


int main() {
  long long X, K, D;
  cin >> X >> K >> D;

  long long idealP = K / 2 - X / D / 2;

  long long p, ans = min(abs(X - K*D), abs(X + K*D));
  for (int d = -2; d <= 2; d++) {
    p = idealP + d;
    if (p >= 0 && p <= K) ans = min(ans, abs(X-K*D + 2*D*p));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
char a[101];
int main()
{
	int n;
	int sum=0;
	int max=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		if(a[i]=='I')sum++;
		if(a[i]=='D')sum--;
		if(sum>max)max=sum;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
long long int dp[51][2501];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, A;
    long long int ans = 0;
    vector<int> vals(N);
    cin >> N >> A;
    for(int i = 0; i < N; i++){
        cin >> vals[i];
    }
    dp[0][0] = 1;
    for(int i = 0; i < N; i++){
        for(int l = N; l > 0; l--){
            for(int m = 0; m < 2501; m++){
                    if(m >= vals[i])
                dp[l][m] += dp[l-1][m-vals[i]];
            }
        }
    }
    for(int i = 1; i <= N; i++){
        ans+=dp[i][A*i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 17664
//gcc -std=gnu11 -O2 -o a.out Main.c -lm
//http://abc043.contest.atcoder.jp/tasks/abc043_b
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include <math.h>
#include <string.h>

int main(void)
{
#define N_MAX	10

	int ret;
	int i,j;
	char strBuf[N_MAX+1];
	
	//-------------------------------------
	//Input process
	//-------------------------------------
	memset(strBuf, 0x00,sizeof(strBuf));
	ret = scanf("%s", strBuf);

	//-------------------------------------
	//Calc process
	//-------------------------------------
	for(i=0;i<sizeof(strBuf);i++){
		if(strBuf[i]==0x00){
			break;
		}
		if(strBuf[i] == 'B'){
			if(i){
				memmove(&strBuf[i-1], &strBuf[i+1], (sizeof(strBuf)-i)+1 );
		}else{
				memmove(&strBuf[0], &strBuf[i+1], (sizeof(strBuf)-1) );
			}
			i=-1;
		}
	}

	//-------------------------------------
	//Output process
	//-------------------------------------
	printf("%s\n", strBuf);

	return(0);
}







Measured memory_bytes: 128
x,k,d=map(int,input().split())
x=abs(x) 

if x%d==0:
    minNear  = x%d + d
    minFar = x%d
    minTransitionToNear = (x-minNear)/d
    #print(minNear)
    #print(minFar)
    #print(minTransitionToNear)
    
else:
    minNear  = x%d
    minFar = x%d - d
    minTransitionToNear = (x-minNear)/d
    #print(minNear)
    #print(minFar)
    #print(minTransitionToNear)
    
if k<minTransitionToNear:
    print(x-k*d)
else:
    if (k-minTransitionToNear)%2==0:
        print(abs(minNear))
    else:
        print(abs(minFar))

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

int main() {
  string S;
  cin >> S;
  
  vector<string> vec = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  
  for (int i = 0; i < 7; i++){
    if (S == vec.at(i)){
      cout << 7 - i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        int b;
        cin >> b;
        a[i] = b - (i+1);
    }
    sort(a.begin(),a.end());
    ll ans;
    if(n%2==0){
        int b,c;
        b = a[n/2-1];
        c = a[n/2];
        ll b_sum=0,c_sum=0;
        rep(i,n){
            b_sum += abs(a[i]-b);
            c_sum += abs(a[i]-c);
        }
        if(b_sum<0) b_sum = LINF;
        if(c_sum<0) c_sum = LINF;
        ans = min(b_sum,c_sum);
    }else{
        int b = a[n/2];
        ll tmp=0;
        rep(i,n){
            tmp += abs(a[i]-b);
        }
        ans = tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			char[] cdata = sc.nextLine().toCharArray();
			if ( cdata.length==1 && cdata[0]=='0' ) break;

			int sum =0;

			int[] idata = new int[cdata.length];
			for (int i=0; i < cdata.length; i++) {
				idata[i] = Character.getNumericValue( cdata[i] );
				sum += idata[i];
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);

	}

}

Measured memory_bytes: 26356
#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 main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll d, n;
    cin >> d >> n;
    if (n == 100)
        n++;
    for (int i = 0; i < d; ++i)
        n *= 100;
    cout << n;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
BC = [tuple(map(int, input().split())) for _ in range(Q)]
total = sum(A)

A_dict = {}
for a in A:
    if a in A_dict:
        A_dict[a] += 1
    else:
        A_dict[a] = 1

for i in range(Q):
    b = BC[i][0]
    c = BC[i][1]

    if b in A_dict:
        total += (c - b) * A_dict[b]
        print(total)
        
        if c in A_dict:
            A_dict[c] += A_dict[b]
        else:
            A_dict[c] = A_dict[b]
        A_dict[b] = 0
    
    else:
        print(total)

Measured memory_bytes: 47500
s = list(map(int, input().split()))
n = s[0]
k = s[1]

a = []
d = []
kashi = []
for i in range(k):
    dapp = int(input())
    d.append(dapp)
    aapp = list(map(int, input().split()))
    a.append(aapp)

for i in range(n):
    kashi.append(False)

for i in range(k):
    for j in range(d[i]):
        kashi[a[i][j] - 1] = True

count = 0
for i in range(n):
    if not kashi[i]:
        count = count + 1

print(count)


Measured memory_bytes: 9208