akhauriyash/Code-Regression huggingface dataset:
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{//Dhatt teri maa ki choot
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner in=new Scanner(System.in);
	    String str=in.nextLine();
	    
	    
	    //Randwa hai kya madarchod
	    if(str.charAt(str.length()-1)=='s') System.out.println(str+"es");
	    else System.out.println(str+"s");
	    //Randi ki choot me garam masala
	    
	}
}

Measured memory_bytes: 38656
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep(i,n-1){
        REP(j,i+1,n){
            auto itr = lower_bound(all(a),a[i]+a[j]);
            ans += max(0LL,distance(a.begin(),itr)-1-j);
        }
    }
    cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int H,W;
int walls;
vector<int> dx{1,0,-1,0};
vector<int> dy{0,1,0,-1};


int main() {
    cin >> H >> W;

    walls = 0;

    vector<vector<char>> G(H+2, vector<char>(W+2, '#'));

    REP(i,H){
        string S;
        cin >> S;
        REP(j,W){
            G[i+1][j+1] = S[j];
            if(S[j] == '#') walls++;
        }
    }

    queue<pair<int,int>> q;
    q.push(make_pair(1,1));

    vector<vector<int>> dist(H+2, vector<int>(W+2, -1));

    dist[1][1] = 1;
    
    int d = -1;

    while(!q.empty()){
        auto v = q.front();
        q.pop();
        if (v == make_pair(H,W)){
            d = dist[v.first][v.second];
            break;
        }
        REP(i,4){
            pair<int,int> next{v.first+dy[i], v.second+dx[i]};
            if (G[next.first][next.second] == '.' && dist[next.first][next.second] == -1){
                dist[next.first][next.second] = dist[v.first][v.second]+1;
                q.push(next);
            }
        }

    }

    if (d==-1){
        cout << -1 << endl;
    }else{
        cout << W*H - walls - d << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
   int n;
   cin >> n;
   vector<ll>a(n),b(n);
   ll sum =0;
   for(int i=0;i<n;i++){cin>>a.at(i);sum+=a.at(i);}
   for(int j=0;j<n;j++){cin>>b.at(j);sum-=b.at(j);}
   bool che = true;
   for(int i=0;i<n;i++){
      if(a.at(i)<b.at(i))che=false;
   }
   if(che){cout<<0<<endl;return 0;}
   if(sum<0){cout<<-1<<endl;return 0;}
   priority_queue<ll>ma;
   priority_queue<ll, vector<ll>, greater<ll>> mi;
   for(int i=0;i<n;i++){
      ll che =a.at(i)-b.at(i);
      ma.push(che);
      mi.push(che);
   }
   ll ans = 0;
    sum =0;
   while(1){
      if(mi.top()>=0)break;
      if(sum==0){
         sum =ma.top();
         ans++;
         ma.pop();
      }
      else{
         ll d = mi.top();
         mi.pop();
         if(abs(d)>=sum){
            mi.push(sum+d);
            sum=0;
         }
         else{
            sum+=d;
            ans++;
         }
      }
   }
   cout << ans<<endl;
}
    



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll t;
  cin >> t;
  while(t--){
   ll n,m,a,b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << endl;
  }
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

std::string s;
ll k;
ll dist[100005];

char next(char x) {
	if (x == 'z') return 'a';
	else return x + 1;
}

int main() {
	std::cin >> s >> k;

	int n = s.size();
	for (int i = 0; i < n; ++i) {
		int d = 'z' - s[i] + 1;
		if (s[i] == 'a') d = 0;
		dist[i] = d;
	}

	for (int i = 0; i < n; ++i) {
		if (dist[i] > k) {
			continue;
		}
		else {
			k -= dist[i];
			s[i] = 'a';
		}
	}

	k = k % 26;
	for (int i = 0; i < k; ++i) {
		s.back() = next(s.back());
	}

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(10);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

ll digitsum(ll n){
    ll ans = 0;
    while(n){
        ans+=n%10,n/=10;
    }
    return ans;
}

ll solve2(ll n){
    ll ans = 0;
    FOR(i,1,n+1)chmax(ans,digitsum(i));
    return ans;
}

ll solve(ll n){
    string N = to_string(n);
    bool flag = 1;
    FOR(i,1,N.size())if(N[i] != '9')flag = 0;
    if(N.size() == 1){
        //cout << N << endl;
        return stoi(N);
    }
    else if(flag){
        //cout << ctoi(N[0]) + 9*(N.size()-1) << endl;
        return ctoi(N[0]) + 9*(N.size()-1);
    }
    else{
        //cout << ctoi(N[0])-1+9*(N.size()-1) << endl;
        return ctoi(N[0])-1+9*(N.size()-1);
    }
}

signed main(){
    ll N;
    cin >> N;
    cout << solve(N) << endl;
}

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

using namespace std;

typedef long ll;

int main(int, char**)
{
	ll n, k, ans = 0;
	string str;
	cin >> n >> k >> str;

	if (str[k-1] == 'A') str[k-1] = 'a';
	else if (str[k-1] == 'B') str[k-1] = 'b';
	else if (str[k-1] == 'C') str[k-1] = 'c';

	cout << str << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b, c, d, e, f, g;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if(a < c){
        e = c;
    }else{
        e = a;
    }
    
    if(b < d){
        f = b;
    }else{
        f = d;
    }
    g = f - e;
    if(g > 0){
        printf("%d", g);
    }else{
        printf("%d", 0);
    }
   
    
}


Measured memory_bytes: 128
a,b,c=map(int,input().split())
d=max(a,b,c)
ad=d-a
bd=d-b
cd=d-c
ope=0
ope+=int(ad/2)+int(bd/2)+int(cd/2)
if ad%2==0 and bd%2==0 and cd%2==0:
  print(ope)
elif ad%2 + bd%2 + cd%2 == 1:
  print(ope+2)
else:
  print(ope+1)

Measured memory_bytes: 3064
///#pragma GCC optimize("Ofast")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
///#pragma GCC optimize("unroll-loops")

#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;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///(X).order_of_key(value) /// return lower_bound(value)
///(*X).find_by_order(index) /// return value (0 index)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); /// mt19937_64 (long long)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<bool> vbb;

const int N = 1000001;
const int MOD = 1000000007;
const ll INF = LLONG_MAX;

#define fast() ios_base::sync_with_stdio(false),cin.tie(NULL)
#define next(x) next_permutation(all(x))
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'
#define PI acos(-1)
#define Case(x) cout<<"Case "<<x<<": "
#define strtoint(a) atoi(a.c_str())
#define dbg(x) cerr<<#x<<" is "<<x<<'\n';
#define fix(x) cout<<fixed<<setprecision(x)
#define leastonepos(x) __builtin_ffs(x)
#define leadingoff(x) __builtin_clz(x)
#define trailingoff(x) __builtin_ctz(x)
#define numofone(x) __builtin_popcount(x)
#define time() cerr<<"Time elapsed : "<<clock()*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n'

#define coutv(v) for(auto it:v)cout<<it<<space;cout<<nl;
#define cinv(v) for(auto &it:v)cin>>it;

///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///



int main()
{
    fast();
    int tc=1,cs=0;
    //cin>>tc;
    while(tc--)
    {
        int n,i,k,j;
        cin>>n>>k;
        vii h(n),dp(n,INT_MAX);
        cinv(h);
        dp[0]=0;
        for(i=0; i<n; i++)
            for(j=1; i+j<n&&j<=k; j++)
                    dp[i+j]=min(dp[i+j],(dp[i]+abs(h[i]-h[i+j])));
        cout<<dp[n-1]<<nl;
    }
}

Measured memory_bytes: 4032
#include <iostream>
#include <iomanip>
#include <string>
#include <deque>
#include <cmath>

using namespace std;

int main()
{
  double l;

  cin >> l;

  double third = l / 3;

  cout << fixed << setprecision(12) << third * third * third << endl;

  return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>

typedef long long ll;



int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool seen = false;
    vector<int> rs;
    vector<int> ws;
    int r;
    int w;
    rs.push_back(0);
    ws.push_back(0);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W') {
            rs.push_back(rs.back());
            ws.push_back(ws.back() + 1);
        }
        if (s[i] == 'R') {
            rs.push_back(rs.back() + 1);
            ws.push_back(ws.back());
        }
    }
    int mn = n;
    for (int i = 0; i <= n; i++) {
        mn = min(mn, max(ws[i], rs.back() - rs[i]));
    }
    cout << mn<< endl;
}

Measured memory_bytes: 5140
# https://beta.atcoder.jp/contests/abc057/tasks/abc057_b
class Point(object):
    def __init__(self, x, y):
        self.x = int(x)
        self.y = int(y)

    @staticmethod
    def manhattan(p1, p2):
        return abs(p1.x - p2.x) + abs(p1.y - p2.y)

def solve():
    # Max(n, m) = (50, 50) => 50 * 2
    n, m = map(int, input().split())
    students = []
    for _ in range(n):
        students.append(Point(*input().split()))

    checkpoints = []
    for _ in range(m):
        checkpoints.append(Point(*input().split()))

    for student in students:
        min_dist = 4 * (10 ** 8)
        min_index = 1
        for index, cp in enumerate(checkpoints):
            manhattan = Point.manhattan(student, cp)
            if min_dist > manhattan:
                min_dist = manhattan
                min_index = index + 1
        print(min_index)


if __name__ == '__main__':
    solve()


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

int main(void){
  int n, a[10000], b[10000], i;
  long long int sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  for(i=0;i<n;i++) scanf("%d",&b[i]);
  for(i=0;i<n;i++){
    if(b[i]>=a[i]) sum+=(b[i]-a[i])/2;
    else sum-=a[i]-b[i];
  }
  if(sum>=0) printf("Yes\n");
  else printf("No\n");

  return 0;
}


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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main (){
    int a,b;
    scanf("%d%d",&a,&b);
    int x=0;
    if(b>a)
    {
        x=a,a=b,b=x;
    }
    else;
    
    int z=b;
    while(a%b!=0){
        z=a%b;
        a=b;
        b=z;
    }
    printf("%d\n",z);
    return 0;
}


Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],dp[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    long long n,b,k,i,x,y,t,f,j,z;
    cin>>n>>k;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	dp[0]=0;
	dp[1]=abs(arr[0]-arr[1]);
	for (i=2;i<k;i++)
	{
		x=1e12;
		for (j=0;j<i;j++)
		{
			y=abs(arr[j]-arr[i])+dp[j];
			x=min(x,y);
		}
		dp[i]=x;
	}
	for (i=k;i<n;i++)
	{
		x=1e12;
		for (j=i-k;j<i;j++)
		{
			y=abs(arr[j]-arr[i])+dp[j];
			x=min(x,y);
		}
		dp[i]=x;
	}	
	cout<<dp[n-1]<<endl;
}


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

int main(void){
	int r,c;
	cin >> r >> c;
	int **a = new int*[r];
	for(int i = 0;i < r;i++){
		a[i] = new int[c];
	}
	for(int i = 0;i < r;i++){
		for(int j = 0;j < c;j++){
			cin >> a[i][j];
		}
	}
	int *col = new int[c];
	int *row = new int[r];
	int sum = 0;
	for(int i = 0;i < r;i++){
		row[i] = 0;
	}
	for(int i = 0;i < c;i++){
		col[i] = 0;
	}
	for(int i = 0;i < r;i++){
		for(int j = 0;j < c;j++){
			col[j] += a[i][j];
			row[i] += a[i][j];
			sum += a[i][j];
		}
	}
	for(int i = 0;i < r;i++){
		for(int j = 0;j < c;j++){
			cout << a[i][j] << " ";
			if(j == c-1){
				cout << row[i] << endl;
			}
		}
	}
	for(int i = 0;i < c;i++){
		cout << col[i] << " ";
	}
	cout << sum << endl;
	delete[] col;
	delete[] row;
	for(int i = 0;i < r;i++){
		delete[] a[i];
	}
	delete[] a;
	return 0;
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

class PartParsistentUnionFind{
    typedef pair<int,int> pii;
private:
    vector<int> par;
    vector<int> time;
    vector<vector<pii>> size;
    int now;
public:
    PartParsistentUnionFind(){}
    PartParsistentUnionFind(int N){init(N);}
    void init(int N){
        par.clear(); time.clear(); size.clear();
        par.assign(N,-1);
        time.resize(N,INT_MAX);
        size.assign(N,vector<pii>(1,{0,1}));
        now = 0;
    }
    int find(int x,int T = INT_MAX){
        if(T == INT_MAX) T = now;
        if(time[x] > T) return x;
        else return find(par[x],T);
    }
    bool unite(int x,int y){
        now++;
        x = find(x,now); y = find(y,now);
        if(x == y) return false;
        if(par[x] < par[y]) swap(x,y);
        par[x] += par[y];
        par[y] = x;
        time[y] = now;
        size[x].push_back({now,par[x]});
        return true;
    }
    int Getnow(){ return now; }
    bool same(int x,int y,int T = INT_MAX){
        if(T == INT_MAX) T = now;
        return find(x,T) == find(y,T);
    }
};

void solve2(){
    int n,q; cin >> n >> q;
    PartParsistentUnionFind PPUF(n);
    vector<pair<int,pii>> query;
    while(q--){
        int com; cin >> com;
        int x,y; cin >> x >> y;
        if(com == 0){
            PPUF.unite(x, y);
        }else{
            query.push_back({PPUF.Getnow(),{x,y}});
        }
    }
    for(auto q:query){
        cout << PPUF.same(q.second.first,q.second.second,q.first) << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //   solve1();
    solve2();
    return 0;
}



Measured memory_bytes: 4392
#include<iostream>
#include<vector>
#include<numeric>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  
  string available="No";
  for (int i=0; i<=25; i++) {
    for (int j=0; j<15; j++) {
      if (4*i + 7*j == N) {
        available = "Yes";
        break;
      }
    }
    if (available == "Yes") break;
  }
  cout << available << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;

int n;
string s;
llint a[500005];

void solve(){
	cin >> s;
	n=s.size();
	llint cnt=0;

	for(int i=1;i<=n;i++){
		if(s[i-1]=='<')cnt++;
		else cnt=0;
		a[i]=max(a[i],cnt);
	}
	cnt=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='>')cnt++;
		else cnt=0;
		a[i]=max(a[i],cnt);
	}
	llint ans=0;
	for(int i=0;i<=n;i++){
		ans+=a[i];
	}
	cout << ans << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

ll fac(ll x) {
  ll ans = 1;
  for (int i = 0; i < x; i++) {
    ans *= i+1;
    ans %= 1000000007;
  }
  
  return ans;
}

int main() {
  ll N,M;
  cin >> N >> M;
  ll count = 0;
  if (N == M) count = fac(N) * fac(M) * 2 % 1000000007;
  else if (N == M+1 || M == N+1) count = fac(N) * fac(M) % 1000000007; 
  
  cout << count << endl;
}

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

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

int main(){
    int N, T;
    int c[100], t[100];

    cin >> N;
    cin >> T;

    const int inf = 100000;

    int min = inf;
    rep(i,N){
        cin >> c[i] >> t[i];
        if(t[i] <= T && min > c[i]) min = c[i];
    }

    if(min == inf) cout << "TLE" << endl;
    else cout << min << endl;

    return 0;
}

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

long long gcd(long long x, long long y){
    if(y==0){
        return x;
    }
    else{
        return gcd(y,x%y);
    }
}

int main(){
    long long a,b,ans =0;

    while(cin>>a>>b){
    ans =0;
   
    ans=gcd(a,b);
    cout<<ans<<" "<<a*b/ans<<endl;
}
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n, a, b;
  cin >> n >> a >> b;
  if (n == 1)
    cout << "Hello World" << endl;
  else
    cout << a + b << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
S = list(input())
ACGT = ['A', 'C', 'G', 'T' ]

max_count = 0

for i in range(len(S)):
    count = 0
    for j in range(i, len(S)):
        if S[j] in ACGT:
            count += 1
        else:
            break
    max_count = max(max_count, count)

print(max_count)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int A = N%10;
        if(A==3)System.out.println("bon");
        else if(A==0||A==1||A==6||A==8)System.out.println("pon");
        else System.out.println("hon");

    }
    public static void main(String[] args) {
        new Main().solve();
    }
    }

Measured memory_bytes: 35684
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int M,D;
	scan(M>>D);
	int ans=0;
	rep1(m,M){
		rep1(d,D){
			int d1=d%10,d2=d/10;
			if(d1>=2&&d2>=2&&d1*d2==m) ans++;
		}
	}
	prin(ans);
	return 0;
}


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

const int N = 200006;
int a[N];

int main () {
    int n; scanf("%d", &n);
    int xor_sum = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        xor_sum ^= a[i];
    }
    for (int i = 1; i <= n; ++i) {
        printf("%d%c", xor_sum ^ a[i], " \n"[i == n]);
    }
}


Measured memory_bytes: 4468
from sys import stdin

a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
now = 0
for i in range(c):
    if now%2 == 0:
        if a%2 == 1:
            a = (a-1)//2
            b += a
        else:
            a = a//2
            b += a
    else:
        if b%2 == 1:
            b = (b-1)//2
            a += b
        else:
            b = b//2
            a += b
    now += 1
print(a,b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll int n,ans,i,a1,a2,ar,aw;
	string s;
	cin>>n;
	cin>>s;
	a1=0;a2=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='W')a2++;
		else a1++;
	}
	ar=0;
	for(i=0;i<a1;i++)
	{
		if(s[i]=='R')ar++;
	}
	aw=0;
	for(i=s.size()-1;i>=n-a2;i--)
	{
		if(s[i]=='W')aw++;
	}
	cout<<min(a1-ar,a2-aw)<<endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> P(N),Q(N),R;
    for(int i = 0; i < N; i++) cin >> P[i];
    for(int i = 0; i < N; i++) cin >> Q[i];
    R = P;
    sort(R.begin(), R.end());

    int a, b;
    int i = 0;
    do{
        if(R == P) a = i;
        if(R == Q) b = i;
        i++;
    }while(next_permutation(R.begin(), R.end()));

    cout << abs(a - b) << endl;
}

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

int main() {
  long long cnt=0, Sum=0;
  string S;
  cin >> S;
  rep(i, S.size()){
    if(S.at(i)=='B') cnt++;
    if(S.at(i)=='W') Sum+=cnt;
  }
  cout << Sum << endl;      
}

Measured memory_bytes: 640
#include	<stdio.h>

int main(int argc, char** argv){
	
	int i, j, k , l, m, n;

	while(scanf("%d", &n) != EOF){
		m = 0;
		for(i = 0; i < 10; i++){
			for(j = 0; j < 10; j++){
				for(k = 0; k < 10; k++){
					for(l = 0; l < 10; l++){
						if(i + j + k + l == n)	m++;
					}
				}
			}
		}
		printf("%d\n", m);
	}
	return 0;
}

Measured memory_bytes: 0
eval"A,B,C,D,E,F="+gets.split*?,
d={}
f=->a,b{
  d[[a,b]] ||= if a*100+b > F || a*E < b
    -1
  else
    [b.quo(a),f[a+A,b],f[a+B,b],f[a,b+C],f[a,b+D]].max
  end
}
f[A,0]
f[B,0]
# a,b=d.sort.max_by{|_,v|v}[0]
# a,b=d.sort_by{|k,v|p [v,k]}[0]
a,b=d.max_by{|_,v|v}[0]
puts"#{a*100+b} #{b}"


Measured memory_bytes: 3708
import sys
def 解():
    input = sys.stdin.readline
    iN = int(input())
    aF = [0]*iN
    aP = [0]*iN
    for i in range(iN):
        aF[i] = int(input().rstrip().replace(' ',''),2)
    for i in range(iN):
        aP[i] = [int(_) for  _ in input().split()]
    iD = 2**10
    iMax = -1*(10**10)
    for i in range(1,iD):
        iM = 0
        for j in range(iN):
            iM += aP[j][bin(aF[j] & i).count("1")]
        if iMax < iM:
            iMax = iM
    print(iMax)
解()


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int r=sc.nextInt();
		int c=sc.nextInt();
		int[][] h=new int[r+1][c+1];

		for(int i=0;i<r;i++) {
			int rsum=0;
			for(int j=0;j<c;j++) {
				int tmp=sc.nextInt();
				rsum +=tmp;
				h[i][j]=tmp;
			}
			h[i][c]=rsum;
		}
		for(int i=0;i<c+1;i++) {
			int rsum=0;
			for(int j=0;j<r;j++) {
				rsum+=h[j][i];
			}
			h[r][i]=rsum;
		}
		for(int i=0;i<r+1;i++) {
			for(int j=0;j<c;j++) {
				System.out.print(h[i][j]+" ");
			}
			System.out.println(h[i][c]);
		}

	}
}


Measured memory_bytes: 41800
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
const int debug=0;
const Int MAX = (debug?30:30*30);
using BS = bitset<MAX*2>;
void det(vector<BS> &v){
  int n=v.size();
  for(Int i=0;i<n;i++){
    for(Int k=i;k<n;k++){
      if(v[k][i]){
	swap(v[i],v[k]);
	break;
      }
    }
    for(Int k=0;k<n;k++)
      if(i!=k&&v[k][i]) v[k]^=v[i];
  }
}

signed main(){
  int m,n,d;
  while(cin>>m>>n>>d,m){
    vector<vector<int> > s(n,vector<int>(m));
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	cin>>s[i][j];
    

    vector<BS> v(n*m,BS(0));
    auto idx=[&](int y,int x){return y*m+x;};
    auto in=[&](int y,int x){return 0<=y&&y<n&&0<=x&&x<m;};
    auto bfs=[&](int y,int x){
      int z=idx(y,x);
      v[z][z]=1;
      v[z][n*m]=s[y][x];
      
      vector<vector<int> > dp(n,vector<int>(m,-1));
      using P = pair<int, int>;
      queue<P> q;
      dp[y][x]=0;
      q.emplace(y,x);
      int dy[]={0,0,1,-1};
      int dx[]={1,-1,0,0};
      while(!q.empty()){
	tie(y,x)=q.front();q.pop();
	if(dp[y][x]==d) v[z][idx(y,x)]=1;
	for(int k=0;k<4;k++){
	  int ny=y+dy[k],nx=x+dx[k];
	  if(!in(ny,nx)||~dp[ny][nx]) continue;
	  dp[ny][nx]=dp[y][x]+1;
	  q.emplace(ny,nx);
	}
      }
    };
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	bfs(i,j);
    
    auto u=v;
    det(v);
    int ans=1;
    for(int i=0;i<n*m;i++){
      int tmp=s[i/m][i%m];
      for(int j=0;j<n*m;j++) tmp+=u[i][j]&v[j][n*m];
      if(debug) cout<<i<<" "<<tmp<<endl;
      ans&=!(tmp&1);
    }
    cout<<ans<<endl;
    if(debug && m==4) return 0;
  }
  return 0;
}



Measured memory_bytes: 3328
// Author :: <Hitesh_Saini>
#include<bits/stdc++.h>

#define __speed() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define dbg(x) cout << "--- " << #x << " = " << x << " ---\n";
#define findmax(v) *max_element(v.begin(), v.end())
#define _sum(a) accumulate(a.begin(), a.end(), 0)
#define tt int t;for(cin>>t; t--; )
#define f0(i, n) for(i = 0; i < int(n); i++)
#define f1(i, n) for(i = 1; i<= int(n); i++)
#define all(x) x.begin(), x.end()
#define pq priority_queue
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define S second
#define ar array
#define F first

using namespace std;
using mii = map<int, int>;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1e9+7,mxN = 2e6+5;

template<typename... Args>void print(Args... args){((cout << args << " "), ...);cout << endl;}
ll mod_pow(ll x, ll y){ll res=1;x%=mod;for(;y>0; y>>=1, x=(x*x)%mod)if(y&1)res=(res*x) % mod; return res; }ll mod_inv ( ll n ){ll ans = mod_pow ( n , mod - 2 ) ;return ans ;}ll mul(ll a, ll b){a%=mod, b%=mod;return (a*b)%mod;}ll sub(ll a,ll b){a%=mod, b%=mod;return (a-b+mod)%mod;}ll add(ll a, ll b){a%=mod, b%=mod;return (a+b)%mod;}
bool prime(ll n){if(n<2)return 0;if(n<4)return 1;if(n%2==0||n%3==0)return 0;for(ll i=5;i*i<=n;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>  
using namespace __gnu_pbds; 
#define iset tree<ll , null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define iof order_of_key
#define findat find_by_order */
ll n;
string st;
void solve(){ //B
		cin >>  n;
		cout << 1000 -(n%1000==0?1000:n%1000);
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
    __speed();
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int l[50];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> l[i];
	sort(l, l + N, greater<int>());
	int sum = 0;
	for (int i = 0; i < K; i++) sum += l[i];
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			Pair kazuyuki = new Pair(b, a);
			Pair takayuki = new Pair(d, c);
			boolean[][] map = new boolean[h + 2][w + 2];
			for (int i = 1; i <= h; i++) {
				for (int j = 1; j <= w; j++) {
					map[i][j] = scanner.nextInt() == 0;
				}
			}
			Deque<Pair> pq = new ArrayDeque<Main.Pair>();
			int dis = dist(takayuki, kazuyuki);
			pq.add(new Pair(takayuki.y, takayuki.x, kazuyuki.y, kazuyuki.x, 0,
					dis));
			String ans = "NA";
			boolean[][][][] mem = new boolean[h + 2][w + 2][h+2][w+2];
			mem[takayuki.y][takayuki.x][kazuyuki.y][kazuyuki.x] = true;
			while (!pq.isEmpty()) {
				Pair pair = pq.poll();
				if (pair.y == pair.dy && pair.x == pair.dx) {
					ans = String.valueOf(pair.cost);
					break;
				}

				for (int i = 0; i < 4; i++) {
					int nty = pair.y + move[i][0];
					int ntx = pair.x + move[i][1];
					int nky = pair.dy + move[i][2];
					int nkx = pair.dx + move[i][3];
					if (!map[nty][ntx]) {
						nty = pair.y;
						ntx = pair.x;
					}
					if (!map[nky][nkx]) {
						nky = pair.dy;
						nkx = pair.dx;
					}
					if (mem[nty][ntx][nky][nkx])
						continue;
					mem[nty][ntx][nky][nkx] = true;
					int newdis = dist(new Pair(nty, ntx), new Pair(nky, nkx));
					pq.offer(new Pair(nty, ntx, nky, nkx, pair.cost + 1,
							pair.cost + 1 + newdis));
				}
			}
			System.out.println(ans);
		}
	}

	int[][] move = { { -1, 0, 1, 0 }, { 0, -1, 0, 1 }, { 1, 0, -1, 0 },
			{ 0, 1, 0, -1 } };

	int dist(Pair a, Pair b) {
		return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
	}

	class Pair implements Comparable<Pair> {
		int y;
		int x;
		int dy;
		int dx;
		int cost;
		int md;

		public Pair(int y, int x, int dy, int dx, int cost, int md) {
			super();
			this.y = y;
			this.x = x;
			this.dy = dy;
			this.dx = dx;
			this.cost = cost;
			this.md = md;
		}

		public Pair(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

		@Override
		public String toString() {
			return "Pair [y=" + y + ", x=" + x + ", dy=" + dy + ", dx=" + dx
					+ ", cost=" + cost + ", md=" + md + "]";
		}

		@Override
		public int compareTo(Pair o) {
			if (this.md == o.md)
				return this.cost - o.cost;
			return this.md - o.md;
		}

	}
}

Measured memory_bytes: 108872
#include<iostream>
#include<cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		if (sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya)) <= (ra + rb) && abs(rb - ra) <= sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya))) {
			cout << "1" << endl;
		}
		else if (sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya)) > (ra + rb)) {
			cout << "0" << endl;
		}
		else if (sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya)) < abs(rb - ra) && rb > ra) {
			cout << "-2" << endl;
		}
		else if (sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya)) < abs(rb - ra) && ra > rb) {
			cout << "2" << endl;
			
		}
	}
	return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>

using namespace std;

int main(){
	char a[30];
	cin>>a;
	for(int i=0;i<5;i++){
		cout<<a[i];
	}
	cout<<" ";
	for(int i=6;i<13;i++){
		cout<<a[i];
	}
	cout<<" ";
	for(int i=14;i<19;i++){
		cout<<a[i];
	}
	cout<<" ";
	return 0;
}

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$s=str_split(trim(fgets(STDIN)));
$ans=0;
$i=1;
while($i<$n-1){
  $a=array_slice($s,0,$i);
  $b=array_slice($s,$i);
  $c=array_intersect($a,$b);
  $ans=max($ans,count(array_count_values($c)));
  ++$i;
}
echo $ans;

Measured memory_bytes: 4604
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def count(s, start):
    cnt = 0
    n = len(s)
    e = str(start) # 偶数番目はstartの文字
    o = str((1,0)[start]) # 奇数番目はstartでない文字（0,1を逆にする）
    for i in range(n):
        if i%2==0 and s[i] != e: cnt += 1
        elif i%2==1 and s[i] != o: cnt += 1
    return cnt

def main():
    S = input()
    cnt_0 = count(S, 0)
    cnt_1 = count(S, 1)
    print(min(cnt_0, cnt_1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
long long int n,p,dp[110][2],num[110];
int main()
{
    scanf("%lld%lld",&n,&p);
    ff(i,1,n)
    {
        long long now;
        scanf("%lld",&now);
        if(now%2)
        num[i]=1;
        else
        num[i]=0;
    }
    if(num[1]==0)
    {
        dp[1][0]=2;
        dp[1][1]=0;
    }
    else
    {
        dp[1][0]=1;
        dp[1][1]=1;
    }
    ff(i,2,n)
    {
        if(num[i]==1)
        {
            dp[i][0]=dp[i-1][1]+dp[i-1][0];
            dp[i][1]=dp[i-1][1]+dp[i-1][0];
        }
        else
        {
            dp[i][0]=2*dp[i-1][0];
            dp[i][1]=2*dp[i-1][1];
        }
    }
    printf("%lld",dp[n][p]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    # define ll long long int
    
    int main(){
    	#ifndef ONLINE_JUDGE
    		freopen("input.txt","r",stdin);
    		freopen("output.txt","w",stdout);
    	#endif

        ios::sync_with_stdio(false);
        cin.tie(0);
        int n,k;
        cin>>n>>k;
        vector <int> B(n+2,0);
        vector<int> a(n);
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }

        while(k--){
            for(int i=0;i<=n+1;i++){
                B[i]=0;
            }
            for(int i=1;i<=n;i++){
                int l=max(1,i-a[i]);
                int r=min(n,i+a[i]);
                B[l]++;
                B[r+1]--;
            }
            
            
          //  cout<<B[1]<<" dsf";
            for(int i=1;i<=n;i++)B[i]+=B[i-1];
        
            // for(int i=1;i<=n;i++)cout<<B[i]<<" ";
            //     cout<<endl;


            bool check=true;

            for(int i=1;i<=n;i++){
                a[i]=B[i];
                if(a[i]!=n)
                    check=false;
            }
            if(check)
                break;    
        }
        for(int i=1;i<=n;i++){
            if(i>1) cout<<" ";
            cout<<a[i];
        }
        cout<<" \n";

    }
    


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

int main() {
  
  int max_time = 48;//12/30から1/1になるまでの最大の時間
  int now_time;//今の時間
  cin >> now_time;
  int next_time = max_time - now_time;
  cout << next_time << endl; // 5
}

Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    double t,d,s;
    cin>>d>>t>>s;
    double x=double(d/s);
    if(x<=t) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 15144
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

using ll = long long;

int main(){
  int x[2], y[2]; cin >> x[0] >> y[0];
  x[1] = -x[0]; y[1] = -y[0];

  ll ans = 1e10;

  for(int i=0; i<2; i++){
    for(int j=0; j<2; j++){
      if(x[i] <= y[j]){
        ll dis = y[j] - x[i];
        if(i) dis++;
        if(j) dis++;

        ans = min(dis, ans);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  string T;
  cin >>T;
  int N=T.size();
  for(int i=0;i<N;i++){
    if(T[i]=='?'){
      T[i]='D';
    }
  }
  cout<<T<<endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int fi[130][130];
int d[130][130];
int xx,yy;

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int t,n; cin >> t >> n;
		if(t==0&&n==0)break;
		for(int i=0;i<130;i++){
			for(int j=0;j<130;j++){
				fi[i][j]=1;
				d[i][j]=1e9;
			}
		}
		for(int i=0;i<n;i++){
			int x,y; cin >> x >> y;
			x+=60; y+=60;
			fi[x][y]=0;
		}
		cin >> xx >> yy;
		xx+=60; yy+=60;
		d[xx][yy]=0;
		queue<pair<int,int>> q;
		q.push(make_pair(xx,yy));
		while(q.size()){
			auto p=q.front(); q.pop();
			int x=p.first,y=p.second;
			for(int i=0;i<6;i++){
				int nx=x+dx[i],ny=y+dy[i];
				if(0<=nx&&nx<130&&0<=ny&&ny<130){
					if(fi[nx][ny]==0)continue;
					if(d[nx][ny]>d[x][y]+1){
						d[nx][ny]=d[x][y]+1;
						q.push(make_pair(nx,ny));
					}
				}
			}
		}
		int res=0;
		for(int i=0;i<130;i++){
			for(int j=0;j<130;j++){
				if(d[i][j]<=t)res++;
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 3188
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
#define UPADHYAY int t;cin>>t;while(t--)
ll p=1e9+7;
ll power(ll n,ll m){
    if(m==0)return 1;
    ll k=power(n,m/2);
    k=(k*k)%p;
    if(m&1)
    return (k*n)%p;
    return k;
    
}
int main(){
    ll n,ans,k;
    cin>>n;
    ans=(power(10,n))%p;
    k=(power(9,n)*2)%p;
    ans=(ans-k+p)%p;
    k=(power(8,n))%p;
    ans=(ans+k)%p;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

typedef long long ll;

ll mod=1e9+7;

ll f(ll x)
{
    ll sum = 1;
    for (int i = 1; i <= x; i ++ )
    {
        sum *= i;
        sum %= mod;
    }
    return sum;
}

int main()
{
    ll n,m;
    cin >> n >> m;

    if (abs(n-m) > 1)
    cout << "0" << endl;
    else if(abs(n-m) == 0)
    {
        ll cnt = 2*f(n)*f(m);
        cout << cnt%mod<< endl;
    }
    else if(abs(n-m) == 1)
    {
        ll cnt = f(n)*f(m);
        cout << cnt%mod<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n;  
cin >>  n;
cout << n * n * n << endl;
  return 0;
}



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

int n,m,q;
int a[11];
int b[21];
LL X[53],Y[53],Z[53],W[53];
int main(){
	
	cin >> n >> m >> q;
	for(int i=1; i<=q ;i++){
		cin >> W[i] >> X[i] >> Y[i] >> Z[i];
	}
	for(int i=1; i<m ;i++)
		b[i]=0;
	
	for(int i=m; i<m+n ;i++) 
		b[i]=1;
		
		
	LL ans=0;
	do{
		{
			int val=1,cnt=1;
		    for(int i=1; i<m+n;i++){
		
			if(!b[i]) val++;
			else{
				a[cnt++]=val;
			}
		}
		}
		LL res=0;
		for(int i=1; i<=q ;i++){
			if(a[X[i]]-a[W[i]]==Y[i]) res+=Z[i];
		}
		ans=max(ans,res);
	}while(next_permutation(b+1,b+m+n));
	cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x-a) < abs(x-b) ? 'A' : 'B') << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    p_tuple = tuple(map(int, input().split()))

    radius = 0
    for i in range(100):
        if x-radius not in p_tuple:
            print(x-radius)
            return
        elif x+radius not in p_tuple:
            print(x+radius)
            return
        else:
            radius += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
n = int(input())
h = [int(x) for x in input().split()]

def abs(x):
    if x >= 0:
        return x
    return -x

c = [0]
c.append(abs(h[1] - h[0]))
for k in range(2, n):
    cnext = min(c[k-2] + abs(h[k]-h[k-2]), c[k-1] + abs(h[k] - h[k-1]))
    c.append(cnext)

print(c[-1])

Measured memory_bytes: 13924