akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

int N, M, l, r, x;
vector<pair<int,int>>v[301];
ll DP[301][301][301], res;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> l >> r >> x;
		v[r].push_back(mkp(l, x));
		if (r - l + 1 < x) {
			cout << 0 << endl;
			return 0;
		}
	}
	DP[0][0][1] = DP[0][1][0] = DP[1][0][0] = 1;
	for (int i = 2; i <= N; ++i) {
		for (int j = 0; j < i - 1; ++j) {
			for (int k = 0; k < i - 1; ++k) {
				bool b[3];
				b[0] = b[1] = b[2] = true;
				for (auto p : v[i]) {
					if (p.second == 1) {
						if (p.first != i) {
							b[1] = b[2] = false;
							if (p.first <= j || p.first <= k) {
								b[0] = false;
							}
						}
					}
					else if (p.second == 2) {
						if (p.first <= j && p.first <= k) {
							b[0] = b[1] = b[2] = false;
						}
						else if (p.first <= j && k < p.first) {
							b[2] = false;
						}
						else if (p.first <= k && j < p.first) {
							b[1] = false;
						}
						else {
							b[0] = false;
						}
					}
					else {
						if (j < p.first&&k < p.first) {
							b[0] = b[1] = b[2] = false;
						}
						else if (p.first <= j && k < p.first) {
							b[0] = b[1] = false;
						}
						else if (p.first <= k && j < p.first) {
							b[0] = b[2] = false;
						}
					}
				}
				if (b[0]) {
					DP[i][j][k] += DP[i - 1][j][k];
					DP[j][i][k] += DP[j][i - 1][k];
					DP[j][k][i] += DP[j][k][i - 1];
					DP[i][j][k] %= mod;
					DP[j][i][k] %= mod;
					DP[j][k][i] %= mod;
				}
				if (b[1]) {
					DP[i - 1][i][k] += DP[i - 1][j][k];
					DP[i][i - 1][k] += DP[j][i - 1][k];
					DP[i][k][i - 1] += DP[j][k][i - 1];
					DP[i - 1][i][k] %= mod;
					DP[i][i - 1][k] %= mod;
					DP[i][k][i - 1] %= mod;
				}
				if (b[2]) {
					DP[i - 1][j][i] += DP[i - 1][j][k];
					DP[j][i - 1][i] += DP[j][i - 1][k];
					DP[j][i][i - 1] += DP[j][k][i - 1];
					DP[i - 1][j][i] %= mod;
					DP[j][i - 1][i] %= mod;
					DP[j][i][i - 1] %= mod;
				}
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			res += DP[i][j][N] + DP[i][N][j] + DP[i][j][N];
			res %= mod;
		}
	}
	cout << res << endl;
}

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

using namespace std;

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

    string s;

    cin >> s;

    const int n = s.size();
    int l = 0;
    while (l < n && s[l] != 'A')
        ++l;

    int r = n - 1;
    while (0 <= r && s[r] != 'Z')
        --r;

    cout << r - l + 1 << endl;

    return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    while(h != 0 && w != 0)
    {
        for(int i=0; i<h; ++i)
        {
            for(int j=0; j<w; ++j)
            {
                if(i == 0 || j == 0) cout << "#";
                else if(i == h-1 || j == w-1) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>
int main(void)
{
	int a[10];
    int x,y,wk;
	for(x=0;x<10;x++)	{
		scanf("%d",&a[x]);
	}
	
	for(x=0;x<9;x++)	 {
		for(y=x+1;y<10;y++)	{
			if(a[x]<a[y])	{
				wk=a[x];
				a[x]=a[y];
				a[y]=wk;
			}
		}
	}
	for(x=0;x<3;x++)	{
		printf("%d\n",a[x]);
	}
	return 0;
}
	
	

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define lli long long
#define INF (int)1e7 

using namespace std;
  
  
class Graph { 
  typedef pair<int, int> p; 

  int V;
  list<p> *adj; 
  
  public: 
  Graph(int V){ 
    this->V = V; 
    adj = new list<p> [V]; 
  } 

  void addEdge(int u, int v, int w){ 
    adj[u].push_back(make_pair(v, w)); 
    adj[v].push_back(make_pair(u, w)); 
  } 
  
  vector<int> shortestPath(int src){ 
    priority_queue< p, vector <p> , greater<p> > pq; 
  
    vector<int> dist(V, INF); 
    pq.push(make_pair(0, src)); 
    dist[src] = 0; 
  
    while (!pq.empty()) { 
        int u = pq.top().second; 
        pq.pop(); 
  
        list< pair<int, int> >::iterator i; 
        for (i = adj[u].begin(); i != adj[u].end(); ++i) { 
            int v = (*i).first; 
            int weight = (*i).second; 
  
            if (dist[v] > dist[u] + weight) { 
                dist[v] = dist[u] + weight; 
                pq.push(make_pair(dist[v], v)); 
            } 
        } 
    } 
    return dist;
  } 
}; 
  

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  Graph g(n+1);
  for(int i=1;i<n;i++){
    g.addEdge(i,i+1,1);
  }
  g.addEdge(x,y,1);
  
  vector<int> ans(n,0);
  for(int i=1;i<n;i++){
    vector<int>vec = g.shortestPath(i);
    for(int j=i;j<=n;j++){
      ans[vec[j]]++;
    }
  }
  for(int i=1;i<n;i++){
    cout << ans[i] << endl;
  }
}

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

int n, m, s;
char c;

int main()
{
	cin >> n >> m;
	
	string d = "";
	bool fl = true;
	
	for(int i=0; i<n; i++)
		d += 'x';
	
	for(int i=0; i<m; i++)
	{
		cin >> s >> c;
		if(s == 1 and c == '0' and n != 1)
			fl = false;
		else if(d[s-1] == 'x')
			d[s-1] = c;
		else if(d[s-1] != 'x' and d[s-1] != c)
			fl = false;
	}
	
	for(int i=0; i<n; i++)
	{
		if(d[i] == 'x' and n == 1)
			d[i] = '0';
		else if(d[i] == 'x' and i>0)
			d[i] = '0';
		else if(d[i] == 'x' and i==0)
			d[i] = '1';
	}
	
	if(fl)
		cout << d << '\n';
	else
		cout << -1 << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define MAX 1000

using namespace std;

int N, ans, cnt, sum;
bool flg;

int main() {
	int A,B;
	cin >> A >> B;

	ans = A - B * 2;
	if(ans>0)	cout << ans << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
 using namespace std;
 typedef long long ll;
 
 int main(void){
 long double a,b,c;
 cin >> a >> b >> c;
 
 long double eps = 1.0E-14;
 if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
 cout << "Yes" << endl;
 } else {
 cout << "No" << endl;
 }
 
 return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll r;
    if (n >= b) {
        r = b - 1;
    } else {
        r = n;
    }
    cout << ll(a * r / b);
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<62)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a/gcd(a,b)*b;}


ll mul(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}

ll power(ll x,ll y){
    if(y==0) return 1;
    else if(y==1) return x%MOD;
    else if(y%2==0) return power(x,y/2)*power(x,y/2)%MOD;
    else return (power(x,y/2)*power(x,y/2))%MOD*x%MOD;
}

ll divi(ll a,ll b){
    return mul(a,power(b,MOD-2));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,a;
    cin>>h>>a;
    puta((h+a-1)/a);


}


Measured memory_bytes: 256
N, M = map(int, input().split())
s = []
for i in range(M):
    s.append([int(i) for i in input().split()])
p = [int(i) for i in input().split()]
ans = 0
for i in range(2 ** N):
    sw = [(i >> j) & 1 for j in range(N)]
    for k, e in enumerate(s):
        c = 0
        for l in e[1:]:
            c += sw[l - 1]
        if c % 2 != p[k]:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i

ans = 0
Prime.prime_division(n).each do |num, count|
  cul = 1
  while cul <= count
    wari = num ** cul
    if n % wari == 0
      n /= wari
      ans += 1
    else
      break
    end

    count -= cul
    cul += 1
  end
end

puts ans

Measured memory_bytes: 14688
#include<bits/stdc++.h>
#define llt long long int
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;

bool palindrome(string s, int n)
{
	bool flag  = true;
	for(int i =0; i <= n/2;i++)
	{
		if(s[i]!=s[n-i-1])
		{
			flag = false;
			break;
		}
	}
	if(flag == false)
	{
		return false;
	}
	else
	{
		return true;
	}
}
int main()
{
	speed;
	string s;
	cin >> s;
	int n = s.length();
	bool flag = palindrome(s,n);
	string k = s.substr(0,(n-1)/2);
	int z = k.length();
	bool flag1 = palindrome(k,z);
	//cout << k << "\n";
	string l = s.substr((n+3)/2-1);
	int m = l.length();
	bool flag2 = palindrome(l,m);
	//cout << l << "\n";
	if(flag==1 && flag1 == 1 && flag2 == 1)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}


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

int main()
{
    int num;
    int a[100010] = {};
    int i,now;
    int ans = 1;
    int flag = 0;
    cin >> num;

    for(i = 0; i < num; i++){
        cin >> a[i];
    }
    for(i = 0; i < num; i++){
        if(flag == 0){
            now = a[i];
            flag = 1;
        }else if(flag == 1){
            if(now < a[i]){
                now = a[i];
                flag = 2;
            }else if(now > a[i]){
                now = a[i];
                flag = 3;
            } 
        }else if(flag == 2){
            if(now > a[i]){
                now = a[i];
                ans++;
                flag = 1;
            }else{
                now = a[i];
            }
        }else if(flag == 3){
            if(now < a[i]){
                now = a[i];
                ans++;
                flag = 1;
            }else{
                now = a[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<ll> a(n);
    rep(i,0,n)scanf("%lld",&a[i]);
    int ans=0; vector<ll> vec;
    rep(mask,1,1<<n){
        ll lcm=1; vec.clear();
        rep(i,0,n){
            if(mask>>i&1){
                lcm=lcm/__gcd(lcm,a[i])*a[i];
            }
            else vec.push_back(a[i]);
        }
        bool f=1;
        rep(i,0,vec.size()){
            if(lcm%vec[i]==0){
                f=0; break;
            }
        }
        if(f)ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
vector<int> answers;
int main(){
    
  while(1){
      int n,m;
      cin>>n>>m;
      if(n==0&&m==0) break;
      vector<vector<int>> p(m,vector<int>(n,0));
      for(int i=0;i<m;i++){
          for(int j=0;j<n;j++){
              cin>>p[i][j];
          }
      }
      int ans=-1;
      for(int i=0;i<n;i++){
          int tmp=0;
          for(int j=0;j<m;j++){
              tmp+=p[j][i];
          }
          ans=max(ans,tmp);
      }
      answers.push_back(ans);
  }
  for(auto ans:answers){
      cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int maxtime(long long a){
    return (a+9)/10*10;
 }

int left_time(long long b){
  return maxtime(b)-b;
}

int main(){
  
  long long a,b,c,d,e;
  
  cin>>a>>b>>c>>d>>e;
  
  long long ans=0;
  
  ans += maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
  
  ans -= max( {left_time(a),left_time(b),left_time(c),left_time(d),left_time(e)} );
  
  cout<<ans<<endl;
  
  return 0; 
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	static final int[] month = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			StringTokenizer st = new StringTokenizer(line);
			int y1 = parseInt(st.nextToken()) - 1;
			int m1 = parseInt(st.nextToken()) - 1;
			int d1 = parseInt(st.nextToken());
			int y2 = parseInt(st.nextToken()) - 1;
			int m2 = parseInt(st.nextToken()) - 1;
			int d2 = parseInt(st.nextToken());
			if ((y1 + 1 | m1 + 1 | d1 | y2 + 1 | m2 + 1 | d2) < 0) {
				break;
			}

			int days1, days2;
			//
			days1 = y1 * 365 + (y1 / 4 - y1 / 100 + y1 / 400);
			days1 += month[m1] + d1;
			if (isLeap(y1 + 1) && m1 + 1 > 2) {
				days1++;
			}
			//
			days2 = y2 * 365 + (y2 / 4 - y2 / 100 + y2 / 400);
			days2 += month[m2] + d2;
			if (isLeap(y2 + 1) && m2 + 1 > 2) {
				days2++;
			}
			System.out.println(days2 - days1);
		}
	}

	static boolean isLeap(int year) {
		return year % 4 == 0 ? (year % 100 == 0 ? (year % 400 == 0 ? true : false) : true) : false;
	}
}

Measured memory_bytes: 16848
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 202020;
int n;
int ar[N];
int main(){
	scanf("%d", &n);
	rep(i, 0, n) scanf("%d", ar + i);
	ll a = ar[0], b = 0, c = ar[1] + ar[2], d = 0;
	rep(i, 3, n) d += ar[i];
	ll ans = 1e18;
	for(int l = 0, mid = 1, r = 2; mid < n - 2; mid++) {
		b += ar[mid];
		c -= ar[mid];
		if(mid < r && l < mid)
			ans = min(ans, max(max(a, b), max(c, d)) - min(min(a, b), min(c, d)));
		while(l + 1 < mid && abs(a - b) >= abs(a + ar[l + 1] - (b - ar[l + 1]))) {
			l++;
			a += ar[l];
			b -= ar[l];
			if(mid < r && l < mid)
				ans = min(ans, max(max(a, b), max(c, d)) - min(min(a, b), min(c, d)));
		}
		while(r + 1 < n - 1 && abs(c - d) >= abs(c + ar[r + 1] - (d - ar[r + 1]))) {
			r++;
			c += ar[r];
			d -= ar[r];
			if(mid < r && l < mid)
				ans = min(ans, max(max(a, b), max(c, d)) - min(min(a, b), min(c, d)));
		}
		ans = min(ans, max(max(a, b), max(c, d)) - min(min(a, b), min(c, d)));
	}
	printf("%lld\n", ans);
	return 0;
}



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

int k;
queue<long long> s;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> k;
    for (int i = 1; i < 10; i++)
        s.push(i);

    long long res;
    while (k--){
        res = s.front();
        s.pop();
        if (res % 10 > 0)
            s.push(res * 10 + res % 10 - 1);
        s.push(res * 10 + res % 10);
        if (res % 10 < 9)
            s.push(res * 10 + res % 10 + 1);
    }
    cout << res <<"\n";
    return 0;
}

Measured memory_bytes: 1792
<?php

fscanf(STDIN, "%d %d", $n, $m);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$queue = new SplPriorityQueue();
for ($i = 0; $i < $n; ++$i) {
    $queue->insert($A[$i], $A[$i]);
}

for ($i = 0; $i < $m; ++$i) {
    $x = $queue->extract();
    $y = floor($x / 2);
    $queue->insert($y, $y);
}

$sum = 0;
while ($queue->valid()) {
    $sum += $queue->extract();
}

echo $sum;


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

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

    int ans = n % 2 == 0 ? n : 2 * n;

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


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

class MainClass
{
    static void Main()
    {
        var KS = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int K = KS[0], S = KS[1];
        int count = 0;
        for(int x = 0; x <= K; x++)
        {
            for(int y = 0; y <= K; y++)
            {
                if (0 <= S - x - y && S - x - y <= K)
                    count++;
            }
        }
        Console.WriteLine(count);
    }
}

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

int main() {
  int D;
  cin >> D;
  if(D == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  else if(D == 23) {
    cout << "Christmas Eve Eve" << endl;
  }
  else if(D == 24) {
    cout << "Christmas Eve" << endl;
  } 
  else if(D == 25) {
    cout << "Christmas" << endl;
  }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
lst = [[] for _ in range(n + 1)]
py = [tuple(map(int, input().split())) for i in range(m)]

for i, (p, y) in enumerate(py):
    lst[p].append((y, i))

ans = [None] * m

for p, l in enumerate(lst):
    l.sort()
    for j, (y, i) in enumerate(l):
        ans[i] = str(p).zfill(6) + str(j + 1).zfill(6)

print(*ans, sep=('\n'))

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

int main() {
    long long n;
    cin >> n;
    vector<long long> a(n,0);
    for (long long i = 0; i < (n); ++i) {
        cin >> a.at(i);
    }
    long long min = *min_element(a.begin(), a.end());
    long long max = *max_element(a.begin(), a.end());
    long long sum = accumulate(a.begin(), a.end(), 0LL);
    cout  << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3196
#include <iostream>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

int main() {
    int n, q, c, t, x, v_size;
    cin >> n >> q;
    vector<priority_queue<int>> v(n);
    for(int i = 0; i < q; ++i) {
        cin >> c;
        if(c == 0) {
            cin >> t >> x;
            v[t].push(x);
        } else if(c == 1) {
            cin >> t;
            if(v[t].size() != 0) {
                cout << v[t].top() << '\n';
            }
        } else {
            cin >> t;
            if(v[t].size() != 0) {
                v[t].pop();
            }
        }
    }
}



Measured memory_bytes: 4068
#include <stdio.h>

int dividing(int math, int english, int japanese)
{
	if (math == 100 || english == 100 || japanese == 100) {
		printf("A\n");
	}else if (math + english >= 180) {
		printf("A\n");
	}else if (math + english + japanese >= 240) {
		printf("A\n");
	} else if (math + english + japanese >= 210) {
		printf("B\n");
	} else if (math + english + japanese >= 150 && math >= 80) {
		printf("B\n");
	} else if (math + english + japanese >= 150 && english >= 80) {
		printf("B\n");
	} else {
		printf("C\n");
	}
}

int main(void)
{
	while (1) {
		int number;
		scanf("%d", &number);
		if (number == 0) {
			break;
		}
		for (int i = 0; i < number; i++) {
			int math;
			int english;
			int japanese;
			scanf("%d %d %d", &math, &english, &japanese);
			dividing(math, english, japanese);
		}
	}
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll inf = 1e9+7;
const ll N=100001;
ll n,a[N],ans=0,w=0;

int main(){
	cin>>n;
	FOR(i,0,N)a[i]=0;
	FOR(i,0,n){
		cin>>a[i];
	}
	FOR(i,0,n){
		w+=a[i];
		if(a[i]==0){
			ans+=w/2;
			w=0;
		}
	}
	ans+=w/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long L;
using namespace std;
 
#define N 100005
#define U [N]={}
map<L,L> path[N];
L par U,dep U,siz U,hev U,cst U,add U,pos U,hl_par U,bit U,
k,n,q,a,b,c,cnt,i,p,r,ret;
void dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d==par[a]) continue;
        par[d]=a;
        dep[d]=dep[a]+1;
        cst[d]=I->second;
        dfs(d);
        siz[a]+=siz[d];
        if(!hev[a] || siz[hev[a]]<siz[d])
            hev[a]=d;
    }
}
   
L edgecost(L a){
    L ret=add[a]+add[par[a]]+cst[a];
    return ret%k ? ret : 0;
}
   
L sum(L i){
    L ret=0;
    while(i){
        ret+=bit[i];
        i-=i&-i;
    }
    return ret;
}
void S(L i, L x){
    x-=sum(i+1)-sum(i);
    i++;
    while(i<N){
        bit[i]+=x;
        i+=i&-i;
    }
}
   
L cost(L a, L b){
    L p=hl_par[a], q=hl_par[b];
    if(p==q) return abs(sum(pos[a])-sum(pos[b]));
    if(dep[p]<dep[q]){
        swap(p, q);
        swap(a, b);
    }
    return sum(pos[a]) - sum(pos[p])
        + edgecost(p) + cost(par[p], b);
}
 
main(){
    cin >> n >> k;
    for(i=0; i<n-1; i++){
        cin >> a >> b >> c;
        path[a][b]=path[b][a]=c;
    }
    dfs(0);
   
    for(i=0; i<n; i++){
        if(i && hev[par[i]]==i) continue;
        L j=i;
        do{
            pos[j]=cnt++;
            hl_par[j]=i;
        }while(j=hev[j]);
    }
    
    for(i=0; i<n; i++)
        S(pos[i], edgecost(hev[i]));
    //for(i=0; i<n; i++)
     //   printf("%d ",sum(i));cout<<endl;
    
    cin >> q;
    for(i=0; i<q; i++){
        string s;
        cin>>s>>a>>b;
        if(s[0]=='a'){
            add[a]+=b;
            S(pos[a], edgecost(hev[a]));
            if(a) S(pos[a]-1, edgecost(a));
        }else{
            //cout << cost(a, b) << endl;
            ret=0;
            for(;;){
                //cout << a << b << endl;
                p=hl_par[a];
                r=hl_par[b];
                if(p==r){
                    cout<<ret+abs(sum(pos[a])-sum(pos[b]))<<endl;
                    break;
                }
                if(dep[p]<dep[r]){
                    swap(p, r);
                    swap(a, b);
                }
                ret+=sum(pos[a])-sum(pos[p])+edgecost(p);
                //cout << "aa" << endl;
                
                a=par[p];
            }
        }
    }
}

Measured memory_bytes: 31944
#include <bits/stdc++.h>
#define ll long long

using namespace std;
set < char > st;
int main()
{
    string s;  cin >> s;
    for(int i = 0;i<s.size();i++)  st.insert(s[i]);
    cout << (st.size() == 1 ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp

lc = 0
addl = 0
for i in 0..n-1
    if s[i] == '('
        lc += 1
    else
        if lc == 0
            addl += 1
        else 
           lc -= 1
        end
    end
end

s = '('*addl + s + ')'*lc

puts s

Measured memory_bytes: 14276
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(Math.abs(x-b) < Math.abs(x-a)){
            System.out.println("B");
        }else{
            System.out.println("A");
        }
        sc.close();
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n;
  cin >> n;
  vl h;
  inputv(h,n);
  ll mx = 0;
  ll ans = 0;
  rep(i,n){
    if(h[i] >= mx){
      ans++;
    }
    mx = max(mx,h[i]);
  }
  cout << ans;
 return 0;
}


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

const int MAX = 500000;
int heap[MAX+1];
int heap_size;
void swap(int *x, int *y){
    int k = *y;
    *y = *x;
    *x = k;
}
int left(int x){
    return 2*x;
}
int right(int x){
    return 2*x+1;
}
void max_heapify(int A[], int i){
    int l, r, largest;
    l = left(i);
    r = right(i);
    if (l <= heap_size && heap[l] > heap[i])
    {
        largest = l;
    }
    else
    {
        largest = i;
    }
    if (r <= heap_size && heap[r] > heap[largest])
    {
        largest = r;
    }
    if (largest != i)
    {
        swap(&A[i], &A[largest]);
        max_heapify(A, largest);
    }
    
}

void build_maxheap(int A[]){
    for (int i = heap_size/2; i >= 1; i--)
    {
        max_heapify(A, i);
    }
    
}

int main(){
    cin >> heap_size;
    for (int i = 1; i <= heap_size; i++)
    {
        cin >> heap[i];
    }
    build_maxheap(heap);
    for (int i = 1; i <= heap_size; i++)
    {
        cout << " " << heap[i];
    }
    cout << endl;
}


Measured memory_bytes: 5032
#include<iostream>

using namespace std;

int main(){
  int x;
  int y;
  int z;
  int _N_MAX = 10050;
  
  int arr[_N_MAX] = {0};
    for(x = 1; x < 105; x++){
      for(y = 1; y < 105; y++){
        for(z = 1; z < 105; z++){
          if(x*x + y*y + z*z + x*y + y*z + z*x < _N_MAX){
            int v = x*x + y*y + z*z + x*y + y*z + z*x;
            arr[v]++;
          }
        }
      }
    }
  int N;
  cin >> N;
  for(int idx = 1; idx <= N; idx++){
    cout << arr[idx] << endl;
  }
}


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

int main() {
    auto n = std::size_t(0);
    auto m = 0;
    std::cin >> n >> m;

    auto adj = std::vector<std::vector<unsigned char>>(n, std::vector<unsigned char>(n, 0));
    for (auto i_ = 0; i_ < m; ++i_) {
        auto a = std::size_t(0);
        auto b = std::size_t(0);
        std::cin >> a >> b;
        adj[a - 1][b - 1] = 1;
        adj[b - 1][a - 1] = 1;
    }

    auto perm = std::vector<unsigned char>();
    perm.reserve(n);
    for (auto i = static_cast<unsigned char>(0); i < n; ++i) perm.emplace_back(i);

    auto counter = 0;
    do {
        auto itr = perm.begin();
        while ((adj[*itr][*(itr + 1)] != 0) && (itr + 1 < perm.end())) itr++;

        if (itr + 1 == perm.end()) counter++;
    } while (std::next_permutation(perm.begin(), perm.end()) && (*perm.begin() == 0));

    std::cout << counter << std::endl;
    return 0;
}

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

int main()
{
    ll x,y,a1,b1,c1,t,i,sum=0;
    cin>>x>>y>>a1>>b1>>c1;
    int a[a1+1],b[b1+1];
    deque<int>c(c1);
    for(int i=0; i<a1; i++)
        cin>>a[i];
    for(int i=0; i<b1; i++)
        cin>>b[i];
    for(int i=0; i<c1; i++)
        cin>>c[i];
    sort(a,a+a1,greater<int>());
    sort(b,b+b1,greater<int>());
    for(int i=0; i<x; i++)
        c.push_back(a[i]);
    for(int i=0; i<y; i++)
        c.push_back(b[i]);
    sort(c.begin(),c.end(),greater<int>());
    for(int i=0; i<x+y; i++)
        sum+=c[i];
    cout<<sum<<endl;
}




Measured memory_bytes: 2176
ary = gets.split("")
k = 1
ary.each do |n|
    if n== "L" && k%2 == 1
        puts "No"
        break
    end
    if k%2 ==0 && n== "R"
        puts "No"
        break
    end
    k+=1
end

puts "Yes" if k-1 == ary.length

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
#define MOD (ll)(1e9 +7)
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	cin>>n;
	vc a(n+1);
	i=1;
	while(i<=n)cin>>a[i++];
	c=0;
	for(i=2;i<=n;i+=2)
	{
	    c^=a[i];
	    c^=a[i-1];
	}
	for(i=1;i<=n;i++)
	cout<<(c^a[i])<<" ";
	return 0;
}


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

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


int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i, n) {
        vector<int> pre(26,0);
        vector<int> post(26,0);
        rep(j, i) pre[s.at(j) - 'a']++;
        for(int k=i; k < n; k++) post[s.at(k) - 'a']++;
        int tmp = 0;
        rep(j, 26) if(pre[j] > 0 && post[j] > 0) tmp++;
        ans = max(tmp, ans);
    }

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


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
print(*l)

for i in range(1,n):
    v = l[i]
    j = i - 1
    while j >= 0 and l[j] > v:
        l[j+1] = l[j]
        j -= 1
    l[j+1] = v
    print(*l)


Measured memory_bytes: 5984
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll,ll> P;
typedef std::pair<ll,P> State;

const ll MOD = 100000007;

// 2 3 -> (1, -1, 1)
// 6 27 -> (3, -4, 1)
State extgcd(ll a, ll b){
    if(b == 0){
        return mp(a, mp(1, 0));
    }
    State s = extgcd(b, a%b);
    P p = s.second;
    return mp(s.first, mp(p.second, p.first-(a/b)*p.second));
}

// 3 7 -> 5
// 11 7 -> 2
ll mod_inverse(ll a, ll m){
    State s = extgcd(a, m);
    return (m + s.second.first % m) % m;
}

ll fact[2001];
P mod_fact(ll n, ll p){
    if(n == 0){return mp(1, 0);}

    ll e = n / p;
    P small = mod_fact(n/p, p);
    e += small.second;

    if(n / p % 2 == 0){return mp(small.first * fact[n%p] % p, e);}
    return mp(small.first * (p - fact[n%p]) % p, e);
}

ll mod_combination(ll n, ll k, ll p){
    if(n < 0 || k < 0 || n < k){return 0;}
    P p1 = mod_fact(n, p), p2 = mod_fact(k, p), p3 = mod_fact(n-k, p);
    if(p1.second > p2.second + p3.second){return 0;}
    return p1.first * mod_inverse(p2.first * p3.first % p, p) % p;
}

int main(){
    fact[0] = 1;
    FOR(i, 1, 2001){
        fact[i] = (fact[i-1] * i) % MOD;
    }

    int r, c, a1, a2, b1, b2;
    std::cin >> r >> c >> a1 >> a2 >> b1 >> b2;

    if(a1 > b1){std::swap(a1, b1);}
    if(a2 > b2){std::swap(a2, b2);}

    int dx[2] = {b1-a1, a1+r-b1}, dy[2] = {b2-a2, a2+c-b2};
    
    int shortestPath = INF;
    
    REP(i, 2){
        REP(j, 2){
            shortestPath = std::min(shortestPath, dx[i]+dy[j]);
        }
    }

    ll res = 0;
    REP(i, 2){
        REP(j, 2){
            if(dx[i] + dy[j] == shortestPath){
                res = (res + mod_combination(dx[i]+dy[j], dx[i], MOD)) % MOD;
            }
        }
    }

    std::cout << res << std::endl;
}

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

int main(){
    int N, K;
    std::cin >> N >> K;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    std::sort(A.begin(), A.end());
    long long sum = 0;
    for(int i=0; i<K; i++){
        sum += A[i];
    }
    
    std::cout << sum << std::endl;
    
    return 0;
}



Measured memory_bytes: 3600
def solve(a, b, c, k):
	sum = 0
	if a > 0:
		if a >= k:
			sum += k 
			print(sum)
			return None
		else:
			sum += a
			k -= a
	k -= b
	if k > 0:
		if c > k:
			sum -= k
			print(sum)
			return None
		else:
			sum -= c
			print(sum)
	else:
		print(sum)



a, b, c, d = [int(x) for x in input().split()]
solve(a, b, c, d)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int h, w;
    std::cin >> h >> w;
    std::vector<std::vector<int>> b(h + 2, std::vector<int>(w + 2));
    std::deque<std::pair<int, int>> q;
    for (int i = 0; i <= w + 1; i++) b[0][i] = b[h + 1][i] = 1;
    for (int i = 1; i <= h; i++) b[i][0] = b[i][w + 1] = 1;
    for (int i = 1; i <= h; i++) {
        std::string s;
        std::cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '#') {
                b[i][j + 1] = 1;
                q.emplace_back(i, j + 1);
            }
        }
    }

    int x[4] { 1, -1, 0, 0 }, y[4] { 0, 0, 1, -1 };
    while (!q.empty()) {
        const auto p = q.front();
        q.pop_front();
        for (int i = 0; i < 4; i++) {
            if (!b[p.first + x[i]][p.second + y[i]]) {
                b[p.first + x[i]][p.second + y[i]] = b[p.first][p.second] + 1;
                q.emplace_back(p.first + x[i], p.second + y[i]);
            }
        }
    }

    int max = 0;
    for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) max = std::max(max, b[i][j]);
    std::cout << max - 1 << std::endl;

    return 0;
}


Measured memory_bytes: 12432
#include<bits/stdc++.h>
using namespace std;
int an[100005];
bool v[100005];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>an[i];
v[1]=1;
int cns=0;
int op=1;
bool ok=1;
while(1)
{
	if(cns>2*n){
		ok=0;
		break;
	}
	if(op==2)
	break;
	if(op==an[op]){
		ok=0;
		break;
	}
	v[op]=0;
	v[an[op]]=1;
	op=an[op];
	cns++;
}
	if(ok){
		cout<<cns<<endl;
		
	}
	else
	cout<<-1<<endl;
	return 0;
} 

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int N,K;cin>>N>>K;
  vector<int> data(K,0);
  for (int i = 1; i <= N; i++)
  {
    data[i%K]++;
  }
  int ANS = 0;
  
  int L = 1;
  int R = K-1;
  // DEBUG(data);
  for (int i = 0; i <= K-1; i++)
  {
    if((i*2) %K == 0)
    {
      ANS += data[i]*data[i]*data[i];
    }
  }
  // DEBUG(ANS);
  

  // while(L <= R)
  // {
  //   ANS += data[0]*data[L]*data[R];
  //   L++;
  //   R--;
  // }
  cout<<ANS<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int int1;
int1 n;
vector <vector<int1> >v;
int main()
{
    cin >> n;
    v.resize(n+2);
    for(int1 i=0;i<n;i++)
    {
        int a,b,c;
        vector<int1>v1;
        cin>>a>>b>>c;
        v[i].push_back(a);
        v[i].push_back(b);
        v[i].push_back(c);
    }
    int1 arr[n+2][4];
    arr[n-1][0]=v[n-1][0];
    arr[n-1][1]=v[n-1][1];
    arr[n-1][2]=v[n-1][2];
    for(int1 i = n-2;i>=0;i--)
    {
        arr[i][0] = v[i][0] + max(arr[i+1][1] , arr[i+1][2]);
        arr[i][1] = v[i][1] + max(arr[i+1][0] , arr[i+1][2]);
        arr[i][2] = v[i][2] + max(arr[i+1][1] , arr[i+1][0]);

    }
    int1 a = max({arr[0][0],arr[0][1],arr[0][2]});
    cout << a <<"\n"; 
}

Measured memory_bytes: 10368
while True:
    H = int(input())
    if H == 0:
        break
    squares = [list(map(int, input().split())) for _ in range(H)]
    score = 0
    while True:
        deleted = False
        for i in range(H):
            for j in range(5, 2, -1):
                for k in range(5 - j + 1):
                    deletable = True
                    first_num = squares[i][k]
                    if first_num == 0:
                        continue
                    for num in squares[i][k + 1:k + j]:
                        if first_num != num:
                            deletable = False
                            break
                    if deletable:
                        score += first_num * j
                        squares[i][k:k + j] = [0] * j
                        deleted = True
        # print(squares)
        if deleted:
            while True:
                not_falled = True
                # 下からやっていった方がいい。また、0行目はやる必要なし
                for i in range(H - 1, 0, -1):
                    for k, num in enumerate(squares[i]):
                        if num == 0 and squares[i - 1][k] != 0:
                            squares[i - 1][k], squares[i][k] = squares[i][k], squares[i - 1][k]
                            not_falled = False
                if not_falled:
                    break
        else:
            break
    print(score)
    # print(squares)



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

int main() {
  int i,k;
  vector<int> a(5);
  for(i=0; i<5; i++)
    cin >> a.at(i);
  cin >> k;
  
  if(a.at(4)-a.at(0)<=k)
    cout << "Yay!";
  else
    cout << ":(";
  cout << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    ll N;
    cin >> N;
    ll p = 0;
    ll s = 0;
    ll m = INF;
    REP(i, N) {
        cin >> A[i];
        if (A[i] < 0)
            p++;
        s += abs(A[i]);
        m = std::min(m, abs(A[i]));
    }

    if (p % 2 == 0)
        cout << s << endl;
    else
        cout << s - 2LL * m << endl;
    return 0;
}

Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
T = LI()
A = LI()
flg = [0] * n
pre = 0
for i in range(n):
    if T[i] > pre:
        flg[i] = 1
        pre = T[i]

pre = 0
for j in range(n - 1, -1, -1):
    if A[j] == pre:
        if flg[j]:
            if T[j] > A[j]:
                print(0)
                exit()
        else:
            T[j] = min(T[j], A[j])
    else:
        if flg[j] and T[j] != A[j]:
            print(0)
            exit()
        else:
            if A[j] > T[j]:
                print(0)
                exit()
            else:
                T[j] = A[j]
                flg[j] = 1
                pre = A[j]

ans = 1
for k in range(n):
    if flg[k] == 0:
        ans = ans * T[k] % mod

print(ans)

Measured memory_bytes: 64620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e5+9;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m,a[N],ans=0;
    vector<int>g[N];
    cin>>n>>m;
    for(int i=1;i<=n;i++){ 
        cin>>a[i];
    }
    for(int x,y,i=1;i<=m;i++){ 
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        bool ok=true;
        for(int j=0;j<g[i].size();j++){ 
            if(a[i]<=a[g[i][j]])ok=false;
        }
        if(ok)ans++;
    }
    cout<<ans<<'\n';
    
    
    
    
    return 0;
}


Measured memory_bytes: 9144
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 3
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	k := getNextInt(scanner)

	n := len(s)
	// dp[桁数][未満かどうか][0でない数字の個数] = 個数
	dp := make([][2][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i][0] = make([]int, k+1)
		dp[i][1] = make([]int, k+1)
	}
	dp[0][0][0] = 1
	for i := 0; i < n; i++ {
		num := int(s[i] - '0')
		// 未満確定
		for ii := 0; ii < k+1; ii++ {
			dp[i+1][1][ii] += dp[i][1][ii]
		}
		for ii := 0; ii < k; ii++ {
			dp[i+1][1][ii+1] += dp[i][1][ii] * 9
		}
		// 未満確定でない
		if num == 0 {
			for ii := 0; ii < k+1; ii++ {
				dp[i+1][0][ii] += dp[i][0][ii]
			}
			continue
		}
		// 0を選択
		for ii := 0; ii < k+1; ii++ {
			dp[i+1][1][ii] += dp[i][0][ii]
		}

		// 1～numまで
		for ii := 0; ii < k; ii++ {
			dp[i+1][1][ii+1] += dp[i][0][ii] * (num - 1)
			dp[i+1][0][ii+1] += dp[i][0][ii]
		}
	}
	fmt.Fprintln(writer, dp[n][0][k]+dp[n][1][k])
}


Measured memory_bytes: 640
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main() {
	lint h, w; cin >> h >> w;
	lint n; cin >> n;
	vl a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	lint cnt = 0;
	vector<vector<lint>> d(h, vector<lint>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i % 2 == 0) {
				if (a[cnt] != 0)
					d[i][j] = cnt + 1, a[cnt]--;
				else {
					cnt++;
					d[i][j] = cnt + 1;
					a[cnt]--;
				}
			}
			else {
				if (a[cnt] != 0)
					d[i][w - j - 1] = cnt + 1, a[cnt]--;
				else {
					cnt++;
					d[i][w - j - 1] = cnt + 1;
					a[cnt]--;
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (j != w - 1)
				cout << d[i][j] << ' ';
			else
				cout << d[i][j] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3736