akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)

int sum[2010][2010];

int query(int x1, int y1, int x2, int y2) {
    if (x1 > x2 || y1 > y2) return 0;
    return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}

int main() {
    int n, k;
    cin >> n >> k;
    rep(i, n) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') {
            y += k;
        }
        x %= 2 * k;
        y %= 2 * k;
        sum[x + 1][y + 1]++;
    }
    rep(i, 2 * k + 1) {
        rep(j, 2 * k) {
            sum[i][j + 1] += sum[i][j];
        }
    }
    rep(j, 2 * k + 1) {
        rep(i, 2 * k) {
            sum[i + 1][j] += sum[i][j];
        }
    }
    int ans = 0;
    rep(i, k + 1) {
        rep(j, k + 1) {
            // x o o o x x
            // x o o o x x
            // o x x x o o
            // o x x x o o
            // o x x x o o
            // x o o o x x
            int score = 0;
            score += query(1, 1, i, j);
            score += query(i + 1, j + 1, i + k, j + k);
            score += query(i + k + 1, j + k + 1, k * 2, k * 2);
            score += query(i + k + 1, 1, k * 2, j);
            score += query(1, j + k + 1, i, k * 2);
            ans = max(ans, score);
            ans = max(ans, n - score);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 16000
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a[10], b[10];

int main()
{
	int a, b, x1, x2, x3, x4, x5, cnt = 0;
	scanf("%d%d", &a, &b);
	for(int i = a; i <= b; i++)
	{
		x1 = i / 10000;
		x2 = (i - x1 * 10000) / 1000;
		x3 = (i - x1 * 10000 - x2 * 1000) / 100;
		x4 = (i - x1 * 10000 - x2 * 1000 - x3 * 100) / 10;
		x5 = i % 10;
		if(x1 == x5 && x2 == x4) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define ET cout << "\n"
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef bbq
#define debug(...) {\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}
#define DB(a,s,e) {for(int _i=s;_i<e;++_i) cerr << a[_i] << " ";cerr << "\n";}
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T,typename ...S> void _do(T &&x,S &&...t){cerr<<x<<", ";_do(t...);}
template<typename a,typename b> ostream& operator << (ostream &s,const pair<a,b> &p){return s<<"("<<p.X<<","<<p.Y<<")";}
#else
#define debug(...)
#define DB(a,s,e)
#endif

int arr[100005];
vector<int> v;

int main()
{
    IOS();
    int n,ans=0;
    cin >> n;
    for(int i=1;i<=n;++i)
        cin >> arr[i],v.pb(arr[i]);
    sort(ALL(v));
    for(int i=1;i<=n;++i)
        if((upper_bound(ALL(v),arr[i])-v.begin())&~i&1)
            ++ans;
    cout << ans << "\n";
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
//typedef int64_t int;
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise cout.precision(10); cout << fixed;
#define pb push_back
#define mk make_pair
#define endl "\n"
#define int int64_t
#define ll long long
#define in(num,n) std::vector<int> num(n); for (int i = 0; i < n; i++)cin >> num[i]
const ll Inf = 1e9 + 7;
std::vector<int> num[3];
int vis[4][100001];
int n, k;
int DP(int i, int pos) {
    if (vis[pos][i] != -1)return vis[pos][i];
    if (i == n)
        return 0;
    int ans = 0;
    for (int j = 0; j < 3; j++) {
        if (j != pos)
            ans = max(ans, DP(i + 1, j) + num[j][i]);
    }

    return  vis[pos][i] = ans;
}



void solve() {

    memset(vis, -1, sizeof(vis));
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        num[0].push_back(x);
        num[1].push_back(y);
        num[2].push_back(z);
    }
    cout << DP(0, 3) << endl;



}


int32_t main()
{
    fastio;
    precise;

    //int test; cin >> test; while (test--)
    solve();
    return 0;
}

Measured memory_bytes: 16556
import           Data.Char

main :: IO ()
main = do
    [a, b] <- map read . words <$> getLine :: IO [Int]
    s <- getLine
    putStrLn $ if f s a
                  && solve (take a s) (drop (a+1) s)
                  then "Yes"
                  else "No"
    where
      f = ((== '-') .) . (!!)

solve = flip ((.).(&&). p) p
    where
      p = all isDigit


Measured memory_bytes: 508
#include<bits/stdc++.h>
//In wrong answers we believe//
#define db 				double
#define ll 				long long int
#define ld				long long double
//#define int 			long long int
#define ull 			unsigned long long
#define vii 			vector <int>
#define vll 			vector < ll >
#define pii 			pair <int, int>
#define fi 				first
#define se 				second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define endl 			'\n'
#define mem(a,b) 		memset(a, b, sizeof a)
#define mkp 			make_pair
#define pb 				push_back
#define max3(a,b,c) 	max(a,max(b,c))
#define min3(a,b,c) 	min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)			a.begin(), a.end()
using namespace std;
db pi		 =			2*acos(0.0);
db eps       =			0.000001;
ll mod       =			(1e9+7);   //998244353
const ll INF =			1000000000000000LL;
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=100001;
bool judgePermutation(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}


int main(){	
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int n,k;
	cin>>n>>k;
	bool vis[n+1]={0};
	rep(i,0,k){
		int d;
		cin>>d;
		rep(ii,0,d){
			int temp;
			cin>>temp;
			vis[temp]=true;
		}
	}
	ll tot=0;
	rep(i,1,n+1) if(!vis[i]) tot++;
	cout<<tot<<endl;
    return 0;
    }

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
long long ans;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n,a[200005];
    scanf("%d",&n);
    for(int i=0; i<n; ++i)
        scanf("%d",&a[i]);

    for(int i=0; i<n-1; i++){
        if(a[i]>a[i+1]){
            ans += a[i]-a[i+1];
            a[i+1] = a[i];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4572
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  ll k;
  cin >> k;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  rep(i, n) a.at(i)--;
  vector<vector<int>> db(60, vector<int>(n));
  rep(i, n) db.at(0).at(i) = a.at(i);
  rep(i, db.size()-1){
    rep(j, n){
      db.at(i+1).at(j) = db.at(i).at(db.at(i).at(j));
    }
  }
  int ans = 0;
  rep(bit, 60){
    if((k & (1LL << bit)) != 0){
      ans = db.at(bit).at(ans);
    }
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 51836
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
k = int(k)

cons = [int(a), int(b), int(c), int(d), int(e)]

flag = 0
for i in range(len(cons)):
    # print(cons[i])
    # print(cons[-1])
    j = 1
    while(True):
        diff = cons[-j] - cons[i]
        if diff > k:
            print(':(')
            flag = 1
            break
        if diff == 0:
            break
        j += 1
    if flag == 1:
        break
else:
    if flag == 0:
        print('Yay!')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll X;
    cin >>X;
    
    
    cout << (X/500)*1000+(X%500)/5*5 << endl;


    return 0;
    

}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#include <vector>

typedef long long ll;
#define rep(i,n) for(ll i = 0; i < n; i++)

using namespace std;

int main(){
	ll n;
	ll k;
	cin >> n >> k;
	ll h[200000];
	rep(i,n) cin >> h[i];

	sort(h,h+n);
	int key = n-k;
	ll ans = 0;


	for(int i = 0; i < key; i++){
		ans += h[i];
	}

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

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

int main()
{
    int N;
    long long A, ans=1;
    cin >> N;
    for(int i=0; i<N; i++)
    {
        cin >> A;
        if(A==0){ans=0;
            break;
        }
        if(A>1000000000000000000/ans)ans=-1;
        if(ans!=-1)ans*=A;
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 3676
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		final int n = sc.nextInt();
		final int k = sc.nextInt();

		List<Integer> lList = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			lList.add(sc.nextInt());
		}

		Collections.sort(lList);
		Collections.reverse(lList);

		int result = 0;
		for (int j = 0; j < k; j++) {
			result = result + lList.get(j);
		}

		System.out.print(result);

	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <numeric>

//#include <map>

using namespace std;

int main()
{

	while (1)
	{
		char ch[1000];
		char* pch;
		pch = ch;
		memset(ch, 0, sizeof(ch));

		string x;
		cin >> x;
		if (x == "0")break;
		
		strcpy(ch, x.c_str());
		int sum = 0;
		int index = 0;
		while (*pch)
		{
			sum += (*pch - 0x30);
			pch++;
		}
		cout << sum << endl;
	}

	return 0;
}

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

using pii = pair<int, int>;

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

    vector<int> X(M);
    for(int i = 0; i < M; ++i){
        cin >> X[i];
    }

    if(N >= M){
        cout << "0" << endl;
        return 0;
    }

    sort(begin(X), end(X));

    vector<bool> s(M, false);

    vector<pii> d(M-1);
    for(int i = 0; i < M-1; ++i){
        d[i] = make_pair(X[i+1]-X[i], i+1);
    }

    sort(begin(d), end(d), greater<pii>());

    --N;
    s[0] = true;
    for(int i = 0; i < M-1 && N > 0; ++i, --N){
        s[d[i].second] = true;
    }

    int ans = 0;
    for(int i = 1; i < M; ++i){
        if(!s[i]) ans += X[i]-X[i-1];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define INF 1000000000000000000
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define x first 
#define y second
const int maxx = 2000006;
const int mod2 = 987654319;
const int maxlog = 20;
const ll mod = 1000000007;

int main() {
    IOS
    int N, ok = 0;
    cin >> N;
    for (int i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            if (i <= 9 && (N / i) <= 9) ok = 1;
        } 
    }
    cout << (ok ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define MAX_V 100100
#define CONST -1
 
vector <pair<int, int> > L[MAX_V];
queue <pair<int, int> > q;
int V[MAX_V];
bool b[MAX_V];

bool dfs(int v){
    b[v] = true;
    bool ans = true;
    for(int next = 0; next < L[v].size(); next++){
        int nv = L[v][next].first;
        int we = L[v][next].second;
        if(V[nv] == CONST) V[nv] = V[v] + we;
        if(V[nv] == V[v] + we){
            if(!b[nv]) ans = dfs(nv);
        }
        else return false;

        if(!ans) return false;
    }
    return true;
}

int main(){
    int N,M;
    cin >> N >> M;
    int l,r,d;
    REP(i,M){
        cin >> l >> r >> d;
        l--;
        r--;
        L[l].push_back(make_pair(r,d));
        L[r].push_back(make_pair(l,-d));
    }

    bool ans = true;
    fill(V, V+MAX_V, CONST);
    REP(i,N){
        if(!b[i]) {
            V[i] = 0;
            ans = dfs(i);
            if(!ans) break;
        }
    }
    

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 12032
package main

import (
	"fmt"
	"math"
)

var N, x int
var ans int

func main() {
	fmt.Scan(&N, &x)
	a := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	for i := 0; i < N-1; i++ {
		if x < a[i]+a[i+1] {
			cnt := (a[i] + a[i+1]) - x
			ans += cnt
			a[i+1] = max(a[i+1]-cnt, 0)

		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


Measured memory_bytes: 5504
from collections import deque
H, W = map(int, input().split())
grid = [["#"] * (W + 2)] + [list("#" + input() + "#")
                            for i in range(H)] + [["#"]*(W+2)]
# print(grid)
stack = deque()
for h in range(1, H+1):
    for w in range(1, W+1):
        # 黒ならスタックにpush
        if grid[h][w] == "#":
            stack.append([h, w])

for i in range(h + w + 3):
    tmp = deque()
    while stack:
        h, w = stack.pop()
        for dh, dw in ([0, 1], [0, -1], [1, 0], [-1, 0]):
            if grid[h + dh][w + dw] == ".":
                grid[h + dh][w + dw] = "#"
                tmp.append([h + dh, w + dw])
    stack = tmp
    if not stack:
        print(i)
        break


Measured memory_bytes: 168668
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> x.at(i);
	}
	int sum;
	int y;
	vector<int> z(100);
	for(int j=0;j<100;j++){
	
		for (int k = 0; k < n; ++k)
		{
			z.at(j)=z.at(j)+(x.at(k)-j)*(x.at(k)-j);

		}

	}
  sort(z.begin(),z.end());
	
	cout << z.at(0) <<endl;

		
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin >> n;
	cout << a[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
int main(){
    int S,W;
    scanf("%d %d",&S,&W);
    if(S<=W) printf("unsafe");
    else printf("safe");
}


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

LL A, B, C, D;
map<LL, LL> memo;
LL solve(LL N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (memo.count(N)) return memo[N];
    LL l2 = (N/2)*2;
    LL r2 = ((N+1)/2)*2;
    LL l3 = (N/3)*3;
    LL r3 = ((N+2)/3)*3;
    LL l5 = (N/5)*5;
    LL r5 = ((N+4)/5)*5;

    LL res = 1e18;
    if (N < res/D) res = N*D;
    res = min(res, llabs(l2-N)*D + A + solve(l2/2));
    res = min(res, llabs(r2-N)*D + A + solve(r2/2));

    res = min(res, llabs(l3-N)*D + B + solve(l3/3));
    res = min(res, llabs(r3-N)*D + B + solve(r3/3));

    res = min(res, llabs(l5-N)*D + C + solve(l5/5));
    res = min(res, llabs(r5-N)*D + C + solve(r5/5));

    memo[N] = res;

    return res;
}

int main() {
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        memo.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << "\n";
    }
}


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

int main(){
    // input
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    for(int i=0;i<x;i++) cin>>a[i];
    for(int i=0;i<y;i++) cin>>b[i];
    for(int i=0;i<z;i++) cin>>c[i];

    vector<ll> ab;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            ab.emplace_back(a[i]+b[j]);
        }
    }

    sort(ab.begin(),ab.end());

    vector<ll> abc;
    for(int i=0;i<ab.size()&&i<k;i++){
        for(int j=0;j<z;j++){
            abc.emplace_back(ab[ab.size()-1-i]+c[j]);
        }
    }

    sort(abc.begin(),abc.end());

    for(int i=0;i<abc.size()&&i<k;i++){
        cout<<abc[abc.size()-1-i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 43368
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using f80 = long double;
using f64 = double;
using i64 = unsigned long long;
using pii = pair<int, int>;

vector<i64> v;
i64 x, y, tx, ty;
int n;

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	x = y = 2;
	for (int i = n - 1; i >= 0; --i) {
		if (x % v[i])
			x = x + v[i] - x % v[i];
		y = max(x + v[i] - 1, y - y % v[i] + v[i] - 1); }

	tx = x, ty = y;
	for (auto i: v) {
		tx-= tx % i;
		ty-= ty % i; }

	if (tx == ty && tx == 2)
		cout << x << ' ' << y << endl;
	else
		cout << "-1\n";

	return 0; }


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    long double a;
    long double b;
    cin >> a >> b;
    ll ret = a * b;
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 3788
// ABC162D.cpp
//#include "pch.h"
#include <iostream>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k=0;
	ll r_ans = 0;
	for (int j = 1; j < n - 1; j++) {
		rep(i, j) {
			k = 2 * j - i;
			if (k < n) {
				if (s[i] == s[j])continue;
				if (s[i] == s[k])continue;
				if (s[j] == s[k])continue;
				r_ans++;
			}
		}
	}
	int r=0,g=0,b=0;
	rep(i, s.size()) {
		if (s[i] == 'R') r++;
		if (s[i] == 'G') g++;
		if (s[i] == 'B') b++;
	}
	ll ans = r * g*b - r_ans;
	cout << ans << endl;
}


Measured memory_bytes: 3192
#include <stdio.h>

int main( void )
{
	int w, h, x, y, r;
	char *str = "Yes";
	
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if( (x-r)<0 || (y-r)<0 || (x+r)>w || (y+r)>h ){
		str = "No";
	}
	
	printf("%s\n", str);
	
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, 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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;

    cout << (1 + n-1) * (n-1) / 2 << endl;

}

Measured memory_bytes: 3640
def partition(A, p, r):
    pivot = A[r]
    ptr = p
    for i in range(p, r):
        if A[i] <= pivot:
            A[ptr], A[i] = A[i], A[ptr]
            ptr += 1
    A[ptr], A[r] = A[r], A[ptr]
    return ptr

if __name__ == "__main__":
    import sys
    N = int(sys.stdin.readline().strip())
    A = [int(e) for e in sys.stdin.readline().strip().split()]
    pivIdx = partition(A, 0, N-1)
    strA = map(str, A)
    strA[pivIdx] = "[{0}]".format(strA[pivIdx])
    print " ".join(strA)

Measured memory_bytes: 16008
S=list(input())
S.append(0)
count=0
people=0
x=[]
x.append(-1)
y=[]
z=[]
for i in range(10**5+1):
    if S[i]==0:
        All = i
        y.append(0)
        break
    if S[i]=='L':
        if S[i+1]=="R":
            x.append(i)
        if S[i+1]==0:
            x.append(i)
    if S[i]=="R":
        if S[i+1]=="L":
            y.append(i)
for j in range(All):
    if j == y[count]:
        people=x[count+1]-x[count]
        if(people%2==0):
            z.append(people//2)
            z.append(people//2)
        else:
            if((y[count]-x[count])%2!=0):
                z.append(people//2+1)
                z.append(people//2)
            else:
                z.append(people//2)
                z.append(people//2+1)
    elif j-1==y[count]:
        count+=1
    else:
        z.append(0)
print(*z)

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

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

    lli n,i,j,k,x;
    cin>>n;
    lli dp[n+1][4],a[n+1][4];
    for(i=1;i<=n;++i)cin>>a[i][1]>>a[i][2]>>a[i][3];
    dp[1][1]=a[1][1];dp[1][2]=a[1][2];dp[1][3]=a[1][3];
    for(i=2;i<=n;++i)
    {
        dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=a[i][3]+max(dp[i-1][2],dp[i-1][1]);
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));






}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
#include<queue>
#include <iomanip>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

int ans[15][15];
int b=0;
int N;

int main()
{

    cin>>N;
    REP(i,0,15){
        REP(j,0,15){
            ans[i][j]=-1;
        }
    }
    REP(i,0,N){
        int a;
        cin>>a;
        REP(j,0,a){
            int x,y;
            cin>>x>>y;
            x--;
            ans[i][x]=y;
        }
    }

    REP(i,0,pow(2,N)){
        int list[N];

        int s=0;
        REP(j,0,N){
            list[j]=(i>>j)&1;
            s+=list[j];
        }
        bool flag=true;
        REP(j,0,N){
            if(list[j]==1){
                REP(k,0,N){
                    if(ans[j][k]!=-1&&ans[j][k]!=list[k]){
                        flag=false;
                    }
                }
            }
        }
        if(flag){
            b=max(b,s);
        }
    }
    cout<<b<<endl;

    
    return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;
use std::cmp::max;

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")
}

fn main() {
    let mut a: i64 = read();
    let b: i64 = read();
    let mut c: i64 = read();
    let d: i64 = read();

    let mut flag = false;

    loop {
        if flag {
            if a <= d {
                println!("No");
                return;
            }
            a -= d;
            flag = !flag;
        } else {
            if c <= b {
                println!("Yes");
                return;
            }
            c -= b;
            flag = !flag;
        }
    }
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ll long long 
#define F first 
#define S second 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define mp make_pair 
#define pb push_back 
#define P(i,j) pair<i,j> 
#define M(i,j) map<i,j> 
#define V(i) vector<i> 
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

using namespace std;


void test(){
	ll n,k,s;
	cin>>n>>k>>s;
	ll a[n];
	ll in=0;
	while(in<k){
		a[in]=s;
		in++;
	}
	ll c=0;
	ll y=2*s;
	
	ll m=1e9;
	
	if(y>m){
		y=1;
	}
	while(c<n-k){
		a[in]=y;
		in++;
		c++;
	}
	f(i,n)cout<<a[i]<<" ";
	cout<<"\n";
}

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

Measured memory_bytes: 2048
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(all(a));
    ll b=-1,c=-1;
    bool abc=0;
    for(ll i=n-1;i>0;i--){
        if(a[i]==a[i-1]&&abc==0){
            abc=1;
            b=a[i];
            i--;
        }
        else if(a[i]==a[i-1]){
            c=a[i];
            break;
        }
            
    }
    if(b==-1||c==-1)
        cout<<0<<endl;
    else
        cout<<b*c<<Endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 1024
#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(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    int sum=0;
    rep(i,n){
        cin >> w[i];
        sum += w[i];
    }

    int ans = sum;
    int now = 0;
    rep(i,n){
        now += w[i];
        sum -= w[i];
        ans = min(ans, abs(sum-now));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int A, B, P, N;
vector<string> vecS;
vector<int> vec;
int dp[100005];

int bit[100005];

void init(){
	for(int i = 1; i <= N; i++) bit[i] = 0;
}

int query(int i)
{
	int sum = 0;
	while(i > 0){
		sum += bit[i];
		sum %= P;
		i -= i&(-i);
	}
	return sum;
}

void add(int i, int val)
{
	while(i <= N){
		bit[i] += val;
		bit[i] %= P;
		i += i&(-i);
	}
}

int main(void)
{
	while(1){
		cin >> A >> B >> P;
		if(A == 0 && B == 0 && P == 0) break;
		
		vecS.clear();
		for(int i = A; i <= B; i++){
			vecS.push_back( to_string(i) );
		}
		sort(vecS.begin(), vecS.end());
		
		vec.clear();
		for(int i = 0; i < vecS.size(); i++){
			vec.push_back( atoi(vecS[i].c_str()) );
		}
		for(int i = 0; i < vec.size(); i++){
			vec[i] -= (A-1);
		}
		N = B - A + 1;
		
		init();
		for(int i = 0; i < vec.size(); i++){
			dp[i] = query(vec[i]) + 1;
			add(vec[i], dp[i]);
		}
		
		int ans = 0;
		for(int i = 0; i < vec.size(); i++){
			ans += dp[i];
			ans %= P;
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 10004
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
 
int main(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	fmt.Scan(&x)

	max := float64(1)
	bp := float64(0)
	for b := float64(1); b <= x; b++ {
		for p := float64(2); p <= x; p++ {
			bp = math.Pow(b, p)
			if x < bp {
				break
			}
			max = math.Max(max, bp)
		}
	}
	fmt.Println(max)
}


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

using namespace std;

int white[200005], black[200005];

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

    int n; string s;
    cin >> n >> s;

    white[n-1] = (int)(s[n-1] == '.');
    black[0] = (int)(s[0] == '#');

    for(int i = n-2; i >= 0; i--) white[i] += white[i+1] + (int)(s[i] == '.');
    for(int i = 1; i < n; i++) black[i] += black[i-1] + (int)(s[i] == '#');

    int result = white[0];

    for(int i = 0; i < n; i++)
        result = min(result, black[i] + white[i+1]);

    cout << result << endl;


    return 0;
}


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

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

  int ans = 0;
  for (int i = 0; i < n; i ++) {
    if (a[i] == b[i] && b[i] == c[i]) continue;
    if (a[i] != b[i] && a[i] != c[i] && b[i] != c[i]) ans += 2;
    else ans ++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){
  int N;std::cin>>N;
  std::vector<int>V(N),C(N);
  for(int i=0;i<N;i++){std::cin>>V[i];}
  for(int i=0;i<N;i++){std::cin>>C[i];}
  int ans=0;
  for (int i=0;i<N;i++){
    ans+=std::max(0,V[i]-C[i]);
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt
--グラフの２頂点の結合を幅探索で調べて出力．

main = do
    [n,m] <- map bsreadInt . BC.words <$> BC.getLine --n頂点，m本の辺
    ab <- map ((map bsreadInt . BC.words)) <$> replicateM m BC.getLine -- a-->b :path のリスト
    let q = Sq.singleton [1]
    let chk = Set.singleton 1

    print $ length $ filter (==False) [connectchk q n (Set.fromList (ab \\ [ab!!(k-1)] ))  chk | k <- [1..m]]

connectchk :: Sq.Seq [Int] -> Int -> Set.Set [Int] -> Set.Set Int -> Bool
connectchk q n adjs chk = foldr (&&) True [ (bsearch q n g adjs chk) /= [] | g <- [2..n] ]
         
adjset :: Int -> Int -> Set.Set [Int] ->  Set.Set Int -> [Int]
adjset x n adjs chk  = [l | l<-[1..n] , Set.member [x,l] adjs || Set.member [l,x] adjs == True , Set.member l chk == False]

bsearch :: Sq.Seq [Int] -> Int -> Int -> Set.Set [Int] -> Set.Set Int -> [Int]
bsearch q n g adjs chk = if Sq.length q == 0
                         then []
                         else if head (sqleft q) == g
                              then reverse $ sqleft q
                              else bsearch q2 n g adjs chk2
                                where qa = sqleft q
                                      q2 = (Sq.drop 1 q) >< (Sq.fromList add)
                                      add = [x : qa | x <- adjset (head qa) n adjs chk]
                                      chk2 = Set.union chk (Set.fromList (adjset (head qa) n adjs chk))
                                      
sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x

    

Measured memory_bytes: 1020
#デフォルト
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

t = list(input())

for i in range(len(t)):
    if (t[i] == "?"):
        print("D",end="")
    else:
        print(t[i],end="")

Measured memory_bytes: 10884
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

def find(x):
    if node[x] < 0:
        return x
    else:
        node[x] = find(node[x])
        return node[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    ret = False
    if x != y:
        ret = True
        if rank[x] > rank[y]:
            node[x] += node[y]
            node[y] = x
        else:
            node[y] += node[x]
            node[x] = y
            if rank[x] == rank[y]:
                rank[y] += 1
    return ret

def is_same(x, y):
    return find(x) == find(y)

def size(x):
    return -node[find(x)]

n, m = map(int,input().split())
node = [-1 for i in range(n + 1)]
rank = [0 for i in range(n + 1)]
e = [[int(i) for i in input().split()] for i in range(m)]
ans = deque()
num = int((n * (n - 1)) // 2)
s = 0
for i in e[::-1]:
    s1 = size(i[0])
    s2 = size(i[1])
    ans.appendleft(num)
    if unite(i[0], i[1]):
        num -= s1 * s2
for i in ans:
    print(i)


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, k;
set<int> s;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>k;
    for (int i=1; i<=n; i++) {
	s.insert(i);
    }

    for (int i=1; i<=k; i++) {
	int d; cin>>d;
	while (d--) {
	    int x; cin>>x;
	    if (s.count(x)) s.erase(x);
	}
    }

    out(s.size());
  

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  return gcd(b,a%b);
}

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

  ll x;
  cin>>x;
  ll u=gcd(360,x);

  ll lcd=x*360/u;
  ll ans=lcd/x;

  cout<<ans<<endl;

}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int a, b, c; cin >> a >> b >> c;
    cout << max(c -(a-b), 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H, W, i, j;
    while(1){
        cin >> H >> W;
        if((H == 0) && (W == 0)) break;
        for(j=0; j<H; j++){
            for(i=0; i<W; i++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}






Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
const int INF32 = 2147483647;
using namespace std;

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

    int N, K;
    cin >> N >> K;
    vector<int> X(N);
    REP(i, N) cin >> X[i];

    int ans = INF32;

    REP(start, N) {
        int end = start + K - 1;
        if (end >= N)
            break;

        int l = abs(X[end]) + abs(X[end] - X[start]);
        int r = abs(X[start]) + abs(X[end] - X[start]);
        ans  = min(ans, min(l, r));
    }

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


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

import math
L = [0] * (N + 1)
R = [0] * (N + 1)

for i in range(N):
    L[i + 1] = math.gcd(L[i], A[i])
    R[N - i - 1] = math.gcd(R[N - i], A[N - i - 1])

ans = 0
for i in range(N):
    ans = max(ans, math.gcd(L[i], R[i+1]))

print(ans)

Measured memory_bytes: 20884
#include <iostream>
#include <string>

using namespace std;

int main() {
    string S;
    cin >> S;

    int len = S.length();

    // 0101...
    int score1 = 0;
    for (int i = 0; i < len; i++) {
        if (i % 2 == 0) {
            if (S[i] != '0') score1++;
        }
        if (i % 2 == 1) {
            if (S[i] != '1') score1++;
        }
    }

    // 1010...
    int score2 = 0;
    for (int i = 0; i < len; i++) {
        if (i % 2 == 0) {
            if (S[i] != '1') score2++;
        }
        if (i % 2 == 1) {
            if (S[i] != '0') score2++;
        }
    }

    cout << min(score1, score2) << endl;

    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		int ans = 0;
		if(s=="RRR"){
			ans = 3;
		} else if(s=="RRS" || s=="SRR"){
			ans = 2;
		} else if(s=="SSS"){
			ans = 0;
		} else {
			ans = 1;
		}
		Console.WriteLine(ans);
	}
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

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


int main(){
  int n; cin >> n;
  vector<int> v(n);cin >> v;
  bitset<100000> bs;
  for(auto&e:v)e--;
  int cnt = 0;
  int p = 0;
  while(p != 1 && !bs[p]){
    cnt++;
    bs[p] = 1;
    p = v[p];
  }
  cout << (p == 1 ? cnt : -1) << endl;
}

 


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;

void warshall_floyd(vector<vector<long long>> &_Date){
    long long N = _Date.size();
    for(long long k = 0; k < N; k++){        //経由頂点
        for(long long i = 0; i < N; i++){    //始点
            for(long long j = 0; j < N; j++){//終点
                _Date[i][j] = min(_Date[i][j], _Date[i][k] + _Date[k][j]);
            }
        }
    }
}

void chmin(long long &a, long long b){
    if(a > b)a = b;
}

int main(){
    long long N, M, R;
    cin >> N >> M >> R;
    
    vector<long long> visit(R);
    vector<vector<long long>> dist(N, vector<long long>(N, INF));
    
    for(long long i = 0; i < R; i++){
        cin >> visit[i];
        visit[i]--;
    }
    for(long long i = 0; i < M; i++){
        long long a, b, t;
        cin >> a >> b >> t;
        a--;
        b--;
        dist[a][b] = t;
        dist[b][a] = t;
    }
    
    sort(visit.begin(), visit.end());
    warshall_floyd(dist);
    
    long long ans = INF;
    
    while(true){
        long long now = visit[0];
        long long res = 0;
        
        for(long long i = 1; i < R; i++){
            res += dist[now][visit[i]];
            now = visit[i];
        }
        
        chmin(ans, res);
        
        if(!next_permutation(visit.begin(), visit.end()))break;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
N,M = map(int,input().split())
A = list(map(int,input().split()))

import heapq


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign

hq = Heapq(A,desc=True)
for _ in range(M):
    highest = hq.pop()
    hq.push(int(highest/2))
ans = 0
for _ in range(N):
    ans += hq.pop()
print(ans)

Measured memory_bytes: 14400
#include<iostream>
using namespace std;
int main(){
	int n,tmp,ans[7];
	while(true){
		cin >> n;
		if(!n)
			return 0;
		for(int i=0; i<7; i++)
			ans[i] = 0;
		for(int i=0; i<n; i++){
			cin >> tmp;
			tmp = (int)(tmp/10);
			if(tmp>6)
				tmp = 6;
			ans[tmp]++;
		}
		for(int i=0; i<7; i++)
			cout << ans[i] << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    int a,b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b)) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, X: int, L: "List[int]"):
    ds = [0] + list(accumulate(L))
    return len([d for d in ds if d <= X])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    L = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, X, L)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
 
int main(){
  int l,r;
  cin>>l>>r;
  int ans=2018;
  r=min(r,l+4038);
  for(ll i=l;i<=r;i++){
    for(ll j=i+1;j<=r;j++){
      int x=i*j%2019;
      ans=min(ans,x);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256