akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;
string a[lmt];


int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
    fast
	ll th,ts,ah,as;
	cin>>th>>ts>>ah>>as;
	while(1){
		ah-=ts;
		if(ah<=0){
			pt("Yes");
			return 0;
		}
	
		th-=as;
		if(th<=0){
			pt("No");
			return 0;
		}


	}

}


/*

// 

*/

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

double P;
int N;

struct Edge { int to, cost; };

vector<vector<Edge>> G;


long double solve(int v, int pre, long double prob, long double additional)
{
    long double res = prob*additional;

    for (auto e : G[v]) {
        if (e.to == pre) continue;
        res += (P * prob) * e.cost;
        res += solve(e.to, v, prob * P, additional);
    }

    return res;
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> P >> N;
    G.resize(N);
    rep(i, N-1) {
        int X, Y, C;
        cin >> X >> Y >> C;
        X--, Y--;
        G[X].push_back({Y, C});
        G[Y].push_back({X, C});
    }

    long double e   = solve(0, -1, 1, 0);
    long double ans = solve(0, -1, 1, e);

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 19280
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N, amount, chil[110], sum = 0, happy = 0, total = 0;
    cin >> N >> amount;
    HAIRETU(N, chil);
    sort(chil, chil+N);
    for (int i = 0; i < N; i++) total += chil[i];
    for (int i = 0; i < N; i++){
        sum += chil[i];
        if (sum > amount){
            happy = i;
            break;
        } else if (sum == amount) {
            happy = N;
        } else {
            happy = N-1;
        }
    }
    cout << happy << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x1, y1, x2, y2, x3, y3, x4, y4;
    int tx, ty;

    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

    tx = x2 - x1;
    ty = y2 - y1;

    x3 = x2 + (-ty);
    y3 = y2 + tx;

    x4 = x3 + (-tx);
    y4 = y3 + (-ty);

    printf("%d %d %d %d\n", x3, y3, x4, y4);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    if (n == 1) {
        printf("Yes\n");
        printf("2\n");
        printf("1 1\n");
        printf("1 1\n");
        return 0;
    }
    ll v = 1, plus = 2;
    bool f = false;
    while(v < n) {
        v += plus;
        plus++;
        if (v == n) f = true;
    }
    if (!f) {
        printf("No\n");
        return 0;
    }
    vector<vector<ll>> ans(plus);
    plus--;
    reps(width, 1, plus + 1) {
        ll height = plus - width;
        ll val = (1 + (width - 1)) * (width - 1) / 2;
        rep(i, width) {
            val++;
            ans[width - 1].push_back(val);
        }
        rep(i, height) {
            val += width + i;
            ans[width - 1].push_back(val);
        }
    }
    reps(i, 1, plus + 1) {
        ans[plus].push_back((i + 1) * i / 2);
    }
    printf("Yes\n");
    printf("%lld\n", sz(ans));
    rep(i, sz(ans)) {
        ll size = sz(ans[i]);
        printf("%lld ", size);
        rep(ii, size) {
            printf("%lld%s", ans[i][ii], (ii == (size - 1)) ? "\n" : " ");
        }
    }
    return 0;
}


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

int main(){
    int n,ans,z=30;
    ans = 0;
    cin>>n;
    vector<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n-1;i++) cin>>c[i];;
    for(int i=0;i<n;i++){
        int j = a[i]-1;
        ans += b[j];
        if(j == z+1) ans += c[z];
        z = j;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef int  i32;
typedef long long i64,ll;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#define NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

class Main{
public:
	void run(){
	//	ifstream cin("in");
	//	ofstream cout( "out" );
		int N;cin >> N;
		string s;cin >>s;

		int res=0;
		REP(i,N){
			string t;cin >>t;

			bool ok=false;
			REP(span,t.size()){
				for(int spos=0;spos<t.size();spos++){
					int si=0;
					for(int ti=spos;ti<t.size();ti+=span){
						if(s[si]==t[ti]){
							si++;
							if(s.size()==si){
								ok=true;break;
							}
						}else{
							break;
						}
					}
				}
			}
			if(ok)res++;
		}
		cout << res<<endl;
	}
};
 int main(){
ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

Measured memory_bytes: 1212
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,K=map(int,readline().split())
    S=readline().strip()

    li=[]
    i=0
    now=0
    if S[0]=="0":
        li.append(0)
    while i<len(S):
        if S[i]=="1":
            while True:
                if S[i]=="1":
                    now+=1
                    i+=1
                    if i==len(S):
                        break
                else:
                    break
        elif S[i]=="0":
            while True:
                if S[i]=="0":
                    now+=1
                    i+=1
                    if i==len(S):
                        break
                else:
                    break
        li.append(now)
        now=0
                
    #累積和
    for i in range(len(li)):
        if i==0:
            continue
        else:
            li[i]+=li[i-1]

    res=0
    if len(li)>=2*K+1:
        for left in range(0,len(li),2):
            if left==0:
                res=li[2*K]
            else:
                res=max(res,li[min(2*K+left,len(li)-1)]-li[left-1])
    else:
        res=li[-1]
    print(res)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 7164
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int ans = 0;
        int r = N;
        int w = 0;
        for (int i = 0; i < N; i++) {
            char c = S.charAt(i);
            if (c == 'W') {
                w++;
                continue;
            }

            while (i < r && (S.charAt(r-1) == 'W' || w > 0)) {
                r--;
                if (S.charAt(r) == 'R') {
                    w--;
                    ans++;
                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 40832
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a[100];
    int n;
    cin>>n;
    a[0]=2;a[1]=1;
    for(int i=2; i<=n; i++)
        a[i]=a[i-1]+a[i-2];
    cout<<a[n];
  return 0;
}


Measured memory_bytes: 384
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var s string
  fmt.Scan(&s)
  ans := "TBD"
  m, _ := strconv.Atoi(string([]rune(s)[5:7]))
  if m <= 4 {ans = "Heisei"}
  fmt.Println(ans)
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func ri() int {
	sc.Scan()
	s := sc.Text()
	a, _ := strconv.Atoi(s)
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	ri()
	m := ri()
	pr := make([]int, m)
	yr := make([]int, m)
	mp := map[int][]int{}
	for i := 0; i < m; i++ {
		p := ri()
		y := ri()
		pr[i] = p
		yr[i] = y
		if v, ok := mp[p]; ok {
			mp[p] = append(v, y)
		} else {
			mp[p] = []int{y}
		}
	}
	for k := range mp {
		sort.Ints(mp[k])
	}
	for i := 0; i < m; i++ {
		ar := mp[pr[i]]
		ind := sort.SearchInts(ar, yr[i])
		s := fmt.Sprintf("%06d%06d", pr[i], ind+1)
		fmt.Println(s)
	}
}


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

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size()-1;++i){
      	for(int j=1;j<s.size()-i;++j){
    		if(s[i]==s[i+j]){
        		cout<<"no"<<endl;
          		return 0;
        	}
        }
    }
  	cout<<"yes"<<endl;
  	return 0;
}

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

int main(){
    int N, K; cin >> N >> K;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        int h; cin >> h;
        if(h>=K) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
int ans,sp[3][3];
char pc[9][5];
bool use[9];

void rec(int c)
{
	if(c==9)
	{
		ans++; return;
	}
	rep(i,9)if(!use[i])
	{
		sp[c/3][c%3]=i; use[i]=1;
		rep(rt,4)
		{
			rep(d,4)
			{
				int y=c/3+dy[d],x=c%3+dx[d];
				if(y<0||x<0||y>=3||x>=3||sp[y][x]<0)continue;
				char c1=pc[i][d],c2=pc[sp[y][x]][d^2];
				if(abs(c1-c2)!=abs('A'-'a'))goto FAIL;
			}
			rec(c+1);
			FAIL:
			rotate(pc[i],pc[i]+1,pc[i]+4);
		}
		sp[c/3][c%3]=-1; use[i]=0;
	}
}

int sol()
{
	rep(i,9)use[i]=0,sp[i/3][i%3]=-1; ans=0;
	rec(0);
	return ans;
}

int main()
{
	int n; scanf("%d",&n);
	rep(i,n)
	{
		rep(j,9)scanf("%s",pc[j]);
		printf("%d\n",sol());
	}
	return 0;
}

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

int main()
{
    int x;
    cin >> x;
    int h = 0;
    h += x / 500 * 1000;
    h += (x % 500) / 5 * 5;
    cout << h << endl;
    return 0;
}

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


int main() {
	vector<int> m;
	m.push_back(1);
	int buf = 6;
	while (buf < 100000) {
		m.push_back(buf);
		buf = buf * 6;
	}
	buf = 9;
	while (buf < 100000) {
		m.push_back(buf);
		buf = buf * 9;
	}
	sort(m.begin(), m.end());

	int N;  cin >> N;
	vector<int> ans(N + 1);
	fill(ans.begin(), ans.end(), N);
	ans[0] = 0;
	ans[1] = 1;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < m.size(); j++) {
			if (i + m[j] <= N) {
				ans[i + m[j]] = min(ans[i + m[j]], ans[i] + 1);
			}
		}
	}
	cout << ans[N] << endl;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();

    if(b-a==c-b){
        System.out.println("YES");
    }else{
      System.out.println("NO");
    }




}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n-1){
        int t;
        cin >> t;
        a[--t]++;
    }

    rep(i, n){
        cout << a[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4840
#include<cstdio>

#define Max 1000000000000000000ll
#define LL long long
#define Fast register
char BUF[30],*S=BUF;
inline LL Getint(){
	Fast LL s=0;Fast char c;
	while(c=*S++,c<48||c>57);
	while(s=s*10+c-48,c=*S++,c>47&&c<58);
	return s;
}

inline LL gcd(const LL&x,const LL&y){return!y?x:gcd(y,x%y);}

int main(){
	fread(BUF,1,30,stdin);
	Fast LL x=Getint(),y=Getint();
//	if(gcd(x,y)==y||x*gcd(x,y)>Max)return(puts("-1"),0);
//	return(printf("%lld",x*gcd(x,y)),0);
	if(gcd(x,y)==y)return(puts("-1"),0);
	Fast LL Ans=x;
	while(true){
		if(Ans>Max)return(puts("-1"),0);
		if(Ans%y)return(printf("%lld",Ans),0);
		Ans+=x;
	}
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c,d=MI()
    s=max(a,c)
    t=min(b,d)
    print(max(0,t-s))

main()


Measured memory_bytes: 38384
#include <iostream>
using namespace std;
void take_primes(int arr[], int &n)
{
  int tmp, div;
  for(int i = 1; i <= n; i++)
  {
    tmp = i;
    div = 2;
    while( tmp > 1 )
      if( tmp % div == 0 ){
        tmp /= div;
        arr[div-2]++;
      }
      else
        div++;
  }
}
int main()
{
  int n;
  long long int ans = 1, mod = 1000000007;
  cin >> n;
  int arr[1000]{};
  take_primes(arr,n);
  for(int i = 0; i < n-1; i++)
  {
    ans *= (arr[i] + 1);
    ans %= mod;
  }
  cout << ans;
}
  
  
  

Measured memory_bytes: 3128
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
min_=min(a)+min(b)
for _ in range(M):
  l=list(map(int,input().split()))
  min_=min(min_,a[l[0]-1]+b[l[1]-1]-l[2])
print(min_)

Measured memory_bytes: 18736
fun main(args: Array<String>) {
    val (A, B, K) = readLine()!!.split(" ").map(String::toLong)
    val a = 0L.coerceAtLeast(A - K)
    val b = 0L.coerceAtLeast(B - (K - (A - a)))
    println("$a $b")
}

Measured memory_bytes: 38204
N = int(input())
T,A = map(int,input().split())
X = list(map(int,input().split()))
res = 100000000
j = 1
for i in X:
    a = abs(A - (T-i*0.006))
    if(res > a):
        res = a
        res1=j        
    j+=1
print(res1)




Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

def dfs(v,p,path):
    for c in g[v]:
        if c == p: continue
        if c == n-1:
            path.append(n-1)
            path.append(v)
            return True
        if dfs(c,v,path):
            path.append(v)
            return True
    return False            

path = []
dfs(0,-1,path)
path.reverse()

#print(path)

from collections import deque
#0 sente 1: gote
q0 = deque()
q1 = deque()
ans = [-1]*n
for i in path[:(1+(len(path)))//2]:
    ans[i] = 0
    q0.append(i)
for i in path[(1+(len(path)))//2:]:
    ans[i] = 1
    q1.append(i)

turn = len(path)&1

while q0 and q1: #キューが空になるまで
    if turn: v = q1.popleft() #キューから情報を取り出す
    else: v = q0.popleft()
    for c in g[v]:
        if ans[c] != -1: continue
        #(nx,ny)が未確認のとき、確認済みにしてキューに入れる------------------
        ans[c] = turn
        if turn: q1.append(c)
        else: q0.append(c)
    turn ^= 1

if q0: print("Fennec")
else: print("Snuke")













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

int partition(int A[], int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      int tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  int tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i + 1;
}


int main() {
  int n;
  cin >> n;
  int A[n];
  for (int i = 0; i < n; i++) cin >> A[i];
  int i = partition(A, 0, n-1);
  for (int j = 0;  j < n; j++) {
    if (j) cout << " ";
    if (j == i) {
      cout << "[" << A[j] << "]";
    } else {
      cout << A[j];
    }
  }
  cout << endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i=0; i<N-1; i++) sum += p[i];
  sum += p[N-1]/2;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
	int t;
	int max;
	int min;
	int block[100];
	cin >> t;

	while(t--)
	{
		max = min = 0;
		int n;
		cin >> n;
		cin >> block[0];
		for(int i=1; i < n; i++) {
			cin >> block[i];
			int sub = block[i] - block[i-1];
			if(max < sub) max = sub;
			if(min > sub) min = sub;
		}
		cout << max << " " << -min << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 80000;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] numbers = new int[MAX];
		
		while(true){
			final String input = sc.next();
			
			if("0".equals(input)){
				break;
			}
			
			final int size = input.length();
			
			for(int i = 0; i < size; i++){
				numbers[i] = input.charAt(i) - '0';
			}
			
			int count = 0;
			int[] DP = new int[11];
			int[] next = new int[11];
			
			for(int i = 0; i < size; i++){
				Arrays.fill(next, 0);
				
				for(int mod = 0; mod < 11; mod++){
					next[(mod * 10 + numbers[i]) % 11] += DP[mod];
				}
				
				if(numbers[i] != 0){
					next[numbers[i]]++;
				}
				
				count += next[0];
				
				int[] tmp = next;
				next = DP;
				DP = tmp;
			}
			
			System.out.println(count);
		}
		
	}

}

Measured memory_bytes: 28892
#include<string>
#include<vector>
#include<iomanip>
#ifndef _WIN32
#include<iostream>
#endif
#include<algorithm>
using namespace std;
#define FOR(i,bg,ed) for(int i =(bg); i< (ed);i++)
#define REP(i,n) FOR(i,0,n) 

struct cww{
	cww(){
		ios::sync_with_stdio(false);
		cin.tie(0);
	}
}star;
typedef long long LL;
const int mod = 1e9 + 7;

typedef vector<int> V;
typedef vector<V> VV;

template<typename T>
istream& operator>>(istream& is, vector<T>& v){
	for (auto &it : v)is >> it;
	return is;
}

int main(){
	int N;
	LL A, B;
	cin >> N>>A>>B;
	A -= B;
	vector<LL> h(N);
	cin >> h;
	LL ng = 0, ok = 1e9;
	auto check = [&](LL m){
		auto g = h;
		REP(i, N)g[i] -= B*m;
		LL need = 0;
		REP(i, N)if (g[i] > 0){
			need += (g[i] + A - 1) / A;
		}
		return m >= need;

	};
	while (ok - ng > 1){
		const int mid = (ng + ok) / 2;
		if (check(mid))
			ok = mid;
		else ng = mid;
		

	}
	cout << ok << endl;

}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		long temp = 0;
		temp = a * c;
		if(temp < a * d) temp = a * d;
		if(temp < b * c) temp = b * c;
		if(temp < b * d) temp = b * d;
		
		System.out.println(temp);
	}

}


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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=1;
bool check(int n){


for(int i=2;i*i<=n;i++){
    if(n%i == 0)
        return 1;
}
return 0;

}
int main()
{
 int x;
 cin>>x;
 for(int i=x;;i++){
    if(!check(i)){
        cout<<i;
        return 0;
    }
 }
 }


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  REP(i,100000){
    if (n < i * i){
      cout << (i - 1)*(i - 1) << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3556
import java.util.Scanner;

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

		Scanner scanner = new Scanner(System.in);

		int n=scanner.nextInt();
		int a=scanner.nextInt();
		int b=scanner.nextInt();

		int result=0;

		for(int i=1;i<=n;i++) {
			int buf=getsumofkakuketa(i);

			if(isMacthed(a, b, buf)) {
				result+=i;
			}
		}

		System.out.println(result);



		scanner.close();

	}

	public static int getsumofkakuketa(int n) {

		int result=0;

		while(true) {

			result+=n%10;

			if(n/10!=0) {
				n/=10;
			}else {
				return result;
			}
		}



	}

	public static boolean isMacthed(int a,int b,int sum) {

		if(sum>=a && sum<=b) {
			return true;
		}else {
			return false;
		}

	}



}







Measured memory_bytes: 21588
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    sA = sum(A)
    divs = []
    i = 1
    while i * i < sA:
        if sA % i == 0:
            divs.append(i)
            divs.append(sA // i)
        i += 1
    if i * i == sA:
        divs.append(i)
    divs.sort()
    for d in reversed(divs):
        t = [i % d for i in A]
        t.sort()
        k = sum(t[:-sum(t) // d])
        if k <= K:
            return d

print(main())


Measured memory_bytes: 41436
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int MAXN = 100005;
const int INF = 1e8;
using namespace std;
int main()

{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
   int n,k;
   cin>>n>>k;
   int ans=0;
   while(n>=k)
   {
             ans++;
             n/=k;
             
   }
   ans++;
   cout<<ans;
   
     
 
}

Measured memory_bytes: 256
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: u32;
    let k: u32;

    input!(n, k);
    if n % k == 0 {
        println!("0");
    } else {
        println!("1");
    }
}

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

public class Main  {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    static HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); 
    static int[][] Factor;
    static long mod = (long)1e9 + 7;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
       

        int S = nextInt();
        
        if(S<3){
            System.out.println(0);
            return;
        }

        int index = 1;
        for (int i=2; i<= S; i++) {
            if(isPrime(i)){
                map.put(index, i);
                index++;
            }
        } 

        Factor = new int[S+1][map.size()+1];

        for (int i=2; i<= S; i++) {
            int row = i;
            for (int j=1; j<= map.size(); j++) {
                int prime = map.get(j);
                while(row%prime==0){
                    row = row/prime;
                    Factor[i][j]++;
                }  
                if(row==1){
                    break;
                }
            } 
        } 


        int[] p = new int[S/3+1];

        long sum = 0;
        for (int x=1; x<p.length; x++) {
            int temp = S - 3*x;
            int bar = x - 1;
            sum += Combin(temp+bar,bar);
            sum %= mod;
        }

        System.out.println(sum);
       
    }
  
    public static long Combin(int a, int b) {
        if(b==0) return 1;

        long total = 1;
        int[] result = new int[map.size()+1];
        int loop = Math.min(b, a-b);

        for (int i=a; i>= a-loop+1; i--) {
            for (int j=1; j<= map.size(); j++) {
                result[j] += Factor[i][j];
            } 
        } 
        for (int i=loop; i>= 1; i--) {
            for (int j=1; j<= map.size(); j++) {
                result[j] -= Factor[i][j];
            } 
        } 

        for (int j=1; j<= map.size(); j++) {
            if(result[j]>0){
                for (int x=1; x<= result[j]; x++) {
                    total *= map.get(j);
                    total %= mod;
                }
            }
        } 

        return total;
    }

    public static boolean isPrime(int n) {  
        if (n <= 1) {  
            return false;  
        }  
        for (int i = 2; i <= Math.sqrt(n); i++) {  
            if (n % i == 0) {  
                return false;  
            }  
        }  
        return true;  
    }  

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 39312
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
void debug(vector<ll> &A){
    cout << "--------\n";
    REP(i, A.size()){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << "--------\n";
}
signed main(){
    ll N, C;
    cin >> N >> C;
    vector<ll> X(N), Y(N);
    for(long long i=0; i<N; i++){
        ll x, y; cin >>x >>y;
        X[i] = x, Y[i] = y;
    }
    vector<ll> CS(N+1);
    for(long long i=0; i<N; i++){
        CS[i+1] = CS[i] + Y[i];
    }
    vector<ll> cCM(N+1);
    for(long long i=0; i<N; i++){
        cCM[i+1] = max(cCM[i], CS[i+1]-X[i]);
    }
    vector<ll> ucCM(N+1);
    for(long long i=0; i<N; i++){
        ucCM[i+1] = max(ucCM[i], CS[N]-CS[N-i-1]-(C-X[N-i-1]));
    }
    //debug(CS);
    //debug(cCM);
    //debug(ucCM);
    ll res = max(cCM[N], ucCM[N]);
    // o -> l -> o -> r
    for(ll l=N-1; l>=0; l--){
        ll score = CS[N]-CS[l] - 2*(C-X[l]) + cCM[l]; 
        res = max(res, score);
    }
    // o -> r -> o -> l
    for(ll r=0; r<N; r++){
        ll score = CS[r+1] - 2*(X[r]) + ucCM[N-r-1];
        res = max(res, score);
    }
    cout << res << endl;
    return 0;
}
// index cloclwise/unclockwise
// 0 N-1
// 1 N-2
// 2 N-3
// i N-i-1
// N-j-1, j

Measured memory_bytes: 4224
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int q = Integer.parseInt(sc.next());
    String str = sc.next();
    char[] ch = new char[n];
    int[] dp = new int[n];
    dp[0] = 0;
    for(int i = 0; i < n; i++) {
      ch[i] = str.charAt(i);
    }
    for(int i = 0; i < n - 1; i++) {
      if(ch[i] == 'A' && ch[i+1] == 'C') dp[i+1] = dp[i] + 1;
      else dp[i+1] = dp[i];
    }
    int l , r, ans;
    for(int i = 0; i < q; i++) {
      ans = 0;
      l = Integer.parseInt(sc.next());
      r = Integer.parseInt(sc.next());
      ans = dp[r-1] - dp[l-1];
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 57628
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {

    ll h, w; cin >> h >> w;
    vector<string> s(h+2);
    REP(i, h) {
        cin >> s[i+1];
        s[i+1] = "#" + s[i+1] + "#";
    }
    s[0]   = string(w+2, '#');
    s[h+1] = string(w+2, '#');

    deque<pair<ll, ll>> q = {{1, 1}};
    vector<vector<ll>> d(h+2, vector<ll>(w+2, -1));
    d[1][1] = 1;
    while (!q.empty()) {

        ll i = q.front().first;
        ll j = q.front().second;
        q.pop_front();

        if (s[i-1][j] == '.' && d[i-1][j] < 0) {
            q.emplace_back(i-1, j);
            d[i-1][j] = d[i][j] + 1;
        }
        if (s[i+1][j] == '.' && d[i+1][j] < 0) {
            q.emplace_back(i+1, j);
            d[i+1][j] = d[i][j] + 1;
        }
        if (s[i][j+1] == '.' && d[i][j+1] < 0) {
            q.emplace_back(i, j+1);
            d[i][j+1] = d[i][j] + 1;
        }
        if (s[i][j-1] == '.' && d[i][j-1] < 0) {
            q.emplace_back(i, j-1);
            d[i][j-1] = d[i][j] + 1;
        }

    }

    if (d[h][w] < 0) {
        cout << -1 << endl;
    } else {
        ll w0 = 0;
        REP(i, h) REP(j, w) if (s[i+1][j+1] == '.') w0++;
        cout << w0 - d[h][w] << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

const int MAX_N = 50;

bool graph[MAX_N][MAX_N];
bool node[MAX_N];
vector<pair<int, int> > pairs;
int skip_node = 0;
int N, M;

void dfs(int id) {
    if (node[id])
        return;
    node[id] = true;
    rep(i, N) {
        // cout << "debug: " << id << " " << i << " " << graph[id][i] << endl;
        if (!graph[id][i])
            continue;
        if (pairs[skip_node].first == i && pairs[skip_node].second == id)
            continue;
        if (pairs[skip_node].first == id && pairs[skip_node].second == i)
            continue;
        dfs(i);
    }
}

int main() {
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        pairs.push_back(make_pair(a, b));
        graph[a][b] = true;
        graph[b][a] = true;
    }
    int ans = 0;
    rep(i, M) {
        rep(i, N) node[i] = false;
        dfs(0);
        bool bridge = false;
        rep(i, N) if (!node[i]) bridge = true;
        if (bridge)
            ans += 1;
        skip_node += 1;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}


int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;

    cin>>n;

    if(n == 1) {
        cout<<0<<endl;
        return 0;
    }

    ll ret1 = 1, ret2 = 1, ret3 = 1;
    for(int i = 1; i <= n; i++) {
        ret1 = (ret1 * 10) % MOD;
        ret2 = (ret2 * 9) % MOD;
        ret3 = (ret3 * 8) % MOD;
    }

    ll ans = (ret1 - (2 * ret2) % MOD + ret3 + MOD) % MOD;

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3632
/*************************************************************************
	> File Name: aoj0009.cpp
	> Author: BMan
	> Mail: luo-kai-jia@163.com
	> Created Time: Wed 24 Oct 2018 08:50:17 PM CST
 ************************************************************************/

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <limits.h>
#include <queue>
#include <math.h>
#include <iostream>

#define FOR(i, x, y) for (int i = x; i <= y; i++)
#define REPEAT(_N) for (int _i = 0; _i < _N; _i++)

using namespace std;

inline bool Read(int &a) { return scanf("%d", &a) != EOF; }

const int maxn = 1 << 20;
int p[maxn];
int Process() {
    p[0] = p[1] = 0;
    for (int i = 2; i < maxn; i++) p[i] = 1;
    for (int i = 2; i < maxn; i++) {
        if (!p[i]) continue;
        for (int j = i + i; j < maxn; j += i) {
            p[j] = 0;
        }
    }
    for (int i = 2; i < maxn; i++) {
        p[i] += p[i - 1];
    }
    int n;
    while (Read(n)) {
        printf("%d\n", p[n]);
    }
    return 0;
}

int main() {
    std::ios::sync_with_stdio(false);
    return Process();
}


Measured memory_bytes: 7344
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

enum NodeType{R, I, L};

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

	int **children = new int*[n];
	int *num_of_children = new int[n];
	int *parent = new int[n];
	int *depth = new int[n];
	NodeType *type = new NodeType[n];
	int *queue = new int[n];
	int front = 0, rear = 0;
	for (int i = 0; i < n; ++i) {
		parent[i] = -1;
	}

	for (int i = 0; i < n; ++i) {
		int id;
		scanf("%d", &id);

		int k;
		scanf("%d", &k);
		num_of_children[id] = k;
		if (k == 0) {
			children[id] = NULL;
		}
		else {
			children[id] = new int[k];
			for (int j = 0; j < k; ++j) {
				int child;
				scanf("%d", &child);
				children[id][j] = child;
				parent[child] = id;
			}
		}
	}

	int node;
	for (int i = 0; i < n; ++i) {
		if (parent[i] == -1) {
			node = i;
			break;
		}
	}
	int root = node;
	queue[rear++] = node;
	depth[node] = 0;
	while (front != rear) {
		node = queue[front++];
		int nChildren = num_of_children[node];
		if (nChildren == 0) {
			type[node] = L;
		}
		else {
			type[node] = I;
			for (int i = 0; i < nChildren; ++i) {
				int child = children[node][i];
				depth[child] = depth[node] + 1;
				queue[rear++] = child;
			}
		}
	}
	type[root] = R;

	for (int i = 0; i < n; ++i) {
		printf("node %d: parent = %d, depth = %d, ", i, parent[i], depth[i]);
		if (type[i] == R) {
			printf("root, [");
		}
		else if (type[i] == I) {
			printf("internal node, [");
		}
		else {
			printf("leaf, [");
		}
		int nChildren = num_of_children[i];
		if (nChildren == 0) {
			printf("]\n");
		}
		else {
			for (int j = 0; j < nChildren - 1; ++j) {
				printf("%d, ", children[i][j]);
			}
			printf("%d]\n", children[i][nChildren - 1]);
		}
	}

	return 0;
}

Measured memory_bytes: 4252
#include"bits/stdc++.h"
using namespace std;
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}

#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);

using ll = long long int;
using intt = long long int;

int main()
{
    ll a,b,n;cin>>a>>b>>n;

    if(n>=b) n = b-1;

    cout<<(floor((a*n)/b) - (a*floor(n/b)))<<endl;

}


Measured memory_bytes: 3840
#include<stdio.h>
int main(void){
	int i, j, H, W;
	while(1){
		//数値を2つ入力
		scanf("%d %d", &H, &W);
		//数値が2とも0なら終了
		if(H == 0 && W == 0){
			break;
		}
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if((i % 2) == 0){
					if(j == (W - 1) && (j % 2) == 0){
						printf("#\n");
					}else if((j % 2) == 0){
						printf("#");
					}else if(j == (W - 1) && (j % 2) == 1){
						printf(".\n");
					}else{
						printf(".");
					}
				}else{
					if(j == (W - 1) && (j % 2) == 0){
						printf(".\n");
					}else if((j % 2) == 0){
						printf(".");
					}else if(j == (W - 1) && (j % 2) == 1){
						printf("#\n");
					}else{
						printf("#");
					}
				}
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 588
_N = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)

a.each.with_index do |x, i|
  while (i > 0 and a[i-1] > x)
    a[i] = a[i-1]
    i -= 1
  end
  a[i] = x
  puts a.join(" ")
end


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

int main() {
    unsigned long L;
    unsigned long R;
    cin >> L;
    cin >> R;
    if (R - L > 2019) {
        cout << 0 << endl;
        return 0;
    }

    unsigned long min = 10000;
    for (unsigned long i = L; i <= R; i++) {
        for (unsigned long j = L; j < i; j++) {
            unsigned long i_mod = i % 2019;
            unsigned long j_mod = j % 2019;
            unsigned long ij_mod = (i * j) % 2019;
            if (ij_mod < min) {
                min = ij_mod;
            }
        }
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#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()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    map<ll,ll> mp;
    for(ll i=2; i<=n; i++){
        ll tmp = i;
        ll a = 2;
        while(tmp >= a*a){
            if(tmp % a == 0){
                mp[a]++;
                tmp /= a;
            }else{
                a++;
            }
        }
        mp[tmp]++;
    }
    ll ans = 1;
    for(auto i : mp){
        if(i.first==1) continue;
        ans *= (i.second + 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

vector<vector<vector<int> > > A(4, vector<vector<int> >(3, vector<int>(10, 0)));
int n;

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    b--;
    f--;
    r--;
    A.at(b).at(f).at(r) += v;
  }

  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 10; k++)
      {
        cout << " " << A.at(i).at(j).at(k);
      }
      cout << endl;
    }
    if (i != 3)
    {
      cout << "####################" << endl;
    }
  }
}


Measured memory_bytes: 3168
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>

int main(void) {
    std::string s;
    std::cin >> s;
    bool f[26] = {};
    for (char c : s) {
        f[c - 'a'] = true;
    }
    for (int i = 0; i < 26; i++) {
        if (f[i] == false) {
            std::cout << (char)('a' + i) << std::endl;
            return 0;
        }
    }
    std::cout << "None" << std::endl;
    return 0;
}

Measured memory_bytes: 512
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    n <- readLn :: IO Int
    ps <- r' :: IO [Int]
    let ss = sort ps
    let eqs = zipWith (==) ps ss
    putStrLn $ case findIndices (== False) eqs of
        [] -> "YES"
        [i,j] -> if ps!!i == ss!!j && ps!!j == ss!!i then "YES" else "No"
        _ -> "NO"







Measured memory_bytes: 508
#include<bits/stdc++.h>
#define sl(x) scanf("%lld",&x)
using namespace std;
typedef long long ll;
const int N = 1e6+5;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
struct node{
	ll x,y;
}p[N];

bool cmp(node a,node b)
{
	return a.y < b.y;
}
int main()
{
	ll i,j,k,n,m,x,y;
	sl(n);sl(m);
	for(i = 0;i < m;i++)
	{
		sl(p[i].x);sl(p[i].y);
	}
	sort(p,p+m,cmp);
	ll l = 0,sum = 0;
	for(i = 0;i < m;i++)
	{
		if(p[i].x >= l)
		{
			l = p[i].y;
			sum++;
		}
	}
	cout<<sum<<endl;
	//system("pause");
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
LL solve(LL x)
{
	if (x == 0) return 0;
	if (x % 4 == 1) return 1;
	if (x % 4 == 2) return x + 1;
	if (x % 4 == 3) return 0;
	return x;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL a, b;
	cin >> a >> b;
	if (b == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	if (a == 0) a++;
	cout << (solve(b) ^ solve(a - 1)) << endl;
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
d = [list(map(int,input().split())) for i in range(2*k)]

s = [i for i in range(1,n+1)]

for i in range(len(d)):
    if i % 2 == 0:
        continue
    else:
        for j in range(len(d[i])):
            if d[i][j] in s:
                s.remove(d[i][j])
      
            
print(len(s))

Measured memory_bytes: 9200