akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var s = cin.Read;
            if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
            {
                WriteLine("Bad");
            }
            else
            {
                WriteLine("Good");
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  printf("%d %d %d\n", z, x, y);
}


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

using ll = long long;
const int INF = 1e9+7;

void solve()
{
	int n;
	int var = 0;
	for(int i=1;i<=5;++i)
	{
		cin >> n;
		if(n==0)
			var=i;
	}
	cout << var << '\n';
}

int main()
{
	int t=1;
	//int t;cin >> t;
	while(t--) solve();
}	

Measured memory_bytes: 3540
import sys
input = sys.stdin.readline


class Human:

    def __init__(self, statements):
        self.statements = statements

    def is_honest(self, honest_list):
        for x, y in self.statements:
            if y:
                if x not in honest_list:
                    return False
            else:
                if x in honest_list:
                    return False
        return True


class Humans:

    def __init__(self):
        self.humans = [None]

    def add(self, human: Human):
        self.humans.append(human)

    def is_all_honest(self, honest_list):
        for i in honest_list:
            if not self.humans[i].is_honest(honest_list):
                return False
        return True


def main():
    n = int(input())
    humans = Humans()
    for _ in range(n):
        a = int(input())
        xy = [tuple(map(int, input().split())) for _ in range(a)]
        humans.add(Human(xy))
    max_honest = 0
    for bit in range(2**n):
        honest_list = []
        for i in range(n):
            if (bit >> i) & 1:
                honest_list.append(i+1)  # 1ずれるため補正
        if humans.is_all_honest(honest_list):
            max_honest = max(max_honest, len(honest_list))
    print(max_honest)


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    int N, L;
    cin >> N >> L;
    vector<string> s(N);
    for(auto &S: s) cin >> S;
    sort(s.begin(),s.end());
    for(auto S: s) cout << S;
    cout << endl;
}   

Measured memory_bytes: 256
"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
import math
import sys
# input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

n = int(input())
matrix = []
#Essentially I'm checking every row element with the previous row's opposing elements and seeing the maximum
for _ in range(n):
    temp = inlt()
    matrix.append(temp)
dp = matrix[0]
m = [0]*3
for i in range(n - 1):
    for j in range(3):
        m[j] = max(dp[(j+1)%3]  + matrix[i+1][j], dp[(j+2)% 3]+ matrix[i+1][j])
    dp = m
    m = [0] * 3
    #print('dp:', dp, ' | ', 'm:', m)
print(max(dp))


Measured memory_bytes: 62680
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {

	ll n, k;
	in(n);
	in(k);

	vll x(n), ans(n - k+1);
	rep(i, 0, n) {
		in(x[i]);
	}

	repeq(i, 0, n - k){
		if (x[i] < 0) {
			if (x[i + k-1] > 0) {
				ans[i] = x[i + k-1] - x[i];
				ans[i] += (-1 * x[i]) < x[i + k-1] ? (-1 * x[i]) : x[i + k-1];
			}
			else {
				ans[i] = -1 * x[i];
			}
		}
		else {
			ans[i] = x[i + k-1];
		}
	}
	sort(ans.begin(), ans.end());
	outn(ans[0]);

	return 0;

}


Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            StringBuilder ans = new StringBuilder();
            for (int i = 0; i < inputString.size(); i++) {
                if (i % 2 == 0) {
                    ans.append(inputString.get(i));
                }
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    vector<vector<int>> x(n), y(n);
    for(int i = 0;i < n;i++){
        cin >> A[i];
        for(int j = 0;j < A[i];j++){
            int a, b;
            cin >> a >> b;
            x[i].push_back(a - 1);
            y[i].push_back(b);
        }
    }
    int res = 0;
    for(int s = 0;s < (1 << n);s++){
        vector<int> v(n, -1);
        queue<int> q;
        for(int i = 0;i < n;i++) if(s & (1 << i)) {
            v[i] = 1;
            q.push(i);
        }
        bool ng = false;
        while(!q.empty() && !ng){
            auto id = q.front(); q.pop();
            for(int i = 0;i < A[id];i++){
                if(v[x[id][i]] == -1){
                    v[x[id][i]] = y[id][i];
                    if (y[id][i] == 1) q.push(x[id][i]);
                    continue;
                }
                if(v[x[id][i]] != y[id][i]){
                    ng = true;
                    break;
                }
            }
        }
        if(!ng){
            res = max(res, __builtin_popcount(s));
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;


int main(void){
    int n,m;
    cin >> n >> m;
    int s[m],c[m];
    REP(i,m) cin >> s[i] >> c[i];
    REP(x,1000){
        int keta=1;
        int nx=x/10;
        vector<int> d(1,x%10);
        while(nx){
            keta++;
            d.push_back(nx%10);
            nx/=10;
        }
        if(keta!=n) continue;
        bool ok=true;
        reverse(ALL(d));
        REP(i,m){
            if(d[s[i]-1]!=c[i])ok=false;
        }
        if(ok){
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

using P = pair<int, int>;
const int INF = 1001001001;

// 0: 左 1: 上 2: 下 3: 右
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};

int main(){
    int H, W; // H: 高さ W: 幅
    cin >> H >> W;

    vector<string> s(H);
    rep(i, H) cin >> s.at(i);

    int ans = 0;

    rep(si, H)rep(sj, W) {
        if (s[si][sj] == '#') continue;

        vector<vector<int>> dist(H, vector<int>(W, INF)); // 最短距離を保存する。
        queue<P> q; // bfs用のキュー

        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF) return;
            dist[i][j] = x;
            q.emplace(i, j);
        };
        update(si, sj, 0);

        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();

            rep(dir, 4) {
                int ni = i + di[dir];
                int nj = j + dj[dir];

                if (ni<0 || ni>=H || nj<0 || nj>=W) continue;
                if (s[ni][nj] == '#') continue;
                update(ni, nj, dist[i][j] + 1);

            }
        }

        rep(i, H)rep(j, W) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
 using namespace std;
 #define ll long long
 int main()
 {
 	ll value,n,m,k;
 	cin>>n>>m>>k;
 	vector<ll> a,b;
 	for(int i=0;i<n;i++)
 	{
 		cin>>value;
 		a.push_back(value);
	 }
	for(int i=0;i<m;i++)
 	{
 		cin>>value;
 		b.push_back(value);
	 }
	 vector<ll> sumA(n+1),sumB(m+1);
	for(int i=0;i<n;i++)
	{
		sumA[i+1]=sumA[i]+a[i];
	 } 
	for(int i=0;i<m;i++)
	{
		sumB[i+1]=sumB[i]+b[i];
	 } 
	 int total=0;
	 for(int i=0;i<=n;i++){
	 	ll other=k-sumA[i]; 
	 	if(other<0)
	 	    continue;
	 	int l=lower_bound(sumB.begin(),sumB.end(),other)-sumB.begin();
		if(l>m || sumB[l]>other)
		       --l;
		total=max(total,i+l);	        
	 } 
 	   cout<<total; 
 	   return 0;
  } 

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

int main() {
    int a, b, c = 0, d = 0;

    cin >> a >> b;
    for (int i = 0; i < b; i++) {
        c += a * pow(10, i);
    }

    for (int i = 0; i < a; i++) {
        d += b * pow(10, i);
    }

    if (a <= b) {
        cout << c << endl;
    } else {
        cout << d << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
s = list(input())
a=0
b=0
frag=True
for i in range(len(s)):
    if (s[i]=='A')and frag :
        a=i  
        frag=False
    elif s[i]=='Z':
        b=i
# print(a)
# print(b)
print(b-a+1)


Measured memory_bytes: 4964
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

int main(){
    string s1,s2;
    while(getline(cin,s1)){
        getline(cin,s2);
        bool judge=false;
        for(int i=0;i<s2.length();i++){
            if(s2[i]==s1[0]){
                string temp2=s2.substr(i);
                string temp1=s1.substr(0,temp2.length());
                if(temp2==temp1){
                    string temp3=s1.substr(temp2.length());
                    string temp4=s2.substr(0,i);
                    if(temp3==temp4)
                        judge=true;
                }
            }
            if(judge==true)
                break;
        }
        if(judge){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
   int n,l; cin>>n>>l;
   vector<int> li(n);
   for(int i=0;i<n;i++){
      li[i]=l+i;
   }
   int minj=300;
   int mini;
   int ans=0;
   for(int i=0;i<n;i++){
      if((abs(li[i]))<minj){
         minj=abs(li[i]);
         mini=li[i];
      }
      ans+=li[i];
   }
   cout<<ans-mini<<endl;
   return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int a[N];
  for (int i=0;i<N;i++) cin >> a[i];
  int sum = 0;
  for (int i=0;i<N;i++){
    sum+=a[i];
  }
  sort(a,a+N,greater<>());
  if(a[M-1]*4*M>=sum){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[100009],dp[100009][4],k,z[4],zx,i,j,xc,pas;
long long g[100009];
vector <long long> v[100009];
map <char, long long> m;
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>k;
    //cin>>r>>s>>p;
    cin>>z[1]>>z[2]>>z[3];
    m['r']=1;m['s']=2;m['p']=3;
    cin>>s;
    for(b=0; b<a; b++){
        if(s[b]=='r'){
            g[b+1]=m['p'];
        }
        if(s[b]=='s'){
            g[b+1]=m['r'];
        }
        if(s[b]=='p') g[b+1]=m['s'];
    }
    for(b=1; b<=a; b++){
        v[b%k].push_back(b);
    }
    for(b=0; b<k; b++){
        if(v[b].size()==0) continue;
        zx=v[b][0];
        for(d=1; d<=3; d++){
            if(d==g[zx]){
                dp[zx][d]=z[d];
            }else{
                dp[zx][d]=0;
            }
        }
        for(c=1; c<v[b].size(); c++){
            zx=v[b][c];
            xc=v[b][c-1];
            for(d=1; d<=3; d++){
                if(d==g[zx]) i=z[d]; else i=0;
                for(e=1; e<=3; e++){
                    if(d==e) continue;
                    if(dp[zx][d]<dp[xc][e]+i) dp[zx][d]=dp[xc][e]+i;
                }
            }
        }
        i=0;
        for(d=1; d<=3; d++){
            if(i<dp[v[b][v[b].size()-1]][d]) i=dp[v[b][v[b].size()-1]][d];
        }
//        cout<<i<<endl;
        pas+=i;
    }
    cout<<pas;
    return 0;
}


Measured memory_bytes: 9324
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    long long n, a[5],t=0,u=0;
    cin >> n>>a[0];
    t += (n - 1) / a[0]+1, u ++;
    for (int i = 1; i < 5;i++) {
        cin >> a[i];
        t = max(u + (n - 1) / a[i]+1, t + 1), u++;
    }
    cout << t << endl;
}
  

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

using namespace std;
#define ll long long
int num[105];
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> num[i];
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(i%2 && num[i]%2)
            cnt++;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>

int main(){
  int W, H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x<0||x>W||y<0||y>H||x-r<0||x+r>W||y-r<0||y+r>H) printf("No\n");
  else printf("Yes\n");
  return 0;
}



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
map<string,int> p;
int main()
{
    FastRead;
    int t;
    cin>>t;
    while (t--)
    {
        string s;
        cin>>s;
        p[s]++;
    }
    cout<<sz(p)<<endl;
    
    return 0;
}

Measured memory_bytes: 19220
#include <stdio.h>
int main(void){
  int k,x;
  scanf("%d%d",&k,&x);

  for(int i=1;i<=2*k-1;i++){
    if((x-k+i>-1000000)&&(x-k+i<100000)){
      printf("%d ",x-k+i);
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	cin >> N;
	lint now = 100000;
	rep(i, N) {
		now += now * 5/100;
		now = now / 1000 * 1000 + 1000 * bool(now % 1000);
	}
	cout << now << endl;
}


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

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        int k = in.nextInt();
        final long mod = 1000000007;
        long[] fact = getFact(n, mod);
        for (int i = 1; i <= k; i++) {
            long ans = modcomb(k - 1, i - 1, fact, mod) * modcomb(n - k - (i - 1) + i, i, fact, mod) % mod;
            System.out.println(ans);
        }
    }

    long modcomb(int n, int r, long[] fact, long mod) {
        if (n < 0 || r < 0 || n < r) return 0;
        return fact[n] * modinv(fact[n - r], mod) % mod * modinv(fact[r], mod) % mod;
    }

    long[] getFact(int n, long mod) {
        long[] fact = new long[n + 1];
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i % mod;
        }
        return fact;
    }

    long modinv(long n, long mod){
        return modpow(n, mod-2, mod);
    }

    long modpow(long n, long a, long mod){
        long res = 1;
        while(a > 0){
            if((a&1)==1) res = (res * n) % mod;
            n = n * n % mod;
            a >>= 1;
        }
        return res;
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 23508
while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    a = [int(input()) for _ in range(n)]
    s = sum(a[0:k])
    ss = [s]
    for i in range(k,n):
        s = s + a[i] - a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11700
#include<stdio.h>

#define SENTINEL 1000000010

int cnt = 0;

void Merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    int i, j, k;

    for(i=0; i<n1; i++) L[i] = A[left + i];

    for(i=0; i<n2; i++) R[i] = A[mid + i];

    L[n1] = SENTINEL;
    R[n2] = SENTINEL;

    i = j = 0;

    for(k=left; k<right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
        cnt++;
    }
}

void MergeSort(int A[], int left, int right){
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        MergeSort(A, left, mid);
        MergeSort(A, mid, right);
        Merge(A, left, mid, right);
    }
}

int main(){
    int n, A[500000 + 10];
    int i, j;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    MergeSort(A, 0, n);

    for(i=0; i<n; i++){
        printf("%d", A[i]);
        if(i != n-1) printf(" "); 
    }
    printf("\n%d\n", cnt);

}





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

using namespace std;

int main() {
    int sum = 0;
    for (int i = 0; i < 4; ++i) {
        int t;
        cin >> t;
        sum += t;
    }
    cout << sum / 60 << '\n';
    sum -= sum / 60 * 60;
    cout << sum << '\n';
}


Measured memory_bytes: 3076
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c;
    cin >> c;
    if(a + b + c > 21)cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define ve vector
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
const int mod = 998244353;
int main(){
    int n, s;
    cin >> n >> s;
    ve<int> a(n);
    rep(i,n) cin >> a[i];
    ve<ve<ll>> dp(n+1, ve<ll>(s+1));
    dp[0][0] = 1;
    rep(i,n){
        rep(j,s+1){
            (dp[i+1][j] += dp[i][j] * 2) %= mod;
            if(j+a[i]<=s){
                (dp[i+1][j+a[i]] = dp[i][j]) %= mod;
            }
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 73716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    VI x(5);
    rep(i, 5) {
        cin >> x[i];
        if (x[i] == 0) cout << (i+1) << endl;
    }
    return 0; 
}

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int A[5];
    for(int i = 0; i < 5; i++)
        scanf("%d", &A[i]);
    int k;
    scanf("%d", &k);
    sort(A, A+5);
    if(A[4] - A[0] > k) printf(":(\n");
    else printf("Yay!\n");
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
typedef long long ll;
const ll INF = 1LL << 60;

struct Edge {
    int from,to,cost;
    Edge(int f,int t,int c) : from(f),to(t),cost(c){}
};

vector<Edge> edges;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,m,a,b,c;
    cin >> n >> m;
    REP(i,m){
        cin >> a >> b >> c;
        --a;--b;
        edges.emplace_back(a,b,-c);
    }
    vector<ll> dist(1010,INF);
    dist[0] = 0;
    for(int i = 0; i <= 2*n; ++i){
        for(Edge e : edges){
            if(dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost){
                dist[e.to] = dist[e.from] + e.cost;
                if(i >= n && e.to == n-1){
                    cout << "inf" << endl;
                    return 0;
                }
            }
        }
    }
    cout << -dist[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import*
def _add(data, k, x):
    while k <= N:
        data[k] += x
        k += k & -k
def add(l, r, x):
    _add(data0, l, -x*(l-1))
    _add(data0, r, x*(r-1))
    _add(data1, l, x)
    _add(data1, r, -x)

def _get(data, k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
def query(l, r):
    return _get(data1, r-1) * (r-1) + _get(data0, r-1) - _get(data1, l-1) * (l-1) - _get(data0, l-1)
N,d,a,*t=map(int,open(0).read().split())
N+=1
z=sorted(zip(*[iter(t)]*2))
data0=[0]*(N+1)
data1=[0]*(N+1)
y=[x for x,_ in z]
c=0
for i,(x,h)in enumerate(z,1):
    h-=query(i,i+1)
    t=0--max(0,h)//a
    j=bisect(y,x+d+d)
    add(1,j+1,t*a)
    c+=t
print(c)

Measured memory_bytes: 127788
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

const long long int MAX_Q = 100, MAX_V = 1000000000;

long long int answer(long long int &a, long long int &b){
  long long int A, B, res;
  if (a <= b) {
    A = a;
    B = b;
  }
  else {
    A = b;
    B = a;
  }
  if (A == B or A+1 == B) res = 2*(A-1);
  else {
    long long int c = (long long int)sqrt(A*B);
    if (c*c == A*B) c--;
    if (c*(c+1)>=A*B) res = 2*(c-1);
    else if(c*c<A*B) res = 2*c-1;
  }

  return res;
}

int main(int argc, char const *argv[]) {
  int q;
  cin >> q;
  long long int A[MAX_Q], B[MAX_Q];

  for (int i = 0; i < q; i++) cin >> A[i] >> B[i];

  for (size_t i = 0; i < q; i++) {
    cout << answer(A[i],B[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

int main(){
  
  int d, g;
  cin >> d >> g;

  vector<pair<int, int>> v(d);
  int ans = 1e8;

  rep(i, d){
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }

  rep(i, (1 << d)){
    bitset<10> bs(i);
    int score = 0, csolved = 0, mxp = -1;
    rep(j, d){
      if(bs[j]){
        score += (j+1)*100*v[j].first + v[j].second;
        csolved += v[j].first;
      }
      else{
        mxp = max(mxp, j);
      }
    }

    if(score >= g){
      ans = min(ans, csolved);
    }
    else{
      repa(j, 1, v[mxp].first){
        score += (mxp+1) * 100;
        csolved++;
        if(score >= g){
          ans = min(ans, csolved);
          break;
        }
      }
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n = read();
    let xyh: Vec<(i64, i64, i64)> = (0..n)
        .map(|_| (read::<i64>(), read::<i64>(), read::<i64>()))
        .collect();
    for i in 0..101 {
        for j in 0..101 {
            let mut ans = 0;
            let mut ok = true;
            let mut pomin = 10_i64.pow(18);
            for k in 0..n {
                let (x, y, h) = xyh[k];
                let dx = if x > i { x - i } else { i - x };
                let dy = if y > j { y - j } else { j - y };
                let po = h + dx + dy;
                if h == 0 {
                    pomin = std::cmp::min(pomin, po);
                    continue;
                }
                if ans == 0 {
                    ans = po;
                } else if ans != po {
                    ok = false;
                }
            }
            if ok && ans <= pomin {
                println!("{} {} {}", i, j, ans);
                return;
            }
        }
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

int main(){
  int r,c;

  while(1){
    cin >>r >>c;
    if(r==0 && c==0) break;
    if(r%2==0 || c%2==0)
      cout << "yes\n";
    else
      cout << "no\n";
  }
  return 0;
}

Measured memory_bytes: 2956
import sys
N,M = map(int,input().split())


if N%2 == 1:
    for i in range(1,M+1):
        print(i,N-i+1)

elif N%4 == 0:
    total = 0
    count = 1
    for i in range(N//4,0,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()
    count = 2
    for i in range(3*(N//4)-1,N//2,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()
else:
    total = 0
    count = 1
    for i in range(N//4,0,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()
    count = 2
    for i in range(3*(N//4),N//2-1,-1):
        print(i,i+count)
        count += 2
        total += 1
        if total >= M:
            sys.exit()

Measured memory_bytes: 69244
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = 1;
    for (int i = 0; i < n-1; i++)
    {
        if (d[i] < d[i+1])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

K, Q = na()
d = na()

for z in range(Q):
    n, x, m = na()

    n -= 1

    rem = n%K
    pre = m-1
    x %= m
    ans = 0
    for i in range(rem):
        pre = x
        x = (x + d[i]) % m
        if pre < x:
            ans += 1

    lpre = 0
    turn = 0
    # print(d[rem:] +  d[:rem])
    j = rem
    for i in range(K):
        cur = (lpre + d[j]) % m
        if lpre < cur:
            turn += 1
        lpre = cur
        j += 1
        if j == K:
            j = 0
    my = turn*m - lpre
    # print(turn, m, my, n//K, x)
    ans += (my * (n//K) + m-x-1) // m - (m-x-1)//m
    print(ans)


Measured memory_bytes: 47316
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string str;
	cin >> str;

	int zero = 0, one = 0;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] == '0')
			zero++;
		else
			one++;
	}

	COUT(min(zero, one) * 2);

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int x,y;
    cin>>x>>y;
    if(abs(x-y)<=1)cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    bool judge = false;
    int count = 0,tmp = 0;
    string s;
    cin >> s;
    if(s[0] == 'A')
    {
        for(int i = 2;i <= s.size() - 2;i++)
        {
            if(s[i] == 'C'){count++; tmp = i;}
        }
        if(count == 1)
        {
            for(int i = 0;i < s.size();i++)
            {
                if(s[i] - 97 < 0)
                {
                    if(i != 0 && i != tmp)
                    {
                        cout << "WA" << endl; return 0;
                    }
                }
            }
            judge = true;
        }
    }
    if(judge){cout << "AC" << endl;}
    else{cout << "WA" << endl;}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,n) for(int j=0;j<n;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector < int> > vee;
typedef pair<int, int> pa;
typedef vector<pair<ll,ll> > vepa;
typedef set<int>se;
typedef map<string,int> mp;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N];
bool visited[N]={};
ll cnt[N],freq[N];
bool f,ff;
int main()
{
   ll x;
   cin>>x;
   ll ans = x%500;
   cout<<1000*(x/500) + (ans/5)*5;

go;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, k, n, a;
  scanf("%lld", &n);
  ll ans[n];
  for(i = 1; i <= n; ++i) {
    scanf("%lld", &a);
    ans[--a] = i;
  }
  for(i = 0; i < n; ++i) printf("%lld ", ans[i]);
  return 0;
}

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


void solution(){
	ll n;
	cin>>n;
	string s;
	ll ac=0,wa=0,tle=0,re=0;
	for(ll i=0; i<n;++i){
		cin>>s;
		if(s=="AC")
			ac++;
		else if(s=="WA")
			wa++;
		else if(s=="TLE")
			tle++;
		else
			re++;
	}
	cout<<"AC x "<<ac<<"\nWA x "<<wa<<"\nTLE x "<<tle<<"\nRE x "<<re<<'\n';
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	solution();
	return 0;
}

Measured memory_bytes: 3660
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"
#define cauto const auto

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

template<class T> T nextI(const T &dec=0){ T re; cin>>re; return re-dec;}
template<class T> vector<T> nextV(const int sz){ vector<T> re(sz); for(auto &x:re) cin>>x; return re;}
template<class T> vector<T> nextV(const int sz, const T &dec){ vector<T> re(sz); for(auto &x:re) cin>>x, x-=dec; return re;}


int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	cauto n=nextI<int>();
	cauto ss=nextV<string>(n);
	map<string,int> mp;
	for(auto s:ss) ++mp[s];
	out(ss,mp,1);
	for(auto s:{"AC", "WA", "TLE", "RE"}) cout<<s<<" x "<<mp[s] NL;
  return 0;
}


Measured memory_bytes: 6348
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int N, M, maxl = 1, minr;
	cin >> N >> M;
	minr = N;
	VI L(M), R(M);
	rep(i, M){
		cin >> L[i] >> R[i];
		maxl = max(maxl, L[i]);
		minr = min(minr, R[i]);
	}

	if(maxl > minr) cout << 0 << endl;
	else cout << minr - maxl + 1 << endl;


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

const int INF = 1001001001;

int main() {
	int n, m, tot = 0;
	cin >> n >> m;
	vector<int> a(n);
	rep(i,n) {
		cin >> a.at(i);
		tot += a.at(i);
	}
	int lim = tot/4/m;
	if (tot % 4*m != 0) lim++;
	sort(a.rbegin(), a.rend());
	string ans = "Yes";
	rep(i,m) {
		if (a.at(i) < lim) {
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int a,s,n;
std::bitset<1<<22>d;     
int main(){
    std::cin>>n;d[0]=1;
    while(n--)std::cin>>a,s+=a,d|=(d<<a);
	while(!d[++s/2]);std::cout<<s/2;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

struct Edge {
  int to;
  int id;
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& g, int u, int v, int id) {
  g[u].push_back(Edge{v,id});
  g[v].push_back(Edge{u,id});
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> d;
  vector<tuple<int,int>> dt;
  for(auto&& i:irange(0,n)){
    int e;
    cin>>e;
    d.push_back(e);
    dt.emplace_back(e,i);
  }
  boost::sort(dt);
  Graph g(n);
  for(auto&& i:irange(0,m)) {
    int u,v;
    cin>>u>>v;
    --u;--v;
    add_edge(g,u,v,i);
  }
  vecint clr(n,-1);
  vecint w(m,1000000000);
  bool valid = true;
  for(auto&& t:dt) {
    int di,i;
    tie(di,i) = t;
    if (clr[i] != -1) continue;
    int md = 1e9+1;
    int idxto = -1;
    int idxe = -1;
    for(auto&& e:g[i]) {
      if (d[e.to] > di) continue;
      if (d[e.to] == md) {
        if (e.to < idxto) {
          idxto = e.to;
          idxe = e.id;
        }
      }
      if (d[e.to] < md) {
        md = d[e.to];
        idxto = e.to;
        idxe = e.id;
      }
    }
    if (idxto < 0) {
      valid = false;
      break;
    }
    if (clr[idxto] == -1) {
      clr[i] = 0;
      clr[idxto] = 1;
    } else {
      clr[i] = 1-clr[idxto];
    }
    w[idxe] = di;
  }
  if (valid) {
    for(auto&& e:clr) {
      if(e==0) {
        cout<<'B';
      }else{
        cout<<'W';
      }
    }
    cout<<endl;
    for(auto&& e:w) {
      cout<<e<<endl;
    }
  } else {
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 12656
import java.util.Scanner;

class Solver {
    void solve(Scanner in) {
        int N = in.nextInt();
        int[] heights = new int[N];
        int prev = 0;
        int sum = 0;
        int max = 0;
        for (int i = 0; i < N; i++) {
            heights[i] = in.nextInt();
            if (prev >= heights[i]){
                prev = heights[i];
                sum++;
            } else {
                prev = heights[i];
                max = Math.max(max, sum);
                sum = 0;
            }
        }
        System.out.println(Math.max(max, sum));
    }
}

class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);

        new Solver().solve(in);

        in.close();
    }
}

Measured memory_bytes: 51188
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL lucas[87];
int main() {
	int N;
	cin >> N;
	lucas[0] = 2;
	lucas[1] = 1;
	for (int i = 2; i <= N; i++) lucas[i] = lucas[i - 1] + lucas[i - 2];
	cout << lucas[N] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,d,x,y,i,c = 0;
	cin >> n >> d;
	for(i=1;i<=n;++i)
	{
		cin >> x >> y;
		if(x*x+y*y<=d*d)
			c++;
	}
	cout << c << "\n";
}

Measured memory_bytes: 3620
#include<cstdio>
#include<deque>
using namespace std;
int k,co[100000],visited[100000];
deque<int> d;

void bfs(int x){
    d.pop_front();
    visited[x]=1;
    if(co[x*10%k]>co[x]){
        co[x*10%k]=co[x];
        d.push_front(x*10%k);
    }
    if(co[(x+1)%k]>co[x]+1){
        co[(x+1)%k]=co[x]+1;
        d.push_back((x+1)%k);
    }
}
int main(){
    scanf("%d",&k);
    for(int i=0;i<k;i++){
        co[i]=1000;
    }
    co[1]=1;
    d.push_back(1);
    while(!d.empty()){
        if(visited[d.front()]==0){
            bfs(d.front());
        }
        else{
            d.pop_front();
        }
    }
    printf("%d\n",co[0]);
}

Measured memory_bytes: 1280
#include <stdio.h>

char toUPPER(char c);
char toLOWER(char c);

int main(void){
  char text[1200];
  scanf("%[^\n]", text);
  for(int i=0; text[i] != '\0'; i++){
    if (text[i] >= 'a' && text[i] <= 'z') text[i] = toUPPER(text[i]);
    else if (text[i] >= 'A' && text[i] <= 'Z') text[i] = toLOWER(text[i]);
  }
  printf("%s\n", text);
  return 0;
}


char toUPPER(char c){
  if (c >= 'a' && c <= 'z'){
    return (c - 0x20);
  }else{
    return c;
  }
}

char toLOWER(char c){
  if (c >= 'A' && c <= 'Z'){
    return (c + 0x20);
  }else{
    return c;
  }
}



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

int n,y;
bool flag=0;

int main(){
	//freopen(".in","r",stdin);
	scanf("%d%d",&n,&y);
	y/=1000;
	for(int i=0;i<=n;i++){
		for(int k=0;k<=n;k++){
			if(9*i+4*k==y-n){
				int c=n-i-k;
				if(10*i+5*k+c==y && c>=0){
					printf("%d %d %d\n",i,k,c);
					flag=1;
					return 0;
				}
			}
		}
	}
	if(!flag)printf("-1 -1 -1\n");
	return 0;
}


Measured memory_bytes: 256
<?php
list($s) = strs();
list($t) = strs();
$n = strlen($s);
$m = strlen($t);
$ss = $s . $s;
$cnt = 0;
$p = -1;
for ($i = 0; $i < $m; ++$i) {
    $np = strpos($ss, $t[$i], $p + 1);
    if ($np === false) exit('-1');
    $cnt += $np - $p;
    $p = $np % $n;
}
echo $cnt;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


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

// ループによる最大公約数
int gcd(int x, int y){
  int r;
  if(x < y) swap(x, y);
  
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int n, i, keep;
  cin >> n;
  
  int a[n];
  for(i = 0; i < n; i++) cin >> a[i];
  
  keep = a[0];
  for(i = 1; i < n; i++){
    keep = gcd(keep, a[i]);
  }
  
  cout << keep << endl;
}

Measured memory_bytes: 640