akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  zjsdut
 *    created: 2020/03/23 15:41:02
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define rep(n)                                                                 \
  for (int TOKENPASTE2(_iter_, __LINE__) = 0,                                  \
                               TOKENPASTE2(_num_, __LINE__) = (int)(n);        \
       TOKENPASTE2(_iter_, __LINE__) < TOKENPASTE2(_num_, __LINE__);           \
       ++TOKENPASTE2(_iter_, __LINE__))
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL && !defined DUIPAI
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  ll n, a, b;
  scan(n, a, b);
  ll ans = n / (a + b) * a;
  ans += min(a, n % (a + b));
  println(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		boolean accepted=false;
		int Cp=0;
		if(str.charAt(0)=='A') {
			twoloop:for(int k=2;k<str.length()-1;k++) {
				if(str.charAt(k)=='C') {
					for(int j=0;j<str.length();j++) {
						if(str.charAt(j)=='C') {
							Cp++;
							continue;
						}
						if(str.charAt(j)=='A') continue;
						if(Character.isUpperCase(str.charAt(j))==true){
							break twoloop;
						}
					}
					accepted=true;
					break;
				}
			}
		}
		//System.out.println(Cp);
		if(accepted&&Cp==1) {
			System.out.println("AC");
		}else {
			System.out.println("WA");
		}
	}

}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		HashMap<Character, Integer> hist = new HashMap<Character, Integer>();
		for (char c : str.toCharArray()) {
			if (hist.containsKey(c)) {
				hist.put(c, hist.get(c) + 1);
			} else {
				hist.put(c, 1);
			}
		}
		if (hist.size() == 2 && hist.get(str.charAt(0)) == 2)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21076
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;

static const int MAX = 200000;
int main(){
    int n;
    cin >> n;

    vector<int> A;
    int x;
    for (int i = 0; i < n; i++){
        scanf("%d", &x);
        A.push_back(x);
    }

    int j = n + 1;
    for (int i = 0; i < n; i++){
        if (A[i] == 1) j = 1;
        else if (A[i] == j + 1) j++;
    }

    cout << n - j << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<vector<pair<ll,ll>>> E(N);
    REP(i,N-1) {
        ll a,b,c;
        cin>>a>>b>>c;
        E[a-1].pb(make_pair(b-1,c));
        E[b-1].pb(make_pair(a-1,c));
    }

    int Q,K;
    cin>>Q>>K;
    vector<ll> dist(N,0);
    vector<bool> used(N,false);
    queue<int> que;
    que.push(K-1);
    used[K-1] = true;

    while (que.size()) {
        int from = que.front();
        que.pop();
        REP(i,E[from].size()) {
            pair<ll,ll> p = E[from][i];
            if (!used[p.first]) {
                dist[p.first] = dist[from] + p.second;
                used[p.first] = true;
                que.push(p.first);
            }
        }
    } 

    vector<int> x(Q),y(Q);    
    REP(i,Q) cin>>x[i]>>y[i];
    REP(i,Q) cout<<dist[x[i]-1]+dist[y[i]-1]<<endl;

    return 0;
}

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

const long long MOD = 1000000007;

int main(void) {
    long long N, K;
    std::cin >> N >> K;

    long long ans = 0;
    for (long long i = K; i <= N + 1; i++) {
        ans = (ans +
               (N * (N + 1) / 2 - (N - i) * (N - i + 1) / 2 - i * (i - 1) / 2) +
               1) %
              MOD;
    }

    printf("%lld\n", ans);

    return 0;
}


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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    string ans;
    for(int i = A; i <= B; i++){
        if(i%K == 0){
            ans = "OK";
            break;
        }
        if(i == B){
            ans = "NG";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    static Scanner sc;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();
        
        int[][] mins = new int[n][26];
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            for (int j = 0; j < s.length(); j++) {
                char c = s.charAt(j);
                mins[i][c - 'a']++;
            }
        }
        String ans = "";
        for (int i = 0; i < 26; i++) {
            int min = 999999;
            for (int j = 0; j < n; j++) {
                min = Math.min(min, mins[j][i]);
            }
            for (int j = 0; j < min; j++) {
                ans += (char)('a' + i);
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 55;
int n,m,D,fa,lim,mx;
vector<int> G[N];
il add_edge(int u,int v){ G[u].push_back(v); }
struct Node{
	ll val,w,id;
	bool operator < (const Node &t) const {
		return w*t.val>t.w*val;
	}
}node[N];
ll ans,val[N],w[N],f[N*N*N];
// f[i] ±íÊ¾µÃµ½ i µÄ¼ÛÖµ£¬ÖÁÉÙÐèÒª¶àÉÙÖØÁ¿ 
il Insert(ll w,ll v){for(ri i=mx;i>=w;--i) f[i]=min(f[i],f[i-w]+v); }
il Updata(Node t){
	int x=lim;
	for(ri i=0;(1<<i)<=x;++i){
		Insert(t.w*(1<<i),t.val*(1<<i));
		x-=1<<i;
	}
	if(x) Insert(t.w*x,t.val*x);
}
il DFS(int u,int fa){
	w[u]=1;
	for(auto v:G[u]) DFS(v,u),val[u]+=val[v],w[u]+=w[v];
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m),read(D),read(val[1]);
	for(ri i=2;i<=n;++i) read(val[i]),read(fa),add_edge(fa,i);
	DFS(1,0),lim=min(n,D),mx=n*n*n;
	for(ri i=1;i<=n;++i) node[i]=(Node){ val[i],w[i],i };
	for(ri i=1;i<=mx;++i) f[i]=1e18;
	for(ri i=1;i<=n;++i) Updata(node[i]);
	sort(node+1,node+1+n);
	while(node[n].id^1) --n;
	for(ri i=0;i<=mx;++i){
		if(f[i]>m) continue;
		ll v=f[i],w=i;
		for(ri j=1;j<n;++j){
			ll k=min(1ll*D-lim,(m-v)/node[j].val);
			v+=k*node[j].val,w+=k*node[j].w;
		}
		ll k=(m-v)/node[n].val;
		ans=max(ans,w+k*node[n].w);
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 typedef pair<int,int> P;
 
 int main()
 {
   int n;
   while(cin>>n)
   {
     long long int count=0;
     if(n<=1000)
     {
       for(int i=0;i<=n;i++) count+=((i+2)*(i+1)/2);
       cout<<count<<endl;
       //printf("%lld\n",count);  
     }
     else
     {
       long long int count=0;
       //vector<P> mm1;
       //vector<P> mm2;
       ///vector<P>::iterator iter;
       int arr[2000+5]={0};
       int arr2[2000+5]={0};
       for(int a=0;a<=1000;a++)
       {
         if((n-a)>3000||(n<a)) continue;
         for(int b=0;b<=1000;b++)
         {
           if((n-a-b)>2000||(n<(a+b))) continue;
           else arr[a+b]++;        
         }        
       }
       for(int c=0;c<=1000;c++)
       {
         if((n-c)>3000) continue;
         for(int d=0;d<=1000;d++)
         {
           if((n-c-d)<0||(n-c-d)>2000) continue;
           else arr2[n-c-d]++;        
         }        
       }
       for(int i=0;i<=2000;i++)
       {
         if((arr[i])&&(arr2[i]))
         {
           count+=arr[i]*arr2[i];                      
         }                                            
       }
       cout<<count<<endl;
       //printf("%lld,",count);
     }
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3104
import sys
n, k = map(int, input().split())
a = list(map(int, input().split()))

dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
  for j in range(i+1, i+k+1):
    if(j<n):
      dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]))
print(dp[n-1])


Measured memory_bytes: 52448
#include<bits/stdc++.h>
using namespace std;
double dp[3000][3000];
double solve(vector<double>&v,int n, int m)
{
    if(m<=0)
    return 1;
    if(n==0)
    return 0;
    if(dp[m][n]>-0.9)
    return dp[m][n];
    return dp[m][n] = v[n]*solve(v,n-1,m-1) + (1-v[n])*solve(v,n-1,m);
}
int main()
{
    int n;
    cin>>n;
    memset(dp,-1,sizeof dp);
    vector<double>v(n+1);
    double ele;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    cout<<fixed<<setprecision(10)<<solve(v,n,(n+1)/2);
}


Measured memory_bytes: 70912
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, A, B = list(map(int, sys.stdin.readline().split()))


# dp = np.ones(W, dtype=int)
# for h in range(1, H - A):
#     dp = dp.cumsum() % MOD
# for h in range(H - A, H):
#     dp[B:] = dp[B:].cumsum() % MOD
# print(dp[-1])


def get_factorials(max, mod=None):
    """
    階乗 0!, 1!, 2!, ..., max!
    :param int max:
    :param int mod:
    :return:
    """
    ret = [1]
    n = 1
    if mod:
        for i in range(1, max + 1):
            n *= i
            n %= mod
            ret.append(n)
    else:
        for i in range(1, max + 1):
            n *= i
            ret.append(n)
    return ret

def mod_inv(a, mod):
    """
    a の逆元
    :param int a:
    :param int mod:
    :return:
    """
    return pow(a, mod - 2, mod)


factorials = get_factorials(H + W, MOD)


def ncr(n, r, mod=None):
    """
    scipy.misc.comb または scipy.special.comb と同じ
    組み合わせの数 nCr
    :param int n:
    :param int r:
    :param int mod: 3 以上の素数であること
    :rtype: int
    """
    if n < r:
        return 0

    return factorials[n] * mod_inv(factorials[r], mod) * mod_inv(factorials[n - r], mod) % mod


ans = 0
for i in range(W - B):
    ans += ncr((H - A - 1) + (W - i - 1), W - i - 1, MOD) * ncr((A - 1) + i, i, MOD)
    ans %= MOD
print(ans)


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

int main()
{
    long long int i,j,k,a,b,c,d,n;
    vector <long long int> v2;
    cin>>n;
    j=0;

    for(i=0;i<n;i++)
    {
        cin>>a;
        //v1.push_back(a);
        v2.push_back(a);
        //reverse(v2.begin(),v2.end());
    }
    if(n%2==0)
    {
        if(n>2)
         a=2;
        else
          a=-1;
        b=n-1;
        while(b>=1)
       {
        cout<<v2[b];
        b-=2;
        cout<<" ";
       }
       cout<<v2[0]<<" ";
       while(a<n)
       {
           cout<<v2[a];
           a+=2;
           if(a!=(n-1))
            cout<<" ";
       }
       cout<<"\n";
    }
    else
    {
        a=n-1;
        if(n>1)
            b=1;
        else
            b=-1;

        while(a>=2)
        {
            cout<<v2[a];
            a-=2;
            cout<<" ";
        }
        cout<<v2[0]<<" ";
        while(b<n && b!=-1)
        {
            cout<<v2[b];
            b+=2;
            if(b!=(n-1))
                cout<<" ";
        }
        cout<<"\n";
    }


    return 0;
}


Measured memory_bytes: 3824
use std::str::FromStr;
use std::io::stdin;
use std::collections::VecDeque;

fn main() {
    let (n, q) = {
        let vec: Vec<usize> = read_vec();
        (vec[0], vec[1])
    };
    let mut tree: Vec<Vec<usize>> = Vec::with_capacity(n);
    let mut values: Vec<u64> = Vec::with_capacity(n);
    let mut visites: Vec<bool> = Vec::with_capacity(n);
    for _ in 0..n {
        tree.push(Vec::new());
        values.push(0);
        visites.push(false);
    }
    for _ in 0..(n - 1) {
        let (a, b) = {
            let vec: Vec<usize> = read_vec();
            (vec[0], vec[1])
        };
        tree[a - 1].push(b - 1);
        tree[b - 1].push(a - 1);
    }
    for _ in 0..q {
        let (p, x) = {
            let vec: Vec<usize> = read_vec();
            (vec[0], vec[1])
        };
        values[p - 1] += x as u64;
    }
    let mut queue: VecDeque<usize> = VecDeque::new();
    queue.push_back(0);
    while !queue.is_empty() {
        let i = queue.pop_front().unwrap();
        visites[i] = true;
        for &j in &tree[i] {
            if !visites[j] {
                values[j] += values[i];
                queue.push_back(j);
            }
        }
    }
    println!("{}", values.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 34940
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    if(n%1000 == 0) cout << 0 << endl;
    else cout << 1000-(n%1000) << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string s;
    cin>>s;
    int count = 700;
    if (s[0]=='o') count+=100;
    if (s[1]=='o') count+=100;
    if (s[2]=='o') count+=100;
    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long[] count = new long[5];
        List<Character> symbols = new ArrayList<Character>() {
            {
                add('M');
                add('A');
                add('R');
                add('C');
                add('H');
            }
        };
        for (int i = 0; i < N; i++) {
            String name = sc.next();
            int index = symbols.indexOf(name.toCharArray()[0]);
            if (index != -1) {
                count[index] = count[index] + 1;
            }
        }

        long ans = 0;
        for (int i = 0; i < symbols.size(); i++) {
            for (int j = i + 1; j < symbols.size(); j++) {
                for (int k = j + 1; k < symbols.size(); k++) {
                    ans += count[i] * count[j] * count[k];
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 44312
import java.util.*;
import java.lang.Math;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    
    String a = "";
    
    for (int i = 0; i < S.length(); i ++) {
      a += "x";
    }
    System.out.println(a);
  }
}

Measured memory_bytes: 21972
#include<stdio.h>
int m[52][52];
void F(int x,int y)
{
	if(m[y][x])
	{
		m[y][x]=0;
		int i,j;
		for(i=-1;i<2;++i)for(j=-1;j<2;++j)F(x+i,y+j);
	}
}
int main()
{
	int h,w,i,j,r;
	while(scanf("%d%d",&w,&h),w)
	{
		for(i=1;i<=h;++i)for(j=1;j<=w;++j)scanf("%d",&m[i][j]);
		for(i=0;i<h+2;++i)m[i][w+1]=0;
		for(r=j=0;j<w+2;++j)m[h+1][j]=0;
		for(i=1;i<=h;++i)for(j=1;j<=w;++j)if(m[i][j])F(j,i),++r;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
  string s; cin >> s;
  if(s[0] == '1') s[0] = '9'; 
  else if(s[0] == '9') s[0] = '1';
  if(s[1] == '1') s[1] = '9'; 
  else if(s[1] == '9') s[1] = '1';
  if(s[2] == '1') s[2] = '9'; 
  else if(s[2] == '9') s[2] = '1';
  cout << s << endl;
}

Measured memory_bytes: 256
import numpy as np

H,W = map(int,input().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:-1] = (np.array([list(input()) for _ in range(H)]) == '.')

L = grid.size
a = np.arange(L)

# x軸方向の集計
def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  
  left_zero = -a.copy() # 左の壁のindexの-1倍
  left_zero[x] = 0
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = a.copy() # 逆順ソートした上で左の壁のindex
  right_zero[x[::-1]] = 0
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)


Measured memory_bytes: 192680
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

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

        // 主処理
        String result = s.replace("hi", "").length() == 0 ? "Yes" : "No";

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

Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    int n,n2; cin >> n >> n2;
    double ans = n*n2;
    ans/=3.305785;
    printf("%f\n",ans);
    return 0;
}

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

int main() {  
    int n;
    char s;
    cin >> n;
    for ( int i = 0; i < n; i++) {
        cin >> s;
        if ( s == 'Y') {
            cout << "Four" << endl;
            break;
        }
        
        if ( i == n-1 && s != 'Y') {
            cout << "Three" << endl;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
h = [int(_) for _ in input().split()] + [0]*N
dp = [float('inf')]*(N*2)
dp[0] = 0
dp[1] = abs(h[0]-h[1])
    
for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
    
print(dp[N-1])

Measured memory_bytes: 14056
#include <cstdio>
double a, b;
int main()
{
	while(~scanf("%lf %lf", &a, &b))
	{
		if(a > b)
			printf("GREATER\n");
		else if (a < b)
			printf("LESS\n");
		else
			printf("EQUAL\n");
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>

using namespace std;
static const int N=100;
static const int INFTY=(1<<21);

int n,m[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i=0;i<n;i++) d[i]=INFTY;
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(m[u][v]==0) continue;
      if(d[v]!=INFTY) continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<< ((d[i]==INFTY)?(-1):d[i])<<endl;
  }
}

int main(){
  int u,k,v;

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

  for(int i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(int j=0;j<k;j++){
      cin>>v;
      v--;
      m[u][v]=1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..

int main(void) {
  int n;
  cin >> n;
  ll a[n];
  rep (i, n) cin >> a[i];

  vector<ll> sum(n + 1, 0);

  rep (i, n) {
    sum[i + 1] = a[i] + sum[i];
  }

  map<ll, ll> cnt;
  rep (i, n + 1) cnt[sum[i]]++;

  ll ans = 0;

  for (auto x: cnt) {
    ll tmp, num;
    tie(tmp, num) = x;
    num--;
    if (num) {
      ans += (ll) num * (num + 1) / 2; 
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5+10 , M = 5e5+10, OO = 0x3f3f3f3f ,  MOD = 1e9+7;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 


int n , k, w[N],v[N];
ll dp[105][N];


ll solve(int idx, int remW){

    if(remW < 0) return -OO;
    if(idx == n) return 0;
    ll& ret = dp[idx][remW];
    if(~ret) return ret;
    return ret = max(solve(idx+1 , remW-w[idx])+v[idx] , solve(idx+1 , remW));

}


    
int main(){
    

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);

    
    scanf("%d %d",&n,&k);
    loop(i, n)
        scanf("%d %d",w+i, v+i);


    memset(dp , -1, sizeof dp);
    printf("%lld\n",solve(0 , k));

    


    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  int N,K; cin >> N >> K;
  int ans;
  if( (N-1) % (K-1) == 0){
    ans = (N-1) / (K-1);
  } else { 
    ans = (N-1) / (K-1) + 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    while(1){
        if(n/100==n%10&&n%10==(n%100)/10){
            break;
        }
        else{
            n++;
        }
    }
    cout << n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#define GRAPH_MATRIX_SIZE 256

typedef enum {
  WHITE,
  GRAY,
} color_t;

typedef struct {
  uint32_t index;
  size_t len;
  uint32_t array[GRAPH_MATRIX_SIZE];
  color_t color;
} graph_vertex_t;

extern bool graph_converts_to_matrix(graph_vertex_t vertexes[], size_t len, uint32_t matrix[][GRAPH_MATRIX_SIZE]);
typedef void (*graph_depth_first_search_callback_t)(uint32_t);
extern void graph_depth_first_search(graph_vertex_t *vertex, size_t num, graph_depth_first_search_callback_t callback_pre,
                                     graph_depth_first_search_callback_t callback_post);

static void aux(graph_vertex_t *vertexes, uint32_t index, graph_depth_first_search_callback_t callback_pre,
                graph_depth_first_search_callback_t callback_post)
{
  graph_vertex_t *vertex = &vertexes[index - 1];
  vertex->color = GRAY;
  if (callback_pre) callback_pre(vertex->index);

  if (vertex->len > 0) {
    uint32_t i;
    for (i = 0; i < vertex->len; i++) {
      uint32_t next_vertex_index = vertex->array[i];
      if (vertexes[next_vertex_index - 1].color == WHITE) {
        aux(vertexes, next_vertex_index, callback_pre, callback_post);
      }
    }
  }
  if (callback_post) callback_post(vertex->index);
}

void graph_depth_first_search(graph_vertex_t *vertexes, size_t num, graph_depth_first_search_callback_t callback_pre,
                              graph_depth_first_search_callback_t callback_post)
{
  if ((vertexes == NULL) || (num == 0)) return;

  uint32_t i;
  for (i = 0; i < num; i++) {
    if (vertexes[i].color == WHITE) {
      aux(vertexes, i + 1, callback_pre, callback_post);
    }
  }

  return;
}

#if !defined(TEST)
#include <stdio.h>
#define VERTEXES 256
static graph_vertex_t vertexes[VERTEXES];
static uint32_t cnt = 0;
static uint32_t timestamp[VERTEXES][2];

static void callback_pre(uint32_t index)
{
  cnt++;
  timestamp[index - 1][0] = cnt;
}

static void callback_post(uint32_t index)
{
  cnt++;
  timestamp[index - 1][1] = cnt;
}

int32_t main(void)
{
  uint32_t num;
  scanf("%u", &num);

  uint32_t i, j;
  for (i = 0; i < num; i++) {
    scanf("%u", &vertexes[i].index);
    scanf("%lu", &vertexes[i].len);
    for (j = 0; j < vertexes[i].len; j++) {
      scanf("%u", &vertexes[i].array[j]);
    }
    vertexes[i].color = WHITE;
  }

  graph_depth_first_search(vertexes, num, callback_pre, callback_post);

  for (i = 0; i < num; i++) {
    printf("%u %u %u\n", i + 1, timestamp[i][0], timestamp[i][1]);
  }
  return 0;
}
#endif

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

int main(){
    int N;
    string S;
    scanf("%d", &N);
    cin >> S;

    if (S.length() <= N) cout << S << "\n";
    else {
        for (int i=0; i<N; i++)
            cout << S[i];
        cout << "...\n";
    }
    return 0;
}


Measured memory_bytes: 3688
program answer
  implicit none

  character(len=50) :: S
  integer :: i, N, count

  read(*,*) N
  read(*,*) S

  count = 0
  do i = 1, N-2
     if(S(i:i+2)=='ABC') then
        count = count + 1
     end if
  end do

  write(*,*) count
  stop
 end program answer


Measured memory_bytes: 2852
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;x=x*x%mod;y>>=1;}return res;}
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
inline ll lcm(ll a,ll b){return a * b / __gcd(a, b);}
//int t,n,m,k;
double a,b,h,m;
int main()
{
    cin>>a>>b>>h>>m;
    double x=pai/6*(h+m/60)-m*pai/30;
    if(x<0) x=-x;
    double s=sqrt(a*a+b*b-2*a*b*cos(x));
    printf("%.10f\n",s);
    return 0;
}


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

using namespace std;

#define ll                long long

static const int maxn = 6e5 + 5;

int cumsum[maxn];

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);


      int n, maxi;
      cin >> n >> maxi;
      int sum = 0;
      int ans = 1;
      for (int i = 1; i <= n; i++)
      {
            int x;
            cin >> x;
            sum += x;
            if (sum <= maxi) ++ans;
      }
      cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

const ll MaxN=1e5+5;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main(){
	ll n;
	cin>>n;
	cout<<48-n<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mod 1000000007
#define MN 2001
#define MM 200005
using namespace std;
inline int in(){
    int x=0;bool f=0; char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
int fct[(MN<<2)+5],inv[(MN<<2)+5],x[MM],y[MM];
int f[(MN<<1)+5][(MN<<1)+5],n,res;
inline int qpow(int x,int k){
	int res=1;
	while (k){
		if (k&1) res=(1ll*res*x)%mod;x=(1ll*x*x)%mod;k>>=1;
	}return res;
}
inline int getc(int x,int y){
	return (1ll*fct[x]*inv[y]%mod*inv[x-y]%mod);
}
int main()
{
	fct[0]=1;n=in();
	for (int i=1;i<=(MN<<2);++i) fct[i]=(1ll*fct[i-1]*i)%mod;
	inv[MN<<2]=qpow(fct[MN<<2],mod-2)%mod;
	for (int i=((MN<<2)-1);i>=0;--i) inv[i]=(1ll*inv[i+1]*(i+1ll))%mod;
	for (int i=1;i<=n;++i) x[i]=in(),y[i]=in(),++f[MN-x[i]][MN-y[i]];
	for (int i=1;i<=(MN<<1);++i)
	for (int j=1;j<=(MN<<1);++j) f[i][j]=(1ll*f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for (int i=1;i<=n;++i) res=(1ll*(res+f[x[i]+MN][y[i]+MN])%mod-1ll*getc(((x[i]+y[i])<<1),(x[i]<<1))+mod)%mod;
	res=(1ll*res*inv[2])%mod;printf("%d",res);return 0;
}

Measured memory_bytes: 64512
n=int(input())
A=list(map(int,input().split()))
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
ans=0
C=Counter(A)
for i,v in C.items():
    if i>v:
        ans+=v
    if i<v:
        ans+=v-i
print(ans)

Measured memory_bytes: 98004
#include<cstdio>
double a,b,c,d,e,f;
void C(double *p,double *q)
{
    double t=*p;
    *p=*q;
    *q=t;
}
int main()
{
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)==6)
    {
        if(a==0)
        {
            C(&a,&d);
            C(&b,&e);
            C(&c,&f);
        }
        double x,y=(f-d*c/a)/(e-b*d/a);
        x=c/a-b*y/a;
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 1080
#include<stdio.h>
#include<math.h>
#define MAX 2000000

int H, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest;
  int temp;
  l = 2 * i;
  r = 2 * i +1;

  //右の子と左の子と自分で値が一番大きいノードを選ぶ//
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;

  if(largest != i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    maxHeapify(largest);
  }
}

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

  for(int i=1;i<=H;i++)scanf("%d",&A[i]);

  for(int i = H/2;i>=1;i--)maxHeapify(i);//番号を下から上に上げる様にカウントするので//
                                         //右→左→上と計算される//
  for(int i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MOD			1000000007
#define FOR(i,l,r)	for(int i=l;i<=r;i++)
#define REP(i,n)	for(int i=1;i<=n;i++)
#define REP0(i,n)	for(int i=0;i<n;i++)
#define PB			push_back
#define MP			make_pair
#define PII			pair<int,int>
#define VI			vector<int>
#define ALL(x)		(x).begin(),(x).end()
int n,a[55];
double cur;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	sort(a+1,a+1+n);
	cur=a[1];
	for(int i=2;i<=n;i++){
		cur=(cur+a[i]*1.0)/2.0;
	}
	cout<<setprecision(9)<<cur<<endl;
	return 0;
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	
	int tmp = a[2] - a[0];
	int ans = a[2] - a[1];
	if((tmp - ans) % 2 == 0){
		ans += (tmp - ans) / 2;
	}
	else{
		ans += (tmp - ans) / 2 + 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e6+10;
const int Mod=1e9+7;

int N;
long long Fal[maxm],Inv1[maxm],Inv2[maxm],DP[maxm];

inline long long C(int x,int y){
	return Fal[x]*Inv2[y]%Mod*Inv2[x-y]%Mod;
}

int main(){
	register int i,Max;
	register long long Ans=0;
    scanf("%d",&N);
    Max=(N+1)>>1;
    Fal[0]=Fal[1]=Inv1[0]=Inv1[1]=Inv2[0]=Inv2[1]=1;
	for(i=2;i<=N;i++){
		Fal[i]=Fal[i-1]*i%Mod;
		Inv1[i]=(Mod-Mod/i)*Inv1[Mod%i]%Mod;
		Inv2[i]=Inv2[i-1]*Inv1[i]%Mod;
	}
	for(i=Max;i<N;i++){
		DP[i]=C(i-1,N-i-1)*Fal[i]%Mod*Fal[N-i-1]%Mod;
	}
	for(i=Max;i<N;i++){
		Ans=(Ans+(DP[i]-DP[i-1])*i)%Mod;
	}
	Ans=(Ans+Mod)%Mod;
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 29440
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a,b;

int main(){
	cin>>a>>b;
	cout<<(a>9||b>9?-1:a*b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n,m;
  cin>>n>>m;
  vi p(m), y(m);
  unordered_map<int, vector<pii>> buf;  // pref => (year, id)
  rep(i,m){
    cin >> p[i] >> y[i];
    buf[p[i]].pb({y[i],i});
  }
  vector<ll> ans(m);
  rep(pref,1,n+1){
    sort(all(buf[pref]));
    ll id_base = (ll)(pref) * 1000000LL;
    int i = 1;
    for(auto year_id : buf[pref]){
      ll id = id_base + i;
      ans[year_id.second] = id;
      i++;
    }
  }
  dump(ans);
  rep(i,m){
    printf("%012lld\n", ans[i]);
  }
  return 0;
}


Measured memory_bytes: 11940
#include<stdio.h>
int main(void){
int n,max=-1000001,min=1000001;
long long sum=0;
scanf("%d",&n);
if(0<n&&n<=10000){
int i;
long number;
for(i=0;i<n;i++){
if(scanf("%ld",&number)==1){
if(-1000000>number||number>1000000)
return 0;
sum+=number;
if(max<number)
max=number;
if(min>number)
min=number;
}}
printf("%d %d %ld\n",min,max,sum);
}
return 0;
}

Measured memory_bytes: 600
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.TreeSet;
public class Main {
	public static class Col implements Comparable<Col>{
		int sum;
		int cards;
		long amount;
		public Col (int sum, int cards, long amount) {
			this.sum = sum;
			this.cards = cards;
			this.amount = amount;
		}
		public int compareTo(Col c) {
			if(sum != c.sum) return sum - c.sum;
			if(cards != c.cards) return cards - c.cards;
			return 0;
		}
	}
	public static void main(String args[]) {
		Sc sc = new Sc(System.in);
		int N = sc.nI();
		int A = sc.nI();
		int [] x = new int[N];
		for(int i = 0; i<N; i++) {
			x[i] = sc.nI();
		}
		TreeSet<Col> set = new TreeSet<>();
		Col newc = new Col(0,0,1);
		set.add(newc);
		for(int i = 0; i<N; i++) {
			TreeSet<Col> newset = new TreeSet<>();
			for(Col c : set) {
				Col nc = new Col(c.sum + x[i],c.cards+1,c.amount);
				Col contains = newset.ceiling(nc);
				if(contains != null && nc.compareTo(contains) == 0) {
					contains.amount += nc.amount;
				} else {
					newset.add(nc);
				}
				contains = newset.ceiling(c);
				if(contains != null && c.compareTo(contains) == 0) {
					contains.amount += c.amount;
				} else {
					newset.add(c);
				}
			}
			set = newset;
		}
		long amount = 0;
		for(int i = 1; i<=N; i++) {
			Col nc = new Col(A*i,i,0);
			Col contains = set.ceiling(nc);
			if(contains != null && nc.compareTo(contains) == 0) 
				amount += contains.amount;
		}
		System.out.println(amount);
	}
}
class Sc {
    public Sc(InputStream i) {
        r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasM() {
        return peekToken() != null;
    }

    public int nI() {
        return Integer.parseInt(nextToken());
    }

    public double nD() { 
        return Double.parseDouble(nextToken());
    }

    public long nL() {
        return Long.parseLong(nextToken());
    }

    public String n() {
        return nextToken();
    }

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
        if (token == null) 
            try {
                while (st == null || !st.hasMoreTokens()) {
                    line = r.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
                token = st.nextToken();
            } catch (IOException e) { }
        return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }
}

Measured memory_bytes: 24512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

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

  for (int i = 0; i < M; ++i)
  {
    int j;
    cin >> j;
    N -= j;
  }

  if (N < -1) cout << "-1" << endl;
  else cout << N << endl;
}

Measured memory_bytes: 3636
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[0]*M]*N
count = 0
for i in range(N):
  A[i] =  list(map(int, input().split()))
for i in range(N):
  integer = 0
  for j in range(M):
    integer += A[i][j] * B[j]
  integer += C
  if integer > 0:
    count += 1
print(count)


Measured memory_bytes: 9072
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	str := scanner.Text()
	for _, s := range str{
		if 'a' <= s && s <= 'z'{
			fmt.Print(strings.ToUpper(string(s)))
		}else if 'A' <= s && s <= 'Z'{
			fmt.Print(strings.ToLower(string(s)))
		}else{
			fmt.Print(string(s))
		}
	}
	fmt.Println("")
}


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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());  //入力した数字
            int n = 0;                            //奇数の数
            float ans = 0.0f;

            if(a % 2 == 0)
            {
                n = a / 2;             
            }
            else
            {
                n = (a + 1) / 2;
            }
            ans = (float)n / a;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    ll a, b, c;
    while (scanf("%lld%lld%lld", &a, &b, &c) != EOF) {
        ll res = min(b, c);
        b -= res; c -= res; res *= 2;
        if (b) res += b;
        if (c) res += min(c, a);
        c -= min(c, a);
        if (c) res++;
        printf("%lld\n", res);
    }
    return 0;
}


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

int main(){
	
	int a,b;
	cin >>a>>b;
	if (  a < b) {
    cout<<"a < b"<<endl;
} else if ( a > b ) {
    cout <<"a > b"<<endl;
} else 
   {cout <<"a == b"<<endl;
    
}
    return 0;
	}


Measured memory_bytes: 1156
#include<iostream>

using namespace std;

void trace(int A[],int N){
	for(int i=0; i < N; i++){
		if(i>0)cout << " ";
		cout << A[i];
	}
	cout << endl;
}

void insetionSort(int A[],int N){
	int v,j;
	for(int i=0; i<N; i++){
		v=A[i];
		j=i-1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A,N);
	}
}
int main(){
	int n;
	cin >> n;
	int A[n];
	for(int i=0; i<n; i++)cin >> A[i];

	insetionSort(A,n);
}


Measured memory_bytes: 3072
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int a1,a2,a3,a4;
bool u[20];
int main(){
	cin>>a1>>a2>>a3>>a4;
	u[a1]=u[a2]=u[a3]=u[a4]=true;
	cout<<((u[1]&&u[9]&&u[7]&&u[4])?"YES":"NO");
	return 0;
}

Measured memory_bytes: 888